Panel: Difference between revisions
Jump to navigation
Jump to search
(Created page with "'''<code>vgui::Panel</code>''' 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 child...") |
No edit summary |
||
Line 1: | Line 1: | ||
{{toc-right}} | |||
'''<code>vgui::Panel</code>''' 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. | '''<code>vgui::Panel</code>''' 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 === | === General === | ||
; <code>SetVisible([[bool]])</code> | ; <code>SetVisible([[bool]])</code> | ||
: | ; <code>[[bool]] IsVisible()</code> | ||
; <code>[[bool]] IsFullyVisible()</code> | |||
: Invisible panels and their children are not drawn or updated and do not receive input messages. <code>IsFullyVisible()</code> checks parent panels for visibility too. | |||
; <code>SetEnabled([[bool]])</code> | |||
; <code>IsEnabled()</code> | |||
: Disabel panels do not receive input and are often drawn with muted colours to indicate this. | |||
; <code>OnThink()</code> | |||
: Called every frame before painting if the panel is visible. {{todo|What about <code>Think()</code>? Is it obsolete? Does it run even if the panel isn't visible?}} | |||
; <code>void OnTick()</code> | |||
: Called at regular intervals if <code>[[IVGui|ivgui()]]->AddTickSignal()</code> is called. | |||
=== Painting === | === Painting === | ||
A panel is drawn | ''A panel is drawn by its "paint" functions. <code>PaintBackground()</code> and <code>Paint()</code> are enabled by default.'' | ||
; <code>PaintBackground()</code> | ; <code>PaintBackground()</code> | ||
Line 27: | Line 38: | ||
; <code>PostChildPaint()</code> | ; <code>PostChildPaint()</code> | ||
; <code>SetPostChildPaintEnabled([[bool]])</code> | ; <code>SetPostChildPaintEnabled([[bool]])</code> | ||
: Performs arbitrary drawing after the panel's children have been painted (i.e. | : Performs arbitrary drawing after the panel's children have been painted (i.e. above them). | ||
; <code>SetSkipChildDuringPainting(Panel *child)</code> | |||
: Prevents a child from drawing, {{confirm|without stopping it from thinking}}. | |||
; <code>SetAlpha([[int]])</code> | |||
: 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 ==== | |||
; <code>Panel *GetParent()</code> | |||
; <code>[[VPANEL]] GetVParent()</code> | |||
; <code>SetParent(Panel*)</code> ''or'' <code>SetParent([[VPANEL]])</code> | |||
: Gets/sets this panel's parent. | |||
; <code>[[bool]] HasParent([[VPANEL]])</code> | |||
: Is the given panel somewhere above this one in the hierarchy? | |||
==== Children ==== | |||
; <code>[[int]] GetChildCount()</code> | |||
; <code>[[Panel]] *GetChild([[int]] index)</code> | |||
; <code>[[Panel]] *FindChildByName([[string|char*]] childName, [[bool]] recurseDown = false)</code> | |||
: Provides access to child panels. | |||
; <code>OnChildAdded([[VPANEL]] child)</code> | |||
: Called when a child is added to this panel. | |||
==== Popups ==== | |||
; <code>PopupMakePopup([[bool]] showTaskbarIcon = true,[[bool]] disabled = false)</code> | |||
; <code>bool IsPopup()</code> | |||
: Popup panels draw outside of their parent's space and do not follow it around. | |||
[[Category:VGUI]] | |||
[[Category:Classes]] |
Revision as of 12:23, 2 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.