Panel
Jump to navigation
Jump to search
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.