Skip to content

Commit e2f2c05

Browse files
committed
Fixes before release.
1 parent 642939b commit e2f2c05

File tree

6 files changed

+36
-13
lines changed

6 files changed

+36
-13
lines changed

examples/arduino32/dynamicMenuItems/dynamicMenuItems.ino

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,12 @@ int CALLBACK_FUNCTION fnListRtCall(RuntimeMenuItem* item, uint8_t row, RenderFnM
333333
Serial.print("Activated "); Serial.println(row);
334334
return true;
335335
} else if(mode == RENDERFN_INVOKE) {
336-
Serial.print("Selected "); Serial.println(row);
337-
// do something with the selected item.
338-
menuMgr.resetMenu(false);
336+
if(row != LIST_PARENT_ITEM_POS) {
337+
Serial.print("Selected ");
338+
Serial.println(row);
339+
// do something with the selected item.
340+
menuMgr.resetMenu(false);
341+
}
339342
return true;
340343
} else if(mode == RENDERFN_VALUE && row < numListItems) {
341344
// if the value is in range we copy the value from our array

examples/esp/esp32s3TftEncoder/esp32s3TftEncoder.ino

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "app_icondata.h"
99
#include "tcMenuVersion.h"
1010
#include <IoLogging.h>
11+
#include <stockIcons/wifiAndConnectionIcons16x12.h>
1112

1213
//
1314
// We use a card layout to present the items, here we demonstrate how to set it up and prepare custom menu items that
@@ -19,6 +20,8 @@
1920
DrawableIcon iconLeft(-1, Coord(11, 22), tcgfx::DrawableIcon::ICON_XBITMAP, ArrowHoriz11x22BitmapLeft, nullptr);
2021
DrawableIcon iconRight(-1, Coord(11, 22), tcgfx::DrawableIcon::ICON_XBITMAP, ArrowHoriz11x22BitmapRight, nullptr);
2122

23+
TitleWidget titleWidget(iconsEthernetConnection, 2, 16, 12);
24+
2225
void setupGridLayoutForCardView() {
2326
auto & factory = renderer.getGraphicsPropertiesFactory();
2427

@@ -43,6 +46,7 @@ void setup() {
4346
Serial.begin(115200);
4447

4548
serEnableLevel(SER_TCMENU_DEBUG, true);
49+
renderer.setFirstWidget(&titleWidget);
4650
setupMenu();
4751

4852
// Here we enable the card layout mode for the main menu by first enabling support, then adding the root menu.
@@ -56,10 +60,14 @@ void setup() {
5660
});
5761

5862
// every second we simulate updating the battery condition indicators.
59-
taskManager.scheduleFixedRate(1, [] {
63+
taskManager.schedule(repeatSeconds(1), [] {
6064
menuBatteryCharge.setCurrentValue(rand() % 100);
6165
menuBatteryCondition.setCurrentValue(rand() % 3);
62-
}, TIME_SECONDS);
66+
});
67+
68+
taskManager.schedule(repeatSeconds(30), [] {
69+
titleWidget.setCurrentState(rand() % 2);
70+
});
6371
}
6472

6573
void loop() {

src/RuntimeMenuItem.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ RuntimeMenuItem *ListRuntimeMenuItem::asParent() {
101101
}
102102

103103
RuntimeMenuItem *ListRuntimeMenuItem::asBackMenu() {
104+
menuType = MENUTYPE_BACK_VALUE;
105+
itemPosition = LIST_PARENT_ITEM_POS;
104106
if(activeItem == 0) {
105107
runCallback();
106108
}
107-
menuType = MENUTYPE_BACK_VALUE;
108-
itemPosition = LIST_PARENT_ITEM_POS;
109109
return this;
110110
}
111111

src/graphics/BaseGraphicalRenderer.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,15 @@ void BaseGraphicalRenderer::subMenuRender(MenuItem* rootItem, uint8_t& locRedraw
9696
auto* pEntry = itemOrderByRow.itemAtIndex(0);
9797
drawMenuItem(pEntry, Coord(0,0), Coord(int(width), drawingLocation.getStartY()), DrawingFlags(drawCompleteScreen, activeItem == pEntry->getMenuItem(), menuMgr.getCurrentEditor() == pEntry->getMenuItem()));
9898
forceDrawWidgets = true;
99+
setTitleOnDisplay(true);
100+
} else if(itemOrderByRow.count() > 0){
101+
bool drawingTitle = itemOrderByRow.itemAtIndex(0)->getPosition().getDrawingMode() == GridPosition::DRAW_TITLE_ITEM;
102+
setTitleOnDisplay(drawingTitle && startRow == 0);
99103
}
100104

101105
// and then we start drawing items until we run out of screen or items
102106
if(drawTheMenuItems(startRow, drawingLocation.getStartY(), drawCompleteScreen)) forceDrawWidgets = true;
103-
setTitleOnDisplay((titleMode == TITLE_FIRST_ROW && startRow == 0) || titleMode == TITLE_ALWAYS);
107+
104108
}
105109

106110
GridPositionRowCacheEntry* BaseGraphicalRenderer::findMenuEntryAndDimensions(const Coord& screenPos, Coord& localStart, Coord& localSize) {
@@ -362,8 +366,10 @@ bool BaseGraphicalRenderer::areRowsOutOfOrder() {
362366
}
363367

364368
void BaseGraphicalRenderer::redrawAllWidgets(bool forceRedraw) {
365-
if(!isTitleOnDisplay() || itemOrderByRow.count() == 0) return;
366-
if(itemOrderByRow.itemAtIndex(0)->getPosition().getDrawingMode() != GridPosition::DRAW_TITLE_ITEM) return;
369+
if(itemOrderByRow.count() == 0 || !isTitleOnDisplay()) return;
370+
if(itemOrderByRow.itemAtIndex(0)->getPosition().getDrawingMode() != GridPosition::DRAW_TITLE_ITEM) {
371+
if(drawingLocation.getCurrentOffset() != 0) return;
372+
}
367373

368374
auto* displayProps = itemOrderByRow.itemAtIndex(0)->getDisplayProperties();
369375
auto widFg = displayProps->getColor(ItemDisplayProperties::HIGHLIGHT1);

src/graphics/GraphicsDeviceRenderer.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,17 +466,21 @@ namespace tcgfx {
466466
forceDrawWidgets = true;
467467
}
468468
if (titleNeeded && (locRedrawMode == MENUDRAW_COMPLETE_REDRAW || titleEntry->getMenuItem()->isChanged(displayNumber))) {
469-
drawMenuItem(titleEntry, Coord(0, 0), cardLayoutPane->getTitleSize(), DrawingFlags(true, activeItem == titleEntry->getMenuItem(), menuMgr.getCurrentEditor() == titleEntry->getMenuItem()));
469+
bool active = titleNeeded && activeItem == titleEntry->getMenuItem();
470+
drawMenuItem(titleEntry, Coord(0, 0), cardLayoutPane->getTitleSize(), DrawingFlags(true, active, menuMgr.getCurrentEditor() == titleEntry->getMenuItem()));
471+
forceDrawWidgets = true;
470472
}
471473
if (entry->getMenuItem()->isChanged(displayNumber) || locRedrawMode == MENUDRAW_COMPLETE_REDRAW) {
472474
getDeviceDrawable()->setDrawColor(entry->getDisplayProperties()->getColor(ItemDisplayProperties::BACKGROUND));
473475
getDeviceDrawable()->drawBox(cardLayoutPane->getMenuLocation(), cardLayoutPane->getMenuSize(), true);
474476
int offsetY = (cardLayoutPane->getMenuSize().y - int(entry->getHeight())) / 2;
475477
Coord menuStart(cardLayoutPane->getMenuLocation().x, cardLayoutPane->getMenuLocation().y + offsetY);
476478
Coord menuSize(cardLayoutPane->getMenuSize().x, int(entry->getHeight()));
477-
drawMenuItem(entry, menuStart, menuSize, DrawingFlags(false, activeItem == titleEntry->getMenuItem(), menuMgr.getCurrentEditor() == titleEntry->getMenuItem()));
479+
bool active = titleNeeded && activeItem == entry->getMenuItem();
480+
drawMenuItem(entry, menuStart, menuSize, DrawingFlags(false, active, menuMgr.getCurrentEditor() == entry->getMenuItem()));
478481
}
479482
cardLayoutPane->prepareAndPaintButtons(this, activeIndex, itemOrderByRow.count(), titleMode != NO_TITLE);
483+
setTitleOnDisplay(true);
480484
} else {
481485
if(locRedrawMode == MENUDRAW_COMPLETE_REDRAW && cardLayoutPane != nullptr) {
482486
cardLayoutPane->notInUse();

src/tcMenuKeyboard.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ void MenuEditingKeyListener::keyPressed(char key, bool held) {
7373
clearState();
7474
menuMgr.resetMenu(held);
7575
} else if (key == enterKey) {
76-
clearState();
76+
if(menuMgr.getCurrentEditor() && menuMgr.getCurrentEditor()->getMenuType() != MENUTYPE_RUNTIME_LIST) {
77+
clearState();
78+
}
7779
menuMgr.onMenuSelect(held);
7880
if(menuMgr.getCurrentEditor() && menuMgr.getCurrentEditor()->getMenuType() == MENUTYPE_INT_VALUE) {
7981
processAnalogKeyPress(reinterpret_cast<AnalogMenuItem*>(menuMgr.getCurrentEditor()), key);

0 commit comments

Comments
 (0)