tcMenu
Public Member Functions | Static Public Member Functions | List of all members
tcgfx::ConfigurableItemDisplayPropertiesFactory Class Reference

#include <GfxMenuConfig.h>

Inheritance diagram for tcgfx::ConfigurableItemDisplayPropertiesFactory:
tcgfx::ItemDisplayPropertiesFactory

Public Member Functions

DrawableIconiconForMenuItem (uint16_t id) override
 
GridPositionWithIdgridPositionForItem (MenuItem *pItem) override
 
ItemDisplayPropertiesconfigFor (MenuItem *pItem, ItemDisplayProperties::ComponentType compType) override
 
ItemDisplayPropertiesconfigForCurrentSub (ItemDisplayProperties::ComponentType compType) override
 
color_t getSelectedColor (ItemDisplayProperties::ColorType colorType, bool isUnderCursor=false) override
 
void addGridPosition (MenuItem *pItem, const GridPosition &position) override
 
void addImageToCache (const DrawableIcon &toAdd)
 
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)
 
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)
 
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)
 
void setSelectedColors (color_t background, color_t text)
 
void setEditCursorMode (EditCursorMode mode, color_t cursorCol, color_t textCol)
 

Static Public Member Functions

static void refreshCache ()
 

Detailed Description

Provides full support for configurability of menu items, in terms of the their grid position and also any associated icons and drawing color / font / padding overrides. Each time the renderer sets up a new menu, it calls into here for each item to find out what settings to use for drawing. It is therefore possible to adjust settings either globally, by sub menu, or for a given menu item. This class also stores icon definitions by menu item, so any items that are set to draw as icons will look in that cache. After updating any drawing values, you should call refreshCache() to ensure it is picked up.

Member Function Documentation

◆ iconForMenuItem()

DrawableIcon* tcgfx::ConfigurableItemDisplayPropertiesFactory::iconForMenuItem ( uint16_t  id)
inlineoverridevirtual

Get the icon associated with a menu ID or nullptr if not available.

Parameters
idthe menu id
Returns
an icon or nullptr

Implements tcgfx::ItemDisplayPropertiesFactory.

◆ gridPositionForItem()

GridPositionWithId* tcgfx::ConfigurableItemDisplayPropertiesFactory::gridPositionForItem ( MenuItem pItem)
inlineoverridevirtual

Gets the grid position override for a given menu item if one is available, or nullptr if not.

Parameters
pItemthe menu item to get the override for
Returns
the override position or nullptr

Implements tcgfx::ItemDisplayPropertiesFactory.

◆ configFor()

ItemDisplayProperties * tcgfx::ConfigurableItemDisplayPropertiesFactory::configFor ( MenuItem pItem,
ItemDisplayProperties::ComponentType  compType 
)
overridevirtual

Get the display configuration for a given item given a component type. This will search for an item at the menu item level first, then at the sub menu item level, and finally it will use the default. It is always safe to call this function, it never returns nullptr.

Parameters
pItemthe item for which we want properties
compTypethe component type we are drawing
Returns
a display properties instance.

Implements tcgfx::ItemDisplayPropertiesFactory.

◆ configForCurrentSub()

ItemDisplayProperties * tcgfx::ConfigurableItemDisplayPropertiesFactory::configForCurrentSub ( ItemDisplayProperties::ComponentType  compType)
overridevirtual

Get the display configuration for the submenu on display and therefore avoiding checking at the item level. Only checks at the sub menu item level, and finally it will use the default. It is always safe to call this function, it never returns nullptr.

Parameters
compTypethe component type we are drawing
Returns
a display properties instance.

Implements tcgfx::ItemDisplayPropertiesFactory.

◆ getSelectedColor()

color_t tcgfx::ConfigurableItemDisplayPropertiesFactory::getSelectedColor ( ItemDisplayProperties::ColorType  colorType,
bool  isUnderCursor = false 
)
inlineoverridevirtual

Gets the selected color for a particular color type (such as background, text etc)

Parameters
colorTypethe color type we need
Returns
the actual color

Implements tcgfx::ItemDisplayPropertiesFactory.

◆ addGridPosition()

void tcgfx::ConfigurableItemDisplayPropertiesFactory::addGridPosition ( MenuItem pItem,
const GridPosition position 
)
inlineoverridevirtual

Adds a new grid position for a particular menu item to the cache of grid positions. Grid positions are stored by menu item and override how and where an item is drawn in the grid.

Parameters
pItemthe item who's position is being overridden
positionthe position override

Implements tcgfx::ItemDisplayPropertiesFactory.

◆ addImageToCache()

void tcgfx::ConfigurableItemDisplayPropertiesFactory::addImageToCache ( const DrawableIcon toAdd)
inline

Adds an icon image to the cache by menu ID. When there is a grid position override that has icon drawing as its rendering type, then the image will be looked up using this cache.

Parameters
toAddthe icon image to add.

◆ setDrawingPropertiesDefault()

void tcgfx::ConfigurableItemDisplayPropertiesFactory::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 
)
inline

Sets the drawing properties that should be used when no overrides exist at any other level. these are basically the defaults for the component type

Parameters
drawingthe component type for which these are the defaults
palettethe palette that should be used
padthe padding that should be used
fontthe font that will be used for text rendering
magthe font number or magnification depending on the drawable used
spacingthe spacing between items
requiredHeightthe required default height for items (can be overridden in position)
defaultJustificationthe default justification (can be overridden in position)
borderthe border to draw around the edges of the item

◆ setDrawingPropertiesForItem()

void tcgfx::ConfigurableItemDisplayPropertiesFactory::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 
)
inline

Sets the drawing properties that should be used for a specific item, it must have the right component type.

Parameters
drawingthe component type for which these are the defaults
idthe menu id for which this override is valid
palettethe palette that should be used
padthe padding that should be used
fontthe font that will be used for text rendering
magthe font number or magnification depending on the drawable used
spacingthe spacing between items
requiredHeightthe required default height for items (can be overridden in position)
defaultJustificationthe default justification (can be overridden in position)
borderthe border to draw around the edges of the item

◆ setDrawingPropertiesAllInSub()

void tcgfx::ConfigurableItemDisplayPropertiesFactory::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 
)
inline

Sets the drawing properties that should be used for a specific item, it must have the right component type.

Parameters
drawingthe component type for which these are the defaults
idthe submenu id for which this override will apply to all children
palettethe palette that should be used
padthe padding that should be used
fontthe font that will be used for text rendering
magthe font number or magnification depending on the drawable used
spacingthe spacing between items
requiredHeightthe required default height for items (can be overridden in position)
defaultJustificationthe default justification (can be overridden in position)
borderthe border to draw around the edges of the item

◆ setSelectedColors()

void tcgfx::ConfigurableItemDisplayPropertiesFactory::setSelectedColors ( color_t  background,
color_t  text 
)
inline

Set the backround and text color for selected items

Parameters
backgroundthe color of the background
textthe color of the text

◆ setEditCursorMode()

void tcgfx::ConfigurableItemDisplayPropertiesFactory::setEditCursorMode ( EditCursorMode  mode,
color_t  cursorCol,
color_t  textCol 
)
inline

Sets the edit cursor mode and cursor color for different display types

Parameters
modethe type of cursor to present
cursorColorthe color of the cursor itself
textColorfor filled cursors, this is the text color on the top of the cursor

◆ refreshCache()

void tcgfx::ConfigurableItemDisplayPropertiesFactory::refreshCache ( )
static

Whenever you've called any method that adjusts the cache by adding new drawing options, you must then call refreshCache to ensure the drawing functions are aware of the change


The documentation for this class was generated from the following files: