1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-21 15:25:17 +03:00

[Horus] UI Refactoring

This commit is contained in:
Bertrand Songis 2016-02-10 14:36:29 +01:00
parent 65fc20ddde
commit cd821116c5
31 changed files with 176 additions and 75 deletions

View file

@ -175,6 +175,7 @@ namespace NAMESPACE {
#include "radio/src/gui/horus/widget.cpp"
#include "radio/src/gui/horus/layout.cpp"
#include "radio/src/gui/horus/layouts/layout2+1.cpp"
#include "radio/src/gui/horus/layouts/layout1x1.cpp"
#include "radio/src/gui/horus/layouts/layout2x2.cpp"
#include "radio/src/gui/horus/layouts/layout2x4.cpp"
#include "radio/src/gui/horus/widgets/gauge.cpp"

View file

@ -0,0 +1,95 @@
/*
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "opentx.h"
class Layout1x1: public Layout
{
public:
Layout1x1(const LayoutFactory * factory, Layout::PersistentData * persistentData):
Layout(factory, persistentData)
{
}
virtual void create()
{
persistentData->options[0].boolValue = true;
persistentData->options[1].boolValue = true;
}
virtual unsigned int getZonesCount() const
{
return 1;
}
virtual Zone getZone(unsigned int index) const
{
Zone zone = { 10, 10, LCD_W - 2*10, LCD_H - 2*10 };
if (persistentData->options[0].boolValue) {
zone.y += MENU_HEADER_HEIGHT;
zone.h -= MENU_HEADER_HEIGHT;
}
if (persistentData->options[1].boolValue) {
zone.x += 35;
zone.w -= 2*35;
zone.h -= 35;
}
return zone;
}
virtual void refresh(bool setup=false);
static const ZoneOption options[];
};
const ZoneOption Layout1x1::options[] = {
{ "Top bar", ZoneOption::Bool },
{ "Sliders+Trims", ZoneOption::Bool },
{ NULL, ZoneOption::Bool }
};
void Layout1x1::refresh(bool setup)
{
lcdDrawBitmap(0, 0, LBM_MAINVIEW_BACKGROUND);
if (persistentData->options[0].boolValue) {
// Top Bar
drawMainViewTopBar();
}
if (persistentData->options[1].boolValue) {
// Sliders + Trims + Flight mode
lcdDrawSizedText(LCD_W / 2 - getTextWidth(g_model.flightModeData[mixerCurrentFlightMode].name, sizeof(g_model.flightModeData[mixerCurrentFlightMode].name), ZCHAR | SMLSIZE) / 2,
237,
g_model.flightModeData[mixerCurrentFlightMode].name,
sizeof(g_model.flightModeData[mixerCurrentFlightMode].name), ZCHAR | SMLSIZE);
drawMainPots();
drawTrims(mixerCurrentFlightMode);
}
Layout::refresh(setup);
}
const uint8_t LBM_LAYOUT_1x1[] __DMA = {
#include "mask_layout1x1.lbm"
};
BaseLayoutFactory<Layout1x1> layout1x1("Layout1x1", LBM_LAYOUT_1x1, Layout1x1::options);

View file

@ -31,9 +31,6 @@ class Layout2x2: public Layout
virtual void create()
{
persistentData->options[0].boolValue = true;
persistentData->options[1].boolValue = true;
persistentData->options[2].boolValue = true;
persistentData->options[3].boolValue = true;
}
virtual unsigned int getZonesCount() const

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 B

View file

@ -34,7 +34,7 @@ void lcdColorsInit()
lcdColorTable[TEXT_BGCOLOR_INDEX] = WHITE;
lcdColorTable[TEXT_INVERTED_COLOR_INDEX] = WHITE;
lcdColorTable[TEXT_INVERTED_BGCOLOR_INDEX] = RED;
lcdColorTable[LINE_COLOR_INDEX] = RGB(88, 88, 90);
lcdColorTable[LINE_COLOR_INDEX] = GREY;
lcdColorTable[SCROLLBOX_COLOR_INDEX] = RED;
lcdColorTable[MENU_TITLE_BGCOLOR_INDEX] = DARKGREY;
lcdColorTable[MENU_TITLE_COLOR_INDEX] = WHITE;
@ -42,8 +42,8 @@ void lcdColorsInit()
lcdColorTable[HEADER_COLOR_INDEX] = DARKGREY;
lcdColorTable[ALARM_COLOR_INDEX] = RED;
lcdColorTable[WARNING_COLOR_INDEX] = YELLOW;
lcdColorTable[TEXT_DISABLE_COLOR_INDEX] = RGB(0x60, 0x60, 0x60);
lcdColorTable[CURVE_AXIS_COLOR_INDEX] = RGB(180, 180, 180);
lcdColorTable[TEXT_DISABLE_COLOR_INDEX] = GREY;
lcdColorTable[CURVE_AXIS_COLOR_INDEX] = LIGHTGREY;
lcdColorTable[CURVE_COLOR_INDEX] = RED;
lcdColorTable[CURVE_CURSOR_COLOR_INDEX] = RED;
lcdColorTable[TITLE_BGCOLOR_INDEX] = RED;

View file

@ -83,7 +83,9 @@
#define BLACK RGB(0, 0, 0)
#define YELLOW RGB(0xF0, 0xD0, 0x10)
#define BLUE RGB(0x30, 0xA0, 0xE0)
#define DARKGREY RGB(0x40, 0x40, 0x40)
#define GREY RGB(96, 96, 96)
#define DARKGREY RGB(64, 64, 64)
#define LIGHTGREY RGB(180, 180, 180)
#define RED RGB(229, 32, 30)
#define DARKRED RGB(160, 0, 6)

View file

@ -22,6 +22,6 @@
bool menuGeneralCustomFunctions(evt_t event)
{
MENU(STR_MENUGLOBALFUNCS, menuTabGeneral, e_GeneralCustomFunctions, NUM_CFN, DEFAULT_SCROLLBAR_X, { NAVIGATION_LINE_BY_LINE|4/*repeated*/ });
MENU(STR_MENUGLOBALFUNCS, LBM_RADIO_ICONS, menuTabGeneral, e_GeneralCustomFunctions, NUM_CFN, { NAVIGATION_LINE_BY_LINE|4/*repeated*/ });
return menuCustomFunctions(event, g_eeGeneral.customFn, globalFunctionsContext);
}

