chore(translation): Theme color constants (#3664)

* translated_theme_text

* translated theme text

* translated theme text

* translated theme text

* translated theme text

Changes to allow direct use of translation strings for all theme text, as per code from @philmoz

* Some minor changes

* Proper translations for CZ,DA,DE,FR,HE,IT,JP,PL

* Translations for CN,TW

* Minor correction
This commit is contained in:
ulfhedlund
2023-06-17 14:05:16 +10:00
committed by GitHub
parent ba56166ff5
commit c8059403b9
20 changed files with 380 additions and 21 deletions
+14 -13
View File
@@ -179,12 +179,14 @@ class ThemedButton : public TextButton
class ThemedTextEdit : public TextEdit
{
public:
ThemedTextEdit(Window *parent, const rect_t &rect, char *text,
ThemedTextEdit(Window *parent, const rect_t &rect, const char *text,
int colorBackgroundIndex, int colorTextIndex) :
TextEdit(parent, rect, text, strlen(text), NO_FOCUS),
TextEdit(parent, rect, editText, strlen(text), NO_FOCUS),
_colorBackgroundIndex(colorBackgroundIndex),
_colorTextIndex(colorTextIndex)
{
strcpy(editText, text);
update();
}
void paint(BitmapBuffer *dc) override
@@ -192,7 +194,7 @@ class ThemedTextEdit : public TextEdit
colorMaintainer.applyColorValues();
lv_obj_set_style_bg_color(lvobj, makeLvColor(COLOR(_colorBackgroundIndex)), LV_PART_MAIN);
lv_obj_set_style_text_color(lvobj, lv_color_white(), LV_PART_MAIN);
FormField::paint(dc);
TextEdit::paint(dc);
colorMaintainer.restoreColorValues();
}
@@ -213,9 +215,9 @@ class ThemedTextEdit : public TextEdit
protected:
int _colorBackgroundIndex;
int _colorTextIndex;
char editText[50];
};
// display controls using the appropriate theme.
class PreviewWindow : public FormGroup
{
@@ -224,25 +226,24 @@ class PreviewWindow : public FormGroup
std::vector<ColorEntry> colorList) :
FormGroup(window, rect, NO_FOCUS), _colorList(colorList)
{
// reset default group to avoid focus
lv_group_t* def_group = lv_group_get_default();
lv_group_set_default(nullptr);
new ThemedStaticText(this, {5, 40, 100, LINE_HEIGHT}, "Checkbox", COLOR_THEME_PRIMARY1_INDEX);
new ThemedStaticText(this, {5, 40, 100, LINE_HEIGHT}, STR_THEME_CHECKBOX, COLOR_THEME_PRIMARY1_INDEX);
new ThemedCheckBox(this, {100 + 15, 40, 20, LINE_HEIGHT}, true);
new ThemedCheckBox(this, {140 + 15, 40, 20, LINE_HEIGHT}, false);
new ThemedButton(this, {190, 40, 100, LINE_HEIGHT + 10}, "Active", true, BUTTON_CHECKED, COLOR_THEME_PRIMARY1_INDEX);
new ThemedButton(this, {190, 75, 100, LINE_HEIGHT + 10}, "Regular", false, 0, COLOR_THEME_PRIMARY1_INDEX);
new ThemedButton(this, {190, 40, 100, LINE_HEIGHT + 10}, STR_THEME_ACTIVE, true, BUTTON_CHECKED, COLOR_THEME_PRIMARY1_INDEX);
new ThemedButton(this, {190, 75, 100, LINE_HEIGHT + 10}, STR_THEME_REGULAR, false, 0, COLOR_THEME_PRIMARY1_INDEX);
new ThemedMainViewHorizontalTrim(this, {5, 65, HORIZONTAL_SLIDERS_WIDTH, 20}, 0);
new ThemedMainViewHorizontalSlider(this, {5, 87, HORIZONTAL_SLIDERS_WIDTH, 20}, 0);
new ThemedStaticText(this, {5, 115, 100, LINE_HEIGHT}, "Warning Text", COLOR_THEME_WARNING_INDEX);
new ThemedStaticText(this, {5, 140, 100, LINE_HEIGHT}, "Disabled Text", COLOR_THEME_DISABLED_INDEX);
new ThemedStaticText(this, {5, 115, 100, LINE_HEIGHT}, STR_THEME_WARNING, COLOR_THEME_WARNING_INDEX);
new ThemedStaticText(this, {5, 140, 100, LINE_HEIGHT}, STR_THEME_DISABLED, COLOR_THEME_DISABLED_INDEX);
static char EditText[] = "Edit";
new ThemedTextEdit(this, {5, 160, 100, LINE_HEIGHT + 1}, EditText,
new ThemedTextEdit(this, {5, 160, 100, LINE_HEIGHT + 1}, STR_THEME_EDIT,
COLOR_THEME_EDIT_INDEX, COLOR_THEME_PRIMARY2_INDEX);
static char FocusText[] = "Focus";
new ThemedTextEdit(this, {110, 160, 100, LINE_HEIGHT + 1}, FocusText,
new ThemedTextEdit(this, {110, 160, 100, LINE_HEIGHT + 1}, STR_THEME_FOCUS,
COLOR_THEME_FOCUS_INDEX, COLOR_THEME_PRIMARY2_INDEX);
ticks = 0;
+3 -3
View File
@@ -128,9 +128,9 @@ static const struct YamlNode r_struct_YAMLTheme[] = {
};
static const char *colorNames[COLOR_COUNT] = {
"DEFAULT", "PRIMARY1", "PRIMARY2", "PRIMARY3",
"SECONDARY1", "SECONDARY2", "SECONDARY3", "FOCUS",
"EDIT", "ACTIVE", "WARNING", "DISABLED", "CUSTOM",
STR_THEME_COLOR_DEFAULT, STR_THEME_COLOR_PRIMARY1, STR_THEME_COLOR_PRIMARY2, STR_THEME_COLOR_PRIMARY3,
STR_THEME_COLOR_SECONDARY1, STR_THEME_COLOR_SECONDARY2, STR_THEME_COLOR_SECONDARY3, STR_THEME_COLOR_FOCUS,
STR_THEME_COLOR_EDIT, STR_THEME_COLOR_ACTIVE, STR_THEME_COLOR_WARNING, STR_THEME_COLOR_DISABLED, STR_THEME_COLOR_CUSTOM,
};
ThemeFile::ThemeFile(std::string themePath, bool loadYAML) :