Merge branch 'kilrah/navigation' into next

This commit is contained in:
Andre Bernet
2016-04-02 12:50:16 +04:00
8 changed files with 44 additions and 31 deletions
+11 -2
View File
@@ -110,11 +110,20 @@ bool menuCommonCalib(evt_t event)
switch (event) { switch (event) {
case EVT_ENTRY: case EVT_ENTRY:
case EVT_KEY_BREAK(KEY_EXIT):
calibrationState = CALIB_START; calibrationState = CALIB_START;
break; break;
case EVT_KEY_FIRST(KEY_EXIT):
if (calibrationState == CALIB_START) {
killEvents(KEY_EXIT);
popMenu();
}
else {
calibrationState = CALIB_START;
}
break;
case EVT_KEY_BREAK(KEY_ENTER): case EVT_KEY_FIRST(KEY_ENTER):
calibrationState++; calibrationState++;
break; break;
} }
@@ -231,8 +231,9 @@ bool menuCustomFunctions(evt_t event, CustomFunctionData * functions, CustomFunc
lcdDrawSizedText(x, y, cfn->play.name, sizeof(cfn->play.name), attr); lcdDrawSizedText(x, y, cfn->play.name, sizeof(cfn->play.name), attr);
else else
lcdDrawTextAtIndex(x, y, STR_VCSWFUNC, 0, attr); lcdDrawTextAtIndex(x, y, STR_VCSWFUNC, 0, attr);
if (active && event==EVT_KEY_BREAK(KEY_ENTER)) { if (attr) s_editMode = 0;
s_editMode = 0; if (attr && event==EVT_KEY_FIRST(KEY_ENTER)) {
killEvents(KEY_ENTER);
char directory[256]; char directory[256];
if (func==FUNC_PLAY_SCRIPT) { if (func==FUNC_PLAY_SCRIPT) {
strcpy(directory, SCRIPTS_FUNCS_PATH); strcpy(directory, SCRIPTS_FUNCS_PATH);
@@ -68,8 +68,9 @@ bool menuModelCustomScriptOne(evt_t event)
lcdDrawSizedText(SCRIPT_ONE_2ND_COLUMN_POS, y, sd.file, sizeof(sd.file), attr); lcdDrawSizedText(SCRIPT_ONE_2ND_COLUMN_POS, y, sd.file, sizeof(sd.file), attr);
else else
lcdDrawTextAtIndex(SCRIPT_ONE_2ND_COLUMN_POS, y, STR_VCSWFUNC, 0, attr); lcdDrawTextAtIndex(SCRIPT_ONE_2ND_COLUMN_POS, y, STR_VCSWFUNC, 0, attr);
if (attr && event==EVT_KEY_BREAK(KEY_ENTER) && !READ_ONLY()) { if (attr) s_editMode = 0;
s_editMode = 0; if (attr && event==EVT_KEY_FIRST(KEY_ENTER) && !READ_ONLY()) {
killEvents(KEY_ENTER);
if (sdListFiles(SCRIPTS_MIXES_PATH, SCRIPTS_EXT, sizeof(sd.file), sd.file, LIST_NONE_SD_FILE)) { if (sdListFiles(SCRIPTS_MIXES_PATH, SCRIPTS_EXT, sizeof(sd.file), sd.file, LIST_NONE_SD_FILE)) {
popupMenuHandler = onModelCustomScriptMenu; popupMenuHandler = onModelCustomScriptMenu;
} }
+1 -1
View File
@@ -505,7 +505,7 @@ bool menuModelTelemetry(evt_t event)
case ITEM_TELEMETRY_IGNORE_SENSOR_INSTANCE: case ITEM_TELEMETRY_IGNORE_SENSOR_INSTANCE:
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_IGNORE_INSTANCE); lcdDrawText(MENUS_MARGIN_LEFT, y, STR_IGNORE_INSTANCE);
editCheckBox(g_model.ignoreSensorIds, TELEM_COL2, y, attr, event); g_model.ignoreSensorIds = editCheckBox(g_model.ignoreSensorIds, TELEM_COL2, y, attr, event);
break; break;
case ITEM_TELEMETRY_RSSI_LABEL: case ITEM_TELEMETRY_RSSI_LABEL:
+3 -8
View File
@@ -412,13 +412,13 @@ bool check(check_event_t event, uint8_t curr, const MenuHandlerFunc * menuTab, u
if (menuTab && !calibrationState) { if (menuTab && !calibrationState) {
int cc = curr; int cc = curr;
switch (event) { switch (event) {
case EVT_KEY_BREAK(KEY_PGDN): case EVT_KEY_FIRST(KEY_PGDN):
if (++cc == menuTabSize) if (++cc == menuTabSize)
cc = 0; cc = 0;
break; break;
case EVT_KEY_BREAK(KEY_PGUP): case EVT_KEY_FIRST(KEY_PGUP):
if (cc-- == 0) if (cc-- == 0)
cc = menuTabSize-1; cc = menuTabSize-1;
break; break;
@@ -455,12 +455,7 @@ bool check(check_event_t event, uint8_t curr, const MenuHandlerFunc * menuTab, u
} }
break; break;
case EVT_KEY_LONG(KEY_EXIT): case EVT_KEY_FIRST(KEY_EXIT):
s_editMode = 0; // TODO needed? we call ENTRY_UP after which does the same
popMenu();
break;
case EVT_KEY_BREAK(KEY_EXIT):
if (s_editMode > 0) { if (s_editMode > 0) {
s_editMode = 0; s_editMode = 0;
break; break;
+15 -10
View File
@@ -89,7 +89,7 @@ bool editZoneOption(coord_t y, const ZoneOption * option, ZoneOptionValue * valu
else else
lcdDrawTextAtIndex(SCREENS_SETUP_2ND_COLUMN, y, STR_VCSWFUNC, 0, attr); // TODO define lcdDrawTextAtIndex(SCREENS_SETUP_2ND_COLUMN, y, STR_VCSWFUNC, 0, attr); // TODO define
if (attr) { if (attr) {
if (event==EVT_KEY_BREAK(KEY_ENTER)) { if (event==EVT_KEY_FIRST(KEY_ENTER)) {
s_editMode = 0; s_editMode = 0;
if (sdListFiles(BITMAPS_PATH, BITMAPS_EXT, sizeof(value->stringValue), value->stringValue, LIST_NONE_SD_FILE)) { if (sdListFiles(BITMAPS_PATH, BITMAPS_EXT, sizeof(value->stringValue), value->stringValue, LIST_NONE_SD_FILE)) {
fileSelectionDone = false; fileSelectionDone = false;
@@ -230,13 +230,13 @@ bool menuWidgetChoice(evt_t event)
break; break;
} }
case EVT_KEY_BREAK(KEY_EXIT): case EVT_KEY_FIRST(KEY_EXIT):
delete currentWidget; delete currentWidget;
currentContainer->setWidget(currentZone, previousWidget); currentContainer->setWidget(currentZone, previousWidget);
popMenu(); popMenu();
return false; return false;
case EVT_KEY_BREAK(KEY_ENTER): case EVT_KEY_FIRST(KEY_ENTER):
delete previousWidget; delete previousWidget;
currentContainer->createWidget(currentZone, registeredWidgets[menuHorizontalPosition]); currentContainer->createWidget(currentZone, registeredWidgets[menuHorizontalPosition]);
storageDirty(EE_MODEL); storageDirty(EE_MODEL);
@@ -296,7 +296,8 @@ bool menuWidgetsSetup(evt_t event)
case EVT_ENTRY: case EVT_ENTRY:
menuVerticalPosition = 0; menuVerticalPosition = 0;
break; break;
case EVT_KEY_BREAK(KEY_EXIT): case EVT_KEY_FIRST(KEY_EXIT):
killEvents(KEY_EXIT);
popMenu(); popMenu();
return false; return false;
} }
@@ -319,7 +320,8 @@ bool menuWidgetsSetup(evt_t event)
} }
if (menuVerticalPosition == i) { if (menuVerticalPosition == i) {
lcdDrawSolidRect(zone.x-padding, zone.y-padding, zone.w+2*padding, zone.h+2*padding, thickness, color); lcdDrawSolidRect(zone.x-padding, zone.y-padding, zone.w+2*padding, zone.h+2*padding, thickness, color);
if (event == EVT_KEY_BREAK(KEY_ENTER)) { if (event == EVT_KEY_FIRST(KEY_ENTER)) {
killEvents(KEY_ENTER);
currentZone = menuVerticalPosition; currentZone = menuVerticalPosition;
currentWidget = currentContainer->getWidget(menuVerticalPosition); currentWidget = currentContainer->getWidget(menuVerticalPosition);
if (currentWidget) { if (currentWidget) {
@@ -395,7 +397,7 @@ T * editThemeChoice(coord_t x, coord_t y, T * array[], uint8_t count, T * curren
} }
if (attr && menuHorizontalPosition >= 0) { if (attr && menuHorizontalPosition >= 0) {
lcdDrawSolidRect(x + (menuHorizontalPosition - menuHorizontalOffset) * 56 - 3, y - 1, 57, 35, 1, TEXT_INVERTED_BGCOLOR); lcdDrawSolidRect(x + (menuHorizontalPosition - menuHorizontalOffset) * 56 - 3, y - 1, 57, 35, 1, TEXT_INVERTED_BGCOLOR);
if (event == EVT_KEY_BREAK(KEY_ENTER)) { if (event == EVT_KEY_FIRST(KEY_ENTER)) {
s_editMode = 0; s_editMode = 0;
return array[menuHorizontalPosition]; return array[menuHorizontalPosition];
} }
@@ -457,7 +459,7 @@ bool menuScreensTheme(evt_t event)
else if (index == optionsCount) { else if (index == optionsCount) {
lcdDrawText(MENUS_MARGIN_LEFT, y, "Top bar"); lcdDrawText(MENUS_MARGIN_LEFT, y, "Top bar");
drawButton(SCREENS_SETUP_2ND_COLUMN, y, "Setup", attr); drawButton(SCREENS_SETUP_2ND_COLUMN, y, "Setup", attr);
if (attr && event == EVT_KEY_BREAK(KEY_ENTER)) { if (attr && event == EVT_KEY_FIRST(KEY_ENTER)) {
currentScreen = customScreens[0]; currentScreen = customScreens[0];
currentContainer = topbar; currentContainer = topbar;
pushMenu(menuWidgetsSetup); pushMenu(menuWidgetsSetup);
@@ -519,6 +521,7 @@ bool menuScreenSetup(int index, evt_t event)
delete customScreens[index]; delete customScreens[index];
currentScreen = customScreens[index] = factory->create(&g_model.screenData[index].layoutData); currentScreen = customScreens[index] = factory->create(&g_model.screenData[index].layoutData);
strncpy(g_model.screenData[index].layoutName, factory->getName(), sizeof(g_model.screenData[index].layoutName)); strncpy(g_model.screenData[index].layoutName, factory->getName(), sizeof(g_model.screenData[index].layoutName));
killEvents(KEY_ENTER);
storageDirty(EE_MODEL); storageDirty(EE_MODEL);
} }
break; break;
@@ -529,7 +532,7 @@ bool menuScreenSetup(int index, evt_t event)
case ITEM_SCREEN_SETUP_WIDGETS_SETUP: case ITEM_SCREEN_SETUP_WIDGETS_SETUP:
drawButton(SCREENS_SETUP_2ND_COLUMN, y, "Setup widgets", attr); drawButton(SCREENS_SETUP_2ND_COLUMN, y, "Setup widgets", attr);
if (attr && event == EVT_KEY_BREAK(KEY_ENTER)) { if (attr && event == EVT_KEY_FIRST(KEY_ENTER)) {
pushMenu(menuWidgetsSetup); pushMenu(menuWidgetsSetup);
} }
break; break;
@@ -546,7 +549,7 @@ bool menuScreenSetup(int index, evt_t event)
} }
else if (menuPageCount > 3 && o == optionsCount) { else if (menuPageCount > 3 && o == optionsCount) {
drawButton(SCREENS_SETUP_2ND_COLUMN, y, STR_REMOVE_SCREEN, attr); drawButton(SCREENS_SETUP_2ND_COLUMN, y, STR_REMOVE_SCREEN, attr);
if (attr && event == EVT_KEY_BREAK(KEY_ENTER)) { if (attr && event == EVT_KEY_LONG(KEY_ENTER)) {
delete currentScreen; delete currentScreen;
if (index != MAX_CUSTOM_SCREENS-1) { if (index != MAX_CUSTOM_SCREENS-1) {
memmove(&g_model.screenData[index], &g_model.screenData[index + 1], sizeof(CustomScreenData) * (MAX_CUSTOM_SCREENS - index - 1)); memmove(&g_model.screenData[index], &g_model.screenData[index + 1], sizeof(CustomScreenData) * (MAX_CUSTOM_SCREENS - index - 1));
@@ -554,6 +557,7 @@ bool menuScreenSetup(int index, evt_t event)
} }
memset(&g_model.screenData[MAX_CUSTOM_SCREENS-1], 0, sizeof(CustomScreenData)); memset(&g_model.screenData[MAX_CUSTOM_SCREENS-1], 0, sizeof(CustomScreenData));
customScreens[MAX_CUSTOM_SCREENS-1] = NULL; customScreens[MAX_CUSTOM_SCREENS-1] = NULL;
killEvents(KEY_ENTER);
chainMenu(menuTabScreensSetup[index > 0 ? index : 1]); chainMenu(menuTabScreensSetup[index > 0 ? index : 1]);
return false; return false;
} }
@@ -599,10 +603,11 @@ bool menuScreenAdd(evt_t event)
{ {
menuPageCount = updateMainviewsMenu(); menuPageCount = updateMainviewsMenu();
if (event == EVT_KEY_BREAK(KEY_ENTER)) { if (event == EVT_KEY_FIRST(KEY_ENTER)) {
customScreens[menuPageCount-2] = registeredLayouts[0]->create(&g_model.screenData[menuPageCount-2].layoutData); customScreens[menuPageCount-2] = registeredLayouts[0]->create(&g_model.screenData[menuPageCount-2].layoutData);
s_editMode = 0; s_editMode = 0;
menuHorizontalPosition = -1; menuHorizontalPosition = -1;
killEvents(KEY_ENTER);
return false; return false;
} }
+4 -2
View File
@@ -165,12 +165,12 @@ bool menuMainView(evt_t event)
pushMenu(menuTabScreensSetup[1]); pushMenu(menuTabScreensSetup[1]);
return false; return false;
case EVT_KEY_BREAK(KEY_PGDN): case EVT_KEY_FIRST(KEY_PGDN):
storageDirty(EE_GENERAL); storageDirty(EE_GENERAL);
g_eeGeneral.view = circularIncDec(g_eeGeneral.view, +1, 0, getMainViewsCount()-1); g_eeGeneral.view = circularIncDec(g_eeGeneral.view, +1, 0, getMainViewsCount()-1);
break; break;
case EVT_KEY_BREAK(KEY_PGUP): case EVT_KEY_FIRST(KEY_PGUP):
killEvents(event); killEvents(event);
storageDirty(EE_GENERAL); storageDirty(EE_GENERAL);
g_eeGeneral.view = circularIncDec(g_eeGeneral.view, -1, 0, getMainViewsCount()-1); g_eeGeneral.view = circularIncDec(g_eeGeneral.view, -1, 0, getMainViewsCount()-1);
@@ -193,6 +193,7 @@ bool menuMainView(evt_t event)
return true; return true;
} }
#if 0
bool menuMainViewChannelsMonitor(evt_t event) bool menuMainViewChannelsMonitor(evt_t event)
{ {
switch (event) { switch (event) {
@@ -204,3 +205,4 @@ bool menuMainViewChannelsMonitor(evt_t event)
return menuChannelsView(event); return menuChannelsView(event);
} }
#endif
+4 -4
View File
@@ -100,7 +100,7 @@ bool menuTextView(evt_t event)
readTextFile(lines_count); readTextFile(lines_count);
break; break;
case EVT_KEY_FIRST(KEY_UP): case EVT_ROTARY_LEFT:
if (menuVerticalOffset == 0) if (menuVerticalOffset == 0)
break; break;
else else
@@ -108,7 +108,7 @@ bool menuTextView(evt_t event)
readTextFile(lines_count); readTextFile(lines_count);
break; break;
case EVT_KEY_FIRST(KEY_DOWN): case EVT_ROTARY_RIGHT:
if (menuVerticalOffset+NUM_BODY_LINES >= lines_count) if (menuVerticalOffset+NUM_BODY_LINES >= lines_count)
break; break;
else else
@@ -116,7 +116,7 @@ bool menuTextView(evt_t event)
readTextFile(lines_count); readTextFile(lines_count);
break; break;
case EVT_KEY_BREAK(KEY_EXIT): case EVT_KEY_FIRST(KEY_EXIT):
popMenu(); popMenu();
break; break;
} }
@@ -131,7 +131,7 @@ bool menuTextView(evt_t event)
#endif #endif
// lcd_putsCenter(MENU_FOOTER_TOP, title, HEADER_COLOR); // lcd_putsCenter(MENU_FOOTER_TOP, title, HEADER_COLOR);
drawVerticalScrollbar(LCD_W-5, 30, MENU_FOOTER_TOP-34, menuVerticalOffset, lines_count, NUM_BODY_LINES); drawVerticalScrollbar(LCD_W-5, 50, 195, menuVerticalOffset, lines_count, NUM_BODY_LINES);
return true; return true;
} }