Defines a button that toggles between two states. More...
#include <Button.h>
Public Member Functions | |
Constructors and Destructors | |
| ToggleButton (const char *buttonName, Canvas &Destination, const Block_Image &DestLoc, const char *buttonText0, FontList::FontID Font0, uint16_t fillColor0, ButtonState::buttonCallbackFunction callback0, const char *buttonText1, FontList::FontID Font1, uint16_t fillColor1, ButtonState::buttonCallbackFunction callback1, uint16_t fontBaseline, const ButtonConfig_t< 2 > config=DEFAULT_BUTTON_CONFIG) | |
| Constructor for a Toggle Button that displays text in each state. | |
| ToggleButton (const char *buttonName, Canvas &Destination, const Block_Image &DestLoc, ROM_Image ButtonImg0, uint16_t ButtonImgColor0, uint16_t ButtonFillColor0, ButtonState::buttonCallbackFunction callback0, ROM_Image ButtonImg1, uint16_t ButtonImgColor1, uint16_t ButtonFillColor1, ButtonState::buttonCallbackFunction callback1, const ButtonConfig_t< 2 > config=DEFAULT_BUTTON_CONFIG) | |
| Constructor for a Toggle Button that displays images in each state. | |
| ~ToggleButton (void)=default | |
| Default destructor. | |
General Methods | |
| void | begin (void) override |
| Initializes the button. This method should be called before first use. | |
Public Member Functions inherited from Button | |
| Button (const char *buttonName, Canvas &DestCanvas, uint16_t dest_x, uint16_t dest_y, uint16_t width, uint16_t height, callback_type whenCallback) | |
| Constructor for creating a Button object. | |
| virtual | ~Button (void)=default |
| Default destructor. | |
| virtual bool | press (FT5316::TouchLocation loc) |
Presses the button if loc is within the bounds of the button. | |
| virtual void | release (void) |
| Called when the button is released. | |
| void | enable (void) |
| Enables the button, making it accept button presses. | |
| void | disable (void) |
| Disables the button, so that it ignores button presses. | |
| void | setState (uint8_t state) |
| Sets the button to the specified state. | |
| void | nextState (void) |
| Advances the button to the next state. | |
| void | draw (void) |
| Draws the image from the current ButtonState onto the destination canvas. | |
| void | draw (Canvas &newCanvas) |
| Draws the image from the current ButtonState onto the specified canvas. | |
| bool | isEnabled (void) const |
| Indicates whether the Button is enabled. | |
| uint16_t | width (void) const |
| Returns the width of the button in pixels. | |
| uint16_t | height (void) const |
| Returns the height of the button in pixels. | |
| uint8_t | state (void) const |
| Returns the current state of the button. | |
Additional Inherited Members | |
Public Types inherited from Button | |
| enum | callback_type { ON_PRESS , ON_RELEASE } |
| Type definition that defines when the callback function is called relative to button press/release. More... | |
Protected Member Functions inherited from Button | |
| void | _validateObject (void) |
| Validates that all ButtonState objects have been defined. | |
| void | _registerButtonStates (ButtonState **buttonStatePtrArr, uint8_t numStates) |
| Registers the ButtonState objects that define this button. | |
| void | _changeCallback (callback_type type) |
| Convenience method that changes when the callback is called. | |
Defines a button that toggles between two states.
Each state has its own image and callback function. The callback function is called whenever the users releases the button.
|
inline |
Constructor for a Toggle Button that displays text in each state.
| [in] | buttonName | String containing the name of the button (used for error messages) |
| [in] | Destination | Destination canvas to where the button is to be drawn |
| [in] | DestLoc | UL x-y coordinate within DestCanvas where the button is to be drawn |
| [in] | buttonText0 | Text to be displayed on the button in state 0 |
| [in] | Font0 | Font to be used when the button is in state 0 |
| [in] | fillColor0 | Fill color to be used when the button is in state 0 |
| [in] | callback0 | Callback function when the button transitions into state 0 |
| [in] | buttonText1 | Text to be displayed on the button in state 1 |
| [in] | Font1 | Font to be used when the button is in state 1 |
| [in] | fillColor1 | Fill color to be used when the button is in state 1 |
| [in] | callback1 | Callback function when the button transitions into state 1 |
| [in] | fontBaseline | Baseline to be used when rendering characters (measured fom top of button) |
| [in] | config | (Optional) Graphical configuration parameters for the button |
|
inline |
Constructor for a Toggle Button that displays images in each state.
| [in] | buttonName | String containing the name of the button (used for error messages) |
| [in] | Destination | Destination canvas to where the current button image is drawn |
| [in] | DestLoc | UL x-y coordinate within DestCanvas where the button is to be drawn |
| [in] | ButtonImg0 | Image in Flash ROM for button in state 0 |
| [in] | ButtonImgColor0 | Color in Flash ROM for button in state 0 |
| [in] | ButtonFillColor0 | Fill color for button in state 0 |
| [in] | callback0 | Callback function when the button transitions to state 0 |
| [in] | ButtonImg1 | Image in Flash ROM for button in state 1 |
| [in] | ButtonImgColor1 | Color in Flash ROM for button in state 1 |
| [in] | ButtonFillColor1 | Fill color for button in state 1 |
| [in] | callback1 | Callback function when the button transitions to state 0 |
| [in] | config | (Optional) Graphical configuration parameters for the button |
The images used by this constructor have transparent backgrounds. They arein the 16-bit color (ARGB format). This object overrides the RGB color of the image with the provided ButtonImgColor value. This color is then overlaid on top of the button fill color to create the final button appearance.
|
default |
Default destructor.
|
overridevirtual |
Initializes the button. This method should be called before first use.
This method loads the button imagery from the source canvas, making the imagery available for use.
Reimplemented from Button.