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

#include <TcThemeBuilder.h>

Public Member Functions

 TcThemeBuilder (GraphicsDeviceRenderer &renderer)
 
TcThemeBuilderwithSelectedColors (color_t bg, color_t fg)
 
TcThemeBuilderwithAdaFont (const GFXfont *font, int mag=1)
 
TcThemeBuilderwithTcUnicodeFont (const UnicodeFont *font)
 
TcThemeBuilderwithNativeFont (const void *data, uint8_t mag)
 
TcThemeBuilderenableTcUnicode ()
 
TcThemeBuilderenablingTcUnicode ()
 
TcThemeBuilderwithCursorIconsXbmp (Coord size, const uint8_t *editIcon, const uint8_t *activeIcon)
 
TcThemeBuilderwithStandardLowResCursorIcons ()
 
TcThemeBuilderwithStandardMedResCursorIcons ()
 
TcThemeBuilderwithSpacing (uint8_t spacing)
 
TcThemeBuilderwithItemPadding (MenuPadding padding)
 
TcThemeBuilderwithTitlePadding (MenuPadding padding)
 
ThemePropertiesBuilderdefaultItemProperties ()
 
ThemePropertiesBuilderdefaultTitleProperties ()
 
ThemePropertiesBuilderdefaultActionProperties ()
 
ThemePropertiesBuildermenuItemOverride (MenuItem &item)
 
ThemePropertiesBuildermenuItemOverride (MenuItem &item, ItemDisplayProperties::ComponentType componentType)
 
ThemePropertiesBuildersubmenuPropertiesItemOverride (SubMenuItem &item)
 
ThemePropertiesBuildersubmenuPropertiesActionOverride (SubMenuItem &item)
 
ThemePropertiesBuildersubmenuPropertiesTitleOverride (SubMenuItem &item)
 
TcThemeBuilderwithPalette (const color_t *cols)
 
TcThemeBuilderwithRenderingSettings (BaseGraphicalRenderer::TitleMode mode, bool useAnalogSliders)
 
TcThemeBuilderdimensionsFromRenderer ()
 
TcThemeBuildermanualDimensions (int x, int y)
 
TcThemeBuilderenableCardLayoutWithXbmImages (Coord iconSize, const uint8_t *leftIcon, const uint8_t *rightIcon, bool isMono)
 
TcThemeBuildersetMenuAsCard (SubMenuItem &item, bool on)
 
TcThemeBuilderaddingTitleWidget (TitleWidget &theWidget)
 
void apply ()
 
ConfigurableItemDisplayPropertiesFactorygetItemFactory ()
 
MenuPadding getPaddingFor (ItemDisplayProperties::ComponentType type)
 
uint8_t getDefaultSpacing () const
 
GraphicsDeviceRenderergetRenderer ()
 
const color_tgetDefaultPalette ()
 
const void * getDefaultFontData ()
 
uint8_t getDefaultFontMag () const
 

Detailed Description

A theme builder class that is used to simply create themes for tcMenu GraphicalDisplayRenderer class. It allows most graphical configurations to be applied without the complexities of directly using the item display factory. This class uses a builder approach where most methods can be chained, because they return references to this class.

Constructor & Destructor Documentation

◆ TcThemeBuilder()

tcgfx::TcThemeBuilder::TcThemeBuilder ( GraphicsDeviceRenderer renderer)
inlineexplicit

Creates a theme builder by providing the renderer to use with it.

Parameters
rendererthe renderer to use, must be a GraphicsDeviceRenderer

Member Function Documentation

◆ withSelectedColors()

TcThemeBuilder& tcgfx::TcThemeBuilder::withSelectedColors ( color_t  bg,
color_t  fg 
)
inline

Set the colours to be used for the background and foreground when an item is selected.

Parameters
bgthe background color
fgthe foreground color
Returns
reference to itself for chaining

◆ withAdaFont()

TcThemeBuilder& tcgfx::TcThemeBuilder::withAdaFont ( const GFXfont *  font,
int  mag = 1 
)
inline

Configure the default font as an adafruit font, normally for use either when using an Adafruit_GFX based library, or tcUnicode which also supports Adafruit font rendering.

