libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
GuiWindow Class Reference

Allows GuiElements to be grouped together into a "window". More...

#include <GuiWindow.h>

Inheritance diagram for GuiWindow:
[legend]

Public Member Functions

 GuiWindow ()
 Constructor.
 
 GuiWindow (int w, int h)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
 ~GuiWindow ()
 Destructor.
 
void append (GuiElement *e)
 Appends a GuiElement to the GuiWindow.
 
void appendWithAutoRemove (GuiElement *e)
 Appends a GuiElement to the GuiWindow, and instructs the GuiElement to inform its parent on destruction.
 
void insert (GuiElement *e, uint32_t i)
 Inserts a GuiElement into the GuiWindow at the specified index.
 
void remove (GuiElement *e)
 Removes the specified GuiElement from the GuiWindow.
 
void removeAll ()
 Removes all GuiElements.
 
bool find (GuiElement *e)
 Looks for the specified GuiElement.
 
GuiElement * getGuiElementAt (uint32_t index) const
 Returns the GuiElement at the specified index.
 
uint32_t getSize ()
 Returns the size of the list of elements.
 
void setVisible (bool v)
 Sets the visibility of the window.
 
void resetState ()
 Resets the window's state to STATE::DEFAULT.
 
void setState (STATE s, int c=-1)
 Sets the window state, propagated to every child element.
 
int getSelected ()
 Gets the index of the GuiElement inside the window that is currently selected.
 
void setFocus (int f)
 Sets the window focus.
 
void changeFocus (GuiElement *e)
 Change the focus to the specified element This is intended for the primary GuiWindow only.
 
void toggleFocus (InputController *c)
 Changes window focus to the next focusable window or element If no element is in focus, changes focus to the first available element If B or 1 button is pressed, changes focus to the next available element This is intended for the primary GuiWindow only.
 
void moveSelectionHor (int d)
 Moves the selected element to the element to the left or right.
 
void moveSelectionVert (int d)
 Moves the selected element to the element above or below.
 
void resetText ()
 Resets the text for all contained elements.
 
void draw ()
 Draws all the elements in this GuiWindow.
 
void update (InputController *c)
 Updates the window and all elements contains within Allows the GuiWindow and all elements to respond to the input data specified.
 
- Public Member Functions inherited from GuiElement
 GuiElement ()
 Constructor.
 
virtual ~GuiElement ()
 Destructor.
 
void setParent (GuiElement *e)
 Set the element's parent.
 
GuiElement * getParent ()
 Gets the element's parent.
 
void setRemoveOnDestroy (bool autoRemove)
 Whether to notify parent on destruction to allow removal.
 
int getLeft ()
 Gets the current leftmost coordinate of the element Considers horizontal alignment, x offset, width, and parent element's GetLeft() / GetWidth() values.
 
int getTop ()
 Gets the current topmost coordinate of the element Considers vertical alignment, y offset, height, and parent element's GetTop() / GetHeight() values.
 
void setMinY (int y)
 Sets the minimum y offset of the element.
 
int getMinY ()
 Gets the minimum y offset of the element.
 
void setMaxY (int y)
 Sets the maximum y offset of the element.
 
int getMaxY ()
 Gets the maximum y offset of the element.
 
void setMinX (int x)
 Sets the minimum x offset of the element.
 
int getMinX ()
 Gets the minimum x offset of the element.
 
void setMaxX (int x)
 Sets the maximum x offset of the element.
 
int getMaxX ()
 Gets the maximum x offset of the element.
 
int getWidth ()
 Gets the current width of the element.
 
int getHeight ()
 Gets the height of the element.
 
void setSize (int w, int h)
 Sets the size (width/height) of the element.
 
bool isVisible ()
 Checks whether or not the element is visible.
 
bool isSelectable ()
 Checks whether or not the element is selectable.
 
bool isClickable ()
 Checks whether or not the element is clickable.
 
bool isHoldable ()
 Checks whether or not the element is holdable.
 
void setSelectable (bool s)
 Sets whether or not the element is selectable.
 
void setClickable (bool c)
 Sets whether or not the element is clickable.
 
void setHoldable (bool h)
 Sets whether or not the element is holdable.
 
