tcMenu
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tcgfx::BaseGraphicalRenderer Class Referenceabstract

#include <BaseGraphicalRenderer.h>

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

Public Types

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 }
 

Public Member Functions

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)
 
virtual LayoutMode getLayoutMode (MenuItem *rootItem)
 
virtual void drawWidget (Coord where, TitleWidget *widget, color_t colorFg, color_t colorBg)=0
 
virtual void drawMenuItem (GridPositionRowCacheEntry *entry, Coord where, Coord areaSize, const DrawingFlags &drawFlags)=0
 
virtual void drawingCommand (RenderDrawingCommand command)=0
 
virtual void fillWithBackgroundTo (int endPoint)=0
 
virtual ItemDisplayPropertiesFactorygetDisplayPropertiesFactory ()=0
 
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

virtual void subMenuRender (MenuItem *rootItem, uint8_t &locRedrawMode, bool &forceDrawWidgets)
 
int heightOfRow (int row, bool includeSpace=false)
 
- Protected Member Functions inherited from BaseMenuRenderer
void countdownToDefaulting ()
 

Protected Attributes

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
 

Additional Inherited Members

- Static Public Member Functions inherited from BaseMenuRenderer
static BaseMenuRenderergetInstance ()
 
- Static Public Member Functions inherited from MenuRenderer
static MenuRenderergetInstance ()
 
- Static Protected Attributes inherited from MenuRenderer
static MenuRenderertheInstance = nullptr
 

Detailed Description

This is the base class for all simpler renderer classes where the height of a row is equal for all entries, and there is always exactly one item on a row. This takes away much of the work to row allocation for simple renderers. Examples of this are the LiquidCrystal renderer

Member Enumeration Documentation

◆ TitleMode

This provides the mode in which the renderer will draw the title, either not at all, always, or as the first row.

Enumerator
NO_TITLE 

never draw the title

TITLE_FIRST_ROW 

the title will only appear when row 0 is selected

TITLE_ALWAYS 

the title will always be shown regardless of index position

◆ RenderDrawingCommand

Represents the possible drawing commands that the base renderer sends to the leaf class

Enumerator
DRAW_COMMAND_CLEAR 

this indicates the screen should be cleared

DRAW_COMMAND_START 

this indicates that the drawing is about to start

DRAW_COMMAND_ENDED 

this indicates that the drawing is ending

Member Function Documentation

◆ getCurrentRendererRoot()

MenuItem* tcgfx::BaseGraphicalRenderer::getCurrentRendererRoot ( )
inline

The current menu from the renderers perspective

Returns
the current menu that the rendering layer is drawing for

◆ initialise()

void tcgfx::BaseGraphicalRenderer::initialise ( )
overridevirtual

Initialise the render setting up the refresh task at the update frequency provided (or leave blank for default).

Parameters
updatesPerSecondthe number of times to update the display per second, set to 0 or leave blank for default

Reimplemented from BaseMenuRenderer.

◆ setDisplayNumber()

void tcgfx::BaseGraphicalRenderer::setDisplayNumber ( uint8_t  displayNum)
inline

TcMenu supports more than one display now, (presently 2) so you set the display number here and it will be passed to the isChanged function to ensure rendering works for both items.

Parameters
displayNumthe display number.

◆ getDisplayNumber()

uint8_t tcgfx::BaseGraphicalRenderer::getDisplayNumber ( )
inline
Returns
the display number as set using setDisplayNumber

◆ setUseSliderForAnalog()

void tcgfx::BaseGraphicalRenderer::setUseSliderForAnalog ( bool  useSlider)
inline

set the use of sliders by default for all integer items

Parameters
useSlidertrue to use sliders

◆ setHasTouchInterface()

void tcgfx::BaseGraphicalRenderer::setHasTouchInterface ( bool  hasTouch)
inline

Enable touch support within the renderer

Parameters
hasTouchtrue to enable touch

◆ setTitleOnDisplay()

void tcgfx::BaseGraphicalRenderer::setTitleOnDisplay ( bool  titleOn)
inline

Set the title as on, so it appears on the display, somewhat internal to the library, control from the theme

Parameters
titleOntrue to turn on

◆ setLastRowExactFit()

void tcgfx::BaseGraphicalRenderer::setLastRowExactFit ( bool  exact)
inline

Set that the last row has to fit exactly, this is for LCD cases and where a gap at the bottom is deemed as better than half rendering.

Parameters
exacttrue for LCD and cases where a gap is better, otherwise false.

◆ setRawTouchMode()

void tcgfx::BaseGraphicalRenderer::setRawTouchMode ( bool  rawTouch)
inline

When this is on, the touch will not look up items, helpful for where you need complete control of the touch interface for a short time.

◆ setEditStatusIconsEnabled()

void tcgfx::BaseGraphicalRenderer::setEditStatusIconsEnabled ( bool  ena)
inline

Turn off editing icons and editor indications of editing for a short time, for example during special layouts such as card layout. This is an override that can force editing icons OFF, it cannot force them ON if no icons were registered.

Parameters
enatrue to enable (Default)

◆ isUseSliderForAnalog()

bool tcgfx::BaseGraphicalRenderer::isUseSliderForAnalog ( ) const
inline
Returns
if using sliders by default for analog items

◆ isHasTouchInterface()

bool tcgfx::BaseGraphicalRenderer::isHasTouchInterface ( ) const
inline
Returns
if there is a touch interface configured

◆ isTitleOnDisplay()

bool tcgfx::BaseGraphicalRenderer::isTitleOnDisplay ( ) const
inline
Returns
if the title is on display (somewhat internal)

◆ isLastRowExactFit()

bool tcgfx::BaseGraphicalRenderer::isLastRowExactFit ( ) const
inline
Returns
if the last row should fit on the display exactly

◆ isRawTouchMode()

bool tcgfx::BaseGraphicalRenderer::isRawTouchMode ( ) const
inline
Returns
if raw touch mode is enabled where it will not recognise item spaces

◆ isEditStatusIconEnabled()

bool tcgfx::BaseGraphicalRenderer::isEditStatusIconEnabled ( ) const
inline
Returns
if the edit icons and other indications are being shown

◆ render()

void tcgfx::BaseGraphicalRenderer::render ( )
overridevirtual

This is the rendering call that must be implemented by subclasses. Generally it is called a few times a second, and should render the menu, if changes are detected

Implements BaseMenuRenderer.

◆ setDisplayDimensions()

void tcgfx::BaseGraphicalRenderer::setDisplayDimensions ( int  w,
int  h 
)
inline

Usually called during the initialisation of the display internally to set the width and height.

Parameters
wdisplay width in current rotation
hdisplay height in current rotation

◆ getLayoutMode()

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

Reimplemented in tcgfx::GraphicsDeviceRenderer.

◆ drawWidget()

virtual void tcgfx::BaseGraphicalRenderer::drawWidget ( Coord  where,
TitleWidget widget,
color_t  colorFg,
color_t  colorBg 
)
pure virtual

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

Implemented in tcgfx::GraphicsDeviceRenderer.

◆ drawMenuItem()

virtual void tcgfx::BaseGraphicalRenderer::drawMenuItem ( GridPositionRowCacheEntry entry,
Coord  where,
Coord  areaSize,
const DrawingFlags drawFlags 
)
pure virtual

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

Implemented in tcgfx::GraphicsDeviceRenderer.

◆ drawingCommand()

virtual void tcgfx::BaseGraphicalRenderer::drawingCommand ( RenderDrawingCommand  command)
pure virtual

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

Implemented in tcgfx::GraphicsDeviceRenderer.

◆ fillWithBackgroundTo()

virtual void tcgfx::BaseGraphicalRenderer::fillWithBackgroundTo ( int  endPoint)
pure virtual

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

Implemented in tcgfx::GraphicsDeviceRenderer.

◆ getDisplayPropertiesFactory()

virtual ItemDisplayPropertiesFactory& tcgfx::BaseGraphicalRenderer::getDisplayPropertiesFactory ( )
pure virtual

Gets the item display factory that provides the formatting information for this renderer, it holds the font, color, padding and grid information. For all bitmapped renderers (EG: AdaFruit_GFX, U8G2) you can safely up cast to the ConfigurableItemDisplayPropertiesFactory

Returns
the display properties factory.

Implemented in tcgfx::GraphicsDeviceRenderer.

◆ findItemIndex()

int tcgfx::BaseGraphicalRenderer::findItemIndex ( MenuItem root,
MenuItem toFind 
)
overridevirtual

Find an item's offset in a given root, safely returns 0.

Parameters
rootthe root item
toFindthe item within that root
Returns
the index if found, otherwise 0.

Reimplemented from BaseMenuRenderer.

◆ itemCount()

uint8_t tcgfx::BaseGraphicalRenderer::itemCount ( MenuItem root,
bool   
)
overridevirtual
Returns
the total number of items in the current menu

Reimplemented from BaseMenuRenderer.

◆ findMenuEntryAndDimensions()

GridPositionRowCacheEntry * tcgfx::BaseGraphicalRenderer::findMenuEntryAndDimensions ( const Coord screenPos,
Coord localStart,
Coord localSize 
)

Provides the menu item grid position and dimensions of it, given a screen position. Usually used by touch screen implementations. Note that this will return nullptr if no entry is found.

Parameters
screenPosthe raw screen position
localStartthe local menu item start position
localSizethe local menu item size
Returns
the grid cache entry or nullptr if no item was found.

◆ getMenuItemAtIndex()

MenuItem * tcgfx::BaseGraphicalRenderer::getMenuItemAtIndex ( MenuItem currentRoot,
uint8_t  idx 
)
overridevirtual

Gets the menu item at a given index, which may be different to the order in the tree.

Reimplemented from BaseMenuRenderer.

◆ getDialog()

BaseDialog * tcgfx::BaseGraphicalRenderer::getDialog ( )
overridevirtual

All base graphical renderers use a dialog based on menu item, this provides the greatest flexibility and also reduces the amount of dialog code. This means nearly every display we support uses menu based dialogs

Returns
a shared menu based dialog instance

Implements MenuRenderer.

◆ getWidth()

int tcgfx::BaseGraphicalRenderer::getWidth ( ) const
inline
Returns
width of the display in current rotation

◆ getHeight()

int tcgfx::BaseGraphicalRenderer::getHeight ( ) const
inline
Returns
height of the display in current rotation

◆ displayPropertiesHaveChanged()

void tcgfx::BaseGraphicalRenderer::displayPropertiesHaveChanged ( )

Force the renderer to completely recalculate the display parameters next time it's drawn.

◆ rootHasChanged()

void tcgfx::BaseGraphicalRenderer::rootHasChanged ( MenuItem newItem)

This is generally called by the navigation listener when the root item has changed due to a new menu being displayed, or display reset event. It will force an immediate recalculation of all items.

Parameters
newItemthe new root item

◆ setActiveItem()

uint8_t tcgfx::BaseGraphicalRenderer::setActiveItem ( MenuItem item)
overridevirtual

Sets the active item to be the menu item selected, also this recalculates the offset required to present that item.

Parameters
itemthe new active item
Returns
the index of the item

Reimplemented from BaseMenuRenderer.

◆ subMenuRender()

void tcgfx::BaseGraphicalRenderer::subMenuRender ( MenuItem rootItem,
uint8_t &  locRedrawMode,
bool &  forceDrawWidgets 
)
protectedvirtual

This is responsible for redrawing a series of menu items onto the screen, it can be overridden as needed in extension classes, such that different rendering can be achieved. The default rendering is vertical, with the items scrolling downward if needed. It is virtual to allow for such extensions.

Parameters
rootItemthe first item in the linked list of children
locRedrawModethe drawing mdoe, a reference, will be updated.
forceDrawWidgetsreference to widgets force update flag, will be updated.

Reimplemented in tcgfx::GraphicsDeviceRenderer.


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