13 #ifndef _GFX_MENU_CONFIG_H_
14 #define _GFX_MENU_CONFIG_H_
17 #include <SimpleCollections.h>
20 #include <IoLogging.h>
25 #define SPECIAL_ID_EDIT_ICON 0xfffe
26 #define SPECIAL_ID_ACTIVE_ICON 0xfffd
48 const uint8_t* activeIcon;
49 const uint8_t* editIcon;
50 uint8_t editIconWidth;
51 uint8_t editIconHeight;
53 uint8_t titleBottomMargin;
54 uint8_t titleFontMagnification;
55 uint8_t itemFontMagnification;
129 uint32_t gridSize: 3;
131 uint32_t gridPosition: 3;
133 uint32_t gridRowSpan: 2;
135 uint32_t gridHeight: 9;
137 uint32_t rowPosition: 7;
139 uint32_t drawingMode: 4;
141 uint32_t justification: 4;
143 GridPosition() : gridSize(0), gridPosition(0), gridHeight(0), rowPosition(0), drawingMode(0),
146 GridPosition(
const GridPosition &other) =
default;
147 GridPosition& operator=(
const GridPosition &other) =
default;
157 : gridSize(1), gridPosition(1), gridHeight(height),rowPosition(row), drawingMode(mode), justification(justification) { }
170 : gridSize(size), gridPosition(pos), gridHeight(hei), rowPosition(row), drawingMode(mode), justification(just) { }
176 int getGridSize()
const {
return gridSize; }
178 int getGridHeight()
const {
return gridHeight; }
180 int getGridPosition()
const {
return gridPosition; }
182 int getRow()
const {
return rowPosition; }
231 const GridPosition &getPosition() {
return thePosition; }
233 uint16_t getKey()
const {
return menuId; }
236 thePosition = newPosition;
267 color_t colors[SIZEOF_COLOR_ARRAY];
269 const void* fontData;
271 uint8_t fontMagnification;
274 uint8_t requiredHeight;
276 ItemDisplayProperties() : propsKey(0), colors{}, padding(), fontData(nullptr), borderWidths(), fontMagnification(1),
277 defaultJustification(
GridPosition::JUSTIFY_TITLE_LEFT_VALUE_RIGHT), spaceAfter(0), requiredHeight(0) {}
278 ItemDisplayProperties(uint32_t key,
const color_t* palette,
const MenuPadding& pad,
const void* font, uint8_t mag, uint8_t spacing,
280 : propsKey(key), padding{pad}, fontData(font), borderWidths(borderWidths), fontMagnification(mag), defaultJustification(defaultJustification),
281 spaceAfter(spacing), requiredHeight(height) {
282 memcpy(colors, palette,
sizeof colors);
284 ItemDisplayProperties(
const ItemDisplayProperties& other) =
default;
285 ItemDisplayProperties& operator=(
const ItemDisplayProperties& other) =
default;
287 uint32_t getKey()
const {
return propsKey; }
290 return defaultJustification;
295 uint8_t getSpaceAfter()
const {
return spaceAfter; }
297 void setSpaceAfter(uint8_t space) { spaceAfter = space; }
299 uint8_t getRequiredHeight()
const {
return requiredHeight; }
301 void setRequiredHeight(uint8_t newHeight) { requiredHeight = newHeight; }
304 return (color < SIZEOF_COLOR_ARRAY) ? colors[color] : RGB(0,0,0);
307 void setColor(
ColorType color, color_t value) {
308 if(color >= SIZEOF_COLOR_ARRAY)
return;
309 colors[color] = value;
312 void setColors(
const color_t* palette) {
313 memcpy(colors, palette,
sizeof colors);
316 const MenuPadding& getPadding()
const {
320 void setPadding(
const MenuPadding& pad) {
324 MenuBorder getBorder()
const {
328 void setBorder(MenuBorder border) {
329 borderWidths = border;
332 uint8_t getFontMagnification()
const {
333 return fontMagnification;
336 void setFontInfo(
const void* font, uint8_t mag) {
337 fontMagnification = mag;
341 const void* getFont() {
415 color_t anEmptyPalette[4] = {0};
417 BtreeList<uint16_t, GridPositionWithId> gridByItem;
438 if(!pItem)
return nullptr;
439 return gridByItem.getByKey(pItem->
getId());
444 auto* grid = gridByItem.getByKey(pItem->
getId());
446 grid->setNewPosition(position);
449 serlogF2(SER_TCMENU_DEBUG,
"Adding grid ", pItem->
getId());
455 #define MENUID_NOTSET 0xffff
458 return ((uint32_t)menuId) | (parentKey ? 0x10000UL : 0UL) | ((uint32_t)ty << 18UL);
481 BtreeList<uint32_t, ItemDisplayProperties> displayProperties;
482 BtreeList<uint16_t, DrawableIcon> iconsByItem;
483 BtreeList<uint16_t, GridPositionWithId> gridByItem;
484 color_t selectedTextColor = RGB(0,0,0);
485 color_t selectedBackgroundColor = RGB(0, 100, 255);
486 color_t editCursorColor = RGB(255, 255, 255);
487 color_t editCursorTextColor = RGB(0, 0, 0);
491 : displayProperties(5, GROW_BY_5),
492 iconsByItem(6, GROW_BY_5) { }
500 return iconsByItem.getByKey(
id);
509 if(!pItem)
return nullptr;
510 return gridByItem.getByKey(pItem->
getId());
539 return colorType == ItemDisplayProperties::BACKGROUND ? editCursorColor : editCursorTextColor;
541 return colorType == ItemDisplayProperties::BACKGROUND ? selectedBackgroundColor : selectedTextColor;
552 auto* grid = gridByItem.getByKey(pItem->
getId());
554 grid->setNewPosition(position);
567 auto* current = iconsByItem.getByKey(toAdd.getKey());
572 iconsByItem.add(toAdd);
591 auto key = MakePropsKey(MENUID_NOTSET,
false, drawing);
592 serlogF2(SER_TCMENU_DEBUG,
"Add def prop: ", key);
593 setDrawingProperties(key, palette, pad, font, mag, spacing, requiredHeight, defaultJustification, border);
611 auto key = MakePropsKey(
id,
false, drawing);
612 serlogF3(SER_TCMENU_DEBUG,
"Add item prop: ", key,
id);
613 setDrawingProperties(key, palette, pad, font, mag, spacing, requiredHeight, defaultJustification, border);
631 auto key = MakePropsKey(
id,
true, drawing);
632 serlogF3(SER_TCMENU_DEBUG,
"Add sub prop: ", key,
id);
633 setDrawingProperties(key, palette, pad, font, mag, spacing, requiredHeight, defaultJustification, border);
642 selectedBackgroundColor = background;
643 selectedTextColor = text;
653 editCursorMode = mode;
654 editCursorColor = cursorCol;
655 editCursorTextColor = textCol;
665 void setDrawingProperties(uint32_t key,
const color_t* palette,
MenuPadding pad,
const void* font, uint8_t mag, uint8_t spacing,
contains a series of core components needed by all graphical renderers
uint32_t color_t
Definition: DrawingPrimitives.h:29
Definition: GfxMenuConfig.h:479
void setDrawingPropertiesAllInSub(ItemDisplayProperties::ComponentType drawing, uint16_t id, const color_t *palette, MenuPadding pad, const void *font, uint8_t mag, uint8_t spacing, uint8_t requiredHeight, GridPosition::GridJustification defaultJustification, MenuBorder border)
Definition: GfxMenuConfig.h:629
static void refreshCache()
Definition: GfxMenuConfig.cpp:128
ItemDisplayProperties * configFor(MenuItem *pItem, ItemDisplayProperties::ComponentType compType) override
Definition: GfxMenuConfig.cpp:66
DrawableIcon * iconForMenuItem(uint16_t id) override
Definition: GfxMenuConfig.h:499
void setEditCursorMode(EditCursorMode mode, color_t cursorCol, color_t textCol)
Definition: GfxMenuConfig.h:652
color_t getSelectedColor(ItemDisplayProperties::ColorType colorType, bool isUnderCursor=false) override
Definition: GfxMenuConfig.h:537
void addImageToCache(const DrawableIcon &toAdd)
Definition: GfxMenuConfig.h:566
void addGridPosition(MenuItem *pItem, const GridPosition &position) override
Definition: GfxMenuConfig.h:550
GridPositionWithId * gridPositionForItem(MenuItem *pItem) override
Definition: GfxMenuConfig.h:508
void setDrawingPropertiesForItem(ItemDisplayProperties::ComponentType drawing, uint16_t id, const color_t *palette, MenuPadding pad, const void *font, uint8_t mag, uint8_t spacing, uint8_t requiredHeight, GridPosition::GridJustification defaultJustification, MenuBorder border)
Definition: GfxMenuConfig.h:609
void setSelectedColors(color_t background, color_t text)
Definition: GfxMenuConfig.h:641
void setDrawingPropertiesDefault(ItemDisplayProperties::ComponentType drawing, const color_t *palette, MenuPadding pad, const void *font, uint8_t mag, uint8_t spacing, uint8_t requiredHeight, GridPosition::GridJustification defaultJustification, MenuBorder border)
Definition: GfxMenuConfig.h:588
ItemDisplayProperties * configForCurrentSub(ItemDisplayProperties::ComponentType compType) override
Definition: GfxMenuConfig.cpp:85
Definition: DrawingPrimitives.h:152
const uint8_t * getIcon(bool selected) const
Definition: DrawingPrimitives.h:228
Coord getDimensions() const
Definition: DrawingPrimitives.h:243
IconType getIconType() const
Definition: DrawingPrimitives.h:250
Definition: GfxMenuConfig.h:69
GridJustification
Definition: GfxMenuConfig.h:93
@ JUSTIFY_TITLE_LEFT_VALUE_RIGHT
Definition: GfxMenuConfig.h:107
@ CORE_JUSTIFY_VALUE_REQUIRED
Definition: GfxMenuConfig.h:102
@ JUSTIFY_LEFT_NO_VALUE
Definition: GfxMenuConfig.h:115
@ JUSTIFY_CENTER_WITH_VALUE
Definition: GfxMenuConfig.h:111
@ CORE_JUSTIFY_RIGHT
Definition: GfxMenuConfig.h:97
@ JUSTIFY_RIGHT_WITH_VALUE
Definition: GfxMenuConfig.h:113
@ JUSTIFY_RIGHT_NO_VALUE
Definition: GfxMenuConfig.h:119
@ CORE_JUSTIFY_CENTER
Definition: GfxMenuConfig.h:99
@ JUSTIFY_LEFT_VALUE_ONLY
Definition: GfxMenuConfig.h:121
@ JUSTIFY_CENTER_VALUE_ONLY
Definition: GfxMenuConfig.h:123
@ JUSTIFY_CENTER_NO_VALUE
Definition: GfxMenuConfig.h:117
@ CORE_JUSTIFY_NAME_REQUIRED
Definition: GfxMenuConfig.h:104
@ CORE_JUSTIFY_LEFT
Definition: GfxMenuConfig.h:95
@ JUSTIFY_TITLE_LEFT_WITH_VALUE
Definition: GfxMenuConfig.h:109
@ JUSTIFY_RIGHT_VALUE_ONLY
Definition: GfxMenuConfig.h:125
GridPosition(GridDrawingMode mode, GridJustification justification, int row, int height=0)
Definition: GfxMenuConfig.h:156
GridDrawingMode
Definition: GfxMenuConfig.h:74
@ DRAW_TEXTUAL_ITEM
Definition: GfxMenuConfig.h:76
@ DRAW_AS_ICON_TEXT
Definition: GfxMenuConfig.h:84
@ DRAW_TITLE_ITEM
Definition: GfxMenuConfig.h:86
@ DRAW_INTEGER_AS_UP_DOWN
Definition: GfxMenuConfig.h:78
@ DRAW_AS_ICON_ONLY
Definition: GfxMenuConfig.h:82
@ DRAW_INTEGER_AS_SCROLL
Definition: GfxMenuConfig.h:80
GridPosition(GridDrawingMode mode, GridJustification just, int size, int pos, int row, int hei)
Definition: GfxMenuConfig.h:169
Definition: GfxMenuConfig.h:218
Definition: GfxMenuConfig.h:358
virtual DrawableIcon * iconForMenuItem(uint16_t id)=0
virtual color_t getSelectedColor(ItemDisplayProperties::ColorType colorType, bool isUnderCursor=false)=0
virtual GridPositionWithId * gridPositionForItem(MenuItem *pItem)=0
virtual ItemDisplayProperties * configForCurrentSub(ItemDisplayProperties::ComponentType compType)=0
virtual ItemDisplayProperties * configFor(MenuItem *pItem, ItemDisplayProperties::ComponentType compType)=0
virtual void addGridPosition(MenuItem *item, const GridPosition &position)=0
Definition: GfxMenuConfig.h:245
ComponentType
Definition: GfxMenuConfig.h:260
ColorType
Definition: GfxMenuConfig.h:250
Definition: GfxMenuConfig.h:413
void addGridPosition(MenuItem *pItem, const GridPosition &position) override
Definition: GfxMenuConfig.h:442
ItemDisplayProperties * configForCurrentSub(ItemDisplayProperties::ComponentType) override
Definition: GfxMenuConfig.h:425
DrawableIcon * iconForMenuItem(uint16_t) override
Definition: GfxMenuConfig.h:429
color_t getSelectedColor(ItemDisplayProperties::ColorType colorType, bool=false) override
Definition: GfxMenuConfig.h:433
GridPositionWithId * gridPositionForItem(MenuItem *pItem) override
Definition: GfxMenuConfig.h:437
ItemDisplayProperties * configFor(MenuItem *pItem, ItemDisplayProperties::ComponentType) override
Definition: GfxMenuConfig.h:421
const uint8_t ArrowHoriz11x22BitmapLeft[] PROGMEM
Definition: directionalIcons.h:21
A series of utilities that used throughout tcMenu.