View file

@ -57,7 +57,7 @@ enum menuGeneralHwItems {
bool menuGeneralHardware(evt_t event)
{
MENU(STR_HARDWARE, menuTabGeneral, e_Hardware, ITEM_SETUP_HW_MAX, DEFAULT_SCROLLBAR_X, { 0, LABEL(Sticks), 0, 0, 0, 0, LABEL(Pots), POTS_ROWS, LABEL(Switches), SWITCHES_ROWS, BLUETOOTH_ROWS 0 });
MENU(STR_HARDWARE, LBM_RADIO_ICONS, menuTabGeneral, e_Hardware, ITEM_SETUP_HW_MAX, { 0, LABEL(Sticks), 0, 0, 0, 0, LABEL(Pots), POTS_ROWS, LABEL(Switches), SWITCHES_ROWS, BLUETOOTH_ROWS 0 });
uint8_t sub = menuVerticalPosition;

View file

@ -169,7 +169,7 @@ bool menuGeneralSdManager(evt_t _event)
}
evt_t event = (EVT_KEY_MASK(_event) == KEY_ENTER ? 0 : _event);
SIMPLE_MENU(SD_IS_HC() ? STR_SDHC_CARD : STR_SD_CARD, menuTabGeneral, e_Sd, reusableBuffer.sdmanager.count, DEFAULT_SCROLLBAR_X);
SIMPLE_MENU(SD_IS_HC() ? STR_SDHC_CARD : STR_SD_CARD, LBM_RADIO_ICONS, menuTabGeneral, e_Sd, reusableBuffer.sdmanager.count);
int index = menuVerticalPosition-menuVerticalOffset;

View file

@ -112,7 +112,7 @@ bool menuGeneralSetup(evt_t event)
}
#endif
MENU(STR_MENURADIOSETUP, menuTabGeneral, e_Setup, ITEM_SETUP_MAX, DEFAULT_SCROLLBAR_X, {
MENU(STR_MENURADIOSETUP, LBM_RADIO_ICONS, menuTabGeneral, e_Setup, ITEM_SETUP_MAX, {
2|NAVIGATION_LINE_BY_LINE, 2|NAVIGATION_LINE_BY_LINE, 1|NAVIGATION_LINE_BY_LINE,
LABEL(SOUND), 0, 0, 0, 0, 0, 0, 0,
CASE_VARIO(LABEL(VARIO)) CASE_VARIO(0) CASE_VARIO(0) CASE_VARIO(0) CASE_VARIO(0)

View file

@ -25,14 +25,12 @@
#define TRAINER_COLUMN_2 TRAINER_COLUMN_1+TRAINER_COLUMN_WIDTH
#define TRAINER_COLUMN_3 TRAINER_COLUMN_2+TRAINER_COLUMN_WIDTH
#define TRAINER_CALIB_POS 12
bool menuGeneralTrainer(evt_t event)
{
uint8_t y;
bool slave = SLAVE_MODE();
MENU(STR_MENUTRAINER, menuTabGeneral, e_Trainer, (slave ? 0 : 6), DEFAULT_SCROLLBAR_X, { 2, 2, 2, 2, 0/*, 0*/ });
MENU(STR_MENUTRAINER, LBM_RADIO_ICONS, menuTabGeneral, e_Trainer, (slave ? 0 : 6), { 2, 2, 2, 2, 0/*, 0*/ });
if (slave) {
lcd_putsCenter(5*FH, STR_SLAVE, TEXT_COLOR);

View file

@ -22,7 +22,7 @@
bool menuGeneralVersion(evt_t event)
{
SIMPLE_MENU(STR_MENUVERSION, menuTabGeneral, e_Vers, 1, DEFAULT_SCROLLBAR_X);
SIMPLE_MENU(STR_MENUVERSION, LBM_RADIO_ICONS, menuTabGeneral, e_Vers, 1);
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + FH, vers_stamp);
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 2*FH, date_stamp);

View file

@ -333,7 +333,7 @@ void editCurveRef(coord_t x, coord_t y, CurveRef & curve, evt_t event, uint8_t a
bool menuModelCurvesAll(evt_t event)
{
SIMPLE_MENU(STR_MENUCURVES, menuTabModel, e_CurvesAll, MAX_CURVES, DEFAULT_SCROLLBAR_X);
SIMPLE_MENU(STR_MENUCURVES, LBM_MODEL_ICONS, menuTabModel, e_CurvesAll, MAX_CURVES);
int8_t sub = menuVerticalPosition;

View file

@ -352,6 +352,6 @@ bool menuCustomFunctions(evt_t event, CustomFunctionData * functions, CustomFunc
bool menuModelCustomFunctions(evt_t event)
{
MENU(STR_MENUCUSTOMFUNC, menuTabModel, e_CustomFunctions, NUM_CFN, DEFAULT_SCROLLBAR_X, { NAVIGATION_LINE_BY_LINE|4/*repeated*/ });
MENU(STR_MENUCUSTOMFUNC, LBM_MODEL_ICONS, menuTabModel, e_CustomFunctions, NUM_CFN, { NAVIGATION_LINE_BY_LINE|4/*repeated*/ });
return menuCustomFunctions(event, g_model.customFn, modelFunctionsContext);
}

View file

@ -126,7 +126,7 @@ bool menuModelCustomScripts(evt_t event)
// lcdDrawNumber(19*FW, 0, luaGetMemUsed(), 0);
// lcdDrawText(19*FW+1, 0, STR_BYTES);
MENU(STR_MENUCUSTOMSCRIPTS, menuTabModel, e_CustomScripts, MAX_SCRIPTS, DEFAULT_SCROLLBAR_X, { NAVIGATION_LINE_BY_LINE|3/*repeated*/ });
MENU(STR_MENUCUSTOMSCRIPTS, LBM_MODEL_ICONS, menuTabModel, e_CustomScripts, MAX_SCRIPTS, { NAVIGATION_LINE_BY_LINE|3/*repeated*/ });
int8_t sub = menuVerticalPosition;

View file

@ -78,7 +78,7 @@ bool isTrimModeAvailable(int mode)
bool menuModelFlightModesAll(evt_t event)
{
MENU(STR_MENUFLIGHTPHASES, menuTabModel, e_FlightModesAll, MAX_FLIGHT_MODES+1, DEFAULT_SCROLLBAR_X, { NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, 0});
MENU(STR_MENUFLIGHTPHASES, LBM_MODEL_ICONS, menuTabModel, e_FlightModesAll, MAX_FLIGHT_MODES+1, { NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, 0});
int sub = menuVerticalPosition;

View file

@ -44,7 +44,7 @@ void onGVARSMenu(const char *result)
bool menuModelGVars(evt_t event)
{
MENU(STR_MENUGLOBALVARS, menuTabModel, e_GVars/* TODO, first2seconds ? CHECK_FLAG_NO_SCREEN_INDEX : 0*/, MAX_GVARS, DEFAULT_SCROLLBAR_X, { NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES});
MENU(STR_MENUGLOBALVARS, LBM_MODEL_ICONS, menuTabModel, e_GVars/* TODO, first2seconds ? CHECK_FLAG_NO_SCREEN_INDEX : 0*/, MAX_GVARS, { NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES, NAVIGATION_LINE_BY_LINE|MAX_FLIGHT_MODES});
int sub = menuVerticalPosition;

View file

@ -36,7 +36,7 @@ enum menuModelHeliItems {
bool menuModelHeli(evt_t event)
{
SIMPLE_MENU(STR_MENUHELISETUP, menuTabModel, e_Heli, ITEM_HELI_MAX, DEFAULT_SCROLLBAR_X);
SIMPLE_MENU(STR_MENUHELISETUP, LBM_MODEL_ICONS, menuTabModel, e_Heli, ITEM_HELI_MAX);
int sub = menuVerticalPosition;

View file

@ -370,7 +370,7 @@ bool menuModelExposAll(evt_t event)
uint8_t chn = expoAddress(s_currIdx)->chn + 1;
int linesCount = getExposLinesCount();
SIMPLE_MENU(STR_MENUINPUTS, menuTabModel, e_InputsAll, linesCount, DEFAULT_SCROLLBAR_X);
SIMPLE_MENU(STR_MENUINPUTS, LBM_MODEL_ICONS, menuTabModel, e_InputsAll, linesCount);
switch (event) {
case EVT_ENTRY:

View file

@ -93,7 +93,7 @@ void onLimitsMenu(const char *result)
bool menuModelLimits(evt_t event)
{
MENU(STR_MENULIMITS, menuTabModel, e_Limits, NUM_CHNOUT+1, DEFAULT_SCROLLBAR_X,
MENU(STR_MENULIMITS, LBM_MODEL_ICONS, menuTabModel, e_Limits, NUM_CHNOUT+1,
{ NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW,
NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW,
NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW,

View file

@ -80,7 +80,7 @@ bool menuModelLogicalSwitches(evt_t event)
{
INCDEC_DECLARE_VARS(EE_MODEL);
MENU(STR_MENULOGICALSWITCHES, menuTabModel, e_LogicalSwitches, NUM_LOGICAL_SWITCH, DEFAULT_SCROLLBAR_X, { NAVIGATION_LINE_BY_LINE|LS_FIELD_LAST/*repeated...*/} );
MENU(STR_MENULOGICALSWITCHES, LBM_MODEL_ICONS, menuTabModel, e_LogicalSwitches, NUM_LOGICAL_SWITCH, { NAVIGATION_LINE_BY_LINE|LS_FIELD_LAST/*repeated...*/} );
int k = 0;
int sub = menuVerticalPosition;

View file

@ -341,7 +341,7 @@ bool menuModelMixAll(evt_t event)
uint8_t chn = mixAddress(s_currIdx)->destCh + 1;
int linesCount = getMixesLinesCount();
SIMPLE_MENU(STR_MIXER, menuTabModel, e_MixAll, linesCount, DEFAULT_SCROLLBAR_X);
SIMPLE_MENU(STR_MIXER, LBM_MODEL_ICONS, menuTabModel, e_MixAll, linesCount);
switch (event) {
case EVT_ENTRY:

View file

@ -181,7 +181,7 @@ bool menuModelSetup(evt_t event)
horzpos_t l_posHorz = menuHorizontalPosition;
bool CURSOR_ON_CELL = (menuHorizontalPosition >= 0);
MENU(STR_MENUSETUP, menuTabModel, e_ModelSetup, ITEM_MODEL_SETUP_MAX, DEFAULT_SCROLLBAR_X,
MENU(STR_MENUSETUP, LBM_MODEL_ICONS, menuTabModel, e_ModelSetup, ITEM_MODEL_SETUP_MAX,
{ 0, 0, TIMERS_ROWS, 0, 1, 0, 0,
LABEL(Throttle), 0, 0, 0,
LABEL(PreflightCheck), 0, 0, SW_WARN_ITEMS(), POT_WARN_ITEMS(), NAVIGATION_LINE_BY_LINE|(NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1), 0,

View file

@ -407,7 +407,7 @@ bool menuModelTelemetry(evt_t event)
}
}
MENU(STR_MENUTELEMETRY, menuTabModel, e_Telemetry, ITEM_TELEMETRY_MAX, DEFAULT_SCROLLBAR_X, { TELEMETRY_TYPE_ROWS RSSI_ROWS SENSORS_ROWS VARIO_ROWS });
MENU(STR_MENUTELEMETRY, LBM_MODEL_ICONS, menuTabModel, e_Telemetry, ITEM_TELEMETRY_MAX, { TELEMETRY_TYPE_ROWS RSSI_ROWS SENSORS_ROWS VARIO_ROWS });
for (int i=0; i<NUM_BODY_LINES; i++) {
coord_t y = MENU_CONTENT_TOP + i*FH;

View file

@ -187,6 +187,8 @@ extern int8_t s_editMode; // global editmode
#define TITLE_ROW ((uint8_t)-1)
#define ORPHAN_ROW ((uint8_t)-2)
#define HIDDEN_ROW ((uint8_t)-3)
#define NAVIGATION_LINE_BY_LINE 0x40
#define CURSOR_ON_LINE() (menuHorizontalPosition<0)
struct CheckIncDecStops {
const int count;
@ -251,9 +253,6 @@ swsrc_t checkIncDecMovedSwitch(swsrc_t val);
#define CHECK_INCDEC_GENVAR(event, var, min, max) \
var = checkIncDecGen(event, var, min, max)
#define NAVIGATION_LINE_BY_LINE 0x40
#define CURSOR_ON_LINE() (menuHorizontalPosition<0)
#define INCDEC_DECLARE_VARS(f) uint8_t incdecFlag = (f); IsValueAvailable isValueAvailable = NULL
#define INCDEC_SET_FLAG(f) incdecFlag = (f)
#define INCDEC_ENABLE_CHECK(fn) isValueAvailable = fn
@ -267,16 +266,16 @@ bool check_submenu_simple(check_event_t event, uint8_t maxrow);
#define MENU_TAB(...) const uint8_t mstate_tab[] = __VA_ARGS__
#define MENU(title, tab, menu, lines_count, scrollbar_X, ...) \
#define MENU(title, icons, tab, menu, lines_count, ...) \
MENU_TAB(__VA_ARGS__); \
if (event == EVT_ENTRY || event == EVT_ENTRY_UP) TRACE("Menu %s displayed ...", title); \
if (!check(event, menu, tab, DIM(tab), mstate_tab, DIM(mstate_tab)-1, lines_count)) return false; \
drawMenuTemplate(title, scrollbar_X); \
drawMenuTemplate(title, icons); \
#define SIMPLE_MENU(title, tab, menu, lines_count, scrollbar_X) \
#define SIMPLE_MENU(title, icons, tab, menu, lines_count) \
if (event == EVT_ENTRY || event == EVT_ENTRY_UP) TRACE("Menu %s displayed ...", title); \
if (!check_simple(event, menu, tab, DIM(tab), lines_count)) return false; \
drawMenuTemplate(title, scrollbar_X); \
drawMenuTemplate(title, icons); \
#define SUBMENU(title, icon, lines_count, ...) \
MENU_TAB(__VA_ARGS__); \

View file

@ -163,7 +163,6 @@ bool menuSetupWidgets(evt_t event)
bool menuSetupScreensView(evt_t event)
{
static uint8_t menuHorizontalOffset;
static uint8_t lastPositionVertical;
currentScreen = customScreens[0];
@ -175,13 +174,15 @@ bool menuSetupScreensView(evt_t event)
}
}
bool needsOffsetCheck = (menuVerticalPosition != 0 || menuHorizontalPosition < 0);
linesCount = 3;
const ZoneOption * options = currentScreen->getFactory()->getOptions();
for (const ZoneOption * option = options; option->name; option++) {
linesCount++;
}
SUBMENU_WITH_OPTIONS("Main views setup", LBM_MAINVIEWS_ICON, linesCount, OPTION_MENU_TITLE_BAR, { uint8_t(countRegisteredLayouts-1), ORPHAN_ROW, 0, 0, 0, 0 });
SUBMENU_WITH_OPTIONS("Main views setup", LBM_MAINVIEWS_ICON, linesCount, OPTION_MENU_TITLE_BAR, { NAVIGATION_LINE_BY_LINE|uint8_t(countRegisteredLayouts-1), ORPHAN_ROW, 0, 0, 0, 0 });
for (int i=0; i<NUM_BODY_LINES; i++) {
coord_t y = MENU_CONTENT_TOP + i * FH;
@ -191,9 +192,20 @@ bool menuSetupScreensView(evt_t event)
switch(k) {
case 0: {
lcdDrawText(MENUS_MARGIN_LEFT, y + FH / 2, "Layout");
if (needsOffsetCheck) {
if (layoutIndex < menuHorizontalOffset) {
menuHorizontalOffset = layoutIndex;
}
else if (layoutIndex > menuHorizontalOffset + 3) {
menuHorizontalOffset = layoutIndex - 3;
}
}
if (attr) {
if (lastPositionVertical != menuVerticalPosition) {
menuHorizontalOffset = max<int>(0, min<int>(layoutIndex - 1, countRegisteredLayouts - 4));
if (menuHorizontalPosition < 0) {
lcdDrawSolidFilledRect(SCREENS_SETUP_2ND_COLUMN-3, y-2, 4*56+1, 2*FH-5, TEXT_INVERTED_BGCOLOR);
}
else {
if (needsOffsetCheck) {
menuHorizontalPosition = layoutIndex;
}
else if (menuHorizontalPosition < menuHorizontalOffset) {
@ -203,22 +215,21 @@ bool menuSetupScreensView(evt_t event)
menuHorizontalOffset = menuHorizontalPosition - 3;
}
}
lastPositionVertical = menuVerticalPosition;
}
int lastDisplayedLayout = min<int>(menuHorizontalOffset + 4, countRegisteredLayouts);
for (int i=menuHorizontalOffset, x=SCREENS_SETUP_2ND_COLUMN; i<lastDisplayedLayout; i++, x += 56) {
const LayoutFactory * factory = registeredLayouts[i];
factory->drawThumb(x, y, currentScreen->getFactory() == factory ? TEXT_INVERTED_BGCOLOR : LINE_COLOR);
factory->drawThumb(x, y, currentScreen->getFactory() == factory ? (menuHorizontalPosition < 0 ? TEXT_INVERTED_COLOR : TEXT_INVERTED_BGCOLOR) : LINE_COLOR);
}
if (menuHorizontalOffset > 0)
lcdDrawBitmapPattern(SCREENS_SETUP_2ND_COLUMN - 12, y, LBM_CARROUSSEL_LEFT, LINE_COLOR);
if (lastDisplayedLayout < countRegisteredLayouts)
lcdDrawBitmapPattern(SCREENS_SETUP_2ND_COLUMN + 4 * 56, y, LBM_CARROUSSEL_RIGHT, LINE_COLOR);
if (attr) {
lcdDrawBitmapPattern(SCREENS_SETUP_2ND_COLUMN - 12, y, LBM_CARROUSSEL_LEFT, menuHorizontalOffset > 0 ? LINE_COLOR : CURVE_AXIS_COLOR);
lcdDrawBitmapPattern(SCREENS_SETUP_2ND_COLUMN + 4 * 56, y, LBM_CARROUSSEL_RIGHT, lastDisplayedLayout < countRegisteredLayouts ? LINE_COLOR : CURVE_AXIS_COLOR);
if (attr && menuHorizontalPosition >= 0) {
lcdDrawSolidRect(SCREENS_SETUP_2ND_COLUMN + (menuHorizontalPosition - menuHorizontalOffset) * 56 - 3, y - 2, 57, 35, TEXT_INVERTED_BGCOLOR);
if (menuHorizontalPosition != layoutIndex && event == EVT_KEY_BREAK(KEY_ENTER)) {
s_editMode = 0;
customScreens[0] = registeredLayouts[menuHorizontalPosition]->create(&g_model.screenData[0].layoutData);
strncpy(g_model.screenData[0].layoutName, customScreens[0]->getFactory()->getName(), sizeof(g_model.screenData[0].layoutName));
storageDirty(EE_MODEL);
return false;
}
}

View file

@ -62,7 +62,7 @@ bool menuAboutView(evt_t event)
break;
}
drawMenuTemplate("About");
drawScreenTemplate("About", LBM_TOPMENU_OPENTX);
uint8_t screenDuration = 150;

View file

@ -91,7 +91,7 @@ bool menuTextView(evt_t event)
{
static int lines_count;
drawMenuTemplate("TEXT VIEWER");
drawScreenTemplate("TEXT VIEWER", LBM_TOPMENU_OPENTX);
switch (event) {
case EVT_ENTRY:

View file

@ -191,10 +191,8 @@ void drawScreenTemplate(const char * title, const uint8_t * icon, uint32_t optio
}
}
void drawMenuTemplate(const char * title, uint16_t scrollbar_X, uint32_t options)
void drawMenuTemplate(const char * title, const uint8_t * const * icons, uint32_t options)
{
const uint8_t * const * icons = (menuVerticalPositions[0] == 0 ? LBM_MODEL_ICONS : LBM_RADIO_ICONS);
drawScreenTemplate(title, icons[0], OPTION_MENU_TITLE_BAR);
if (menuVerticalPosition < 0) {

View file

@ -72,7 +72,7 @@ int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int
// Screen templates
void drawScreenTemplate(const char * title, const uint8_t * icon, uint32_t options=0);
void drawMenuTemplate(const char * title, uint16_t scrollbar_X=0, uint32_t options=0);
void drawMenuTemplate(const char * title, const uint8_t * const * icons, uint32_t options=0);
void drawSplash();
void drawSleepBitmap();
void drawShutdownBitmap(uint32_t index);

View file

@ -41,7 +41,7 @@ void ModelPanelWidget::refresh()
int scale = getBitmapScale(modelBitmap, zone.w, zone.h);
int width = getBitmapScaledSize(getBitmapWidth(modelBitmap), scale);
int height = getBitmapScaledSize(getBitmapHeight(modelBitmap), scale);
lcdDrawBitmap(zone.x + (zone.w - width) / 2, zone.y + zone.h - MODEL_BITMAP_HEIGHT / 2 - height / 2, modelBitmap, 0, 0, scale);
lcdDrawBitmap(zone.x + (zone.w - width) / 2, zone.y + zone.h - height / 2 - height / 2, modelBitmap, 0, 0, scale);
}
else {
int scale = getBitmapScale(modelBitmap, zone.w, zone.h);