Updates
This commit is contained in:
+11
-11
@@ -69,35 +69,35 @@ void TextButton::paint(BitmapBuffer * dc)
|
||||
{
|
||||
FormField::paint(dc);
|
||||
|
||||
LcdFlags textColor = TEXT_COLOR;
|
||||
LcdFlags textColor = DEFAULT_COLOR;
|
||||
|
||||
if (checked()) {
|
||||
if (hasFocus()) {
|
||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, TEXT_INVERTED_BGCOLOR);
|
||||
dc->drawSolidFilledRect(3, 3, rect.w - 6, rect.h - 6, TEXT_INVERTED_BGCOLOR);
|
||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, FOCUS_BGCOLOR);
|
||||
dc->drawSolidFilledRect(3, 3, rect.w - 6, rect.h - 6, FOCUS_BGCOLOR);
|
||||
}
|
||||
else {
|
||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 1, CURVE_AXIS_COLOR);
|
||||
dc->drawSolidFilledRect(2, 2, rect.w - 4, rect.h - 4, TEXT_INVERTED_BGCOLOR);
|
||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 1, DISABLE_COLOR);
|
||||
dc->drawSolidFilledRect(2, 2, rect.w - 4, rect.h - 4, FOCUS_BGCOLOR);
|
||||
}
|
||||
textColor = TEXT_INVERTED_COLOR;
|
||||
textColor = FOCUS_COLOR;
|
||||
}
|
||||
else {
|
||||
if (flags & BUTTON_BACKGROUND) {
|
||||
if (hasFocus()) {
|
||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, TEXT_INVERTED_BGCOLOR);
|
||||
dc->drawSolidFilledRect(2, 2, rect.w - 4, rect.h - 4, CURVE_AXIS_COLOR);
|
||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, FOCUS_BGCOLOR);
|
||||
dc->drawSolidFilledRect(2, 2, rect.w - 4, rect.h - 4, DISABLE_COLOR);
|
||||
}
|
||||
else {
|
||||
dc->drawSolidFilledRect(0, 0, rect.w, rect.h, CURVE_AXIS_COLOR);
|
||||
dc->drawSolidFilledRect(0, 0, rect.w, rect.h, DISABLE_COLOR);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (hasFocus()) {
|
||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, TEXT_INVERTED_BGCOLOR);
|
||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, FOCUS_BGCOLOR);
|
||||
}
|
||||
else {
|
||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 1, CURVE_AXIS_COLOR);
|
||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 1, DISABLE_COLOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -22,7 +22,7 @@
|
||||
|
||||
void CheckBox::paint(BitmapBuffer * dc)
|
||||
{
|
||||
theme->drawCheckBox(dc, getValue(), hasFocus());
|
||||
theme->drawCheckBox(dc, this);
|
||||
}
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
@@ -32,7 +32,7 @@ void CheckBox::onKeyEvent(event_t event)
|
||||
|
||||
if (event == EVT_KEY_BREAK(KEY_ENTER)) {
|
||||
onKeyPress();
|
||||
setValue(!getValue());
|
||||
_setValue(!getValue());
|
||||
invalidate({0, 0, 20, 20});
|
||||
}
|
||||
else {
|
||||
@@ -45,7 +45,7 @@ void CheckBox::onKeyEvent(event_t event)
|
||||
bool CheckBox::onTouchEnd(coord_t x, coord_t y)
|
||||
{
|
||||
onKeyPress();
|
||||
setValue(!getValue());
|
||||
_setValue(!getValue());
|
||||
setFocus();
|
||||
invalidate({0, 0, 20, 20});
|
||||
return true;
|
||||
|
||||
+9
-4
@@ -27,8 +27,8 @@ class CheckBox : public FormField {
|
||||
CheckBox(Window * parent, const rect_t & rect, std::function<uint8_t()> getValue, std::function<void(uint8_t)> setValue,
|
||||
LcdFlags flags = 0) :
|
||||
FormField(parent, rect),
|
||||
getValue(getValue),
|
||||
setValue(setValue)
|
||||
_getValue(getValue),
|
||||
_setValue(setValue)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -49,9 +49,14 @@ class CheckBox : public FormField {
|
||||
bool onTouchEnd(coord_t x, coord_t y) override;
|
||||
#endif
|
||||
|
||||
uint8_t getValue() const
|
||||
{
|
||||
return _getValue();
|
||||
}
|
||||
|
||||
protected:
|
||||
std::function<uint8_t()> getValue;
|
||||
std::function<void(uint8_t)> setValue;
|
||||
std::function<uint8_t()> _getValue;
|
||||
std::function<void(uint8_t)> _setValue;
|
||||
};
|
||||
|
||||
#endif // _CHECKBOX_H_
|
||||
|
||||
+2
-2
@@ -41,9 +41,9 @@ void Choice::paint(BitmapBuffer * dc)
|
||||
//
|
||||
// LcdFlags textColor;
|
||||
// if (editMode)
|
||||
// textColor = TEXT_INVERTED_COLOR;
|
||||
// textColor = FOCUS_COLOR;
|
||||
// else if (hasFocus())
|
||||
// textColor = TEXT_INVERTED_BGCOLOR;
|
||||
// textColor = FOCUS_BGCOLOR;
|
||||
// else
|
||||
// textColor = 0;
|
||||
//
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ class ColorBox: public Window {
|
||||
void paint(BitmapBuffer * dc) override
|
||||
{
|
||||
lcdSetColor(color);
|
||||
dc->drawSolidFilledRect(0, 0, width(), height(), TEXT_COLOR);
|
||||
dc->drawSolidFilledRect(0, 0, width(), height(), DEFAULT_COLOR);
|
||||
dc->drawSolidFilledRect(1, 1, width() - 2, height() - 2, CUSTOM_COLOR);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ Dialog::Dialog(std::string title, const rect_t rect):
|
||||
|
||||
void Dialog::paint(BitmapBuffer * dc)
|
||||
{
|
||||
dc->drawRect(0, 0, width() - 1, height() - 1, 1, SOLID, TEXT_COLOR);
|
||||
dc->drawRect(0, 0, width() - 1, height() - 1, 1, SOLID, DEFAULT_COLOR);
|
||||
dc->drawSolidFilledRect(1, 1, width() - 3, PAGE_LINE_HEIGHT, TITLE_BGCOLOR);
|
||||
dc->drawText(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, title.c_str(), MENU_TITLE_COLOR);
|
||||
dc->drawSolidFilledRect(1, PAGE_LINE_HEIGHT + 1, width() - 3, height() - PAGE_LINE_HEIGHT - 3, TEXT_BGCOLOR);
|
||||
|
||||
+5
-5
@@ -99,22 +99,22 @@ void FormGroup::onKeyEvent(event_t event)
|
||||
void FormField::paint(BitmapBuffer * dc)
|
||||
{
|
||||
if (editMode) {
|
||||
dc->drawSolidFilledRect(0, 0, rect.w, rect.h, TEXT_INVERTED_BGCOLOR);
|
||||
dc->drawSolidFilledRect(0, 0, rect.w, rect.h, FOCUS_BGCOLOR);
|
||||
}
|
||||
else if (hasFocus()) {
|
||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, TEXT_INVERTED_BGCOLOR);
|
||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, FOCUS_BGCOLOR);
|
||||
}
|
||||
else if (!(windowFlags & BORDER_FOCUS_ONLY)) {
|
||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 1, CURVE_AXIS_COLOR);
|
||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 1, DISABLE_COLOR);
|
||||
}
|
||||
}
|
||||
|
||||
void FormGroup::paint(BitmapBuffer * dc)
|
||||
{
|
||||
if (!editMode && hasFocus()) {
|
||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, TEXT_INVERTED_BGCOLOR);
|
||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, FOCUS_BGCOLOR);
|
||||
}
|
||||
else if (!(windowFlags & BORDER_FOCUS_ONLY)) {
|
||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 1, CURVE_AXIS_COLOR);
|
||||
dc->drawSolidRect(0, 0, rect.w, rect.h, 1, DISABLE_COLOR);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -133,7 +133,7 @@ void TextKeyboard::paint(BitmapBuffer * dc)
|
||||
}
|
||||
else if (*c == '\t') {
|
||||
// spacebar
|
||||
dc->drawBitmapPattern(x, y, LBM_KEY_SPACEBAR, TEXT_COLOR);
|
||||
dc->drawBitmapPattern(x, y, LBM_KEY_SPACEBAR, DEFAULT_COLOR);
|
||||
x += 135;
|
||||
}
|
||||
else if (*c == '\n') {
|
||||
@@ -143,7 +143,7 @@ void TextKeyboard::paint(BitmapBuffer * dc)
|
||||
x += 80;
|
||||
}
|
||||
else if (int8_t(*c) < 0) {
|
||||
dc->drawBitmapPattern(x, y, LBM_SPECIAL_KEYS[uint8_t(*c - 128)], TEXT_COLOR);
|
||||
dc->drawBitmapPattern(x, y, LBM_SPECIAL_KEYS[uint8_t(*c - 128)], DEFAULT_COLOR);
|
||||
x += 45;
|
||||
}
|
||||
else {
|
||||
|
||||
+4
-4
@@ -122,10 +122,10 @@ enum FontSizeIndex
|
||||
#define COLOR(index) LcdFlags((index) << 16)
|
||||
#define COLOR_IDX(att) uint8_t((att) >> 16)
|
||||
|
||||
//#define TEXT_COLOR COLOR(TEXT_COLOR_INDEX)
|
||||
//#define DEFAULT_COLOR COLOR(DEFAULT_COLOR_INDEX)
|
||||
//#define TEXT_BGCOLOR COLOR(TEXT_BGCOLOR_INDEX)
|
||||
//#define TEXT_INVERTED_COLOR COLOR(TEXT_INVERTED_COLOR_INDEX)
|
||||
//#define TEXT_INVERTED_BGCOLOR COLOR(TEXT_INVERTED_BGCOLOR_INDEX)
|
||||
//#define FOCUS_COLOR COLOR(FOCUS_COLOR_INDEX)
|
||||
//#define FOCUS_BGCOLOR COLOR(FOCUS_BGCOLOR_INDEX)
|
||||
//#define TEXT_STATUSBAR_COLOR COLOR(TEXT_STATUSBAR_COLOR_INDEX)
|
||||
//#define LINE_COLOR COLOR(LINE_COLOR_INDEX)
|
||||
#define SCROLLBOX_COLOR COLOR(SCROLLBOX_COLOR_INDEX)
|
||||
@@ -137,7 +137,7 @@ enum FontSizeIndex
|
||||
//#define ALARM_COLOR COLOR(ALARM_COLOR_INDEX)
|
||||
//#define WARNING_COLOR COLOR(WARNING_COLOR_INDEX)
|
||||
//#define TEXT_DISABLE_COLOR COLOR(TEXT_DISABLE_COLOR_INDEX)
|
||||
//#define CURVE_AXIS_COLOR COLOR(CURVE_AXIS_COLOR_INDEX)
|
||||
//#define DISABLE_COLOR COLOR(DISABLE_COLOR_INDEX)
|
||||
//#define CURVE_COLOR COLOR(CURVE_COLOR_INDEX)
|
||||
//#define CURVE_CURSOR_COLOR COLOR(CURVE_CURSOR_COLOR_INDEX)
|
||||
//#define TITLE_BGCOLOR COLOR(TITLE_BGCOLOR_INDEX)
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ void MenuWindow::paint(BitmapBuffer * dc)
|
||||
dc->drawText(10, i * lineHeight + (lineHeight - 20) / 2, text[0] == '\0' ? "---" : text, flags);
|
||||
}
|
||||
if (i > 0) {
|
||||
dc->drawSolidHorizontalLine(0, i * lineHeight - 1, width, CURVE_AXIS_COLOR);
|
||||
dc->drawSolidHorizontalLine(0, i * lineHeight - 1, width, DISABLE_COLOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -27,6 +27,6 @@ void MenuToolbarButton::paint(BitmapBuffer * dc)
|
||||
dc->drawSizedText(rect.w / 2, (rect.h - getFontHeight(flags)) / 2 + 1, &picto, 1, CENTERED | MENU_TITLE_COLOR);
|
||||
}
|
||||
else {
|
||||
dc->drawSizedText(rect.w / 2, (rect.h - getFontHeight(flags)) / 2 + 1, &picto, 1, CENTERED | TEXT_COLOR);
|
||||
dc->drawSizedText(rect.w / 2, (rect.h - getFontHeight(flags)) / 2 + 1, &picto, 1, CENTERED | DEFAULT_COLOR);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -85,7 +85,7 @@ class MenuToolbar: public Window {
|
||||
|
||||
void paint(BitmapBuffer * dc) override
|
||||
{
|
||||
dc->clear(CURVE_AXIS_COLOR);
|
||||
dc->clear(DISABLE_COLOR);
|
||||
}
|
||||
|
||||
#if defined(HARDWARE_KEYS)
|
||||
|
||||
+4
-4
@@ -34,13 +34,13 @@ void NumberEdit::paint(BitmapBuffer * dc)
|
||||
|
||||
LcdFlags textColor;
|
||||
if (editMode)
|
||||
textColor = TEXT_INVERTED_COLOR;
|
||||
textColor = FOCUS_COLOR;
|
||||
else if (hasFocus())
|
||||
textColor = TEXT_INVERTED_BGCOLOR;
|
||||
textColor = FOCUS_BGCOLOR;
|
||||
else if (enabled)
|
||||
textColor = TEXT_COLOR;
|
||||
textColor = DEFAULT_COLOR;
|
||||
else
|
||||
textColor = CURVE_AXIS_COLOR;
|
||||
textColor = DISABLE_COLOR;
|
||||
|
||||
int32_t value = getValue();
|
||||
if (displayFunction)
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@
|
||||
void StaticText::paint(BitmapBuffer * dc)
|
||||
{
|
||||
if (flags & BUTTON_BACKGROUND)
|
||||
dc->drawSolidFilledRect(0, 0, rect.w, rect.h, CURVE_AXIS_COLOR);
|
||||
dc->drawSolidFilledRect(0, 0, rect.w, rect.h, DISABLE_COLOR);
|
||||
if (flags & CENTERED)
|
||||
dc->drawText(rect.w / 2, (rect.h - getFontHeight(flags)) / 2, text.c_str(), CENTERED | flags);
|
||||
else
|
||||
|
||||
+7
-7
@@ -29,24 +29,24 @@ void TextEdit::paint(BitmapBuffer * dc)
|
||||
FormField::paint(dc);
|
||||
|
||||
if (editMode) {
|
||||
dc->drawSizedText(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, value, length, TEXT_INVERTED_COLOR);
|
||||
dc->drawSizedText(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, value, length, FOCUS_COLOR);
|
||||
coord_t left = (cursorPos == 0 ? 0 : getTextWidth(value, cursorPos));
|
||||
char s[] = { value[cursorPos], '\0' };
|
||||
dc->drawSolidFilledRect(FIELD_PADDING_LEFT + left - 1, FIELD_PADDING_TOP + 1, getTextWidth(s, 1) + 1, height() - 2, TEXT_INVERTED_COLOR);
|
||||
dc->drawText(FIELD_PADDING_LEFT + left, FIELD_PADDING_TOP, s, TEXT_COLOR);
|
||||
dc->drawSolidFilledRect(FIELD_PADDING_LEFT + left - 1, FIELD_PADDING_TOP + 1, getTextWidth(s, 1) + 1, height() - 2, FOCUS_COLOR);
|
||||
dc->drawText(FIELD_PADDING_LEFT + left, FIELD_PADDING_TOP, s, DEFAULT_COLOR);
|
||||
}
|
||||
else {
|
||||
const char * displayedValue = value;
|
||||
LcdFlags textColor;
|
||||
if (strlen(value) == 0) {
|
||||
displayedValue = "---";
|
||||
textColor = hasFocus() ? TEXT_INVERTED_BGCOLOR : CURVE_AXIS_COLOR;
|
||||
textColor = hasFocus() ? FOCUS_BGCOLOR : DISABLE_COLOR;
|
||||
}
|
||||
else if (hasFocus()) {
|
||||
textColor = TEXT_INVERTED_BGCOLOR;
|
||||
textColor = FOCUS_BGCOLOR;
|
||||
}
|
||||
else {
|
||||
textColor = TEXT_COLOR;
|
||||
textColor = DEFAULT_COLOR;
|
||||
}
|
||||
dc->drawSizedText(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, displayedValue, length, textColor);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ void TextEdit::paint(BitmapBuffer * dc)
|
||||
auto keyboard = TextKeyboard::instance();
|
||||
if (hasFocus() && keyboard->getField() == this) {
|
||||
coord_t cursorPos = keyboard->getCursorPos();
|
||||
dc->drawSolidFilledRect(cursorPos + 2, FIELD_PADDING_TOP, 2, 21, 0); // TEXT_INVERTED_BGCOLOR);
|
||||
dc->drawSolidFilledRect(cursorPos + 2, FIELD_PADDING_TOP, 2, 21, 0); // FOCUS_BGCOLOR);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
+6
-1
@@ -21,6 +21,7 @@
|
||||
#define _THEME_H_
|
||||
|
||||
#include "bitmapbuffer.h"
|
||||
#include "checkbox.h"
|
||||
|
||||
class PageHeader;
|
||||
class ChoiceBase;
|
||||
@@ -34,7 +35,11 @@ class Theme {
|
||||
public:
|
||||
virtual void drawMessageBox(const char * title, const char * text, const char * action, LcdFlags flags) const = 0;
|
||||
virtual void drawProgressBar(BitmapBuffer * dc, coord_t x, coord_t y, coord_t w, coord_t h, int value) const = 0;
|
||||
virtual void drawCheckBox(BitmapBuffer * dc, bool value, bool focus) const = 0;
|
||||
virtual void drawCheckBox(BitmapBuffer * dc, CheckBox * checkBox) const
|
||||
{
|
||||
return drawCheckBox(dc, checkBox->getValue(), 0, 0, checkBox->hasFocus());
|
||||
}
|
||||
virtual void drawCheckBox(BitmapBuffer * dc, bool checked, coord_t x, coord_t y, bool focus = false) const = 0;
|
||||
virtual void drawChoice(BitmapBuffer * dc, ChoiceBase * choice, const char * str) const = 0;
|
||||
virtual void drawSlider(BitmapBuffer * dc, int vmin, int vmax, int value, const rect_t & rect, bool edit, bool focus) const = 0;
|
||||
virtual void drawPageHeader(BitmapBuffer * dc, const PageHeader * page) const = 0;
|
||||
|
||||
Reference in New Issue
Block a user