Solo Controller Documentation 1.0
Documentation for the Solo Controller
 
Loading...
Searching...
No Matches
ToggleButton Class Reference

Defines a button that toggles between two states. More...

#include <Button.h>

Inheritance diagram for ToggleButton:
Button MomentaryButton

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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ ToggleButton() [1/2]

ToggleButton::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 )
inline

Constructor for a Toggle Button that displays text in each state.

Parameters
[in]buttonNameString containing the name of the button (used for error messages)
[in]DestinationDestination canvas to where the button is to be drawn
[in]DestLocUL x-y coordinate within DestCanvas where the button is to be drawn
[in]buttonText0Text to be displayed on the button in state 0
[in]Font0Font to be used when the button is in state 0
[in]fillColor0Fill color to be used when the button is in state 0
[in]callback0Callback function when the button transitions into state 0
[in]buttonText1Text to be displayed on the button in state 1
[in]Font1Font to be used when the button is in state 1
[in]fillColor1Fill color to be used when the button is in state 1
[in]callback1Callback function when the button transitions into state 1
[in]fontBaselineBaseline to be used when rendering characters (measured fom top of button)
[in]config(Optional) Graphical configuration parameters for the button

◆ ToggleButton() [2/2]

ToggleButton::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 )
inline

Constructor for a Toggle Button that displays images in each state.

Parameters
[in]buttonNameString containing the name of the button (used for error messages)
[in]DestinationDestination canvas to where the current button image is drawn
[in]DestLocUL x-y coordinate within DestCanvas where the button is to be drawn
[in]ButtonImg0Image in Flash ROM for button in state 0
[in]ButtonImgColor0Color in Flash ROM for button in state 0
[in]ButtonFillColor0Fill color for button in state 0
[in]callback0Callback function when the button transitions to state 0
[in]ButtonImg1Image in Flash ROM for button in state 1
[in]ButtonImgColor1Color in Flash ROM for button in state 1
[in]ButtonFillColor1Fill color for button in state 1
[in]callback1Callback 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.

◆ ~ToggleButton()

ToggleButton::~ToggleButton ( void )
default

Default destructor.

Parameters
None.

Member Function Documentation

◆ begin()

void ToggleButton::begin ( void )
overridevirtual

Initializes the button. This method should be called before first use.

Parameters
None.

This method loads the button imagery from the source canvas, making the imagery available for use.

Reimplemented from Button.


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