From a141e460462a8c656fed6f6bb6262e84df28920c Mon Sep 17 00:00:00 2001 From: philmoz Date: Sun, 4 May 2025 21:23:27 +1000 Subject: [PATCH] feat(color): add fixed color set to the color picker (#6182) --- radio/src/gui/colorlcd/colors.cpp | 61 +++++++++++++------ radio/src/gui/colorlcd/colors.h | 28 ++++++--- .../gui/colorlcd/controls/color_editor.cpp | 54 +++++++++++++--- .../src/gui/colorlcd/controls/color_editor.h | 5 +- .../gui/colorlcd/controls/color_picker.cpp | 55 +++++++++-------- .../src/gui/colorlcd/radio/preview_window.cpp | 6 +- radio/src/gui/colorlcd/startup_shutdown.cpp | 6 +- .../src/gui/colorlcd/themes/theme_manager.cpp | 10 +-- radio/src/lua/api_colorlcd.cpp | 4 +- radio/src/lua/api_general.cpp | 35 ++++++----- radio/src/translations.cpp | 1 + radio/src/translations.h | 1 + radio/src/translations/cn.h | 1 + radio/src/translations/cz.h | 1 + radio/src/translations/da.h | 1 + radio/src/translations/de.h | 1 + radio/src/translations/en.h | 1 + radio/src/translations/es.h | 1 + radio/src/translations/fi.h | 1 + radio/src/translations/fr.h | 1 + radio/src/translations/he.h | 1 + radio/src/translations/it.h | 1 + radio/src/translations/jp.h | 1 + radio/src/translations/ko.h | 1 + radio/src/translations/nl.h | 1 + radio/src/translations/pl.h | 1 + radio/src/translations/pt.h | 1 + radio/src/translations/ru.h | 1 + radio/src/translations/se.h | 1 + radio/src/translations/tw.h | 1 + radio/src/translations/ua.h | 1 + 31 files changed, 197 insertions(+), 88 deletions(-) diff --git a/radio/src/gui/colorlcd/colors.cpp b/radio/src/gui/colorlcd/colors.cpp index 99b9ee6dc..14b33cc8c 100644 --- a/radio/src/gui/colorlcd/colors.cpp +++ b/radio/src/gui/colorlcd/colors.cpp @@ -26,6 +26,7 @@ #include const uint16_t defaultColors[] = { + // Theme RGB(0, 0, 0), // PRIMARY1 RGB(255, 255, 255), // PRIMARY2 RGB(12, 63, 102), // PRIMARY3 @@ -38,13 +39,32 @@ const uint16_t defaultColors[] = { RGB(224, 0, 0), // WARNING RGB(140, 140, 140), // DISABLED RGB(170, 85, 0), // CUSTOM - RGB(0, 0, 0), // FIXED BLACK - RGB(255, 255, 255), // FIXED WHITE - RGB(128, 128, 128), // FIXED GREY + // Fixed + RGB(0x00, 0x00, 0x00), // BLACK + RGB(0xFF, 0xFF, 0xFF), // WHITE + RGB(0xEA, 0xEA, 0xEA), // LIGHTWHITE + RGB(0xC0, 0xC0, 0xC0), // LIGHTGREY + RGB(0x40, 0x40, 0x40), // DARKGREY + RGB(0x60, 0x60, 0x60), // GREY + RGB(0xFF, 0x00, 0x00), // RED + RGB(0xA0, 0x00, 0x00), // DARKRED + RGB(0xFF, 0x99, 0x99), // LIGHTRED + RGB(0x00, 0xFF, 0x00), // GREEN + RGB(0x00, 0xA0, 0x00), // DARKGREEN + RGB(0x00, 0xB4, 0x3C), // BRIGHTGREEN + RGB(0x00, 0x00, 0xFF), // BLUE + RGB(0x00, 0x00, 0xA0), // DARKBLUE + RGB(0x00, 0xFF, 0xFF), // CYAN + RGB(0xFF, 0xFF, 0x00), // YELLOW + RGB(0x9C, 0x6D, 0x20), // LIGHTBROWN + RGB(0x6A, 0x48, 0x10), // DARKBROWN + RGB(0xE5, 0x64, 0x1E), // ORANGE + RGB(0x80, 0x00, 0x80), // MAGENTA }; // Needs to be initialised at compile time so widget color options work uint16_t lcdColorTable[] = { + // Theme RGB(0, 0, 0), // PRIMARY1 RGB(255, 255, 255), // PRIMARY2 RGB(12, 63, 102), // PRIMARY3 @@ -57,9 +77,27 @@ uint16_t lcdColorTable[] = { RGB(224, 0, 0), // WARNING RGB(140, 140, 140), // DISABLED RGB(170, 85, 0), // CUSTOM - RGB(0, 0, 0), // FIXED BLACK - RGB(255, 255, 255), // FIXED WHITE - RGB(128, 128, 128), // FIXED GREY + // Fixed + RGB(0x00, 0x00, 0x00), // BLACK + RGB(0xFF, 0xFF, 0xFF), // WHITE + RGB(0xEA, 0xEA, 0xEA), // LIGHTWHITE + RGB(0xC0, 0xC0, 0xC0), // LIGHTGREY + RGB(0x40, 0x40, 0x40), // DARKGREY + RGB(0x60, 0x60, 0x60), // GREY + RGB(0xFF, 0x00, 0x00), // RED + RGB(0xA0, 0x00, 0x00), // DARKRED + RGB(0xFF, 0x99, 0x99), // LIGHTRED + RGB(0x00, 0xFF, 0x00), // GREEN + RGB(0x00, 0xA0, 0x00), // DARKGREEN + RGB(0x00, 0xB4, 0x3C), // BRIGHTGREEN + RGB(0x00, 0x00, 0xFF), // BLUE + RGB(0x00, 0x00, 0xA0), // DARKBLUE + RGB(0x00, 0xFF, 0xFF), // CYAN + RGB(0xFF, 0xFF, 0x00), // YELLOW + RGB(0x9C, 0x6D, 0x20), // LIGHTBROWN + RGB(0x6A, 0x48, 0x10), // DARKBROWN + RGB(0xE5, 0x64, 0x1E), // ORANGE + RGB(0xC0, 0x00, 0xC0), // MAGENTA }; uint32_t HSVtoRGB(float H, float S, float V) @@ -164,17 +202,6 @@ void RGBtoHSV(uint8_t R, uint8_t G, uint8_t B, float &fH, float &fS, float &fV) } } -// TODO: work out how to remove this function -LcdColorIndex indexFromColor(uint32_t lcdFlags) -{ - uint16_t color = COLOR_VAL(lcdFlags); - - for (uint8_t i = 0; i < TOTAL_COLOR_COUNT; i += 1) - if (lcdColorTable[i] == color) return (LcdColorIndex)i; - - return CUSTOM_COLOR_INDEX; -} - // Return flags with RGB color value instead of indexed theme color LcdFlags colorToRGB(LcdFlags colorFlags) { diff --git a/radio/src/gui/colorlcd/colors.h b/radio/src/gui/colorlcd/colors.h index 26f8dae3d..6ade2c5b1 100644 --- a/radio/src/gui/colorlcd/colors.h +++ b/radio/src/gui/colorlcd/colors.h @@ -42,12 +42,29 @@ enum LcdColorIndex { CUSTOM_COLOR_INDEX, // Variable count - LCD_COLOR_COUNT, + THEME_COLOR_COUNT, // Fixed Colors - COLOR_BLACK_INDEX = LCD_COLOR_COUNT, + COLOR_BLACK_INDEX = THEME_COLOR_COUNT, COLOR_WHITE_INDEX, + COLOR_LIGHTWHITE_INDEX, + COLOR_LIGHTGREY_INDEX, COLOR_GREY_INDEX, + COLOR_DARKGREY_INDEX, + COLOR_RED_INDEX, + COLOR_DARKRED_INDEX, + COLOR_LIGHTRED_INDEX, + COLOR_GREEN_INDEX, + COLOR_DARKGREEN_INDEX, + COLOR_BRIGHTGREEN_INDEX, + COLOR_BLUE_INDEX, + COLOR_DARKBLUE_INDEX, + COLOR_CYAN_INDEX, + COLOR_YELLOW_INDEX, + COLOR_LIGHTBROWN_INDEX, + COLOR_DARKBROWN_INDEX, + COLOR_ORANGE_INDEX, + COLOR_MAGENTA_INDEX, TOTAL_COLOR_COUNT, }; @@ -96,13 +113,6 @@ enum LcdColorIndex { extern uint16_t lcdColorTable[]; extern const uint16_t defaultColors[]; -inline void lcdSetColor(uint16_t color) -{ - lcdColorTable[CUSTOM_COLOR_INDEX] = color; -} - -LcdColorIndex indexFromColor(uint32_t lcdFlags); - #define COLOR(index) \ ((uint32_t) \ lcdColorTable[unsigned(index & 0xFF) >= TOTAL_COLOR_COUNT \ diff --git a/radio/src/gui/colorlcd/controls/color_editor.cpp b/radio/src/gui/colorlcd/controls/color_editor.cpp index 1493ea825..e4eb622cf 100644 --- a/radio/src/gui/colorlcd/controls/color_editor.cpp +++ b/radio/src/gui/colorlcd/controls/color_editor.cpp @@ -91,8 +91,6 @@ class ColorBar : public FormField rel_pos.x = point_act.x - obj_coords.x1; rel_pos.y = point_act.y - obj_coords.y1; - TRACE("PRESSING [%d,%d]", rel_pos.x, rel_pos.y); - bar->value = bar->screenToValue(rel_pos.y); lv_event_send(target->parent, LV_EVENT_VALUE_CHANGED, nullptr); } @@ -390,7 +388,7 @@ class ThemeColorType : public ColorType void makeButton(Window* parent, uint16_t color) { - auto btn = new TextButton(parent, rect_t{}, " "); + auto btn = new TextButton(parent, {0, 0, BTN_W, 0}, ""); etx_bg_color(btn->getLvObj(), (LcdColorIndex)color); btn->setPressHandler([=]() { m_color = color; @@ -412,6 +410,46 @@ class ThemeColorType : public ColorType makeButton(hbox, c2); if (c3 != c2) makeButton(hbox, c3); } + + static LAYOUT_VAL(BTN_W, 44, 44, LS(44)) +}; + +// Color editor that shows the system fixed colors as buttons +class FixedColorType : public ColorType +{ + public: + FixedColorType(Window* parent, uint32_t color) + { + m_color = color; + + auto vbox = new Window(parent, rect_t{}); + vbox->padAll(PAD_OUTLINE); + vbox->setFlexLayout(LV_FLEX_FLOW_ROW_WRAP, PAD_OUTLINE); + lv_obj_set_flex_align(vbox->getLvObj(), LV_FLEX_ALIGN_CENTER, + LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_SPACE_AROUND); + + for (int c = COLOR_BLACK_INDEX; c < TOTAL_COLOR_COUNT; c += 1) + makeButton(vbox, c); + } + + uint32_t getRGB() { return m_color; } + + protected: + uint32_t m_color; + + void makeButton(Window* parent, uint16_t color) + { + auto btn = new TextButton(parent, {0, 0, BTN_W, 0}, ""); + etx_bg_color(btn->getLvObj(), (LcdColorIndex)color); + btn->setPressHandler([=]() { + m_color = color; + lv_event_send(parent->getParent()->getLvObj(), + LV_EVENT_VALUE_CHANGED, nullptr); + return 0; + }); + } + + static LAYOUT_VAL(BTN_W, 44, 44, LS(44)) }; ///////////////////////////////////////////////////////////////////////// @@ -420,7 +458,7 @@ class ThemeColorType : public ColorType ColorEditor::ColorEditor(Window* parent, const rect_t& rect, uint32_t color, std::function setValue, std::function preview, - COLOR_EDITOR_FMT fmt) : + COLOR_EDITOR_FMT fmt, COLOR_EDITOR_TYPE typ) : Window(parent, rect), _setValue(std::move(setValue)), _preview(std::move(preview)), format(fmt) { @@ -436,8 +474,7 @@ ColorEditor::ColorEditor(Window* parent, const rect_t& rect, uint32_t color, } } _color = color; - _colorType = new HSVColorType(this, _color); - _colorType->setText(); + setColorEditorType(typ); lv_obj_add_event_cb(lvobj, ColorEditor::value_changed, LV_EVENT_VALUE_CHANGED, nullptr); @@ -457,9 +494,12 @@ void ColorEditor::setColorEditorType(COLOR_EDITOR_TYPE colorType) } else if (colorType == HSV_COLOR_EDITOR) { _colorType = new HSVColorType(this, _color); setText(); - } else { + } else if (colorType == THM_COLOR_EDITOR) { _colorType = new ThemeColorType(this, _color); setText(); + } else { + _colorType = new FixedColorType(this, _color); + setText(); } // Update color bars invalidate(); diff --git a/radio/src/gui/colorlcd/controls/color_editor.h b/radio/src/gui/colorlcd/controls/color_editor.h index 4b362368b..8035217c2 100644 --- a/radio/src/gui/colorlcd/controls/color_editor.h +++ b/radio/src/gui/colorlcd/controls/color_editor.h @@ -29,7 +29,8 @@ constexpr int MAX_BARS = 3; enum COLOR_EDITOR_TYPE { RGB_COLOR_EDITOR = 0, HSV_COLOR_EDITOR, - THM_COLOR_EDITOR + THM_COLOR_EDITOR, + FXD_COLOR_EDITOR, }; // the ColorEditor() control is a group of other controls @@ -39,7 +40,7 @@ class ColorEditor : public Window ColorEditor(Window* parent, const rect_t& rect, uint32_t color, std::function setValue = nullptr, std::function preview = nullptr, - COLOR_EDITOR_FMT fmt = RGB565); + COLOR_EDITOR_FMT fmt = RGB565, COLOR_EDITOR_TYPE typ = HSV_COLOR_EDITOR); #if defined(DEBUG_WINDOWS) std::string getName() const override { return "ColorEditor"; } diff --git a/radio/src/gui/colorlcd/controls/color_picker.cpp b/radio/src/gui/colorlcd/controls/color_picker.cpp index 8d3d4496e..7102bcead 100644 --- a/radio/src/gui/colorlcd/controls/color_picker.cpp +++ b/radio/src/gui/colorlcd/controls/color_picker.cpp @@ -61,11 +61,13 @@ class ColorEditorPopup : public BaseDialog r = GET_RED32(rgb); g = GET_GREEN32(rgb); b = GET_BLUE32(rgb); } - colorPad->setColor(r, g, b); + if (colorPad) + colorPad->setColor(r, g, b); char s[10]; sprintf(s, "%02X%02X%02X", r, g, b); - hexStr->setText(s); + if (hexStr) + hexStr->setText(s); } void onCancel() override @@ -79,22 +81,18 @@ class ColorEditorPopup : public BaseDialog std::function _setValue, std::function _preview, COLOR_EDITOR_FMT fmt) : - BaseDialog(STR_COLOR_PICKER, false, COLOR_EDIT_WIDTH, - LV_SIZE_CONTENT), + BaseDialog(STR_COLOR_PICKER, false, COLOR_EDIT_WIDTH, COLOR_EDIT_HEIGHT), origColor(color), setValue(std::move(_setValue)), format(fmt) { FlexGridLayout grid(col_dsc, row_dsc); auto line = form->newLine(grid); rect_t r{0, 0, CE_SZ, CE_SZ}; - auto cedit = - new ColorEditor(line, r, color, [=](uint32_t c) { updateColor(c); }, _preview, format); - lv_obj_set_style_grid_cell_x_align(cedit->getLvObj(), LV_GRID_ALIGN_CENTER, - 0); + auto cedit = new ColorEditor(line, r, color, [=](uint32_t c) { updateColor(c); }, _preview, format, THM_COLOR_EDITOR); + lv_obj_set_style_grid_cell_x_align(cedit->getLvObj(), LV_GRID_ALIGN_CENTER, 0); auto vbox = new Window(line, rect_t{}); - lv_obj_set_style_grid_cell_x_align(vbox->getLvObj(), LV_GRID_ALIGN_CENTER, - 0); + lv_obj_set_style_grid_cell_x_align(vbox->getLvObj(), LV_GRID_ALIGN_CENTER, 0); vbox->setFlexLayout(LV_FLEX_FLOW_COLUMN, PAD_MEDIUM, r.w, r.h); auto hbox = new Window(vbox, rect_t{}); @@ -103,7 +101,7 @@ class ColorEditorPopup : public BaseDialog lv_obj_set_flex_align(hbox_obj, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_SPACE_AROUND); - colorPad = new ColorSwatch(hbox, {0, 0, COLOR_PAD_WIDTH, EdgeTxStyles::STD_FONT_HEIGHT}, + colorPad = new ColorSwatch(hbox, {0, 0, COLOR_PAD_WIDTH, EdgeTxStyles::UI_ELEMENT_HEIGHT}, COLOR_THEME_PRIMARY1); hexStr = new StaticText(hbox, {0, 0, EdgeTxStyles::EDIT_FLD_WIDTH, 0}, "", COLOR_THEME_PRIMARY1_INDEX, FONT(L)); @@ -112,43 +110,52 @@ class ColorEditorPopup : public BaseDialog hbox = new Window(vbox, rect_t{}); hbox->padAll(PAD_TINY); - hbox->setFlexLayout(LV_FLEX_FLOW_ROW, PAD_MEDIUM); + hbox->setFlexLayout(LV_FLEX_FLOW_ROW_WRAP, PAD_MEDIUM); lv_obj_set_flex_align(hbox->getLvObj(), LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_SPACE_AROUND); - auto rgbBtn = new TextButton(hbox, rect_t{}, "RGB"); - auto hsvBtn = new TextButton(hbox, rect_t{}, "HSV"); - auto thmBtn = new TextButton(hbox, rect_t{}, "SYS"); + auto thmBtn = new TextButton(hbox, {0, 0, BTN_W, 0}, STR_THEME); + auto fxdBtn = new TextButton(hbox, {0, 0, BTN_W, 0}, STR_FIXED); + auto hsvBtn = new TextButton(hbox, {0, 0, BTN_W, 0}, "HSV"); + auto rgbBtn = new TextButton(hbox, {0, 0, BTN_W, 0}, "RGB"); rgbBtn->setPressHandler([=]() { cedit->setColorEditorType(RGB_COLOR_EDITOR); hsvBtn->check(false); thmBtn->check(false); + fxdBtn->check(false); return 1; }); - rgbBtn->padAll(PAD_MEDIUM); hsvBtn->setPressHandler([=]() { cedit->setColorEditorType(HSV_COLOR_EDITOR); rgbBtn->check(false); thmBtn->check(false); + fxdBtn->check(false); return 1; }); - hsvBtn->padAll(PAD_MEDIUM); thmBtn->setPressHandler([=]() { cedit->setColorEditorType(THM_COLOR_EDITOR); rgbBtn->check(false); hsvBtn->check(false); + fxdBtn->check(false); + return 1; + }); + + fxdBtn->setPressHandler([=]() { + cedit->setColorEditorType(FXD_COLOR_EDITOR); + rgbBtn->check(false); + hsvBtn->check(false); + thmBtn->check(false); return 1; }); - thmBtn->padAll(PAD_MEDIUM); // color editor defaults to HSV - hsvBtn->check(true); + thmBtn->check(true); + lv_group_focus_obj(thmBtn->getLvObj()); - hbox = new Window(vbox, rect_t{}); - hbox->padTop(BTN_PAD_TOP); + hbox = new Window(vbox, {0, height() - EdgeTxStyles::UI_ELEMENT_HEIGHT - PAD_SMALL, 0, 0}); hbox->setFlexLayout(LV_FLEX_FLOW_ROW, PAD_MEDIUM); lv_obj_set_flex_align(hbox->getLvObj(), LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_END, LV_FLEX_ALIGN_SPACE_BETWEEN); @@ -166,11 +173,11 @@ class ColorEditorPopup : public BaseDialog }); } - static LAYOUT_VAL(CE_SZ, 182, 182, LS(182)) - static LAYOUT_VAL2(COLOR_EDIT_WIDTH, LCD_W * 0.8, LCD_W * 0.7) + static LAYOUT_VAL(CE_SZ, 186, 186, LS(186)) + static LAYOUT_VAL2(COLOR_EDIT_WIDTH, LCD_W * 0.9, LCD_W * 0.9) + static LAYOUT_VAL2(COLOR_EDIT_HEIGHT, LCD_H * 0.9, LV_SIZE_CONTENT) static LAYOUT_VAL(COLOR_PAD_WIDTH, 52, 52, LS(52)) static LAYOUT_VAL(BTN_W, 80, 80, LS(80)) - static LAYOUT_VAL(BTN_PAD_TOP, 60, 60, LS(60)) }; ColorPicker::ColorPicker(Window* parent, const rect_t& rect, diff --git a/radio/src/gui/colorlcd/radio/preview_window.cpp b/radio/src/gui/colorlcd/radio/preview_window.cpp index c21a599c3..75663e351 100644 --- a/radio/src/gui/colorlcd/radio/preview_window.cpp +++ b/radio/src/gui/colorlcd/radio/preview_window.cpp @@ -45,7 +45,7 @@ class ColorMaintainer void applyColorValues() { // save old values; - for (auto i = 0; i < LCD_COLOR_COUNT; i++) { + for (auto i = 0; i < THEME_COLOR_COUNT; i++) { oldColorVals[i] = lcdColorTable[i]; } @@ -58,7 +58,7 @@ class ColorMaintainer void restoreColorValues() { - for (auto i = 0; i < LCD_COLOR_COUNT; i++) { + for (auto i = 0; i < THEME_COLOR_COUNT; i++) { lcdColorTable[i] = oldColorVals[i]; } @@ -66,7 +66,7 @@ class ColorMaintainer } protected: - uint32_t oldColorVals[LCD_COLOR_COUNT]; + uint32_t oldColorVals[THEME_COLOR_COUNT]; std::vector colorList; }; diff --git a/radio/src/gui/colorlcd/startup_shutdown.cpp b/radio/src/gui/colorlcd/startup_shutdown.cpp index c97604c67..58281995b 100644 --- a/radio/src/gui/colorlcd/startup_shutdown.cpp +++ b/radio/src/gui/colorlcd/startup_shutdown.cpp @@ -85,12 +85,12 @@ void drawSplash() new StaticLZ4Image(splashScreen, IMG_X - logo->width / 2, IMG_Y - logo->height / 2, logo); - new StaticText(splashScreen, {TXT_X - TXT_XO, TXT_Y, TXT_W, TXT_H}, ver_str.c_str(), COLOR_GREY_INDEX, CENTERED); + new StaticText(splashScreen, {TXT_X - TXT_XO, TXT_Y, TXT_W, TXT_H}, ver_str.c_str(), COLOR_LIGHTGREY_INDEX, CENTERED); new StaticText(splashScreen, {TXT_X - TXT_XO, TXT_Y + TXT_H, TXT_W, TXT_H}, - nam_str.c_str(), COLOR_GREY_INDEX, CENTERED); + nam_str.c_str(), COLOR_LIGHTGREY_INDEX, CENTERED); #if !defined(VERSION_TAG) new StaticText(splashScreen, {TXT_X - TXT_XO, TXT_Y + TXT_H * 2, TXT_W, TXT_H}, - git_str.c_str(), COLOR_GREY_INDEX, CENTERED); + git_str.c_str(), COLOR_LIGHTGREY_INDEX, CENTERED); #endif } diff --git a/radio/src/gui/colorlcd/themes/theme_manager.cpp b/radio/src/gui/colorlcd/themes/theme_manager.cpp index a41b0f02d..6e2d5bf37 100644 --- a/radio/src/gui/colorlcd/themes/theme_manager.cpp +++ b/radio/src/gui/colorlcd/themes/theme_manager.cpp @@ -75,7 +75,7 @@ PACK(struct YAMLThemeSummary { }); PACK(struct YAMLThemeColors { - uint32_t colors[LCD_COLOR_COUNT - 1]; // We don't use CUSTOM + uint32_t colors[THEME_COLOR_COUNT - 1]; // We don't use CUSTOM }); PACK(struct YAMLTheme { @@ -112,18 +112,18 @@ static const struct YamlNode w_struct_YAMLTheme[] = { YAML_STRUCT("---\r\nsummary", (SELECTED_THEME_NAME_LEN + ThemeFile::AUTHOR_LENGTH + ThemeFile::INFO_LENGTH + 3) * 8, struct_YAMLThemeSummary, NULL), - YAML_STRUCT("colors", (LCD_COLOR_COUNT - 1) * 32, struct_YAMLThemeColors, + YAML_STRUCT("colors", (THEME_COLOR_COUNT - 1) * 32, struct_YAMLThemeColors, NULL), YAML_END}; static const struct YamlNode r_struct_YAMLTheme[] = { YAML_STRUCT("summary", (SELECTED_THEME_NAME_LEN + ThemeFile::AUTHOR_LENGTH + ThemeFile::INFO_LENGTH + 3) * 8, struct_YAMLThemeSummary, NULL), - YAML_STRUCT("colors", (LCD_COLOR_COUNT - 1) * 32, struct_YAMLThemeColors, + YAML_STRUCT("colors", (THEME_COLOR_COUNT - 1) * 32, struct_YAMLThemeColors, NULL), YAML_END}; -static const char* const colorNames[LCD_COLOR_COUNT] = { +static const char* const colorNames[THEME_COLOR_COUNT] = { STR_THEME_COLOR_PRIMARY1, STR_THEME_COLOR_PRIMARY2, STR_THEME_COLOR_PRIMARY3, STR_THEME_COLOR_SECONDARY1, STR_THEME_COLOR_SECONDARY2, STR_THEME_COLOR_SECONDARY3, @@ -208,7 +208,7 @@ void ThemeFile::deSerialize() name = yt.summary.name; author = yt.summary.author; info = yt.summary.info; - for (int i = 0; i < LCD_COLOR_COUNT - 1; i += 1) { + for (int i = 0; i < THEME_COLOR_COUNT - 1; i += 1) { colorList.emplace_back( ColorEntry{(LcdColorIndex)(i), yt.colors.colors[i]}); } diff --git a/radio/src/lua/api_colorlcd.cpp b/radio/src/lua/api_colorlcd.cpp index fc5439e96..0b56e5b98 100644 --- a/radio/src/lua/api_colorlcd.cpp +++ b/radio/src/lua/api_colorlcd.cpp @@ -946,7 +946,7 @@ static int luaLcdSetColor(lua_State *L) unsigned int index = COLOR_VAL((uint32_t)luaL_checkinteger(L, 1)); uint16_t color = COLOR_VAL(colorToRGB(luaL_checkinteger(L, 2))); - if (index < LCD_COLOR_COUNT && lcdColorTable[index] != color) { + if (index < THEME_COLOR_COUNT && lcdColorTable[index] != color) { lcdColorTable[index] = color; styles->applyColors(); } @@ -970,7 +970,7 @@ Get the color value from flags static int luaLcdGetColor(lua_State *L) { LcdFlags flags = luaL_checkinteger(L, 1); - if ((flags & RGB_FLAG) || (COLOR_VAL(flags) & 0xFF) < LCD_COLOR_COUNT) { + if ((flags & RGB_FLAG) || (COLOR_VAL(flags) & 0xFF) < THEME_COLOR_COUNT) { LcdFlags col = colorToRGB(flags) & (COLOR_MASK(~0u) | RGB_FLAG); lua_pushinteger(L, col); } else { diff --git a/radio/src/lua/api_general.cpp b/radio/src/lua/api_general.cpp index 48c43ba28..0e280c55d 100644 --- a/radio/src/lua/api_general.cpp +++ b/radio/src/lua/api_general.cpp @@ -3118,7 +3118,7 @@ LROT_BEGIN(etxcst, NULL, 0) LROT_NUMENTRY( COLOR_THEME_DISABLED, COLOR2FLAGS(COLOR_THEME_DISABLED_INDEX) ) LROT_NUMENTRY( CUSTOM_COLOR, COLOR2FLAGS(CUSTOM_COLOR_INDEX) ) - // Old style theme color constants + // Old style theme color constants - TODO: remove in 3.0 LROT_NUMENTRY( ALARM_COLOR, COLOR2FLAGS(COLOR_THEME_WARNING_INDEX) ) LROT_NUMENTRY( BARGRAPH_BGCOLOR, COLOR2FLAGS(COLOR_THEME_SECONDARY3_INDEX) ) LROT_NUMENTRY( BARGRAPH1_COLOR, COLOR2FLAGS(COLOR_THEME_SECONDARY1_INDEX) ) @@ -3151,21 +3151,24 @@ LROT_BEGIN(etxcst, NULL, 0) // Literal colors LROT_NUMENTRY( BLACK, COLOR2FLAGS(COLOR_BLACK_INDEX) ) LROT_NUMENTRY( WHITE, COLOR2FLAGS(COLOR_WHITE_INDEX) ) - LROT_NUMENTRY( LIGHTWHITE, RGB2FLAGS(0xEA, 0xEA, 0xEA) ) - LROT_NUMENTRY( YELLOW, RGB2FLAGS(0xFF, 0xFF, 0x00) ) - LROT_NUMENTRY( BLUE, RGB2FLAGS(0x00, 0x00, 0xFF) ) - LROT_NUMENTRY( DARKBLUE, RGB2FLAGS(0x00, 0x00, 0xA0) ) - LROT_NUMENTRY( GREY, RGB2FLAGS(0x60, 0x60, 0x60) ) - LROT_NUMENTRY( DARKGREY, RGB2FLAGS(0x40, 0x40, 0x40) ) - LROT_NUMENTRY( LIGHTGREY, RGB2FLAGS(0xC0, 0xC0, 0xC0) ) - LROT_NUMENTRY( RED, RGB2FLAGS(0xFF, 0x00, 0x00) ) - LROT_NUMENTRY( DARKRED, RGB2FLAGS(0xA0, 0x00, 0x00) ) - LROT_NUMENTRY( GREEN, RGB2FLAGS(0x00, 0xFF, 0x00) ) - LROT_NUMENTRY( DARKGREEN, RGB2FLAGS(0x00, 0xA0, 0x00) ) - LROT_NUMENTRY( LIGHTBROWN, RGB2FLAGS(0x9C, 0x6D, 0x20) ) - LROT_NUMENTRY( DARKBROWN, RGB2FLAGS(0x6A, 0x48, 0x10) ) - LROT_NUMENTRY( BRIGHTGREEN, RGB2FLAGS(0x00, 0xB4, 0x3C) ) - LROT_NUMENTRY( ORANGE, RGB2FLAGS(0xE5, 0x64, 0x1E) ) + LROT_NUMENTRY( LIGHTWHITE, COLOR2FLAGS(COLOR_LIGHTWHITE_INDEX) ) + LROT_NUMENTRY( LIGHTGREY, COLOR2FLAGS(COLOR_LIGHTGREY_INDEX) ) + LROT_NUMENTRY( GREY, COLOR2FLAGS(COLOR_GREY_INDEX) ) + LROT_NUMENTRY( DARKGREY, COLOR2FLAGS(COLOR_DARKGREY_INDEX) ) + LROT_NUMENTRY( RED, COLOR2FLAGS(COLOR_RED_INDEX) ) + LROT_NUMENTRY( DARKRED, COLOR2FLAGS(COLOR_DARKRED_INDEX) ) + // LROT_NUMENTRY( LIGHTRED, COLOR2FLAGS(COLOR_LIGHTRED_INDEX) ) // Add once above legacy entries are removed + LROT_NUMENTRY( GREEN, COLOR2FLAGS(COLOR_GREEN_INDEX) ) + LROT_NUMENTRY( DARKGREEN, COLOR2FLAGS(COLOR_DARKGREEN_INDEX) ) + LROT_NUMENTRY( BRIGHTGREEN, COLOR2FLAGS(COLOR_BRIGHTGREEN_INDEX) ) + LROT_NUMENTRY( BLUE, COLOR2FLAGS(COLOR_BLUE_INDEX) ) + LROT_NUMENTRY( DARKBLUE, COLOR2FLAGS(COLOR_DARKBLUE_INDEX) ) + // LROT_NUMENTRY( CYAN, COLOR2FLAGS(COLOR_CYAN_INDEX) ) // Add once above legacy entries are removed + LROT_NUMENTRY( YELLOW, COLOR2FLAGS(COLOR_YELLOW_INDEX) ) + LROT_NUMENTRY( LIGHTBROWN, COLOR2FLAGS(COLOR_LIGHTBROWN_INDEX) ) + LROT_NUMENTRY( DARKBROWN, COLOR2FLAGS(COLOR_DARKBROWN_INDEX) ) + LROT_NUMENTRY( ORANGE, COLOR2FLAGS(COLOR_ORANGE_INDEX) ) + // LROT_NUMENTRY( MAGENTA, COLOR2FLAGS(COLOR_MAGENTA_INDEX) ) // Add once above legacy entries are removed #else LROT_NUMENTRY( FIXEDWIDTH, FIXEDWIDTH ) diff --git a/radio/src/translations.cpp b/radio/src/translations.cpp index b3ec71b95..b6a31745a 100644 --- a/radio/src/translations.cpp +++ b/radio/src/translations.cpp @@ -997,6 +997,7 @@ const char STR_RED[] = TR_RED; const char STR_GREEN[] = TR_GREEN; const char STR_BLUE[] = TR_BLUE; const char STR_COLOR_PICKER[] = TR_COLOR_PICKER; +const char STR_FIXED[] = TR_FIXED; const char STR_EDIT_THEME_DETAILS[] = TR_EDIT_THEME_DETAILS; const char STR_THEME_COLOR_DEFAULT[] = TR_THEME_COLOR_DEFAULT; const char STR_THEME_COLOR_PRIMARY1[] = TR_THEME_COLOR_PRIMARY1; diff --git a/radio/src/translations.h b/radio/src/translations.h index c1326987a..75484d6f6 100644 --- a/radio/src/translations.h +++ b/radio/src/translations.h @@ -1185,6 +1185,7 @@ extern const char STR_RED[]; extern const char STR_BLUE[]; extern const char STR_GREEN[]; extern const char STR_COLOR_PICKER[]; +extern const char STR_FIXED[]; extern const char STR_EDIT_THEME_DETAILS[]; extern const char STR_THEME_COLOR_DEFAULT[]; extern const char STR_THEME_COLOR_PRIMARY1[]; diff --git a/radio/src/translations/cn.h b/radio/src/translations/cn.h index 283c65ebd..f59345e5c 100644 --- a/radio/src/translations/cn.h +++ b/radio/src/translations/cn.h @@ -1195,6 +1195,7 @@ #define TR_BLUE "蓝" #define TR_GREEN "绿" #define TR_COLOR_PICKER "拾取颜色" +#define TR_FIXED "Fixed" #define TR_EDIT_THEME_DETAILS "主题信息" #define TR_THEME_COLOR_DEFAULT "默认" #define TR_THEME_COLOR_PRIMARY1 "主色1" diff --git a/radio/src/translations/cz.h b/radio/src/translations/cz.h index a116a6635..77ce4cd7e 100644 --- a/radio/src/translations/cz.h +++ b/radio/src/translations/cz.h @@ -1211,6 +1211,7 @@ #define TR_BLUE "Modrá" #define TR_GREEN "Zelená" #define TR_COLOR_PICKER "Výběr barvy" +#define TR_FIXED "Fixed" #define TR_EDIT_THEME_DETAILS "Editovat motiv" #define TR_THEME_COLOR_DEFAULT "DEFAULTNÍ" #define TR_THEME_COLOR_PRIMARY1 "PRIMÁRNÍ1" diff --git a/radio/src/translations/da.h b/radio/src/translations/da.h index 7fba8d420..65b6e3134 100644 --- a/radio/src/translations/da.h +++ b/radio/src/translations/da.h @@ -1211,6 +1211,7 @@ #define TR_BLUE "Blå" #define TR_GREEN "Grøn" #define TR_COLOR_PICKER "Farve vælger" +#define TR_FIXED "Fixed" #define TR_EDIT_THEME_DETAILS "Ret tema detajler" #define TR_THEME_COLOR_DEFAULT "STANDARD" #define TR_THEME_COLOR_PRIMARY1 "PRIMÆR 1" diff --git a/radio/src/translations/de.h b/radio/src/translations/de.h index bbc6dd234..6e514167b 100644 --- a/radio/src/translations/de.h +++ b/radio/src/translations/de.h @@ -1202,6 +1202,7 @@ #define TR_BLUE "Blau" #define TR_GREEN "Grün" #define TR_COLOR_PICKER "Farbauswahl" +#define TR_FIXED "Fixed" #define TR_EDIT_THEME_DETAILS "Theme Details Bearb." #define TR_THEME_COLOR_DEFAULT "Standard" #define TR_THEME_COLOR_PRIMARY1 "Primär1" diff --git a/radio/src/translations/en.h b/radio/src/translations/en.h index 50dcbd268..8548050d0 100644 --- a/radio/src/translations/en.h +++ b/radio/src/translations/en.h @@ -1199,6 +1199,7 @@ #define TR_BLUE "Blue" #define TR_GREEN "Green" #define TR_COLOR_PICKER "Color Picker" +#define TR_FIXED "Fixed" #define TR_EDIT_THEME_DETAILS "Edit Theme Details" #define TR_THEME_COLOR_DEFAULT "DEFAULT" #define TR_THEME_COLOR_PRIMARY1 "PRIMARY1" diff --git a/radio/src/translations/es.h b/radio/src/translations/es.h index aefb85129..10114f6d0 100644 --- a/radio/src/translations/es.h +++ b/radio/src/translations/es.h @@ -1199,6 +1199,7 @@ #define TR_BLUE "Blue" #define TR_GREEN "Green" #define TR_COLOR_PICKER "Color Picker" +#define TR_FIXED "Fixed" #define TR_EDIT_THEME_DETAILS "Edit Theme Details" #define TR_THEME_COLOR_DEFAULT "DEFAULT" #define TR_THEME_COLOR_PRIMARY1 "PRIMARY1" diff --git a/radio/src/translations/fi.h b/radio/src/translations/fi.h index 369eaf162..723f39aba 100644 --- a/radio/src/translations/fi.h +++ b/radio/src/translations/fi.h @@ -1213,6 +1213,7 @@ #define TR_BLUE "Sininen" #define TR_GREEN "Vihreä" #define TR_COLOR_PICKER "Värinvalitsija" +#define TR_FIXED "Fixed" #define TR_EDIT_THEME_DETAILS "Edit Theme Details" #define TR_THEME_COLOR_DEFAULT "DEFAULT" #define TR_THEME_COLOR_PRIMARY1 "PRIMARY1" diff --git a/radio/src/translations/fr.h b/radio/src/translations/fr.h index 68abd1ce6..b1e900bcb 100644 --- a/radio/src/translations/fr.h +++ b/radio/src/translations/fr.h @@ -1215,6 +1215,7 @@ #define TR_BLUE "Bleu" #define TR_GREEN "Vert" #define TR_COLOR_PICKER "Pipette à couleurs" +#define TR_FIXED "Fixed" #define TR_EDIT_THEME_DETAILS "Éditer Détails Thème" #define TR_THEME_COLOR_DEFAULT "DEFAUT" #define TR_THEME_COLOR_PRIMARY1 "PRIMAIRE 1" diff --git a/radio/src/translations/he.h b/radio/src/translations/he.h index c95e4d5fa..0bd860464 100644 --- a/radio/src/translations/he.h +++ b/radio/src/translations/he.h @@ -1198,6 +1198,7 @@ #define TR_BLUE "כחול" #define TR_GREEN "ירוק" #define TR_COLOR_PICKER "בחירת צבע" +#define TR_FIXED "Fixed" #define TR_EDIT_THEME_DETAILS "עריכת ערכת נושא" #define TR_THEME_COLOR_DEFAULT "DEFAULT" #define TR_THEME_COLOR_PRIMARY1 "ראשי 1" diff --git a/radio/src/translations/it.h b/radio/src/translations/it.h index 4ba449fb6..1c8ecd34b 100644 --- a/radio/src/translations/it.h +++ b/radio/src/translations/it.h @@ -1192,6 +1192,7 @@ #define TR_BLUE "Blu" #define TR_GREEN "Verde" #define TR_COLOR_PICKER "Picker Colori" +#define TR_FIXED "Fixed" #define TR_EDIT_THEME_DETAILS "Edita dett. tema" #define TR_THEME_COLOR_DEFAULT "PREDEFINITO" #define TR_THEME_COLOR_PRIMARY1 "PRIMARIO1" diff --git a/radio/src/translations/jp.h b/radio/src/translations/jp.h index 1484808a7..899603303 100644 --- a/radio/src/translations/jp.h +++ b/radio/src/translations/jp.h @@ -1198,6 +1198,7 @@ #define TR_BLUE "青" #define TR_GREEN "緑" #define TR_COLOR_PICKER "ピックアップ色" +#define TR_FIXED "Fixed" #define TR_EDIT_THEME_DETAILS "テーマ詳細の編集" #define TR_THEME_COLOR_DEFAULT "デフォルト" #define TR_THEME_COLOR_PRIMARY1 "プライマリ 1" diff --git a/radio/src/translations/ko.h b/radio/src/translations/ko.h index c89934b6f..8cc4be17c 100644 --- a/radio/src/translations/ko.h +++ b/radio/src/translations/ko.h @@ -1254,6 +1254,7 @@ #define TR_BLUE "파랑" #define TR_GREEN "초록" #define TR_COLOR_PICKER "색상 선택" +#define TR_FIXED "Fixed" #define TR_EDIT_THEME_DETAILS "테마 세부 설정" #define TR_THEME_COLOR_DEFAULT "기본" #define TR_THEME_COLOR_PRIMARY1 "기본색 1" diff --git a/radio/src/translations/nl.h b/radio/src/translations/nl.h index 44d7ff57b..147a625a6 100644 --- a/radio/src/translations/nl.h +++ b/radio/src/translations/nl.h @@ -1205,6 +1205,7 @@ #define TR_BLUE "Blue" #define TR_GREEN "Green" #define TR_COLOR_PICKER "Color Picker" +#define TR_FIXED "Fixed" #define TR_EDIT_THEME_DETAILS "Edit Theme Details" #define TR_THEME_COLOR_DEFAULT "DEFAULT" #define TR_THEME_COLOR_PRIMARY1 "PRIMARY1" diff --git a/radio/src/translations/pl.h b/radio/src/translations/pl.h index 33bacb94b..860f0af45 100644 --- a/radio/src/translations/pl.h +++ b/radio/src/translations/pl.h @@ -1197,6 +1197,7 @@ #define TR_BLUE "Niebieski" #define TR_GREEN "Zielony" #define TR_COLOR_PICKER "Wybór koloru" +#define TR_FIXED "Fixed" #define TR_EDIT_THEME_DETAILS "Edytuj szablon" #define TR_THEME_COLOR_DEFAULT "DOMYŚLNY" #define TR_THEME_COLOR_PRIMARY1 "GŁÓWNY1" diff --git a/radio/src/translations/pt.h b/radio/src/translations/pt.h index 89e90c667..f0ada6554 100644 --- a/radio/src/translations/pt.h +++ b/radio/src/translations/pt.h @@ -1202,6 +1202,7 @@ #define TR_BLUE "Blue" #define TR_GREEN "Green" #define TR_COLOR_PICKER "Color Picker" +#define TR_FIXED "Fixed" #define TR_EDIT_THEME_DETAILS "Edit Theme Details" #define TR_THEME_COLOR_DEFAULT "DEFAULT" #define TR_THEME_COLOR_PRIMARY1 "PRIMARY1" diff --git a/radio/src/translations/ru.h b/radio/src/translations/ru.h index ec36ac921..016ab38a2 100644 --- a/radio/src/translations/ru.h +++ b/radio/src/translations/ru.h @@ -1201,6 +1201,7 @@ #define TR_BLUE "Синяяя" #define TR_GREEN "Зеленая" #define TR_COLOR_PICKER "Средство выбора цвета" +#define TR_FIXED "Fixed" #define TR_EDIT_THEME_DETAILS "Редакт детали темы" #define TR_THEME_COLOR_DEFAULT "По умолчанию" #define TR_THEME_COLOR_PRIMARY1 "ОСНОВНОЙ1" diff --git a/radio/src/translations/se.h b/radio/src/translations/se.h index 5c95d4a2d..a394b145e 100644 --- a/radio/src/translations/se.h +++ b/radio/src/translations/se.h @@ -1234,6 +1234,7 @@ #define TR_BLUE "Blå" #define TR_GREEN "Grön" #define TR_COLOR_PICKER "Färgväljare" +#define TR_FIXED "Fixed" #define TR_EDIT_THEME_DETAILS "Ändra temainformation" #define TR_THEME_COLOR_DEFAULT "DEFAULT" #define TR_THEME_COLOR_PRIMARY1 "PRIMÄR1" diff --git a/radio/src/translations/tw.h b/radio/src/translations/tw.h index ca7925da7..5da0343a1 100644 --- a/radio/src/translations/tw.h +++ b/radio/src/translations/tw.h @@ -1200,6 +1200,7 @@ #define TR_BLUE "藍" #define TR_GREEN "綠" #define TR_COLOR_PICKER "拾取顏色" +#define TR_FIXED "Fixed" #define TR_EDIT_THEME_DETAILS "主題信息" #define TR_THEME_COLOR_DEFAULT "默認" #define TR_THEME_COLOR_PRIMARY1 "主色1" diff --git a/radio/src/translations/ua.h b/radio/src/translations/ua.h index 140a613ad..f41b3b392 100644 --- a/radio/src/translations/ua.h +++ b/radio/src/translations/ua.h @@ -1201,6 +1201,7 @@ #define TR_BLUE "Синій" #define TR_GREEN "Зелений" #define TR_COLOR_PICKER "Обирач кольору" +#define TR_FIXED "Fixed" #define TR_EDIT_THEME_DETAILS "Редагувати деталі теми" #define TR_THEME_COLOR_DEFAULT "ЗАМОВЧ" #define TR_THEME_COLOR_PRIMARY1 "ОСНОВНИЙ1"