|
| 1 | +#ifndef THEME_COOL_BLUE |
| 2 | +#define THEME_COOL_BLUE |
| 3 | + |
| 4 | +// |
| 5 | +// Note only include this file ONCE, in a CPP file. We do this automatically when using a Theme by adding to setupMenu() |
| 6 | +// |
| 7 | + |
| 8 | +// tcMenu drawing properties take a 4 color palette for items, titles and actions. |
| 9 | +// this renderer shares the color configuration for items and actions. |
| 10 | +color_t coolBlueTitlePalette[] = {RGB(0,0,0), RGB(20,132,255), RGB(192,192,192), RGB(0,133,255)}; |
| 11 | +color_t coolBlueItemPalette[] = {RGB(255, 255, 255), RGB(0,64,135), RGB(20,133,255), RGB(31,100,178)}; |
| 12 | + |
| 13 | +void installCoolBlueTraditionalTheme(GraphicsDeviceRenderer& bgr, const MenuFontDef& itemFont, const MenuFontDef& titleFont, bool needEditingIcons) { |
| 14 | + // first we keep a reference to the screen size, and set the dimensions on the renderer. |
| 15 | + auto width = bgr.getDeviceDrawable()->getDisplayDimensions().x; |
| 16 | + auto height = bgr.getDeviceDrawable()->getDisplayDimensions().y; |
| 17 | + bgr.setDisplayDimensions(width, height); |
| 18 | + |
| 19 | + // get hold of the item display factory that holds the drawing configuration. |
| 20 | + auto& factory = bgr.getGraphicsPropertiesFactory(); |
| 21 | + |
| 22 | + // when an item is active, it will show in these colours instead of the default. |
| 23 | + factory.setSelectedColors(RGB(31, 88, 100), RGB(255, 255, 255)); |
| 24 | + |
| 25 | + // here we calculate the item padding and row heights based on the resolution of the display |
| 26 | + bool medResOrBetter = width > 160; |
| 27 | + MenuPadding titlePadding(medResOrBetter ? 4 : 2); |
| 28 | + MenuPadding itemPadding(2); |
| 29 | + int titleHeight = bgr.heightForFontPadding(titleFont.fontData, titleFont.fontMag, titlePadding); |
| 30 | + int itemHeight = bgr.heightForFontPadding(itemFont.fontData, itemFont.fontMag, itemPadding); |
| 31 | + |
| 32 | + // we set the editing and selected icons here based on the row height. |
| 33 | + if(needEditingIcons && itemHeight > 12) { |
| 34 | + factory.addImageToCache(DrawableIcon(SPECIAL_ID_EDIT_ICON, Coord(16, 12),DrawableIcon::ICON_XBITMAP, defEditingIcon)); |
| 35 | + factory.addImageToCache(DrawableIcon(SPECIAL_ID_ACTIVE_ICON, Coord(16, 12),DrawableIcon::ICON_XBITMAP, defActiveIcon)); |
| 36 | + } |
| 37 | + else if(needEditingIcons) { |
| 38 | + factory.addImageToCache(DrawableIcon(SPECIAL_ID_EDIT_ICON, Coord(8, 6),DrawableIcon::ICON_XBITMAP, loResEditingIcon)); |
| 39 | + factory.addImageToCache(DrawableIcon(SPECIAL_ID_ACTIVE_ICON, Coord(8, 6),DrawableIcon::ICON_XBITMAP, loResActiveIcon)); |
| 40 | + } |
| 41 | + |
| 42 | + // we tell the library how to draw titles, items and actions by default. |
| 43 | + factory.setDrawingPropertiesDefault(ItemDisplayProperties::COMPTYPE_TITLE, coolBlueTitlePalette, titlePadding, titleFont.fontData, titleFont.fontMag, |
| 44 | + medResOrBetter ? 3 : 1, titleHeight, GridPosition::JUSTIFY_TITLE_LEFT_WITH_VALUE, MenuBorder()); |
| 45 | + factory.setDrawingPropertiesDefault(ItemDisplayProperties::COMPTYPE_ITEM, coolBlueItemPalette, itemPadding, itemFont.fontData, itemFont.fontMag, |
| 46 | + 1, itemHeight, GridPosition::JUSTIFY_TITLE_LEFT_VALUE_RIGHT, MenuBorder()); |
| 47 | + factory.setDrawingPropertiesDefault(ItemDisplayProperties::COMPTYPE_ACTION, coolBlueItemPalette, itemPadding, itemFont.fontData, itemFont.fontMag, |
| 48 | + 1, itemHeight, GridPosition::JUSTIFY_TITLE_LEFT_VALUE_RIGHT, MenuBorder()); |
| 49 | + |
| 50 | + // after adjusting the drawing configuration, we must always refresh the cache. |
| 51 | + tcgfx::ConfigurableItemDisplayPropertiesFactory::refreshCache(); |
| 52 | +} |
| 53 | + |
| 54 | +#endif //THEME_COOL_BLUE |
0 commit comments