mirror of
https://github.com/opentx/opentx.git
synced 2025-07-20 06:45:10 +03:00
Code simplification
This commit is contained in:
parent
8f5b844e23
commit
8c0f69746f
4 changed files with 13 additions and 35 deletions
|
@ -217,46 +217,31 @@ bool isInputSourceAvailable(int source);
|
||||||
|
|
||||||
#define CHECK_FLAG_NO_SCREEN_INDEX 1
|
#define CHECK_FLAG_NO_SCREEN_INDEX 1
|
||||||
bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTabSize, const pm_uint8_t *horTab, uint8_t horTabMax, vertpos_t maxrow, uint16_t scrollbar_X, uint8_t flags=0);
|
bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTabSize, const pm_uint8_t *horTab, uint8_t horTabMax, vertpos_t maxrow, uint16_t scrollbar_X, uint8_t flags=0);
|
||||||
void check_simple(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTabSize, vertpos_t maxrow, uint16_t scrollbar_X);
|
bool check_simple(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTabSize, vertpos_t maxrow, uint16_t scrollbar_X);
|
||||||
void check_submenu_simple(check_event_t event, uint8_t maxrow, uint16_t scrollbar_X);
|
bool check_submenu_simple(check_event_t event, uint8_t maxrow, uint16_t scrollbar_X);
|
||||||
void title(const pm_char * s);
|
|
||||||
#define TITLE(str) title(str)
|
|
||||||
|
|
||||||
#define MENU_TAB(...) const uint8_t mstate_tab[] = __VA_ARGS__
|
#define MENU_TAB(...) const uint8_t mstate_tab[] = __VA_ARGS__
|
||||||
|
|
||||||
#define MENU_CHECK(tab, menu, lines_count, scrollbar_X) \
|
|
||||||
check(event, menu, tab, DIM(tab), mstate_tab, DIM(mstate_tab)-1, lines_count, scrollbar_X)
|
|
||||||
|
|
||||||
#define MENU_CHECK_FLAGS(tab, menu, flags, lines_count, scrollbar_X) \
|
|
||||||
check(event, menu, tab, DIM(tab), mstate_tab, DIM(mstate_tab)-1, lines_count, scrollbar_X, flags)
|
|
||||||
|
|
||||||
void drawMenuTemplate(const char *title, evt_t event, int pageIndex=0, int pageCount=0);
|
void drawMenuTemplate(const char *title, evt_t event, int pageIndex=0, int pageCount=0);
|
||||||
|
|
||||||
#define MENU(title, tab, menu, lines_count, scrollbar_X, ...) \
|
#define MENU(title, tab, menu, lines_count, scrollbar_X, ...) \
|
||||||
|
MENU_TAB(__VA_ARGS__); \
|
||||||
if (event == EVT_ENTRY || event == EVT_ENTRY_UP) TRACE("Menu %s displayed ...", title); \
|
if (event == EVT_ENTRY || event == EVT_ENTRY_UP) TRACE("Menu %s displayed ...", title); \
|
||||||
MENU_TAB(__VA_ARGS__); \
|
if (!check(event, menu, tab, DIM(tab), mstate_tab, DIM(mstate_tab)-1, lines_count, scrollbar_X)) return; \
|
||||||
if (!MENU_CHECK(tab, menu, lines_count, scrollbar_X)) return; \
|
|
||||||
drawMenuTemplate(title, event, menu, DIM(tab)); \
|
drawMenuTemplate(title, event, menu, DIM(tab)); \
|
||||||
|
|
||||||
#define MENU_FLAGS(title, tab, menu, flags, lines_count, scrollbar_X, ...) \
|
|
||||||
MENU_TAB(__VA_ARGS__); \
|
|
||||||
MENU_CHECK_FLAGS(tab, menu, flags, lines_count, scrollbar_X); \
|
|
||||||
TITLE(title)
|
|
||||||
|
|
||||||
#define SIMPLE_MENU_NOTITLE(tab, menu, lines_count, scrollbar_X) \
|
|
||||||
check_simple(event, menu, tab, DIM(tab), lines_count, scrollbar_X);
|
|
||||||
|
|
||||||
#define SIMPLE_MENU(title, tab, menu, lines_count, scrollbar_X) \
|
#define SIMPLE_MENU(title, tab, menu, lines_count, scrollbar_X) \
|
||||||
|
if (event == EVT_ENTRY || event == EVT_ENTRY_UP) TRACE("Menu %s displayed ...", title); \
|
||||||
|
if (!check_simple(event, menu, tab, DIM(tab), lines_count, scrollbar_X)) return; \
|
||||||
drawMenuTemplate(title, event, menu, DIM(tab)); \
|
drawMenuTemplate(title, event, menu, DIM(tab)); \
|
||||||
SIMPLE_MENU_NOTITLE(tab, menu, lines_count, scrollbar_X)
|
|
||||||
|
|
||||||
#define SUBMENU(title, lines_count, scrollbar_X, ...) \
|
#define SUBMENU(title, lines_count, scrollbar_X, ...) \
|
||||||
MENU_TAB(__VA_ARGS__); \
|
MENU_TAB(__VA_ARGS__); \
|
||||||
drawMenuTemplate(title, event); \
|
if (!check(event, 0, NULL, 0, mstate_tab, DIM(mstate_tab)-1, lines_count, scrollbar_X)) return; \
|
||||||
check(event, 0, NULL, 0, mstate_tab, DIM(mstate_tab)-1, lines_count, scrollbar_X)
|
drawMenuTemplate(title, event);
|
||||||
|
|
||||||
#define SIMPLE_SUBMENU_NOTITLE(lines_count, scrollbar_X) \
|
#define SIMPLE_SUBMENU_NOTITLE(lines_count, scrollbar_X) \
|
||||||
check_submenu_simple(event, lines_count, scrollbar_X);
|
if (!check_submenu_simple(event, lines_count, scrollbar_X)) return
|
||||||
|
|
||||||
#define SIMPLE_SUBMENU(title, lines_count, scrollbar_X) \
|
#define SIMPLE_SUBMENU(title, lines_count, scrollbar_X) \
|
||||||
SIMPLE_SUBMENU_NOTITLE(lines_count, scrollbar_X); \
|
SIMPLE_SUBMENU_NOTITLE(lines_count, scrollbar_X); \
|
||||||
|
|
|
@ -448,14 +448,14 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void check_simple(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTabSize, vertpos_t rowcount, uint16_t scrollbar_X)
|
bool check_simple(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTabSize, vertpos_t rowcount, uint16_t scrollbar_X)
|
||||||
{
|
{
|
||||||
check(event, curr, menuTab, menuTabSize, 0, 0, rowcount, scrollbar_X);
|
return check(event, curr, menuTab, menuTabSize, 0, 0, rowcount, scrollbar_X);
|
||||||
}
|
}
|
||||||
|
|
||||||
void check_submenu_simple(check_event_t event, uint8_t rowcount, uint16_t scrollbar_X)
|
bool check_submenu_simple(check_event_t event, uint8_t rowcount, uint16_t scrollbar_X)
|
||||||
{
|
{
|
||||||
check_simple(event, 0, 0, 0, rowcount, scrollbar_X);
|
return check_simple(event, 0, 0, 0, rowcount, scrollbar_X);
|
||||||
}
|
}
|
||||||
|
|
||||||
void repeatLastCursorMove(evt_t event)
|
void repeatLastCursorMove(evt_t event)
|
||||||
|
|
|
@ -249,9 +249,6 @@ void title(const pm_char * s);
|
||||||
MENU_TAB(__VA_ARGS__); \
|
MENU_TAB(__VA_ARGS__); \
|
||||||
MENU_CHECK_FLAGS(title, tab, menu, flags, lines_count)
|
MENU_CHECK_FLAGS(title, tab, menu, flags, lines_count)
|
||||||
|
|
||||||
#define SIMPLE_MENU_NOTITLE(tab, menu, lines_count) \
|
|
||||||
check_simple(NULL, event, menu, tab, DIM(tab), lines_count);
|
|
||||||
|
|
||||||
#define SIMPLE_MENU(title, tab, menu, lines_count) \
|
#define SIMPLE_MENU(title, tab, menu, lines_count) \
|
||||||
check_simple(title, event, menu, tab, DIM(tab), lines_count)
|
check_simple(title, event, menu, tab, DIM(tab), lines_count)
|
||||||
|
|
||||||
|
|
|
@ -600,10 +600,6 @@ void check(const char *name, check_event_t event, uint8_t curr, const MenuFuncP
|
||||||
displayScrollbar(scrollbar_X, MENU_HEADER_HEIGHT, LCD_H-MENU_HEADER_HEIGHT, s_pgOfs, linesCount, NUM_BODY_LINES);
|
displayScrollbar(scrollbar_X, MENU_HEADER_HEIGHT, LCD_H-MENU_HEADER_HEIGHT, s_pgOfs, linesCount, NUM_BODY_LINES);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name) {
|
|
||||||
title(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_posVert = l_posVert;
|
m_posVert = l_posVert;
|
||||||
m_posHorz = l_posHorz;
|
m_posHorz = l_posHorz;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue