fix(color): Unify button colors (#2367)

* Button: change bg color to COLOR_THEME_PRIMARY2

And text color to COLOR_THEME_SECONDARY1

Fixes #2304

* fix: TextButton constuctor calls

Setting the font in the constructor never worked, but did set the text color to black.

* chore: Bump libopenui
This commit is contained in:
Raphael Coeffic
2022-09-27 12:52:08 +10:00
committed by GitHub
parent 8ad390d59b
commit d8bcecfc82
6 changed files with 25 additions and 37 deletions
+1 -2
View File
@@ -124,8 +124,7 @@ struct FMTrimSettings : public Dialog {
SET_DIRTY(); SET_DIRTY();
return 0; return 0;
} }
}, });
0, COLOR_THEME_PRIMARY1);
if (tr->mode != TRIM_MODE_NONE) btn->check(); if (tr->mode != TRIM_MODE_NONE) btn->check();
btn->setWidth(LV_DPI_DEF / 2); btn->setWidth(LV_DPI_DEF / 2);
+14 -22
View File
@@ -61,7 +61,6 @@ constexpr int BUTTONS_HEIGHT = 30;
constexpr int MODEL_CELLS_PER_LINE = 2; constexpr int MODEL_CELLS_PER_LINE = 2;
#if LCD_W > LCD_H // Landscape #if LCD_W > LCD_H // Landscape
constexpr LcdFlags textFont = FONT(STD);
constexpr int LABELS_WIDTH = 132; constexpr int LABELS_WIDTH = 132;
constexpr int LAY_MARGIN = 5; constexpr int LAY_MARGIN = 5;
constexpr coord_t MODEL_SELECT_CELL_WIDTH = constexpr coord_t MODEL_SELECT_CELL_WIDTH =
@@ -69,7 +68,6 @@ constexpr coord_t MODEL_SELECT_CELL_WIDTH =
(MODEL_CELLS_PER_LINE + 1) * MODEL_CELL_PADDING) / (MODEL_CELLS_PER_LINE + 1) * MODEL_CELL_PADDING) /
MODEL_CELLS_PER_LINE; MODEL_CELLS_PER_LINE;
#else // Portrait #else // Portrait
constexpr LcdFlags textFont = FONT(XS);
constexpr int LAY_MARGIN = 8; constexpr int LAY_MARGIN = 8;
constexpr int LABELS_HEIGHT = 140; constexpr int LABELS_HEIGHT = 140;
constexpr coord_t MODEL_SELECT_CELL_WIDTH = constexpr coord_t MODEL_SELECT_CELL_WIDTH =
@@ -147,18 +145,17 @@ class ButtonHolder : public FormWindow
addButton(mask_sort_date_up, mask_sort_date_down); addButton(mask_sort_date_up, mask_sort_date_down);
// New label button // New label button
auto btn = new TextButton( auto btn = new TextButton(this, rect_t{},
this, rect_t{},
#if LCD_W > LCD_H #if LCD_W > LCD_H
STR_NEW, STR_NEW,
#else #else
STR_NEW_LABEL, STR_NEW_LABEL,
#endif #endif
[=]() { [=]() {
if(_newLabelHandler) _newLabelHandler(); if (_newLabelHandler) _newLabelHandler();
return 0; return 0;
}, });
BUTTON_BACKGROUND | OPAQUE, textFont);
btn->padAll(lv_dpx(4)); btn->padAll(lv_dpx(4));
lv_obj_align(btn->getLvObj(), LV_ALIGN_RIGHT_MID, 0, 0); lv_obj_align(btn->getLvObj(), LV_ALIGN_RIGHT_MID, 0, 0);
@@ -524,8 +521,7 @@ class LabelDialog : public Dialog
if (saveHandler != nullptr) saveHandler(label); if (saveHandler != nullptr) saveHandler(label);
deleteLater(); deleteLater();
return 0; return 0;
}, });
BUTTON_BACKGROUND | OPAQUE, textFont);
btn->setWidth(LV_DPI_DEF); btn->setWidth(LV_DPI_DEF);
btn = new TextButton( btn = new TextButton(
@@ -533,8 +529,7 @@ class LabelDialog : public Dialog
[=]() { [=]() {
deleteLater(); deleteLater();
return 0; return 0;
}, });
BUTTON_BACKGROUND | OPAQUE, textFont);
btn->setWidth(LV_DPI_DEF); btn->setWidth(LV_DPI_DEF);
content->setWidth(LCD_W * 0.8); content->setWidth(LCD_W * 0.8);
@@ -658,13 +653,10 @@ void ModelLabelsWindow::buildHead(PageHeader *hdr)
setTitle(); setTitle();
// new model button // new model button
auto btn = new TextButton( auto btn = new TextButton(hdr, rect_t{}, STR_NEW_MODEL, [=]() {
hdr, rect_t{}, STR_NEW_MODEL, newModel();
[=]() { return 0;
newModel(); });
return 0;
},
BUTTON_BACKGROUND | OPAQUE, textFont);
btn->padAll(lv_dpx(4)); btn->padAll(lv_dpx(4));
+2 -1
View File
@@ -149,10 +149,11 @@ class ThemedButton : public TextButton
public: public:
ThemedButton(FormGroup *window, const rect_t &rect, std::string text, bool isChecked, WindowFlags windowFlags, ThemedButton(FormGroup *window, const rect_t &rect, std::string text, bool isChecked, WindowFlags windowFlags,
LcdColorIndex colorIndex) : LcdColorIndex colorIndex) :
TextButton(window, rect, text, nullptr, windowFlags | NO_FOCUS, COLOR(colorIndex)), TextButton(window, rect, text, nullptr, windowFlags | NO_FOCUS),
_colorIndex(colorIndex), _colorIndex(colorIndex),
_isChecked(isChecked) _isChecked(isChecked)
{ {
setTextFlags(COLOR(colorIndex));
setPressHandler([=] () { return _isChecked; }); setPressHandler([=] () { return _isChecked; });
} }
+5 -9
View File
@@ -59,7 +59,6 @@
#if (LCD_W > LCD_H) #if (LCD_W > LCD_H)
constexpr int BUTTON_HEIGHT = 30; constexpr int BUTTON_HEIGHT = 30;
constexpr int BUTTON_WIDTH = 75; constexpr int BUTTON_WIDTH = 75;
constexpr LcdFlags textFont = FONT(STD);
constexpr rect_t detailsDialogRect = {50, 50, 400, 170}; constexpr rect_t detailsDialogRect = {50, 50, 400, 170};
constexpr int labelWidth = 150; constexpr int labelWidth = 150;
@@ -69,7 +68,6 @@ constexpr int COLOR_BOX_HEIGHT = 27;
#else #else
constexpr int BUTTON_HEIGHT = 30; constexpr int BUTTON_HEIGHT = 30;
constexpr int BUTTON_WIDTH = 65; constexpr int BUTTON_WIDTH = 65;
constexpr LcdFlags textFont = FONT(XS);
constexpr rect_t detailsDialogRect = {5, 50, LCD_W - 10, 340}; constexpr rect_t detailsDialogRect = {5, 50, LCD_W - 10, 340};
constexpr int labelWidth = 120; constexpr int labelWidth = 120;
@@ -112,12 +110,12 @@ class ThemeDetailsDialog: public Dialog
saveHandler(this->theme); saveHandler(this->theme);
deleteLater(); deleteLater();
return 0; return 0;
}, BUTTON_BACKGROUND | OPAQUE, textFont); });
r.x -= (BUTTON_WIDTH + 5); r.x -= (BUTTON_WIDTH + 5);
new TextButton(&content->form, r, STR_CANCEL, [=] () { new TextButton(&content->form, r, STR_CANCEL, [=] () {
deleteLater(); deleteLater();
return 0; return 0;
}, BUTTON_BACKGROUND | OPAQUE, textFont); });
} }
protected: protected:
@@ -270,16 +268,14 @@ protected:
[=] () { [=] () {
setActiveColorBar(0); setActiveColorBar(0);
return 1; return 1;
}, }));
0, COLOR_THEME_PRIMARY1));
r.x += (BUTTON_WIDTH + 5); r.x += (BUTTON_WIDTH + 5);
_tabs.emplace_back( _tabs.emplace_back(
new TextButton(window, r, "HSV", new TextButton(window, r, "HSV",
[=] () { [=] () {
setActiveColorBar(1); setActiveColorBar(1);
return 1; return 1;
}, }));
0, COLOR_THEME_PRIMARY1));
_tabs[1]->check(true); _tabs[1]->check(true);
} }
}; };
@@ -352,7 +348,7 @@ class ThemeEditPage : public Page
_dirty = true; _dirty = true;
}); });
return 0; return 0;
}, BUTTON_BACKGROUND | OPAQUE, textFont); });
} }
void buildBody(FormGroup *window) void buildBody(FormGroup *window)
@@ -296,12 +296,12 @@ static void style_init(void)
: lv_disp_dpx(theme.disp, 8))); : lv_disp_dpx(theme.disp, 8)));
lv_style_set_bg_opa(&styles.btn, LV_OPA_COVER); lv_style_set_bg_opa(&styles.btn, LV_OPA_COVER);
lv_style_set_bg_color(&styles.btn, makeLvColor(COLOR_THEME_SECONDARY2)); lv_style_set_bg_color(&styles.btn, makeLvColor(COLOR_THEME_PRIMARY2));
lv_style_set_border_opa(&styles.btn, LV_OPA_0); lv_style_set_border_opa(&styles.btn, LV_OPA_0);
lv_style_set_border_width(&styles.btn, BORDER_WIDTH); lv_style_set_border_width(&styles.btn, BORDER_WIDTH);
lv_style_set_text_color(&styles.btn, color_text); lv_style_set_text_color(&styles.btn, makeLvColor(COLOR_THEME_SECONDARY1));
lv_style_set_pad_hor(&styles.btn, PAD_SMALL); lv_style_set_pad_hor(&styles.btn, PAD_SMALL);
lv_style_set_pad_ver(&styles.btn, PAD_SMALL); lv_style_set_pad_ver(&styles.btn, PAD_SMALL);
lv_style_set_pad_column(&styles.btn, lv_disp_dpx(theme.disp, 5)); lv_style_set_pad_column(&styles.btn, lv_disp_dpx(theme.disp, 5));