2020-02-10 04:30:01 -05:00
|
|
|
#include "button.h"
|
2020-02-12 00:42:50 -05:00
|
|
|
|
|
|
|
#include <avr/pgmspace.h>
|
|
|
|
|
2020-02-10 04:30:01 -05:00
|
|
|
#include "color_theme.h"
|
2020-02-12 00:42:50 -05:00
|
|
|
#include "nano_gui.h"
|
2020-04-22 00:13:33 -04:00
|
|
|
#include "scratch_space.h"
|
2020-02-10 04:30:01 -05:00
|
|
|
|
|
|
|
void drawButton(Button* button)
|
|
|
|
{
|
|
|
|
uint16_t tc = COLOR_INACTIVE_TEXT;
|
|
|
|
uint16_t bgc = COLOR_INACTIVE_BACKGROUND;
|
|
|
|
const uint16_t bdc = COLOR_INACTIVE_BORDER;
|
2020-02-10 04:34:02 -05:00
|
|
|
switch(button->status())
|
|
|
|
{
|
|
|
|
case ButtonStatus_e::Stateless://Fallthrough intended
|
|
|
|
case ButtonStatus_e::Inactive://Fallthrough intended
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
//Colors are initialized for this, so we're done
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ButtonStatus_e::Active:
|
|
|
|
{
|
|
|
|
tc = COLOR_ACTIVE_TEXT;
|
|
|
|
bgc = COLOR_ACTIVE_BACKGROUND;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-10 04:30:01 -05:00
|
|
|
if(nullptr != button->text){
|
2020-02-12 00:42:50 -05:00
|
|
|
strncpy_P(b,button->text,sizeof(b));
|
2020-02-10 04:30:01 -05:00
|
|
|
}
|
|
|
|
else if(nullptr != button->text_override){
|
|
|
|
button->text_override(b,sizeof(b));
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
//Something's messed up
|
|
|
|
//Serial.println(F("No text for button!"));
|
|
|
|
return;
|
|
|
|
}
|
2020-02-12 00:42:50 -05:00
|
|
|
displayText(b, button->x, button->y, button->w, button->h, tc, bgc, bdc);
|
2020-02-10 04:30:01 -05:00
|
|
|
}
|