Chesto 0.9
A declarative and element-based library for creating GUIs on homebrew'd consoles
Public Member Functions | Public Attributes | List of all members
Chesto::DropDown Class Reference
Inheritance diagram for Chesto::DropDown:
Inheritance graph
[legend]
Collaboration diagram for Chesto::DropDown:
Collaboration graph
[legend]

Public Member Functions

 DropDown (int physicalButton, std::vector< std::pair< std::string, std::string > > choices, std::function< void(std::string)> onSelect, int textSize, std::string defaultChoice="", bool isDarkMode=false)
 
bool process (InputEvents *event)
 process any input that is received for this element More...
 
- Public Member Functions inherited from Chesto::Button
 Button (std::string text, int button, bool dark=false, int size=20, int width=0)
 
void render (Element *parent)
 display the current state of the display More...
 
bool process (InputEvents *event)
 process any input that is received for this element More...
 
void updateBounds ()
 
void updateText (const std::string &inc_text)
 
const std::string getText ()
 
- Public Member Functions inherited from Chesto::Element
virtual bool process (InputEvents *event)
 process any input that is received for this element More...
 
virtual void render (Element *parent)
 display the current state of the display More...
 
bool onTouchDown (InputEvents *event)
 
bool onTouchDrag (InputEvents *event)
 
bool onTouchUp (InputEvents *event)
 
void hide ()
 
void unhide ()
 
void renderBackground (bool fill=true)
 
void addNode (std::unique_ptr< Element > node)
 
void remove (Element *element)
 
void removeAll ()
 
void position (int x, int y)
 position the element More...
 
void recalcPosition (Element *parent)
 
float getEffectiveScale () const
 
CST_Rect getBounds ()
 
CST_Renderer * getRenderer ()
 
ElementsetPosition (int x, int y)
 
ElementsetAction (std::function< void()> func)
 
ElementsetAbsolute (bool isAbs)
 
template<typename T , typename... Args>
T * createNode (Args &&... args)
 
Elementconstrain (int flags, int padding=0)
 
ElementconstrainToTarget (Element *target, int flags, int padding=0)
 
Elementanimate (int durationIn, std::function< void(float)> onStep, std::function< void()> onFinish)
 
ElementmoveToFront ()
 
ElementsetTouchable (bool touchable)
 
void screenshot (std::string path)
 Take a screenshot of this element and its children, and save it to the given path. More...
 

Public Attributes

std::vector< std::pair< std::string, std::string > > choices
 
std::function< void(std::string)> onSelect
 
std::string selectedChoice
 
- Public Attributes inherited from Chesto::Button
std::string myLastSeenGamepad = ""
 
TextElement text
 
int fixedWidth = 0
 
bool dark = false
 
- Public Attributes inherited from Chesto::Element
std::function< void()> action = NULL
 the action to call (from binded callback) on touch or button selection https://stackoverflow.com/questions/14189440/c-class-member-callback-simple-examples More...
 
std::function< void(InputEvents *event)> actionWithEvents = NULL
 
std::vector< std::unique_ptr< Element, std::function< void(Element *)> > > elements
 visible GUI child elements of this element More...
 
float scale = 1.0f
 
bool touchable = false
 whether or not this element can be touched (highlights bounds) More...
 
bool dragging = false
 whether or not this element is currently being dragged More...
 
bool needsRedraw = false
 whether or not this element needs the screen redrawn next time it's processed More...
 
int futureRedrawCounter = 0
 whether this element needs a redraw for the next X redraws (decreases each time) (0 is no redraws) More...
 
int lastMouseY = 0
 the last Y, X coordinate of the mouse (from a drag probably) More...
 
int lastMouseX = 0
 
bool hasBackground = false
 
rgb backgroundColor = {0, 0, 0}
 
int backgroundOpacity = 0xff
 
bool isAbsolute = false
 
Elementparent = nullptr
 the parent element (reference only, not owned) More...
 
bool hidden = false
 whether this element should skip rendering or not More...
 
bool isProtected = false
 
int elasticCounter = 0
 how much time is left in an elastic-type flick/scroll set by the last distance traveled in a scroll, and counts down every frame More...
 
int width = 0
 width and height of this element (must be manually set, isn't usually calculated (but is in some cases, like text or images)) More...
 
int height = 0
 
int x = 0
 
int y = 0
 
int xAbs = 0
 
int yAbs = 0
 
double angle = 0
 rotation angle in degrees More...
 
int cornerRadius = 0
 
int tag = 0
 
std::vector< std::unique_ptr< Constraint > > constraints
 
std::vector< std::unique_ptr< Animation > > animations
 
bool useColorMask = false
 whether or not to overlay a color mask on top of this element More...
 
CST_Color maskColor = {0,0,0,0}
 The color to overlay on top. More...
 

Additional Inherited Members

- Public Types inherited from Chesto::Element
typedef Element super
 
- Static Public Member Functions inherited from Chesto::Button
static std::string getControllerButtonImageForPlatform (int button, bool isGray, bool isOutline)
 
- Protected Member Functions inherited from Chesto::Element
void addStackMember (Element *element)
 

Detailed Description

Definition at line 23 of file DropDown.hpp.

Constructor & Destructor Documentation

◆ DropDown()

Chesto::DropDown::DropDown ( int  physicalButton,
std::vector< std::pair< std::string, std::string > >  choices,
std::function< void(std::string)>  onSelect,
int  textSize,
std::string  defaultChoice = "",
bool  isDarkMode = false 
)

Definition at line 9 of file DropDown.cpp.

16 : Button(defaultChoice.empty() ? "Select..." : ([&choices, &defaultChoice]() {
17 for (const auto& choice : choices) {
18 if (choice.first == defaultChoice) return choice.second;
19 }
20 return defaultChoice;
21 })(), physicalButton, isDarkMode, textSize, 0)
22{
23 this->choices = choices;
24 this->onSelect = onSelect;
25 this->selectedChoice = defaultChoice;
26
27 this->setAction([
28 this,
29 callback = this->onSelect,
30 isDarkMode
31 ]() {
32 RootDisplay::pushScreen(std::make_unique<DropDownChoices>(
33 this->choices,
34 callback,
35 isDarkMode
36 ));
37 });
38}

Member Function Documentation

◆ process()

bool Chesto::DropDown::process ( InputEvents event)
virtual

process any input that is received for this element

Reimplemented from Chesto::Button.

Definition at line 40 of file DropDown.cpp.

40 {
41 return Button::process(event);
42}
bool process(InputEvents *event)
process any input that is received for this element
Definition: Button.cpp:155

Member Data Documentation

◆ choices

std::vector<std::pair<std::string, std::string> > Chesto::DropDown::choices

Definition at line 34 of file DropDown.hpp.

◆ onSelect

std::function<void(std::string)> Chesto::DropDown::onSelect

Definition at line 35 of file DropDown.hpp.

◆ selectedChoice

std::string Chesto::DropDown::selectedChoice

Definition at line 36 of file DropDown.hpp.


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