|
| 1 | +#ifndef TCMENU_THEME_MONO_INVERSE |
| 2 | +#define TCMENU_THEME_MONO_INVERSE |
| 3 | + |
| 4 | +#include <graphics/TcThemeBuilder.h> |
| 5 | + |
| 6 | +color_t defaultItemPaletteMono[] = {WHITE, BLACK, WHITE, WHITE}; |
| 7 | + |
| 8 | +#define TITLE_BORDER_THICKNESS 2 |
| 9 | +#define TITLE_SPACING 2 |
| 10 | + |
| 11 | +/** |
| 12 | + * This is one of the stock themes, you can modify it to meet your requirements, and it will not be updated by tcMenu |
| 13 | + * Designer unless you delete it. This sets up the fonts, spacing and padding for all items. |
| 14 | + * @param gr the graphical renderer |
| 15 | + * @param itemFont the font for items |
| 16 | + * @param titleFont the font for titles |
| 17 | + * @param needEditingIcons if editing icons are needed |
| 18 | + */ |
| 19 | +void installMonoBorderTitleTheme(GraphicsDeviceRenderer& gr, const MenuFontDef& itemFont, const MenuFontDef& titleFont, |
| 20 | + bool needEditingIcons, BaseGraphicalRenderer::TitleMode titleMode, bool useUnicode) { |
| 21 | + |
| 22 | + // See https://tcmenu.github.io/documentation/arduino-libraries/tc-menu/themes/rendering-with-themes-icons-grids/ |
| 23 | + TcThemeBuilder themeBuilder(gr); |
| 24 | + themeBuilder.withSelectedColors(0, 1) |
| 25 | + .dimensionsFromRenderer() |
| 26 | + .withItemPadding(MenuPadding(1)) |
| 27 | + .withRenderingSettings(titleMode, false) |
| 28 | + .withPalette(defaultItemPaletteMono) |
| 29 | + .withNativeFont(itemFont.fontData, itemFont.fontMag) |
| 30 | + .withSpacing(1); |
| 31 | + |
| 32 | + if(needEditingIcons) { |
| 33 | + themeBuilder.withStandardLowResCursorIcons(); |
| 34 | + } |
| 35 | + |
| 36 | + if(useUnicode) { |
| 37 | + themeBuilder.enableTcUnicode(); |
| 38 | + } |
| 39 | + |
| 40 | + themeBuilder.defaultTitleProperties() |
| 41 | + .withNativeFont(titleFont.fontData, titleFont.fontMag) |
| 42 | + .withJustification(tcgfx::GridPosition::JUSTIFY_TITLE_LEFT_WITH_VALUE) |
| 43 | + .withSpacing(TITLE_SPACING) |
| 44 | + .withBorder(MenuBorder(0, 0, TITLE_BORDER_THICKNESS, 0)) |
| 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 |
0 commit comments