Parameters
fontthe adafruit font
magthe magnification factor - defaults to 1.
Returns
reference to itself for chaining

◆ withTcUnicodeFont()

TcThemeBuilder& tcgfx::TcThemeBuilder::withTcUnicodeFont ( const UnicodeFont *  font)
inline

Configure the default font as a tcUnicode font, this is only supported when tcUnicode is enabled.

Parameters
fontthe tcUnicode font
Returns
reference to itself for chaining

◆ withNativeFont()

TcThemeBuilder& tcgfx::TcThemeBuilder::withNativeFont ( const void *  data,
uint8_t  mag 
)
inline

Configure the default font as a native font consulting the plugin documentation for the chosen display and library.

Parameters
fontthe native font
magthe native mag value
Returns
reference to itself for chaining

◆ enableTcUnicode()

TcThemeBuilder & TcThemeBuilder::enableTcUnicode ( )

Turn on tcUnicode drawing support if it is not already turned on. This means that instead of using native fonts, the rendering engine will use TcUnicode for all text drawing. This is seamless from the rendering perspective, but requires that you use fonts supported by TcUnicode, these are Adafruit or TcUnicode fonts.

Returns
reference to itself for chaining

◆ enablingTcUnicode()

TcThemeBuilder& tcgfx::TcThemeBuilder::enablingTcUnicode ( )
inline

Prefer to use enableTcUnicode() instead

Returns
reference to itself for chaining

◆ withCursorIconsXbmp()

TcThemeBuilder & TcThemeBuilder::withCursorIconsXbmp ( Coord  size,
const uint8_t *  editIcon,
const uint8_t *  activeIcon 
)

Provide custom cursor icons that are used when an item is selected or edited. Use this when you don't want to use the standard cursor icons. Note that the two icons must be the same size. Cursor icons are the visual cues, IE the active arrow and the editing icon usually on the left of an item.

Parameters
sizethe size of the icons
editIconthe edit icon in XBM form
activeIconthe active icon in XBM form
Returns
reference to itself for chaining

◆ withStandardLowResCursorIcons()

TcThemeBuilder & TcThemeBuilder::withStandardLowResCursorIcons ( )

Use the standard lower resolution cursor icons suitable for OLED and similar resolution displays. Cursor icons are the visual cues, IE the active arrow and the editing icon usually on the left of an item.

Returns
reference to itself for chaining

◆ withStandardMedResCursorIcons()

TcThemeBuilder & TcThemeBuilder::withStandardMedResCursorIcons ( )

Use the standard medium resolution cursor icons suitable for larger TFT and higher resolution displays Cursor icons are the visual cues, IE the active arrow and the editing icon usually on the left of an item.

Returns
reference to itself for chaining

◆ withSpacing()

TcThemeBuilder& tcgfx::TcThemeBuilder::withSpacing ( uint8_t  spacing)
inline

Set the standard spacing that will be used by default unless overridden

Parameters
spacingthe standard item spacing
Returns
reference to itself for chaining

◆ withItemPadding()

TcThemeBuilder& tcgfx::TcThemeBuilder::withItemPadding ( MenuPadding  padding)
inline

Set the item padding that will be used by default, unless overridden

Parameters
paddingthe padding to apply
Returns
reference to itself for chaining

◆ withTitlePadding()

TcThemeBuilder& tcgfx::TcThemeBuilder::withTitlePadding ( MenuPadding  padding)
inline

Set the title spacing that will be used by default, unless overridden

Parameters
paddingthe padding to apply
Returns
reference to itself for chaining

◆ defaultItemProperties()

ThemePropertiesBuilder& tcgfx::TcThemeBuilder::defaultItemProperties ( )
inline

Get access to default theme properties for regular items.

Returns
a theme properties builder

◆ defaultTitleProperties()

ThemePropertiesBuilder& tcgfx::TcThemeBuilder::defaultTitleProperties ( )
inline

Get access to default theme properties for title items.

Returns
a theme properties builder

◆ defaultActionProperties()

ThemePropertiesBuilder& tcgfx::TcThemeBuilder::defaultActionProperties ( )
inline

Get access to default theme properties for action items.

Returns
a theme properties builder

◆ menuItemOverride() [1/2]

ThemePropertiesBuilder & TcThemeBuilder::menuItemOverride ( MenuItem item)

