Skip to content

Default panel types

The Fern edited this page Oct 4, 2020 · 6 revisions

The root panel

The root panel is an extension of the frame panel. Every app has a root panel that all additional panels are attached to. Root panels cannot be created using GPnl.AddPanel and are only created once per app.

Panel:SetFullScreen( bool )                    -- Sets the fullscreen state of the app
bool = Panel:GetFullScreen()                   -- Returns whether the app is in fullscreen

panel

The default panel has nothing special to it. It purely uses the default functions and callbacks without any addition. This means it's the best panel to override as you don't need to care about unnecessary functions.

frame

The frame is very useful when you want to easily open new tabs/windows in an App. The root panel is an extended frame-type panel.

tab = Panel:AddTab( name, type )               -- Adds a tab to the frame with a unique name
tabs = Panel:GetTabs()                         -- Returns a list of available tabs
Panel:OpenTab( name, time, newanim, oldanim )  -- Opens a specific tab. Can be given an animation for the new tab and old tab

toggle

The toggle panel is useful when you want to make a checkbox-like panel. It is styled like the default toggle in an iPhone.

Panel:SetToggle( bool )                        -- Sets the state of the toggle
bool = Panel:GetToggle()                       -- Returns the state of the toggle

It also has a callback function for when you click it.

Panel:OnChange( bool )                         -- Called when the user clicks on the toggle

scroll

The scroll panel is useful when an App contains many panels bunked on top of each other. This panel changes the y-position of its child panels when OnScroll( num ) is called. The panel automatically changes height based on the size of the child panels it has.

Panel:SetScrollSpeed( float )                  -- Sets the scrolling speed of the panel
float = Panel:GetScrollSpeed()                 -- Gets the scrolling speed of the panel

textentry

The textentry is a preset for a generic textfield. It comes prepackaged with all the features you would need.

Panel:SetText( string )                        -- Sets the current text
string = Panel:GetText()                       -- Returns the current text

Panel:SetFont( font )                          -- Sets the font
font = Panel:GetFont()                         -- Returns the font

Panel:SetAlignment( hor, ver )                 -- Sets the alignment of the text (uses the TEXT_ALIGN_* enums)
hor,ver = Panel:GetAlignment()                 -- Gets the alignment of the text

Panel:SetForeColor( color )                    -- Set the text color
color = Panel:GetForeColor()                   -- Gets the text color

Panel:SetBackColor( color )                    -- Set the background color
color = Panel:GetBackColor()                   -- Gets the background color

Panel:SetSelectionColor( color )               -- Set the selection color
color = Panel:GetSelectionColor()              -- Gets the selection color

The textentry also has 3 callback functions.

Panel:OnEnter( string )                        -- Called when the player presses enter
Panel:OnChange( string )                       -- Called when the textinput changes
Panel:OnCancel()                               -- Called when the player cancels the input

html

The html panel makes it easy to create browsers and Apps that rely on websites. After setting the size of the panel you should call the Init() function. Resizing the panel after calling Init() can lead to some funky results.

Panel:Init( url )                              -- Needs to be called after setting the size of the panel
dhtml = Panel:GetHTML()                        -- Returns the DHTML panel of this panel

video

The video panel creates a web-based video player with audio that changes with volume setting. It's somewhat based on the html panel. The panel is quite slow, due to the fact that it copies the entirety of the video into a browser to display.

Panel:Open( path )                             -- Needs to be called after setting the size of the panel. Only ".mp4" and ".webm" extensions are supported

Continue to GPhone Library