Panel: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(Script parameters) |
||
Line 68: | Line 68: | ||
; <code>bool IsPopup()</code> | ; <code>bool IsPopup()</code> | ||
: Popup panels draw outside of their parent's space and do not follow it around. | : Popup panels draw outside of their parent's space and do not follow it around. | ||
== Script parameters == | |||
''These can be used within a .res layout file.'' | |||
{{ScriptVar|fieldName|string|Sets the control's name. Default is NULL.}} | |||
{{ScriptVar|wide|int}} | |||
{{ScriptVar|tall|int|The initial size of the panel.}} | |||
{{ScriptVar|xpos|int}} | |||
{{ScriptVar|ypos|int|The X and Y position of the panel's pinned corner relative to its parent. By default this value is an offset from the left/top edge, but the special characters <code>c</code> and <code>r</code> allow positioning relative to the centre and right/bottom edge respectively. Examples: | |||
:* <code>xpos 300</code> | |||
:* <code>xpos r300</code> | |||
:* <code>xpos c0</code> | |||
}} | |||
{{ScriptVar|PinCorner|choices|The pinned corner is the one positioned at xpos/ypos. Values are: | |||
:* <code>TOPLEFT</code> (default) | |||
:* <code>TOPRIGHT</code> | |||
:* <code>BOTTOMLEFT</code> | |||
:* <code>BOTTOMRIGHT</code> | |||
}} | |||
{{ScriptVar|PinnedCornerOffsetX|int}} | |||
{{ScriptVar|PinnedCornerOffsetY|int}} | |||
{{ScriptVar|UnpinnedCornerOffsetX|int}} | |||
{{ScriptVar|UnpinnedCornerOffsetY|int|{{todo}}}} | |||
{{ScriptVar|zpos|int|The Z position. Default is <code>1</code>. Higher numbers are drawn on top of lower numbers.}} | |||
{{ScriptVar|IgnoreScheme|bool|{{todo|"Only get colors if we're ignoring the scheme."}} See also <code>[[IScheme]]</code>.}} | |||
{{ScriptVar|visible|bool|Whether the control is visible.}} | |||
{{ScriptVar|enabled|bool|Whether the control can be used.}} | |||
{{ScriptVar|tabPosition|int|Controls the order in which panels are focused on when {{key|tab}} is pressed. Valid range is 0-255. Default is 0.}} | |||
{{ScriptVar|tooltiptext|string|Text displayed when mouse is hovered over this panel. No support on consoles.}} | |||
{{ScriptVar|paintbackground|bool}} | |||
{{ScriptVar|paintborder|bool|Whether to draw the background/border of the panel. Default is -1, which means no value will be applied.}} | |||
{{ScriptVar|AutoResize|choices|Sets which edges of the panel can be resized. Values are: | |||
:* <code>NO</code> (default) | |||
:* <code>RIGHT</code> | |||
:* <code>DOWN</code> | |||
:* <code>DOWNANDRIGHT</code> | |||
}} | |||
[[Category:VGUI]] | [[Category:VGUI]] | ||
[[Category:Classes]] | [[Category:Classes]] |
Revision as of 02:16, 3 August 2011
vgui::Panel
is the base class of all VGUI elements. It is a rectangle which covers an area of the screen and can draw itself, handle events, and host children.
Functions
General
SetVisible(bool)
bool IsVisible()
bool IsFullyVisible()
- Invisible panels and their children are not drawn or updated and do not receive input messages.
IsFullyVisible()
checks parent panels for visibility too. SetEnabled(bool)
IsEnabled()
- Disabel panels do not receive input and are often drawn with muted colours to indicate this.
OnThink()
- Called every frame before painting if the panel is visible. Todo: What about
Think()
? Is it obsolete? Does it run even if the panel isn't visible? void OnTick()
- Called at regular intervals if
ivgui()->AddTickSignal()
is called.
Painting
A panel is drawn by its "paint" functions. PaintBackground()
and Paint()
are enabled by default.
PaintBackground()
SetPaintBackgroundEnabled(bool)
- Draws the background of the panel.
Paint()
SetPaintEnabled(bool)
- Draws the contents of the panel.
Confirm:Does not draw children.
PaintBorder()
SetPaintBorderEnabled(bool)
SetBorder(IBorder *border)
IBorder *GetBorder()
- Paints a border around the panel.
SetBorder()
must be called beforeSetPaintBorderEnabled()
.- Get an
IBorder
fromIScheme::GetBorder()
inApplySchemeSettings()
. - See
swarm/resource/sourcescheme.res
for examples of border definitions.
- Get an
PostChildPaint()
SetPostChildPaintEnabled(bool)
- Performs arbitrary drawing after the panel's children have been painted (i.e. above them).
SetSkipChildDuringPainting(Panel *child)
- Prevents a child from drawing, .
Confirm:without stopping it from thinking
SetAlpha(int)
- Sets the alpha of this panel and its children panels. 0 is invisible, 255 is opaque.
Hierarchy
Each panel has one parent and can have many children. Unless made a popup, children are drawn relative to and within the confines of their parent panel.
Parents
Panel *GetParent()
VPANEL GetVParent()
SetParent(Panel*)
orSetParent(VPANEL)
- Gets/sets this panel's parent.
bool HasParent(VPANEL)
- Is the given panel somewhere above this one in the hierarchy?
Children
int GetChildCount()
Panel *GetChild(int index)
Panel *FindChildByName(char* childName, bool recurseDown = false)
- Provides access to child panels.
OnChildAdded(VPANEL child)
- Called when a child is added to this panel.
Popups
PopupMakePopup(bool showTaskbarIcon = true,bool disabled = false)
bool IsPopup()
- Popup panels draw outside of their parent's space and do not follow it around.
Script parameters
These can be used within a .res layout file.
fieldName
<string>- Sets the control's name. Default is NULL.
wide
<integer>tall
<integer>- The initial size of the panel.
xpos
<integer>ypos
<integer>- The X and Y position of the panel's pinned corner relative to its parent. By default this value is an offset from the left/top edge, but the special characters
c
andr
allow positioning relative to the centre and right/bottom edge respectively. Examples:xpos 300
xpos r300
xpos c0
PinCorner
<choices>- The pinned corner is the one positioned at xpos/ypos. Values are:
TOPLEFT
(default)TOPRIGHT
BOTTOMLEFT
BOTTOMRIGHT
PinnedCornerOffsetX
<integer>PinnedCornerOffsetY
<integer>UnpinnedCornerOffsetX
<integer>UnpinnedCornerOffsetY
<integer>- [Todo]
zpos
<integer>- The Z position. Default is
1
. Higher numbers are drawn on top of lower numbers. IgnoreScheme
<boolean>- Todo: "Only get colors if we're ignoring the scheme."See also
IScheme
. visible
<boolean>- Whether the control is visible.
enabled
<boolean>- Whether the control can be used.
tabPosition
<integer>- Controls the order in which panels are focused on when Tab ⇆ is pressed. Valid range is 0-255. Default is 0.
tooltiptext
<string>- Text displayed when mouse is hovered over this panel. No support on consoles.
paintbackground
<boolean>paintborder
<boolean>- Whether to draw the background/border of the panel. Default is -1, which means no value will be applied.
AutoResize
<choices>- Sets which edges of the panel can be resized. Values are:
NO
(default)RIGHT
DOWN
DOWNANDRIGHT