libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
GuiButton.h
1/****************************************************************************
2 * libgui
3 * Daryl Borth 2009-2026
4 * GuiButton.h
5 ***************************************************************************/
6#pragma once
7
8#define MAX_BTN_LABELS 3
9
12class GuiButton : public GuiElement
13{
14 public:
18 GuiButton(int w = 0, int h = 0);
20 ~GuiButton();
23 void setImage(GuiElement* i);
26 void setImageOver(GuiElement* i);
29 void setImageHold(GuiElement* i);
35 void setIcon(GuiElement* i);
38 void setIconOver(GuiElement* i);
41 void setIconHold(GuiElement* i);
44 void setIconClick(GuiElement* i);
48 void setLabel(GuiText* t, int n = 0);
52 void setLabelOver(GuiText* t, int n = 0);
56 void setLabelHold(GuiText* t, int n = 0);
60 void setLabelClick(GuiText* t, int n = 0);
63 void setSoundOver(GuiSound * s);
66 void setSoundHold(GuiSound * s);
69 void setSoundClick(GuiSound * s);
71 void draw() override;
73 void resetText();
76 void setState(STATE s, int c = -1) override;
78 void resetState() override;
81 void update(InputController * c);
82 protected:
91 GuiText * label[MAX_BTN_LABELS];
92 GuiText * labelOver[MAX_BTN_LABELS];
93 GuiText * labelHold[MAX_BTN_LABELS];
94 GuiText * labelClick[MAX_BTN_LABELS];
98};
GuiElement * iconClick
Button icon for STATE::CLICKED.
Definition GuiButton.h:90
void setLabel(GuiText *t, int n=0)
Sets the button's label.
Definition GuiButton.cpp:82
void resetState() override
Resets the state and mirrors it into the button's images and icons.
GuiText * labelOver[MAX_BTN_LABELS]
Label(s) to display for STATE::SELECTED.
Definition GuiButton.h:92
GuiElement * image
Button image (default): a GuiImage, GuiShape or any element.
Definition GuiButton.h:83
void update(InputController *c)
Constantly called to allow the GuiButton to respond to updated input data.
void setIconClick(GuiElement *i)
Sets the button's icon on click.
Definition GuiButton.cpp:77
GuiElement * imageOver
Button image for STATE::SELECTED.
Definition GuiButton.h:84
GuiSound * soundOver
Sound to play for STATE::SELECTED.
Definition GuiButton.h:95
GuiSound * soundHold
Sound to play for STATE::HELD.
Definition GuiButton.h:96
GuiElement * imageClick
Button image for STATE::CLICKED.
Definition GuiButton.h:86
GuiButton(int w=0, int h=0)
Constructor.
Definition GuiButton.cpp:9
void setSoundHold(GuiSound *s)
Sets the sound to play on hold.
GuiText * labelClick[MAX_BTN_LABELS]
Label(s) to display for STATE::CLICKED.
Definition GuiButton.h:94
void setImage(GuiElement *i)
Sets the button's image.
Definition GuiButton.cpp:42
void draw() override
Constantly called to draw the GuiButton.
void setImageHold(GuiElement *i)
Sets the button's image on hold.
Definition GuiButton.cpp:52
void setSoundClick(GuiSound *s)
Sets the sound to play on click.
void setIcon(GuiElement *i)
Sets the button's icon.
Definition GuiButton.cpp:62
void setSoundOver(GuiSound *s)
Sets the sound to play on over.
void setLabelClick(GuiText *t, int n=0)
Sets the button's label on click.
GuiElement * imageHold
Button image for STATE::HELD.
Definition GuiButton.h:85
~GuiButton()
Destructor.
Definition GuiButton.cpp:38
GuiElement * icon
Button icon (drawn after button image)
Definition GuiButton.h:87
void setImageClick(GuiElement *i)
Sets the button's image on click.
Definition GuiButton.cpp:57
void setLabelOver(GuiText *t, int n=0)
Sets the button's label on over (eg: different colored text)
Definition GuiButton.cpp:88
GuiSound * soundClick
Sound to play for STATE::CLICKED.
Definition GuiButton.h:97
GuiElement * iconOver
Button icon for STATE::SELECTED.
Definition GuiButton.h:88
GuiText * labelHold[MAX_BTN_LABELS]
Label(s) to display for STATE::HELD.
Definition GuiButton.h:93
void resetText()
Resets the text for all contained elements.
void setLabelHold(GuiText *t, int n=0)
Sets the button's label on hold.
Definition GuiButton.cpp:94
GuiText * label[MAX_BTN_LABELS]
Label(s) to display (default)
Definition GuiButton.h:91
void setState(STATE s, int c=-1) override
Sets the state and mirrors it into the button's images and icons, so a state-aware element such as Gu...
GuiElement * iconHold
Button icon for STATE::HELD.
Definition GuiButton.h:89
void setIconOver(GuiElement *i)
Sets the button's icon on over.
Definition GuiButton.cpp:67
void setIconHold(GuiElement *i)
Sets the button's icon on hold.
Definition GuiButton.cpp:72
void setImageOver(GuiElement *i)
Sets the button's image on over.
Definition GuiButton.cpp:47
GuiElement()
Constructor.
Definition GuiElement.cpp:9
Sound conversion and playback.
Definition GuiSound.h:27
Display, manage, and manipulate text in the GUI.
Definition GuiText.h:10
Logical controller for one input channel.
STATE
Interaction state of a GuiElement (default, selected, clicked, held, disabled).
Definition GuiElement.h:36