Aether
SDL2 based UI Framework for NX
Public Member Functions | List of all members
Aether::ControlBar Class Reference

A container holding control elements (and nothing else) which automatically arranges them at the bottom of the screen. More...

#include <ControlBar.hpp>

Inheritance diagram for Aether::ControlBar:
Aether::Container Aether::Element

Public Member Functions

 ControlBar ()
 Constructs a new empty ControlBar. It automatically positions itself at the bottom of the screen. Use setX/Y/W/H to configure position + size if needed.
 
void addControl (const Button btn, const std::string &label)
 Adds a new control to the left of the bar with the given attributes. Does nothing if one already exists with the same button. More...
 
void disableControl (const Button btn)
 Disables the requested control item. Does nothing if the button has not been added. More...
 
void enableControl (const Button btn)
 Enables the requested control item. Does nothing if the button has not been added. More...
 
void moveControl (const Button btn, const Button before)
 Moves a control to another position. Provide 'NO_BUTTON' as the 'before' button to move to the very right of the bar. More...
 
void updateControl (const Button btn, const std::string &label)
 Update the label associated with the button. More...
 
void removeAllControls ()
 Remove all controls from the container.
 
bool removeControl (const Button btn)
 Remove the control for the given button. More...
 
void setDisabledColour (const Colour colour)
 Set the colour to tint disabled controls with. More...
 
void setEnabledColour (const Colour colour)
 Set the colour to tint enabled controls with. More...
 
void setW (int w)
 Set the width of the container. More...
 
void setH (int h)
 Set the height of the container. More...
 
- Public Member Functions inherited from Aether::Container
 Container (int x=0, int y=0, int w=100, int h=100)
 Construct a new Container object. More...
 
void setActive ()
 Re-highlight/focus the focused element.
 
void setInactive ()
 Removes focus from the focused element.
 
void addElement (Element *e)
 Adds new element a child. More...
 
bool handleEvent (InputEvent *e)
 Attempt to handle a given event. More...
 
bool removeElement (Element *e)
 Attempt to delete given child element. More...
 
void removeAllElements ()
 Deletes all children elements.
 
bool returnElement (Element *e)
 Attempt to remove the given child element. More...
 
void returnAllElements ()
 Removes (but does not delete) all children elements.
 
- Public Member Functions inherited from Aether::Element
 Element (int x=0, int y=0, int w=100, int h=100)
 Construct a new Element object. More...
 
int x ()
 Returns x-coordinate of element. More...
 
int y ()
 Returns y-coordinate of element. More...
 
int w ()
 Returns width of element. More...
 
int h ()
 Returns height of element. More...
 
virtual void setX (int x)
 Set x-coordinate of element. More...
 
virtual void setY (int y)
 Set y-coordinate of element. More...
 
virtual void setXY (int x, int y)
 Set co-ordinates of element. More...
 
virtual void setWH (int w, int h)
 Set size of element. More...
 
virtual void setXYWH (int x, int y, int w, int h)
 Setter size and co-ordinates of element. More...
 
Elementparent ()
 Returns the parent element of this element. More...
 
void setParent (Element *p)
 Set the parent element of this element. More...
 
bool isVisible ()
 Check if current element is visible on-screen. More...
 
bool hidden ()
 Check if current element is hidden. More...
 
void setHidden (bool b)
 Set whether element is hidden or not. More...
 
bool selected ()
 Check if current element is selected. More...
 
virtual void setSelected (bool b)
 Set whether element is selected or not. More...
 
bool selectable ()
 Check if current element is selectable. More...
 
void setSelectable (bool b)
 Set whether element is selectable or not. More...
 
bool touchable ()
 Check if current element is touch responsive. More...
 
void setTouchable (bool b)
 Set whether element is touch responsive or not. More...
 
bool highlighted ()
 Check if current element is highlighted. More...
 
void setHighlighted (bool b)
 Set whether element is highlighted or not. More...
 
bool hasHighlighted ()
 Check if current element has highlighted children element. More...
 
void setHasHighlighted (bool b)
 Set whether element has highlighted children element or not. More...
 
bool hasSelectable ()
 Check if current element has selectable children element. More...
 
void setHasSelectable (bool b)
 Set whether element has selectable children element or not. More...
 
bool hasSelected ()
 Check if current element has selected children element. More...
 
void setHasSelected (bool b)
 Set whether element has selected children element or not. More...
 
