Skip to content

Commit 699a72e

Browse files
committed
#229 theme builder example from latest designer
1 parent 44ef11c commit 699a72e

File tree

4 files changed

+66
-41
lines changed

4 files changed

+66
-41
lines changed

examples/esp/esp32s2Saola/ThemeMonoInverse.h

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#ifndef TCMENU_THEME_MONO_INVERSE
2+
#define TCMENU_THEME_MONO_INVERSE
3+
4+
#include <graphics/TcThemeBuilder.h>
5+
6+
color_t defaultItemPaletteMono[] = {1, 0, 1, 1};
7+
color_t defaultTitlePaletteMono[] = {0, 1, 0, 0};
8+
9+
#define TITLE_PADDING 2
10+
#define TITLE_SPACING 2
11+
12+
/**
13+
* This is one of the stock themes, you can modify it to meet your requirements, and it will not be updated by tcMenu
14+
* Designer unless you delete it. This sets up the fonts, spacing and padding for all items.
15+
* @param gr the graphical renderer
16+
* @param itemFont the font for items
17+
* @param titleFont the font for titles
18+
* @param needEditingIcons if editing icons are needed
19+
*/
20+
void installMonoInverseTitleTheme(GraphicsDeviceRenderer& gr, const MenuFontDef& itemFont, const MenuFontDef& titleFont,
21+
bool needEditingIcons, BaseGraphicalRenderer::TitleMode titleMode, bool useUnicode) {
22+
TcThemeBuilder themeBuilder(gr);
23+
themeBuilder.withSelectedColors(0, 2)
24+
.dimensionsFromRenderer()
25+
.withItemPadding(MenuPadding(1))
26+
.withRenderingSettings(titleMode, false)
27+
.withPalette(defaultItemPaletteMono)
28+
.withNativeFont(itemFont.fontData, itemFont.fontMag)
29+
.withSpacing(1);
30+
31+
if(needEditingIcons) {
32+
themeBuilder.withStandardLowResCursorIcons();
33+
}
34+
35+
if(useUnicode) {
36+
themeBuilder.enablingTcUnicode();
37+
}
38+
39+
themeBuilder.defaultTitleProperties()
40+
.withNativeFont(titleFont.fontData, titleFont.fontMag)
41+
.withPalette(defaultTitlePaletteMono)
42+
.withPadding(MenuPadding(TITLE_PADDING))
43+
.withJustification(tcgfx::GridPosition::JUSTIFY_TITLE_LEFT_WITH_VALUE)
44+
.withSpacing(TITLE_SPACING)
45+
.apply();
46+
47+
themeBuilder.defaultActionProperties()
48+
.withJustification(tcgfx::GridPosition::JUSTIFY_TITLE_LEFT_WITH_VALUE)
49+
.apply();
50+
51+
themeBuilder.defaultItemProperties()
52+
.withJustification(tcgfx::GridPosition::JUSTIFY_TITLE_LEFT_VALUE_RIGHT)
53+
.apply();
54+
55+
themeBuilder.apply();
56+
}
57+
58+
#endif //TCMENU_THEME_MONO_INVERSE

examples/esp/esp32s2Saola/esp32s2Saola.emf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@
366366
"lastRemoteUuids": [
367367
"46c30011-cac6-4598-a7b8-b0630d55daab"
368368
],
369-
"lastThemeUuid": "0dd60ceb-7e0f-46e2-8d40-b264eb3aa7e0",
369+
"lastThemeUuid": "396ED4DF-AD7B-4951-A848-A9E5838A549B",
370370
"applicationUUID": "b447b433-fe4f-4ce7-8746-d94bfeefc707",
371371
"applicationName": "ESP32-S2 Saola board",
372372
"lastProperties": [
@@ -539,7 +539,8 @@
539539
"menuDefinitions": []
540540
},
541541
"packageNamespace": "",
542-
"appIsModular": false
542+
"appIsModular": false,
543+
"listOfEmbeddedForms": []
543544
},
544545
"stringLists": []
545546
}

examples/esp/esp32s2Saola/generated/esp32s2Saola_menu.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
use elsewhere.
99
*/
1010

11+
// Generated for Arduino ESP32 by TcMenu 4.3.1-SNAPSHOT on 2024-08-26T12:55:56.108558600Z.
12+
1113
#include <tcMenu.h>
1214
#include "esp32s2Saola_menu.h"
13-
#include "../ThemeMonoInverse.h"
15+
#include "../ThemeMonoInverseBuilder.h"
1416

1517
// Global variable declarations
1618
const PROGMEM ConnectorLocalInfo applicationInfo = { "ESP32-S2 Saola board", "b447b433-fe4f-4ce7-8746-d94bfeefc707" };
@@ -90,15 +92,13 @@ void setupMenu() {
9092
menuConnectivityIoTMonitor.setLocalOnly(true);
9193
menuConnectivityAuthenticator.setLocalOnly(true);
9294

93-
// Code generated by plugins.
95+
// Code generated by plugins and new operators.
9496
gfx.begin();
9597
renderer.setUpdatesPerSecond(10);
9698
switches.init(internalDigitalIo(), SWITCHES_POLL_EVERYTHING, true);
9799
menuMgr.initForEncoder(&renderer, &menuIntEdit, 5, 6, 7);
98100
remoteServer.addConnection(&ethernetConnection);
99-
renderer.setTitleMode(BaseGraphicalRenderer::TITLE_ALWAYS);
100-
renderer.setUseSliderForAnalog(false);
101-
installMonoInverseTitleTheme(renderer, MenuFontDef(nullptr, 1), MenuFontDef(nullptr, 1), true);
101+
installMonoInverseTitleTheme(renderer, MenuFontDef(nullptr, 1), MenuFontDef(nullptr, 1), true, BaseGraphicalRenderer::TITLE_ALWAYS, false);
102102

103103
// We have an IoT monitor, register the server
104104
menuConnectivityIoTMonitor.setRemoteServer(remoteServer);

0 commit comments

Comments
 (0)