From dcc9dcbe9951e5e84d1c1785a27debc72c0f77f6 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Tue, 1 Mar 2016 19:54:55 +0100 Subject: [PATCH] [Horus] Screens Setup bugfixes --- radio/src/gui/horus/menus.h | 12 ++++++--- radio/src/gui/horus/screens_setup.cpp | 39 ++++++++++++++------------- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/radio/src/gui/horus/menus.h b/radio/src/gui/horus/menus.h index e26f6ea6f..94555a454 100644 --- a/radio/src/gui/horus/menus.h +++ b/radio/src/gui/horus/menus.h @@ -297,6 +297,10 @@ bool check_submenu_simple(check_event_t event, uint8_t maxrow); if (!check(event, 0, NULL, 0, mstate_tab, DIM(mstate_tab)-1, lines_count)) return false; \ drawScreenTemplate(title, icon, options); +#define CUSTOM_SUBMENU_WITH_OPTIONS(title, icon, lines_count, options) \ + if (!check(event, 0, NULL, 0, mstate_tab, DIM(mstate_tab)-1, lines_count)) return false; \ + drawScreenTemplate(title, icon, options); + #define SIMPLE_SUBMENU_NOTITLE(lines_count) \ if (!check_submenu_simple(event, lines_count)) return false @@ -332,9 +336,11 @@ void editCurveRef(coord_t x, coord_t y, CurveRef & curve, evt_t event, uint8_t a extern uint8_t s_curveChan; -#define WARNING_TYPE_ASTERISK 0 -#define WARNING_TYPE_CONFIRM 1 -#define WARNING_TYPE_INPUT 2 +#define WARNING_TYPE_ALERT 0 +#define WARNING_TYPE_ASTERISK 1 +#define WARNING_TYPE_CONFIRM 2 +#define WARNING_TYPE_INPUT 3 +#define WARNING_TYPE_INFO 4 extern const pm_char * warningText; extern const pm_char * warningInfoText; diff --git a/radio/src/gui/horus/screens_setup.cpp b/radio/src/gui/horus/screens_setup.cpp index 9ba593d2a..847b28c93 100644 --- a/radio/src/gui/horus/screens_setup.cpp +++ b/radio/src/gui/horus/screens_setup.cpp @@ -152,16 +152,31 @@ void editZoneOption(coord_t y, const ZoneOption * option, ZoneOptionValue * valu } } +int getOptionsCount(const ZoneOption * options) +{ + if (options == NULL) { + return 0; + } + else { + int count = 0; + for (const ZoneOption * option = options; option->name; option++) { + count++; + } + return count; + } +} + template bool menuSettings(const char * title, const T * object, uint32_t i_flags, evt_t event) { - linesCount = 0; const ZoneOption * options = object->getOptions(); - for (const ZoneOption * option = options; option->name; option++) { - linesCount++; + linesCount = getOptionsCount(options); + uint8_t mstate_tab[MAX_WIDGET_OPTIONS]; + for (int i=0; iname; option++) { - count++; - } - return count; - } -} - enum menuScreensThemeItems { ITEM_SCREEN_SETUP_THEME, ITEM_SCREEN_SETUP_THEME_OPTION1 = ITEM_SCREEN_SETUP_THEME+2 @@ -490,7 +491,7 @@ bool menuScreenSetup(int index, evt_t event) uint8_t mstate_tab[2 + MAX_LAYOUT_OPTIONS] = { uint8_t(NAVIGATION_LINE_BY_LINE|uint8_t(countRegisteredLayouts-1)), ORPHAN_ROW }; for (int i=0; i