#include <TcDrawableButton.h>
Public Types | |
enum | ButtonDrawingMode { NORMAL , SELECTED , PRESSED , NOT_SELECTABLE } |
Public Member Functions | |
TcDrawableButton (const Coord &where, const Coord &size, color_t bgCol, color_t fgCol, color_t selCol, const char *text, const DeviceFontDrawingMode &font) | |
TcDrawableButton (const Coord &where, const Coord &size, color_t bgCol, color_t fgCol, color_t selCol, const tcgfx::DrawableIcon *icon) | |
TcDrawableButton (const tcgfx::DrawableIcon *icon) | |
TcDrawableButton (const char *text, const DeviceFontDrawingMode &font) | |
bool | touchInBounds (const Coord &location) const |
void | setButtonOnMonoDisplay (bool mono) |
bool | isButtonOnMonoDisplay () |
void | setButtonDrawingMode (ButtonDrawingMode mode) |
void | setDirty (bool d) |
bool | isDirty () const |
bool | isIconDrawn () const |
ButtonDrawingMode | getButtonDrawingMode () |
void | paintButton (DeviceDrawable *drawable) |
void | setPosition (const Coord &position) |
void | setPositionAndSize (const Coord &position, const Coord &newSize) |
void | setColors (color_t bgCol, color_t fgCol, color_t selCol) |
void | setText (const char *newText) |
A drawable button that can render onto TcMenu drawables, it easily integrates with touch screens and draws onto a very wide range of displays. Has semantics similar to a regular button on all displays. It has a position and size, color,
TcDrawableButton::TcDrawableButton | ( | const Coord & | where, |
const Coord & | size, | ||
color_t | bgCol, | ||
color_t | fgCol, | ||
color_t | selCol, | ||
const char * | text, | ||
const DeviceFontDrawingMode & | font | ||
) |
Create a button object that has only text at a particular point and size and color.
where | the position to start drawing. |
size | the size of the button |
bgCol | the background color |
fgCol | the foreground color |
text | the text to be presented. |
TcDrawableButton::TcDrawableButton | ( | const Coord & | where, |
const Coord & | size, | ||
color_t | bgCol, | ||
color_t | fgCol, | ||
color_t | selCol, | ||
const tcgfx::DrawableIcon * | icon | ||
) |
Create a button object that has an icon at a particular point and size and color.
where | the position to start drawing. |
size | the size of the button |
bgCol | the background color |
fgCol | the foreground color |
text | the text to be presented or nullptr if there is no text. |
|
explicit |
Create an icon based button where it is more convenient to set the color and positioning later
icon | the icon to draw with |
TcDrawableButton::TcDrawableButton | ( | const char * | text, |
const DeviceFontDrawingMode & | font | ||
) |
Create a text based b1utton where it is more convenient to set the color and positioning later
text | the text to draw |
font | the font to draw with |
bool TcDrawableButton::touchInBounds | ( | const Coord & | location | ) | const |
Returns true if the touch coordinates provided are within the bounds of this button, it also sets the pressed flag
location | the touch location |
|
inline |
On mono OLED displays there is no in-between value that suits greying out, the easiest is to remove from view and the only selected action we have is to invert the button.
mono | true- when on a monochrmoe two color display |
|
inline |
|
inline |
Set the button mode
pressed |
|
inline |
Marks the button as dirty and therefore requiring a screen update.
d |
|
inline |
If the button needs painting
|
inline |
If the button is an icon button
|
inline |
void TcDrawableButton::paintButton | ( | DeviceDrawable * | drawable | ) |
paint onto the drawable, using a sub-device if it is supported, will only draw when dirty flag is set.
drawable | the drawable to draw onto |
void TcDrawableButton::setPosition | ( | const Coord & | position | ) |
Set a new position for the button, note you will need to clear from the old location
position | the new screen position |
Set both the position and size of the button at the same time
position | the screen position |
newSize | the new size |
Change the colors associated with the button
bgCol | the background |
fgCol | the foreground |
selCol | the selected background |