STATE getState ()
 Gets the element's current state.
 
int getStateChan ()
 Gets the controller channel that last changed the element's state.
 
void setAlpha (int a)
 Sets the element's alpha value.
 
int getAlpha ()
 Gets the element's alpha value Considers alpha, alphaDyn, and the parent element's GetAlpha() value.
 
void setScale (float s)
 Sets the element's x and y scale.
 
void setScaleX (float s)
 Sets the element's x scale.
 
void setScaleY (float s)
 Sets the element's y scale.
 
void setScale (int w, int h)
 Sets the element's x and y scale, using the provided max width/height.
 
float getScale ()
 Gets the element's current scale Considers scale, scaleDyn, and the parent element's GetScale() value.
 
float getScaleX ()
 Gets the element's current x scale Considers scale, scaleDyn, and the parent element's GetScale() value.
 
float getScaleY ()
 Gets the element's current y scale Considers scale, scaleDyn, and the parent element's GetScale() value.
 
void setTrigger (GuiTrigger *t)
 Set a new GuiTrigger for the element.
 
void setTrigger (uint8_t i, GuiTrigger *t)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
bool isRumble ()
 Checks whether rumble was requested by the element.
 
void setRumble (bool r)
 Sets whether or not the element is requesting a rumble event.
 
void setEffect (int e, int a, int t=0)
 Set an effect for the element.
 
void setEffectOnOver (int e, int a, int t=0)
 Sets an effect to be enabled on wiimote cursor over.
 
void setEffectGrow ()
 Shortcut to SetEffectOnOver(EFFECT::SCALE, 4, 110)
 
int getEffect ()
 Gets the current element effects.
 
bool isInside (int x, int y)
 Checks whether the specified coordinates are within the element's boundaries.
 
void setPosition (int x, int y)
 Sets the element's position.
 
void updateEffects ()
 Updates the element's effects (dynamic values) Called by Draw(), used for animation purposes.
 
void setUpdateCallback (UpdateCallback u)
 Sets a function to called after after Update() Callback function can be used to response to changes in the state of the element, and/or update the element's attributes.
 
int isFocused ()
 Checks whether the element is in focus.
 
virtual void setAlignment (ALIGN_H hor, ALIGN_V vert)
 Sets the element's alignment respective to its parent element.
 
virtual void getNaturalSize (int &w, int &h)
 Layout protocol: how a layout container (GuiRow, GuiColumn, GuiGrid, GuiOverlay) asks about and arranges its children.
 
virtual void setLayoutPosition (int x, int y)
 Places the element so its top-left corner is at (x, y) relative to its parent's top-left (default: LEFT/TOP alignment plus an offset)
 
virtual void setLayoutSize (int w, int h)
 Gives the element a size chosen by a container (default: sets width and height)
 
virtual void layout ()
 Brings the element's own layout up to date.
 
virtual void collectNavigable (std::vector< GuiElement * > &out)
 Appends the elements that selection can move between (default: this element; layout containers add their children instead, so the D-pad moves through them)
 

Protected Member Functions

bool collectNavigation (std::vector< GuiElement * > &out)
 Gathers the elements selection can move between, looking inside layout containers.
 
void moveSelectionIn (std::vector< GuiElement * > &list, NAV_DIR d)
 Moves the selection within a collected list by on-screen geometry.
 

Protected Attributes

std::vector< GuiElement * > _elements
 Contains all elements within the GuiWindow.
 
- Protected Attributes inherited from GuiElement
GuiTrigger * trigger [MAX_TRIGGERS]
 GuiTriggers (input actions) that this element responds to.
 
UpdateCallback updateCB
 Callback function to call when this element is updated.
 
GuiElement * parentElement
 Parent element.
 
bool removeOnDestroy
 Whether to instruct parent to remove this element when it is destroyed.
 
int focus
 Element focus (-1 = focus disabled, 0 = not focused, 1 = focused)
 
int width
 Element width.
 
int height
 Element height.
 
int xoffset
 Element X offset.
 
int yoffset
 Element Y offset.
 
int ymin
 Element's min Y offset allowed.
 
int ymax
 Element's max Y offset allowed.
 
int xmin
 Element's min X offset allowed.
 