void setFocused (Element *e)
 Sets current element as unfocused and instead focuses a sub-element. More...
 
void setFocussed (Element *e)
 Sets current element as unfocused and instead focuses a sub-element. More...
 
Elementfocused ()
 Returns the currently focused element. More...
 
Elementfocussed ()
 Returns the currently focused element. More...
 
std::function< void()> onPressFunc ()
 Returns function invoked when the element is pressed. More...
 
void onPress (std::function< void()> f)
 Sets the function to invoked when the element is pressed. More...
 
virtual void update (unsigned int dt)
 Update is passed time since last frame (for animations) More...
 
virtual void render ()
 Render child elements + highlights.
 
virtual DrawablerenderHighlightBG ()
 Renders the highlight background. More...
 
virtual DrawablerenderHighlight ()
 Renders the highlight border. More...
 
virtual DrawablerenderSelection ()
 Renders the selection overlay. More...
 
virtual ~Element ()
 Destroy the Element object.
 

Additional Inherited Members

- Protected Member Functions inherited from Aether::Container
void addElementAt (Element *e, size_t i)
 
- Protected Member Functions inherited from Aether::Element
void renderHighlightTextures ()
 Renders cached highlight textures.
 
void renderSelectionTexture ()
 Renders cached selection texture.
 
void addElementAt (Element *e, size_t i)
 Add element at given index in vector. More...
 
- Protected Attributes inherited from Aether::Element
Elementparent_
 Pointer to parent element, if there is one.
 
std::vector< Element * > children
 Vector of child elements (used to call their methods)
 
Elementfocused_
 Children element which is highlighted/focused (to regain focus on activation)
 
- Static Protected Attributes inherited from Aether::Element
static Colour hiBGColour
 Background colour if element is highlighted.
 
static Colour hiBorderColour
 Border colour if element is highlighted.
 
static Colour selColour
 Selected colour if element is highlighted.
 
static unsigned int hiSize
 Size of highlight border.
 
static DrawablehiBGTex
 Highlight background texture.
 
static DrawablehiBorderTex
 Highlight border texture.
 
static DrawableselTex
 Selection texture.
 
static Rendererrenderer
 
static bool isTouch
 Indicator on whether the touch is "active" (i.e. hide highlighting) or not.
 

Detailed Description

A container holding control elements (and nothing else) which automatically arranges them at the bottom of the screen.

Member Function Documentation

◆ addControl()

void Aether::ControlBar::addControl ( const Button  btn,
const std::string &  label 
)

Adds a new control to the left of the bar with the given attributes. Does nothing if one already exists with the same button.

When touched, a global button press event is sent out.

Parameters
btnButton to add control item for.
labelLabel to show adjacent to button.

◆ disableControl()

void Aether::ControlBar::disableControl ( const Button  btn)

Disables the requested control item. Does nothing if the button has not been added.

Parameters
btnButton to disable.

◆ enableControl()

void Aether::ControlBar::enableControl ( const Button  btn)

Enables the requested control item. Does nothing if the button has not been added.

Parameters
btnButton to enable.

◆ moveControl()

void Aether::ControlBar::moveControl ( const Button  btn,
const Button  before 
)

Moves a control to another position. Provide 'NO_BUTTON' as the 'before' button to move to the very right of the bar.

Parameters
btnButton to move.
beforeButton to place 'before' (to the left of)

◆ removeControl()

bool Aether::ControlBar::removeControl ( const Button  btn)

Remove the control for the given button.

Parameters
btnControl to remove.
Returns
True if removed, false if not found.

◆ setDisabledColour()

void Aether::ControlBar::setDisabledColour ( const Colour  colour)

Set the colour to tint disabled controls with.

Parameters
colourColour used for tinting.

◆ setEnabledColour()

void Aether::ControlBar::setEnabledColour ( const Colour  colour)

Set the colour to tint enabled controls with.

Parameters
colourColour used for tinting.

◆ setH()

void Aether::ControlBar::setH ( int  h)
virtual

Set the height of the container.

Parameters
hHeight of container in pixels

Reimplemented from Aether::Element.

◆ setW()

void Aether::ControlBar::setW ( int  w)
virtual

Set the width of the container.

Parameters
wWidth of container in pixels

Reimplemented from Aether::Element.

◆ updateControl()

void Aether::ControlBar::updateControl ( const Button  btn,
const std::string &  label 
)

Update the label associated with the button.

Parameters
btnButton to update.
labelNew label to set.

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