tcMenu
Public Types | Public Member Functions | List of all members
tcgfx::TcDrawableButton Class Reference

#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)
 

Detailed Description

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,

Constructor & Destructor Documentation

◆ TcDrawableButton() [1/4]

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.

Parameters
wherethe position to start drawing.
sizethe size of the button
bgColthe background color
fgColthe foreground color
textthe text to be presented.

◆ TcDrawableButton() [2/4]

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.

Parameters
wherethe position to start drawing.
sizethe size of the button
bgColthe background color
fgColthe foreground color
textthe text to be presented or nullptr if there is no text.

◆ TcDrawableButton() [3/4]

TcDrawableButton::TcDrawableButton ( const tcgfx::DrawableIcon icon)
explicit

Create an icon based button where it is more convenient to set the color and positioning later

Parameters
iconthe icon to draw with

◆ TcDrawableButton() [4/4]

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

Parameters
textthe text to draw
fontthe font to draw with

Member Function Documentation

◆ touchInBounds()

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

Parameters
locationthe touch location
Returns
true if within the buttons bounds

◆ setButtonOnMonoDisplay()

void tcgfx::TcDrawableButton::setButtonOnMonoDisplay ( bool  mono)
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.

Parameters
monotrue- when on a monochrmoe two color display

◆ isButtonOnMonoDisplay()

bool tcgfx::TcDrawableButton::isButtonOnMonoDisplay ( )
inline
Returns
true if the button hides when unselectable, otherwise false and the button will grey out instead.

◆ setButtonDrawingMode()

void tcgfx::TcDrawableButton::setButtonDrawingMode ( ButtonDrawingMode  mode)
inline

Set the button mode

Parameters
pressed

◆ setDirty()

void tcgfx::TcDrawableButton::setDirty ( bool  d)
inline

Marks the button as dirty and therefore requiring a screen update.

Parameters
d

◆ isDirty()

bool tcgfx::TcDrawableButton::isDirty ( ) const
inline

If the button needs painting

Returns
true if needs painting, otherwise false

◆ isIconDrawn()

bool tcgfx::TcDrawableButton::isIconDrawn ( ) const
inline

If the button is an icon button

Returns
true if icon, false if text

◆ getButtonDrawingMode()

ButtonDrawingMode tcgfx::TcDrawableButton::getButtonDrawingMode ( )
inline
Returns
the current drawing mode of the button

◆ paintButton()

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.

Parameters
drawablethe drawable to draw onto

◆ setPosition()

void TcDrawableButton::setPosition ( const Coord position)

Set a new position for the button, note you will need to clear from the old location

Parameters
positionthe new screen position

◆ setPositionAndSize()

void TcDrawableButton::setPositionAndSize ( const Coord position,
const Coord newSize 
)

Set both the position and size of the button at the same time

Parameters
positionthe screen position
newSizethe new size

◆ setColors()

void TcDrawableButton::setColors ( color_t  bgCol,
color_t  fgCol,
color_t  selCol 
)

Change the colors associated with the button

Parameters
bgColthe background
fgColthe foreground
selColthe selected background

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