int xmax
 Element's max X offset allowed.
 
int xoffsetDyn
 Element X offset, dynamic (added to xoffset value for animation effects)
 
int yoffsetDyn
 Element Y offset, dynamic (added to yoffset value for animation effects)
 
int alpha
 Element alpha value (0-255)
 
int alphaDyn
 Element alpha, dynamic (multiplied by alpha value for blending/fading effects)
 
float xscale
 Element X scale (1 = 100%)
 
float yscale
 Element Y scale (1 = 100%)
 
float scaleDyn
 Element scale, dynamic (multiplied by alpha value for blending/fading effects)
 
int effects
 Currently enabled effect(s).
 
int effectAmount
 Effect amount.
 
int effectTarget
 Effect target amount.
 
int effectsOver
 Effects to enable when wiimote cursor is over this element.
 
int effectAmountOver
 EffectAmount to set when wiimote cursor is over this element.
 
int effectTargetOver
 EffectTarget to set when wiimote cursor is over this element.
 
ALIGN_H alignmentHor
 Horizontal element alignment, respective to parent element (LEFT, RIGHT, CENTRE)
 
ALIGN_V alignmentVert
 Horizontal element alignment, respective to parent element (TOP, BOTTOM, MIDDLE)
 
STATE state
 Element state (DEFAULT, SELECTED, CLICKED, DISABLED)
 
int stateChan
 Which controller channel is responsible for the last change in state.
 
bool selectable
 Whether or not this element selectable (can change to SELECTED state)
 
bool clickable
 Whether or not this element is clickable (can change to CLICKED state)
 
bool holdable
 Whether or not this element is holdable (can change to HELD state)
 
bool visible
 Visibility of the element.
 
bool rumble
 Wiimote rumble (on/off) - set to on when this element requests a rumble event.
 

Detailed Description

Allows GuiElements to be grouped together into a "window".

Definition at line 10 of file GuiWindow.h.

Constructor & Destructor Documentation

◆ GuiWindow() [1/2]

GuiWindow::GuiWindow ( )

Constructor.

Definition at line 9 of file GuiWindow.cpp.

◆ GuiWindow() [2/2]

GuiWindow::GuiWindow ( int w,
int h )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
wWidth of window
hHeight of window

Definition at line 16 of file GuiWindow.cpp.

◆ ~GuiWindow()

GuiWindow::~GuiWindow ( )

Destructor.

Definition at line 23 of file GuiWindow.cpp.

Member Function Documentation

◆ append()

void GuiWindow::append ( GuiElement * e)

Appends a GuiElement to the GuiWindow.

Parameters
eThe GuiElement to append. If it is already in the GuiWindow, it is removed first

Definition at line 31 of file GuiWindow.cpp.

◆ appendWithAutoRemove()

void GuiWindow::appendWithAutoRemove ( GuiElement * e)

Appends a GuiElement to the GuiWindow, and instructs the GuiElement to inform its parent on destruction.

Parameters
eThe GuiElement to append. If it is already in the GuiWindow, it is removed first

Definition at line 41 of file GuiWindow.cpp.

◆ changeFocus()

void GuiWindow::changeFocus ( GuiElement * e)

Change the focus to the specified element This is intended for the primary GuiWindow only.

Parameters
eGuiElement that should have focus

Definition at line 170 of file GuiWindow.cpp.

◆ collectNavigation()

bool GuiWindow::collectNavigation ( std::vector< GuiElement * > & out)
protected

Gathers the elements selection can move between, looking inside layout containers.

Parameters
outReceives the elements
Returns
true if any came from inside a layout container

Definition at line 266 of file GuiWindow.cpp.

◆ draw()

void GuiWindow::draw ( )
virtual

Draws all the elements in this GuiWindow.

Implements GuiElement.

Definition at line 109 of file GuiWindow.cpp.

◆ find()

bool GuiWindow::find ( GuiElement * e)

Looks for the specified GuiElement.

Parameters
eThe GuiElement to find
Returns
true if found, false otherwise

Definition at line 85 of file GuiWindow.cpp.

◆ getGuiElementAt()

GuiElement * GuiWindow::getGuiElementAt ( uint32_t index) const

Returns the GuiElement at the specified index.

