Aether
SDL2 based UI Framework for NX
ControlBar.hpp
1 #ifndef AETHER_CONTROLCONTAINER_HPP
2 #define AETHER_CONTROLCONTAINER_HPP
3 
4 #include "Aether/base/Container.hpp"
5 
6 // Forward declare
7 namespace Aether {
8  class ControlItem;
9 };
10 
11 namespace Aether {
16  class ControlBar : public Container {
17  private:
18  // Hide the regular addElement methods in order to only allow Controls.
24 
28  Colour disabledColour;
29 
33  Colour enabledColour;
34 
41  ControlItem * getControl(const Button btn);
42 
47  void repositionItems();
48 
49  public:
55  ControlBar();
56 
67  void addControl(const Button btn, const std::string & label);
68 
75  void disableControl(const Button btn);
76 
83  void enableControl(const Button btn);
84 
93  void moveControl(const Button btn, const Button before);
94 
101  void updateControl(const Button btn, const std::string & label);
102 
106  void removeAllControls();
107 
114  bool removeControl(const Button btn);
115 
121  void setDisabledColour(const Colour colour);
122 
128  void setEnabledColour(const Colour colour);
129 
135  void setW(int w);
136 
142  void setH(int h);
143  };
144 };
145 
146 #endif
void returnAllElements()
Removes (but does not delete) all children elements.
bool removeElement(Element *e)
Attempt to delete given child element.
A container is an element that contains other elements. It implements the required behaviour to navig...
Definition: Container.hpp:16
void setH(int h)
Set the height of the container.
void setW(int w)
Set the width of the container.
void setEnabledColour(const Colour colour)
Set the colour to tint enabled controls with.
void setDisabledColour(const Colour colour)
Set the colour to tint disabled controls with.
void disableControl(const Button btn)
Disables the requested control item. Does nothing if the button has not been added.
int w()
Returns width of element.
Stores RGBA values representing a colour. Each component can be within the range 0 to 255 (inclusive)...
Definition: Colour.hpp:9
void addElement(Element *e)
Adds new element a child.
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 exis...
int h()
Returns height of element.
Base namespace for all Aether related classes and functions.
A container holding control elements (and nothing else) which automatically arranges them at the bott...
Definition: ControlBar.hpp:16
bool returnElement(Element *e)
Attempt to remove the given child element.
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 r...
void removeAllControls()
Remove all controls from the container.
An item used by and updated by the ControlBar element. It shows a button icon and label...
Definition: ControlItem.hpp:11
bool removeControl(const Button btn)
Remove the control for the given button.
void updateControl(const Button btn, const std::string &label)
Update the label associated with the button.
void enableControl(const Button btn)
Enables the requested control item. Does nothing if the button has not been added.
Button
Enum class for buttons Avoids confusion with SDL/libnx names.
Definition: Types.hpp:12
ControlBar()
Constructs a new empty ControlBar. It automatically positions itself at the bottom of the screen...
void removeAllElements()
Deletes all children elements.