ubitxv6/button.cpp

45 lines
997 B
C++
Raw Normal View History

#include "button.h"
2020-02-12 00:42:50 -05:00
#include <avr/pgmspace.h>
#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"
void drawButton(Button* button)
{
uint16_t tc = COLOR_INACTIVE_TEXT;
uint16_t bgc = COLOR_INACTIVE_BACKGROUND;
const uint16_t bdc = COLOR_INACTIVE_BORDER;
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;
}
}
if(nullptr != button->text){
2020-02-12 00:42:50 -05:00
strncpy_P(b,button->text,sizeof(b));
}
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);
}