Parameters
indexThe index of the element
Returns
A pointer to the element at the index, nullptr on error (eg: out of bounds)

Definition at line 97 of file GuiWindow.cpp.

◆ getSelected()

int GuiWindow::getSelected ( )
virtual

Gets the index of the GuiElement inside the window that is currently selected.

Returns
index of selected GuiElement

Reimplemented from GuiElement.

Definition at line 248 of file GuiWindow.cpp.

◆ getSize()

uint32_t GuiWindow::getSize ( )

Returns the size of the list of elements.

Returns
The size of the current element list

Definition at line 104 of file GuiWindow.cpp.

◆ insert()

void GuiWindow::insert ( GuiElement * e,
uint32_t i )

Inserts a GuiElement into the GuiWindow at the specified index.

Parameters
eThe GuiElement to insert. If it is already in the GuiWindow, it is removed first
iIndex in which to insert the element

Definition at line 48 of file GuiWindow.cpp.

◆ moveSelectionHor()

void GuiWindow::moveSelectionHor ( int d)

Moves the selected element to the element to the left or right.

Parameters
dDirection to move (-1 = left, 1 = right)

Definition at line 303 of file GuiWindow.cpp.

◆ moveSelectionIn()

void GuiWindow::moveSelectionIn ( std::vector< GuiElement * > & list,
NAV_DIR d )
protected

Moves the selection within a collected list by on-screen geometry.

Definition at line 279 of file GuiWindow.cpp.

◆ moveSelectionVert()

void GuiWindow::moveSelectionVert ( int d)

Moves the selected element to the element above or below.

Parameters
dDirection to move (-1 = up, 1 = down)

Definition at line 373 of file GuiWindow.cpp.

◆ remove()

void GuiWindow::remove ( GuiElement * e)
virtual

Removes the specified GuiElement from the GuiWindow.

Parameters
eGuiElement to be removed

Reimplemented from GuiElement.

Definition at line 58 of file GuiWindow.cpp.

◆ removeAll()

void GuiWindow::removeAll ( )

Removes all GuiElements.

Definition at line 75 of file GuiWindow.cpp.

◆ resetState()

void GuiWindow::resetState ( )
virtual

Resets the window's state to STATE::DEFAULT.

Reimplemented from GuiElement.

Definition at line 126 of file GuiWindow.cpp.

◆ resetText()

void GuiWindow::resetText ( )
virtual

Resets the text for all contained elements.

Reimplemented from GuiElement.

Definition at line 427 of file GuiWindow.cpp.

◆ setFocus()

void GuiWindow::setFocus ( int f)
virtual

Sets the window focus.

Parameters
fFocus

Reimplemented from GuiElement.

Definition at line 160 of file GuiWindow.cpp.

◆ setState()

void GuiWindow::setState ( STATE s,
int c = -1 )
virtual

Sets the window state, propagated to every child element.

Parameters
sState
cController channel number (-1 for any channel)

Reimplemented from GuiElement.

Definition at line 138 of file GuiWindow.cpp.

◆ setVisible()

void GuiWindow::setVisible ( bool v)
virtual

Sets the visibility of the window.

Parameters
vvisibility (true = visible)

Reimplemented from GuiElement.

Definition at line 149 of file GuiWindow.cpp.

◆ toggleFocus()

void GuiWindow::toggleFocus ( InputController * c)

Changes window focus to the next focusable window or element If no element is in focus, changes focus to the first available element If B or 1 button is pressed, changes focus to the next available element This is intended for the primary GuiWindow only.

Parameters
cPointer to a InputController, containing the current input data

Definition at line 185 of file GuiWindow.cpp.

◆ update()

void GuiWindow::update ( InputController * c)
virtual

Updates the window and all elements contains within Allows the GuiWindow and all elements to respond to the input data specified.

Parameters
cPointer to a InputController, containing the current input data

Reimplemented from GuiElement.

Definition at line 436 of file GuiWindow.cpp.

Member Data Documentation

◆ _elements

std::vector<GuiElement*> GuiWindow::_elements
protected

Contains all elements within the GuiWindow.

Definition at line 93 of file GuiWindow.h.


The documentation for this class was generated from the following files: