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

#include <GraphicsDeviceRenderer.h>

Inheritance diagram for tcgfx::GraphicsDeviceRenderer:
tcgfx::BaseGraphicalRenderer BaseMenuRenderer MenuRenderer

Public Member Functions

 GraphicsDeviceRenderer (int bufferSize, const char *appTitle, DeviceDrawable *drawable)
 
void drawWidget (Coord where, TitleWidget *widget, color_t colorFg, color_t colorBg) override
 
void drawMenuItem (GridPositionRowCacheEntry *entry, Coord where, Coord areaSize, const DrawingFlags &drawingFlags) override
 
void drawingCommand (RenderDrawingCommand command) override
 
void fillWithBackgroundTo (int endPoint) override
 
int heightForFontPadding (const void *font, int mag, MenuPadding &padding)
 
void setGraphicsConfiguration (void *gfxConfig)
 
void prepareDisplay (bool monoPalette, const void *itemFont, int magItem, const void *titleFont, int magTitle, bool needEditingIcons)
 
ItemDisplayPropertiesFactorygetDisplayPropertiesFactory () override
 
ConfigurableItemDisplayPropertiesFactorygetGraphicsPropertiesFactory ()
 
DeviceDrawablegetDeviceDrawable ()
 
void enableTcUnicode ()
 
void enableCardLayout (const DrawableIcon &left, const DrawableIcon &right, MenuTouchScreenManager *touchManager, bool monoDisplay)
 
void setCardLayoutStatusForSubMenu (MenuItem *root, bool onOrOff)
 
LayoutMode getLayoutMode (MenuItem *rootItem) override
 
- Public Member Functions inherited from tcgfx::BaseGraphicalRenderer
MenuItemgetCurrentRendererRoot ()
 
 BaseGraphicalRenderer (int bufferSize, int wid, int hei, bool lastRowExact, const char *appTitle)
 
void initialise () override
 
void setTitleMode (TitleMode mode)
 
void setDisplayNumber (uint8_t displayNum)
 
uint8_t getDisplayNumber ()
 
void setUseSliderForAnalog (bool useSlider)
 
void setHasTouchInterface (bool hasTouch)
 
void setTitleOnDisplay (bool titleOn)
 
void setLastRowExactFit (bool exact)
 
void setRawTouchMode (bool rawTouch)
 
void setEditStatusIconsEnabled (bool ena)
 
bool isUseSliderForAnalog () const
 
bool isHasTouchInterface () const
 
bool isTitleOnDisplay () const
 
bool isLastRowExactFit () const
 
bool isRawTouchMode () const
 
bool isEditStatusIconEnabled () const
 
void render () override
 
void setDisplayDimensions (int w, int h)
 
int findItemIndex (MenuItem *root, MenuItem *toFind) override
 
uint8_t itemCount (MenuItem *root, bool) override
 
GridPositionRowCacheEntryfindMenuEntryAndDimensions (const Coord &screenPos, Coord &localStart, Coord &localSize)
 
MenuItemgetMenuItemAtIndex (MenuItem *currentRoot, uint8_t idx) override
 
BaseDialoggetDialog () override
 
int getWidth () const
 
int getHeight () const
 
void displayPropertiesHaveChanged ()
 
void rootHasChanged (MenuItem *newItem)
 
uint8_t setActiveItem (MenuItem *item) override
 
- Public Member Functions inherited from BaseMenuRenderer
 BaseMenuRenderer (int bufferSize, RendererType rType=RENDER_TYPE_BASE, uint8_t displayNum=0)
 
 ~BaseMenuRenderer () override
 
void setUpdatesPerSecond (int updatesSec)
 
void turnOffDisplayUpdates (bool)
 
void setResetIntervalTimeSeconds (uint16_t interval)
 
void turnOffResetLogic ()
 
void resetNotifiesOnly (uint16_t ticks)
 
void setResetCallback (ResetCallbackFn resetFn)
 
void setCustomDrawingHandler (CustomDrawing *customDrawingParam)
 
CustomDrawinggetCurrentCustomDrawing ()
 
void exec () override
 
bool tryTakeSelectIfNeeded (int currentReading, RenderPressMode pressMode) override
 
MenuItemgetActiveItem ()
 
int findActiveItem (MenuItem *root)
 
void setFirstWidget (TitleWidget *widget)
 
TitleWidgetgetFirstWidget ()
 
void menuAltered ()
 
void takeOverDisplay (RendererCallbackFn displayFn=nullptr)
 
void giveBackDisplay ()
 
void resetToDefault ()
 
void redrawRequirement (MenuRedrawState state)
 
void invalidateAll ()
 
- Public Member Functions inherited from MenuRenderer
 MenuRenderer (RendererType rendererType, int bufferSize)
 
virtual ~MenuRenderer ()
 
char * getBuffer ()
 
uint8_t getBufferSize ()
 
RendererType getRendererType ()
 

Protected Member Functions

void subMenuRender (MenuItem *rootItem, uint8_t &locRedrawMode, bool &forceDrawWidgets) override
 
bool isActiveOrEditing (MenuItem *pItem, const DrawingFlags &drawingFlags)
 
- Protected Member Functions inherited from tcgfx::BaseGraphicalRenderer
int heightOfRow (int row, bool includeSpace=false)
 
- Protected Member Functions inherited from BaseMenuRenderer
void countdownToDefaulting ()
 

Additional Inherited Members

- Public Types inherited from tcgfx::BaseGraphicalRenderer
enum  TitleMode : uint8_t { NO_TITLE , TITLE_FIRST_ROW , TITLE_ALWAYS }
 
enum  RenderDrawingCommand { DRAW_COMMAND_CLEAR , DRAW_COMMAND_START , DRAW_COMMAND_ENDED }
 
- Public Types inherited from BaseMenuRenderer
enum  DisplayTakeoverMode { NOT_TAKEN_OVER , TAKEN_OVER_FN , START_CUSTOM_DRAW , RUNNING_CUSTOM_DRAW }
 
- Static Public Member Functions inherited from BaseMenuRenderer
static BaseMenuRenderergetInstance ()
 
- Static Public Member Functions inherited from MenuRenderer
static MenuRenderergetInstance ()
 
- Protected Attributes inherited from tcgfx::BaseGraphicalRenderer
BtreeList< uint16_t, GridPositionRowCacheEntryitemOrderByRow
 
TitleMode titleMode = TITLE_FIRST_ROW
 
uint16_t width
 
uint16_t height
 
CachedDrawingLocation drawingLocation
 
uint8_t flags
 
- Protected Attributes inherited from BaseMenuRenderer
uint8_t lastOffset
 
uint8_t updatesPerSecond
 
uint8_t displayNumber = 0
 
MenuRedrawState redrawMode
 
uint16_t ticksToReset
 
uint16_t resetValInTicks
 
TitleWidgetfirstWidget
 
CustomDrawingcustomDrawing
 
BaseDialogdialog
 
DisplayTakeoverMode displayTakenMode
 
RenderPressMode renderFnPressType
 
RendererCallbackFn renderCallback
 
MenuItemactiveItem = nullptr
 
- Protected Attributes inherited from MenuRenderer
char * buffer
 
uint8_t bufferSize
 
RendererType rendererType
 
- Static Protected Attributes inherited from MenuRenderer
static MenuRenderertheInstance = nullptr
 

Detailed Description

This class contains all the drawing code that is used for most graphical displays, it relies on an instance of device drawable to do the drawing. It can also use sub drawing if the drawing device supports it, and it is enabled. This means that on supported devices it is possible to do flicker free rendering.

To support a new display, do not touch this class unless something is amiss or there is a bug, instead just implement the above DeviceDrawable for that display. Take a look at the other rendering classes we already have for an example of how.

Member Function Documentation

◆ drawWidget()

void tcgfx::GraphicsDeviceRenderer::drawWidget ( Coord  where,
TitleWidget widget,
color_t  colorFg,
color_t  colorBg 
)
overridevirtual

Draw a widget into the title area at the position indicated, the background will need to be cleared before performing the operation.

Parameters
wherethe position on the screen to draw the widget
widgetthe widget to be drawn.
colorFgthe foreground color
colorBgthe background color

Implements tcgfx::BaseGraphicalRenderer.

◆ drawMenuItem()

void tcgfx::GraphicsDeviceRenderer::drawMenuItem ( GridPositionRowCacheEntry entry,
Coord  where,
Coord  areaSize,
const DrawingFlags drawFlags 
)
overridevirtual

Draw a menu item onto the display using the instructions

Parameters
theItemthe item to be rendered
modethe suggested mode in which to draw
wherethe position on the display to render at
areaSizethe size of the area where it should be rendered

Implements tcgfx::BaseGraphicalRenderer.

◆ drawingCommand()

void tcgfx::GraphicsDeviceRenderer::drawingCommand ( RenderDrawingCommand  command)
overridevirtual

This sends general purpose commands that can be implemened by the leaf class as needed.

Implements tcgfx::BaseGraphicalRenderer.

◆ fillWithBackgroundTo()

void tcgfx::GraphicsDeviceRenderer::fillWithBackgroundTo ( int  endPoint)
overridevirtual

This indicates to the renderer leaf class that the background color should be filled from Y end point to the end of the screen.

Parameters
endPointthe last drawing point in the Y location

Implements tcgfx::BaseGraphicalRenderer.

◆ heightForFontPadding()

int tcgfx::GraphicsDeviceRenderer::heightForFontPadding ( const void *  font,
int  mag,
MenuPadding padding 
)

Get the height for the font and add the descent to the bottom padding.

Parameters
fontthe font to measure
magany magnification to apply - if supported
paddingthe padding for the item, bottom will be adjusted
Returns
the height of the item.

◆ setGraphicsConfiguration()

void tcgfx::GraphicsDeviceRenderer::setGraphicsConfiguration ( void *  gfxConfig)

Set up the display based on the legacy graphics configuration. This is deprecated and you should move to using prepareDisplay. New code should NOT use this as it will be removed in a future build.

Deprecated:
use prepareDisplay with displayProperties overrides instead as per all examples.
Parameters
gfxConfigthe legacy graphics configuration

◆ prepareDisplay()

void tcgfx::GraphicsDeviceRenderer::prepareDisplay ( bool  monoPalette,
const void *  itemFont,
int  magItem,
const void *  titleFont,
int  magTitle,
bool  needEditingIcons 
)

Set up the display using a basic configuration. Setting factories with default colours and sizes.

Parameters
monoPalettetrue if the display is monochrome, otherwise false.
itemFontthe font to use for items
titleFontthe font to use for the title
needEditingIconstrue if editing icons should be prepared, otherwise false.

◆ getDisplayPropertiesFactory()

ItemDisplayPropertiesFactory& tcgfx::GraphicsDeviceRenderer::getDisplayPropertiesFactory ( )
inlineoverridevirtual

Gets the abstract display properties factory, used internally to get the factory regardless of what actual type it is, in user code that is using graphics properties factory, use getGraphicsPropertiesFactory

Returns
the properties factory

Implements tcgfx::BaseGraphicalRenderer.

◆ getGraphicsPropertiesFactory()

ConfigurableItemDisplayPropertiesFactory& tcgfx::GraphicsDeviceRenderer::getGraphicsPropertiesFactory ( )
inline

Gets the graphical display properties factory, so that you can add graphics configuration easily.

Returns
the properties factory

◆ getDeviceDrawable()

DeviceDrawable* tcgfx::GraphicsDeviceRenderer::getDeviceDrawable ( )
inline

Gets the underlying device drawable so that you can render to the screen in a device independent way. On most systems this is a very thin wrapper on the library and performs very well for all but the most intensive of drawing operations.

Returns
the underlying device drawable.

◆ enableTcUnicode()

void tcgfx::GraphicsDeviceRenderer::enableTcUnicode ( )
inline

Enables TcUnicode as the default font processor for all operations, and ensures that the unicode helper can be accessed too.

◆ enableCardLayout()

void tcgfx::GraphicsDeviceRenderer::enableCardLayout ( const DrawableIcon left,
const DrawableIcon right,
MenuTouchScreenManager touchManager,
bool  monoDisplay 
)

Enables the card layout system for the items provided, a card layout shows a single item at once, with left and right images present that work somewhat like buttons. Rotating the encoder (or up/down buttons) will result in switching between the menu items. This works particularly well when combined with using drawable icons for each of the menu items. Note that after enabling, you must call setCardLayoutStatusForSubMenu to enable menus, see the method docs for details.

Parameters
leftthe icon to use for left, (takes its colors from the title)
rightthe icon to use for right, (takes its colors from the title)
touchManageroptionally provide the touch manager to make the buttons work with a touch screen
monoDisplayfor mono displays the direction buttons completely disappears instead of greying out

◆ setCardLayoutStatusForSubMenu()

void tcgfx::GraphicsDeviceRenderer::setCardLayoutStatusForSubMenu ( MenuItem root,
bool  onOrOff 
)

Allows the card layout mode to be enabled for a root item, this is the first item in the linked list, for submenus you can obtain this by calling menuSub.getChild() on a submenu, or for root call rootMenuItem() to get the first item of the root menu.

Parameters
rootthe root menu item to change status
onOrOfftrue if on, otherwise false.

◆ getLayoutMode()

LayoutMode tcgfx::GraphicsDeviceRenderer::getLayoutMode ( MenuItem rootItem)
overridevirtual
Returns
the layout mode that would be applied for a given root menu item, see the enum.

Reimplemented from tcgfx::BaseGraphicalRenderer.

◆ subMenuRender()

void tcgfx::GraphicsDeviceRenderer::subMenuRender ( MenuItem rootItem,
uint8_t &  locRedrawMode,
bool &  forceDrawWidgets 
)
overrideprotectedvirtual

Overrides the default implementation to allow for card based layouts, if this is not enabled for the submenu then regular rendering is used instead.

Parameters
rootItemthe first item in the linked list for this submenu
locRedrawModereference to the local redraw mode. May be updated
forceDrawWidgetsreference to if the widgets are to be force drawn, may be updated

Reimplemented from tcgfx::BaseGraphicalRenderer.


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