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

A Spinner contains a number which can be increased/decreased by pressing the associated up/down buttons or the dpad. More...

#include <Spinner.hpp>

Inheritance diagram for Aether::Spinner:
Aether::Container Aether::Element

Public Member Functions

 Spinner (int x, int y, int w=90)
 Construct a new Spinner object. Value is initialized to 0. More...
 
bool handleEvent (InputEvent *e)
 Attempt to handle given event. More...
 
void update (unsigned int dt)
 Updates spinner container. Updates textures and values as necessary. More...
 
void setActive ()
 Set the spinner as active (focused)
 
void setInactive ()
 Set the spinner as inactive (un-focused)
 
bool wrapAround ()
 Get whether to wrap around value if is overflowed/underflowed. More...
 
void setWrapAround (bool b)
 Set whether to wrap around value if is overflowed/underflowed. More...
 
unsigned int digits ()
 Get current value padding (number of zeros to pad value with) More...
 
void setDigits (unsigned int p)
 Set current value padding (number of zeros to pad value with) More...
 
void setLabel (std::string s)
 Set the current label string. More...
 
std::string label ()
 Get the current label string. More...
 
int changeAmount ()
 Get the step size to change value by. More...
 
void setChangeAmount (int a)
 Set the step size to change value by. More...
 
int value ()
 Get the spinner value. More...
 
void setValue (int v)
 Set the spinner value. More...
 
int min ()
 Get the minimum value. More...
 
void setMin (int m)
 Set the minimum value. More...
 
int max ()
 Get the maximum value. More...
 
void setMax (int m)
 Set the maximum value. More...
 
Colour getArrowColour ()
 Get the arrow colour. More...
 
void setArrowColour (Colour c)
 Set the arrow colour. More...
 
Colour getHighlightColour ()
 Get the highlight colour. More...
 
void setHighlightColour (Colour c)
 Set the highlight colour. More...
 
Colour getTextColour ()
 Get the text colour. More...
 
void setTextColour (Colour c)
 Set the text colour. 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 addElement (Element *e)
 Adds new element a child. 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 setW (int w)
 Set width of element. More...
 
virtual void setH (int h)
 Set height 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 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 Spinner contains a number which can be increased/decreased by pressing the associated up/down buttons or the dpad.

Note
This element has a default height and should not be changed!

Constructor & Destructor Documentation

◆ Spinner()

Aether::Spinner::Spinner ( int  x,
int  y,
int  w = 90 
)

Construct a new Spinner object. Value is initialized to 0.

Parameters
xx-coordinate of start position offset
yy-coordinate of start position offset
wspinner width (default 90)

Member Function Documentation

◆ changeAmount()

int Aether::Spinner::changeAmount ( )

Get the step size to change value by.

Returns
step size

◆ digits()

unsigned int Aether::Spinner::digits ( )

Get current value padding (number of zeros to pad value with)

Returns
number of zeros to pad with

◆ getArrowColour()

Colour Aether::Spinner::getArrowColour ( )

Get the arrow colour.

Returns
arrow colour

◆ getHighlightColour()

Colour Aether::Spinner::getHighlightColour ( )

Get the highlight colour.

Returns
highlight colour

◆ getTextColour()

Colour Aether::Spinner::getTextColour ( )

Get the text colour.

Returns
text colour

◆ handleEvent()

bool Aether::Spinner::handleEvent ( InputEvent e)
virtual

Attempt to handle given event.

Parameters
eevent to attempt handle
Returns
true if event was handled
false otherwise

Reimplemented from Aether::Container.

◆ label()

std::string Aether::Spinner::label ( )

Get the current label string.

Returns
label string

◆ max()

int Aether::Spinner::max ( )

Get the maximum value.

Returns
max value

◆ min()

int Aether::Spinner::min ( )

Get the minimum value.

Returns
min value

◆ setArrowColour()

void Aether::Spinner::setArrowColour ( Colour  c)

Set the arrow colour.

Parameters
cnew arrow colour

◆ setChangeAmount()

void Aether::Spinner::setChangeAmount ( int  a)

Set the step size to change value by.

Parameters
anew step size

◆ setDigits()

void Aether::Spinner::setDigits ( unsigned int  p)

Set current value padding (number of zeros to pad value with)

Note
0 to disable padding
Parameters
pnew number of zeros to pad with

◆ setHighlightColour()

void Aether::Spinner::setHighlightColour ( Colour  c)

Set the highlight colour.

Parameters
cnew highlight colour

◆ setLabel()

void Aether::Spinner::setLabel ( std::string  s)

Set the current label string.

Note
Set as empty string to remove label
Parameters
snew label string

◆ setMax()

void Aether::Spinner::setMax ( int  m)

Set the maximum value.

Parameters
mnew max value

◆ setMin()

void Aether::Spinner::setMin ( int  m)

Set the minimum value.

Parameters
mnew min value

◆ setTextColour()

void Aether::Spinner::setTextColour ( Colour  c)

Set the text colour.

Parameters
cnew text colour

◆ setValue()

void Aether::Spinner::setValue ( int  v)

Set the spinner value.

Parameters
vnew value

◆ setWrapAround()

void Aether::Spinner::setWrapAround ( bool  b)

Set whether to wrap around value if is overflowed/underflowed.

Parameters
btrue if value should be wrapped, false otherwise

◆ update()

void Aether::Spinner::update ( unsigned int  dt)
virtual

Updates spinner container. Updates textures and values as necessary.

Parameters
dtchange in time

Reimplemented from Aether::Element.

◆ value()

int Aether::Spinner::value ( )

Get the spinner value.

Returns
value

◆ wrapAround()

bool Aether::Spinner::wrapAround ( )

Get whether to wrap around value if is overflowed/underflowed.

Returns
true if value should be wrapped
false otherwise

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