Get access to theme properties for a specific menu item, with this you can change how an item renders, and even apply different grid settings. This guesses the component type in most cases but if you want to force a particular component type see the override method with the second parameter.

Parameters
itemthe menu item to override drawing
Returns
a theme properties builder

◆ menuItemOverride() [2/2]

ThemePropertiesBuilder & TcThemeBuilder::menuItemOverride ( MenuItem item,
ItemDisplayProperties::ComponentType  componentType 
)

Get access to theme properties for a specific menu item, with this you can change how an item renders, and even apply different grid settings. This specifically sets the component type for situations where it cannot be easily guessed.

Parameters
itemthe menu item to override drawing.
componentTypeone of COMPTYPE_TITLE, COMPTYPE_ITEM, COMPTYPE_ACTION
Returns
a theme properties builder

◆ submenuPropertiesItemOverride()

ThemePropertiesBuilder& tcgfx::TcThemeBuilder::submenuPropertiesItemOverride ( SubMenuItem item)
inline

Get access to theme properties for a sub menu, with this you can change how all items in that submenu render This applies to regular items

Parameters
itemthe sub menu item
Returns
a theme properties builder

◆ submenuPropertiesActionOverride()

ThemePropertiesBuilder& tcgfx::TcThemeBuilder::submenuPropertiesActionOverride ( SubMenuItem item)
inline

Get access to theme properties for a sub menu, with this you can change how all items in that submenu render This applies to action items

Parameters
itemthe sub menu item
Returns
a theme properties builder

◆ submenuPropertiesTitleOverride()

ThemePropertiesBuilder& tcgfx::TcThemeBuilder::submenuPropertiesTitleOverride ( SubMenuItem item)
inline

Get access to theme properties for a sub menu, with this you can change how all items in that submenu render This applies to title items

Parameters
itemthe sub menu item
Returns
a theme properties builder

◆ withPalette()

TcThemeBuilder & TcThemeBuilder::withPalette ( const color_t cols)

Set the default palette that will be used unless overrridden

Parameters
colsthe colors to use, must be 4 entry array.
Returns
reference to itself for chaining

◆ withRenderingSettings()

TcThemeBuilder& tcgfx::TcThemeBuilder::withRenderingSettings ( BaseGraphicalRenderer::TitleMode  mode,
bool  useAnalogSliders 
)
inline

Set up the core rendering settings, that is the way the title should be drawn, and also if analog sliders should be used to represent analog items.

Parameters
modehow the title should be drawing, one of BaseGraphicalRenderer::TitleMode enum values.
useAnalogSliderstrue to use sliders, otherwise false
Returns
reference to itself for chaining

◆ dimensionsFromRenderer()

TcThemeBuilder & TcThemeBuilder::dimensionsFromRenderer ( )

Apply the dimensions from the device drawable to the renderer, this takes the device specific size and applies it to the renderer.

Returns
reference to itself for chaining

◆ manualDimensions()

TcThemeBuilder & TcThemeBuilder::manualDimensions ( int  x,
int  y 
)

Manually set the dimensions of the display, for cases where dimensionsFromRenderer does not work.

Parameters
xthe width
ythe height
Returns
reference to itself for chaining

◆ enableCardLayoutWithXbmImages()

TcThemeBuilder & TcThemeBuilder::enableCardLayoutWithXbmImages ( Coord  iconSize,
const uint8_t *  leftIcon,
const uint8_t *  rightIcon,
bool  isMono 
)

Use this to enable card layout for the root menu, and configure the icons that will be used for left and right buttons.

Parameters
iconSizethe size of the left and right icons
leftIconthe icon for left
rightIconthe icon for right
isMonotrue if mono, otherwise false
Returns
reference to itself for chaining

◆ setMenuAsCard()

TcThemeBuilder & TcThemeBuilder::setMenuAsCard ( SubMenuItem item,
bool  on 
)

Toggle card layout on and off for a given submenu.

Parameters
itemthe sub menu to turn on/off
onthe status for that submenu
Returns
reference to itself for chaining

◆ apply()

void TcThemeBuilder::apply ( )

Call after you've finished configuring your theme, this forces a refresh and ensures it presents properly.


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