From 44a1733f0bb4e1022cbaca79ccc963156b1c0101 Mon Sep 17 00:00:00 2001 From: Peter Feerick Date: Fri, 11 Mar 2022 19:31:35 +1000 Subject: [PATCH] chore: Touch and Narrow LCD template tweaks (#1675) * Make the buttons double height so easier to touch * Add translation strings, add info for blank model * Wrap STR_NO_TEMPLATES text on narrow screen --- radio/src/gui/colorlcd/model_select.cpp | 33 +++++++++++++++++-------- radio/src/translations.cpp | 2 ++ radio/src/translations.h | 2 ++ radio/src/translations/cn.h.txt | 2 ++ radio/src/translations/cz.h.txt | 2 ++ radio/src/translations/de.h.txt | 2 ++ radio/src/translations/en.h.txt | 2 ++ radio/src/translations/es.h.txt | 2 ++ radio/src/translations/fi.h.txt | 2 ++ radio/src/translations/fr.h.txt | 2 ++ radio/src/translations/it.h.txt | 2 ++ radio/src/translations/nl.h.txt | 2 ++ radio/src/translations/pl.h.txt | 2 ++ radio/src/translations/pt.h.txt | 2 ++ radio/src/translations/se.h.txt | 2 ++ radio/src/translations/tw.h.txt | 2 ++ 16 files changed, 53 insertions(+), 10 deletions(-) diff --git a/radio/src/gui/colorlcd/model_select.cpp b/radio/src/gui/colorlcd/model_select.cpp index f60fe42e8..0a9bb1faa 100644 --- a/radio/src/gui/colorlcd/model_select.cpp +++ b/radio/src/gui/colorlcd/model_select.cpp @@ -25,6 +25,7 @@ #include "storage/modelslist.h" #include "libopenui.h" #include "standalone_lua.h" +#include "str_functions.h" #if LCD_W > LCD_H constexpr int MODEL_CELLS_PER_LINE = 3; @@ -183,7 +184,8 @@ class SelectTemplate : public TemplatePage updateInfo(); } }); - grid.nextLine(); + tb->setHeight(PAGE_LINE_HEIGHT * 2); + grid.spacer(tb->height() + 5); } body.setInnerHeight(grid.getWindowHeight()); } @@ -194,16 +196,24 @@ class SelectTemplate : public TemplatePage rect_t rect = body.getRect(); rect.x = PAGE_PADDING; rect.y = PAGE_PADDING; - rect.w = rect.w - 2 * PAGE_PADDING; + rect.w = rect.w - (2 * PAGE_PADDING); + +#if LCD_W > LCD_H rect.h = PAGE_LINE_HEIGHT; - new StaticText(&body, rect, STR_NO_TEMPLATES, 0, COLOR_THEME_PRIMARY1); + int charBreak = 60; +#else + rect.h = PAGE_LINE_HEIGHT * 2; + int charBreak = 40; +#endif + new StaticText(&body, rect, wrap(STR_NO_TEMPLATES, charBreak), 0, COLOR_THEME_PRIMARY1); + // The following button is needed because the EXIT key does not work without... rect = body.getRect(); rect.x = rect.w - PAGE_PADDING - 100; - rect.y = rect.h - PAGE_PADDING - PAGE_LINE_HEIGHT; + rect.y = rect.h - PAGE_PADDING - (PAGE_LINE_HEIGHT * 2); rect.w = 100; - rect.h = PAGE_LINE_HEIGHT; - new TemplateButton(&body, rect, STR_EXIT, [=]() -> uint8_t { deleteLater(); return 0; }); + rect.h = PAGE_LINE_HEIGHT * 2; + new TextButton(&body, rect, STR_EXIT, [=]() -> uint8_t { deleteLater(); return 0; }); } else { snprintf(buffer, LEN_BUFFER, "%s%c%s%s", path, '/', files.front().c_str(), TEXT_EXT); updateInfo(); @@ -225,17 +235,19 @@ class SelectTemplateFolder : public TemplatePage FormGridLayout grid; grid.spacer(PAGE_PADDING); - auto tfb = new TemplateButton(&body, grid.getLabelSlot(), "Blank Model", [=]() -> uint8_t { + auto tfb = new TemplateButton(&body, grid.getLabelSlot(), STR_BLANK_MODEL, [=]() -> uint8_t { deleteLater(); return 0; }); + snprintf(infoText, LEN_INFO_TEXT, "%s", STR_BLANK_MODEL_INFO); tfb->setFocusHandler([=](bool active) { if (active) { - snprintf(infoText, LEN_INFO_TEXT, "%c", '\0'); + snprintf(infoText, LEN_INFO_TEXT, "%s", STR_BLANK_MODEL_INFO); invalidate(); } }); - grid.nextLine(); + tfb->setHeight(PAGE_LINE_HEIGHT * 2); + grid.spacer(tfb->height() + 5); std::list directories; FILINFO fno; @@ -273,7 +285,8 @@ class SelectTemplateFolder : public TemplatePage updateInfo(); } }); - grid.nextLine(); + tfb->setHeight(PAGE_LINE_HEIGHT * 2); + grid.spacer(tfb->height() + 5); } body.setInnerHeight(grid.getWindowHeight()); } diff --git a/radio/src/translations.cpp b/radio/src/translations.cpp index 827ac3b29..e987dc4b8 100644 --- a/radio/src/translations.cpp +++ b/radio/src/translations.cpp @@ -931,6 +931,8 @@ const char STR_SELECT_TEMPLATE[] = TR_SELECT_TEMPLATE; const char STR_SELECT_TEMPLATE_FOLDER[] = TR_SELECT_TEMPLATE_FOLDER; const char STR_NO_TEMPLATES[] = TR_NO_TEMPLATES; const char STR_SAVE_TEMPLATE[] = TR_SAVE_TEMPLATE; +const char STR_BLANK_MODEL[] = TR_BLANK_MODEL; +const char STR_BLANK_MODEL_INFO[] = TR_BLANK_MODEL_INFO; const char STR_FILE_EXISTS[] = TR_FILE_EXISTS; const char STR_ASK_OVERWRITE[] = TR_ASK_OVERWRITE; diff --git a/radio/src/translations.h b/radio/src/translations.h index 6e503bef9..275983329 100644 --- a/radio/src/translations.h +++ b/radio/src/translations.h @@ -612,6 +612,8 @@ extern const char STR_SELECT_TEMPLATE[]; extern const char STR_SELECT_TEMPLATE_FOLDER[]; extern const char STR_NO_TEMPLATES[]; extern const char STR_SAVE_TEMPLATE[]; +extern const char STR_BLANK_MODEL[]; +extern const char STR_BLANK_MODEL_INFO[]; extern const char STR_FILE_EXISTS[]; extern const char STR_ASK_OVERWRITE[]; #define STR_UPDATE_LIST STR_DELAYDOWN diff --git a/radio/src/translations/cn.h.txt b/radio/src/translations/cn.h.txt index 3b8fc2a80..d7a50ce8a 100644 --- a/radio/src/translations/cn.h.txt +++ b/radio/src/translations/cn.h.txt @@ -784,6 +784,8 @@ #define TR_SELECT_TEMPLATE "SELECT A MODEL TEMPLATE:" #define TR_NO_TEMPLATES "No model templates were found in this folder" #define TR_SAVE_TEMPLATE "Save as template" +#define TR_BLANK_MODEL "Blank Model" +#define TR_BLANK_MODEL_INFO "Create a blank model" #define TR_FILE_EXISTS "FILE ALREADY EXISTS" #define TR_ASK_OVERWRITE "Do you want to overwrite?" diff --git a/radio/src/translations/cz.h.txt b/radio/src/translations/cz.h.txt index f4e61b19e..beeffe0c0 100644 --- a/radio/src/translations/cz.h.txt +++ b/radio/src/translations/cz.h.txt @@ -818,6 +818,8 @@ #define TR_SELECT_TEMPLATE "SELECT A MODEL TEMPLATE:" #define TR_NO_TEMPLATES "No model templates were found in this folder" #define TR_SAVE_TEMPLATE "Save as template" +#define TR_BLANK_MODEL "Blank Model" +#define TR_BLANK_MODEL_INFO "Create a blank model" #define TR_FILE_EXISTS "FILE ALREADY EXISTS" #define TR_ASK_OVERWRITE "Do you want to overwrite?" diff --git a/radio/src/translations/de.h.txt b/radio/src/translations/de.h.txt index 48da96486..feea44349 100644 --- a/radio/src/translations/de.h.txt +++ b/radio/src/translations/de.h.txt @@ -820,6 +820,8 @@ #define TR_SELECT_TEMPLATE "SELECT A MODEL TEMPLATE:" #define TR_NO_TEMPLATES "No model templates were found in this folder" #define TR_SAVE_TEMPLATE "Save as template" +#define TR_BLANK_MODEL "Blank Model" +#define TR_BLANK_MODEL_INFO "Create a blank model" #define TR_FILE_EXISTS "FILE ALREADY EXISTS" #define TR_ASK_OVERWRITE "Do you want to overwrite?" diff --git a/radio/src/translations/en.h.txt b/radio/src/translations/en.h.txt index 448dcb839..68b68db1d 100644 --- a/radio/src/translations/en.h.txt +++ b/radio/src/translations/en.h.txt @@ -824,6 +824,8 @@ #define TR_SELECT_TEMPLATE "SELECT A MODEL TEMPLATE:" #define TR_NO_TEMPLATES "No model templates were found in this folder" #define TR_SAVE_TEMPLATE "Save as template" +#define TR_BLANK_MODEL "Blank Model" +#define TR_BLANK_MODEL_INFO "Create a blank model" #define TR_FILE_EXISTS "FILE ALREADY EXISTS" #define TR_ASK_OVERWRITE "Do you want to overwrite?" diff --git a/radio/src/translations/es.h.txt b/radio/src/translations/es.h.txt index f23165c55..30f04adbf 100644 --- a/radio/src/translations/es.h.txt +++ b/radio/src/translations/es.h.txt @@ -822,6 +822,8 @@ #define TR_SELECT_TEMPLATE "SELECT A MODEL TEMPLATE:" #define TR_NO_TEMPLATES "No model templates were found in this folder" #define TR_SAVE_TEMPLATE "Save as template" +#define TR_BLANK_MODEL "Blank Model" +#define TR_BLANK_MODEL_INFO "Create a blank model" #define TR_FILE_EXISTS "FILE ALREADY EXISTS" #define TR_ASK_OVERWRITE "Do you want to overwrite?" diff --git a/radio/src/translations/fi.h.txt b/radio/src/translations/fi.h.txt index d5633a666..0cd31e12b 100644 --- a/radio/src/translations/fi.h.txt +++ b/radio/src/translations/fi.h.txt @@ -836,6 +836,8 @@ #define TR_SELECT_TEMPLATE "SELECT A MODEL TEMPLATE:" #define TR_NO_TEMPLATES "No model templates were found in this folder" #define TR_SAVE_TEMPLATE "Save as template" +#define TR_BLANK_MODEL "Blank Model" +#define TR_BLANK_MODEL_INFO "Create a blank model" #define TR_FILE_EXISTS "FILE ALREADY EXISTS" #define TR_ASK_OVERWRITE "Do you want to overwrite?" diff --git a/radio/src/translations/fr.h.txt b/radio/src/translations/fr.h.txt index 851db73bd..1ba53ee0d 100644 --- a/radio/src/translations/fr.h.txt +++ b/radio/src/translations/fr.h.txt @@ -841,6 +841,8 @@ #define TR_SELECT_TEMPLATE "SELECT A MODEL TEMPLATE:" #define TR_NO_TEMPLATES "No model templates were found in this folder" #define TR_SAVE_TEMPLATE "Save as template" +#define TR_BLANK_MODEL "Blank Model" +#define TR_BLANK_MODEL_INFO "Create a blank model" #define TR_FILE_EXISTS "FILE ALREADY EXISTS" #define TR_ASK_OVERWRITE "Do you want to overwrite?" diff --git a/radio/src/translations/it.h.txt b/radio/src/translations/it.h.txt index 714c767c0..8b4ad3dc0 100644 --- a/radio/src/translations/it.h.txt +++ b/radio/src/translations/it.h.txt @@ -842,6 +842,8 @@ #define TR_SELECT_TEMPLATE "SELECT A MODEL TEMPLATE:" #define TR_NO_TEMPLATES "No model templates were found in this folder" #define TR_SAVE_TEMPLATE "Save as template" +#define TR_BLANK_MODEL "Blank Model" +#define TR_BLANK_MODEL_INFO "Create a blank model" #define TR_FILE_EXISTS "FILE ALREADY EXISTS" #define TR_ASK_OVERWRITE "Do you want to overwrite?" diff --git a/radio/src/translations/nl.h.txt b/radio/src/translations/nl.h.txt index 694a3c4d0..a5b99a728 100644 --- a/radio/src/translations/nl.h.txt +++ b/radio/src/translations/nl.h.txt @@ -828,6 +828,8 @@ #define TR_SELECT_TEMPLATE "SELECT A MODEL TEMPLATE:" #define TR_NO_TEMPLATES "No model templates were found in this folder" #define TR_SAVE_TEMPLATE "Save as template" +#define TR_BLANK_MODEL "Blank Model" +#define TR_BLANK_MODEL_INFO "Create a blank model" #define TR_FILE_EXISTS "FILE ALREADY EXISTS" #define TR_ASK_OVERWRITE "Do you want to overwrite?" diff --git a/radio/src/translations/pl.h.txt b/radio/src/translations/pl.h.txt index 9de0361bc..701000a9a 100644 --- a/radio/src/translations/pl.h.txt +++ b/radio/src/translations/pl.h.txt @@ -839,6 +839,8 @@ #define TR_SELECT_TEMPLATE "SELECT A MODEL TEMPLATE:" #define TR_NO_TEMPLATES "No model templates were found in this folder" #define TR_SAVE_TEMPLATE "Save as template" +#define TR_BLANK_MODEL "Blank Model" +#define TR_BLANK_MODEL_INFO "Create a blank model" #define TR_FILE_EXISTS "FILE ALREADY EXISTS" #define TR_ASK_OVERWRITE "Do you want to overwrite?" diff --git a/radio/src/translations/pt.h.txt b/radio/src/translations/pt.h.txt index c053a3deb..ddb13e1d3 100644 --- a/radio/src/translations/pt.h.txt +++ b/radio/src/translations/pt.h.txt @@ -847,6 +847,8 @@ #define TR_SELECT_TEMPLATE "SELECT A MODEL TEMPLATE:" #define TR_NO_TEMPLATES "No model templates were found in this folder" #define TR_SAVE_TEMPLATE "Save as template" +#define TR_BLANK_MODEL "Blank Model" +#define TR_BLANK_MODEL_INFO "Create a blank model" #define TR_FILE_EXISTS "FILE ALREADY EXISTS" #define TR_ASK_OVERWRITE "Do you want to overwrite?" diff --git a/radio/src/translations/se.h.txt b/radio/src/translations/se.h.txt index c99bdae07..22eef0f02 100644 --- a/radio/src/translations/se.h.txt +++ b/radio/src/translations/se.h.txt @@ -847,6 +847,8 @@ #define TR_SELECT_TEMPLATE "SELECT A MODEL TEMPLATE:" #define TR_NO_TEMPLATES "No model templates were found in this folder" #define TR_SAVE_TEMPLATE "Save as template" +#define TR_BLANK_MODEL "Blank Model" +#define TR_BLANK_MODEL_INFO "Create a blank model" #define TR_FILE_EXISTS "FILE ALREADY EXISTS" #define TR_ASK_OVERWRITE "Do you want to overwrite?" diff --git a/radio/src/translations/tw.h.txt b/radio/src/translations/tw.h.txt index b3733247b..3e33b315f 100644 --- a/radio/src/translations/tw.h.txt +++ b/radio/src/translations/tw.h.txt @@ -775,6 +775,8 @@ #define TR_SELECT_TEMPLATE "SELECT A MODEL TEMPLATE:" #define TR_NO_TEMPLATES "No model templates were found in this folder" #define TR_SAVE_TEMPLATE "Save as template" +#define TR_BLANK_MODEL "Blank Model" +#define TR_BLANK_MODEL_INFO "Create a blank model" #define TR_FILE_EXISTS "FILE ALREADY EXISTS" #define TR_ASK_OVERWRITE "Do you want to overwrite?"