Aether
SDL2 based UI Framework for NX
Spinner.hpp
1 #ifndef AETHER_SPINNER_HPP
2 #define AETHER_SPINNER_HPP
3 
4 #include "Aether/base/Container.hpp"
5 #include "Aether/primary/Text.hpp"
6 #include "Aether/utils/Types.hpp"
7 
11 enum class SpinnerHoldAction {
12  UpHeld,
13  UpHeldRepeat,
14  DownHeld,
15  DownHeldRepeat,
16  NoHeld
17 };
18 
19 namespace Aether {
25  class Spinner : public Container {
26  private:
28  Text * up;
30  Text * down;
32  Text * str;
34  Text * label_;
36  Element * upContainer;
38  Element * downContainer;
40  bool isFocused;
42  bool wrap;
44  unsigned int padding;
46  int amount;
48  int min_;
50  int max_;
52  int value_;
54  SpinnerHoldAction held;
56  uint32_t holdTime;
58  Colour arrowC;
60  Colour highlightC;
62  Colour textC;
63 
68  void incrementVal();
69 
74  void decrementVal();
75 
76  public:
85  Spinner(int x, int y, int w = 90);
86 
94  bool handleEvent(InputEvent * e);
95 
102  void update(unsigned int dt);
103 
107  void setActive();
108 
112  void setInactive();
113 
120  bool wrapAround();
121 
127  void setWrapAround(bool b);
128 
134  unsigned int digits();
135 
141  void setDigits(unsigned int p);
142 
148  void setLabel(std::string s);
149 
155  std::string label();
156 
162  int changeAmount();
163 
169  void setChangeAmount(int a);
170 
176  int value();
177 
183  void setValue(int v);
184 
190  int min();
191 
197  void setMin(int m);
198 
204  int max();
205 
211  void setMax(int m);
212 
218  Colour getArrowColour();
219 
225  void setArrowColour(Colour c);
226 
232  Colour getHighlightColour();
233 
239  void setHighlightColour(Colour c);
240 
246  Colour getTextColour();
247 
253  void setTextColour(Colour c);
254  };
255 };
256 
257 #endif
A container is an element that contains other elements. It implements the required behaviour to navig...
Definition: Container.hpp:16
Element for rendering a single line of text. It can optionally scroll when overflowing.
Definition: Text.hpp:15
A Spinner contains a number which can be increased/decreased by pressing the associated up/down butto...
Definition: Spinner.hpp:25
Stores RGBA values representing a colour. Each component can be within the range 0 to 255 (inclusive)...
Definition: Colour.hpp:9
Element is the base class to be inherited to form all other types of elements.
Definition: Element.hpp:18
Base namespace for all Aether related classes and functions.
A class that represents an Aether input event.
Definition: InputEvent.hpp:25