Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
BaseMenuRenderer Class Referenceabstract

#include <BaseRenderers.h>

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

Public Types


Public Member Functions

 BaseMenuRenderer (int bufferSize, RendererType rType=RENDER_TYPE_BASE)
 ~BaseMenuRenderer () override
void initialise () override
void setUpdatesPerSecond (int updatesSec)
void setResetIntervalTimeSeconds (uint16_t interval)
void setResetCallback (ResetCallbackFn resetFn)
void setCustomDrawingHandler (CustomDrawing *customDrawingParam)
void exec () override
virtual void render ()=0
bool tryTakeSelectIfNeeded (int currentReading, RenderPressMode pressMode) override
virtual MenuItemgetMenuItemAtIndex (MenuItem *pItem, uint8_t idx)
virtual int findActiveItem (MenuItem *root)
virtual uint8_t itemCount (MenuItem *item, bool includeNonVisible)
void setFirstWidget (TitleWidget *widget)
void menuAltered ()
void takeOverDisplay (RendererCallbackFn displayFn=nullptr)
void giveBackDisplay ()
void resetToDefault ()
void redrawRequirement (MenuRedrawState state)
void menuValueToText (MenuItem *item, MenuDrawJustification justification)
void invalidateAll ()
- Public Member Functions inherited from MenuRenderer
 MenuRenderer (RendererType rendererType, int bufferSize)
virtual BaseDialoggetDialog ()=0
virtual ~MenuRenderer ()
char * getBuffer ()
uint8_t getBufferSize ()
RendererType getRendererType ()

Protected Member Functions

void countdownToDefaulting ()

Protected Attributes

uint8_t lastOffset
uint8_t updatesPerSecond
uint16_t ticksToReset
uint16_t resetValInTicks
MenuRedrawState redrawMode
union {
ResetCallbackFn resetCallback
bool isCustomDrawing
DisplayTakeoverMode displayTakenMode
RenderPressMode renderFnPressType
RendererCallbackFn renderCallback
- Protected Attributes inherited from MenuRenderer
char * buffer
uint8_t bufferSize
RendererType rendererType

Additional Inherited Members

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

Detailed Description

This class provides the base functionality that will be required by most implementations of renderer, you can extend this class to add new renderers, it proivides much of the core functionality that's needed by a renderer.

Renderers work in a similar way to a game loop, the render method is repeatedly called and in this loop any rendering or event callbacks should be handled.

Constructor & Destructor Documentation

◆ BaseMenuRenderer()

BaseMenuRenderer::BaseMenuRenderer ( int  bufferSize,
RendererType  rType = RENDER_TYPE_BASE 

constructs the renderer with a given buffer size

bufferSizesize of text buffer to create

◆ ~BaseMenuRenderer()

BaseMenuRenderer::~BaseMenuRenderer ( )

Destructs the class removing the allocated buffer

Member Function Documentation

◆ initialise()

void BaseMenuRenderer::initialise ( )

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

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

Implements MenuRenderer.

◆ setUpdatesPerSecond()

void BaseMenuRenderer::setUpdatesPerSecond ( int  updatesSec)

Set the number of updates per second for the display, use caution not to set too high, never set to 0.

updatesSecthe number of updates.

◆ setResetIntervalTimeSeconds()

void BaseMenuRenderer::setResetIntervalTimeSeconds ( uint16_t  interval)

Adjust the default reset interval of 30 seconds. Maximum value is 60 seconds. At this point the reset callback is called and the menu is reset to root with no present editor.


◆ setResetCallback()

void BaseMenuRenderer::setResetCallback ( ResetCallbackFn  resetFn)

Sets the callback that will receive reset events when the menu has not been edited for some time. You can optionally use an instance of CustomDrawing instead of this, and that will be notified of both reset events and take over display events.

◆ setCustomDrawingHandler()

void BaseMenuRenderer::setCustomDrawingHandler ( CustomDrawing customDrawingParam)

Sets the CustomDrawing implementation that will handle both the reset event and also any custom drawing that needs to be done. The reset method will be called whenever the display times out back to it's defaults, the started will be called when the display is first taken over, followed by renderLoop until it's given back.

◆ exec()

void BaseMenuRenderer::exec ( )

Called by taskManager when we are scheduled

◆ render()

virtual void BaseMenuRenderer::render ( )
pure virtual

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

Implemented in tcgfx::BaseGraphicalRenderer.

◆ tryTakeSelectIfNeeded()

bool BaseMenuRenderer::tryTakeSelectIfNeeded ( int  currentReading,
RenderPressMode  pressMode 

If this renderer has been taken over, displaying a dialog or needs to do something special with a button press, then this function can take action BEFORE anything else

editorthe current editor
Ah it

Implements MenuRenderer.

◆ getMenuItemAtIndex()

MenuItem * BaseMenuRenderer::getMenuItemAtIndex ( MenuItem pItem,
uint8_t  idx 

Gets the menu item at a specific position

rootthe root item
idxthe index to find
the item at the index or root.

Reimplemented in tcgfx::BaseGraphicalRenderer.

◆ findActiveItem()

int BaseMenuRenderer::findActiveItem ( MenuItem root)

Find the active item offset in the list

rootthe root item
the position 0 based.

Reimplemented in tcgfx::BaseGraphicalRenderer.

◆ itemCount()

uint8_t BaseMenuRenderer::itemCount ( MenuItem item,
bool  includeNonVisible 

Get the count of items in the current root

itemthe root item
includeNonVisibleif non visible should be included
the count

Reimplemented in tcgfx::BaseGraphicalRenderer.

◆ setFirstWidget()

void BaseMenuRenderer::setFirstWidget ( TitleWidget widget)

For menu systems that support title widgets, this will allow the first widget.

thefirst widget in a chain of widgets linked by next pointer.

◆ menuAltered()

void BaseMenuRenderer::menuAltered ( )

Called when the menu has been altered, to reset the countdown to reset behaviour

◆ takeOverDisplay()

void BaseMenuRenderer::takeOverDisplay ( RendererCallbackFn  displayFn = nullptr)

In order to take over the display, provide a callback function that will receive the regular render call backs instead of this renderer. If you have already registered a custom drawing class that implements CustomDrawing by calling setCustomDrawing(..) then you can omit the display function parameter, and your custom drawing class will be called instead.

displayFnthe callback to render the display

◆ giveBackDisplay()

void BaseMenuRenderer::giveBackDisplay ( )

Call this method to clear custom display rendering after a call to takeOverDisplay. It will cause a complete repaint of the display.

◆ resetToDefault()

void BaseMenuRenderer::resetToDefault ( )

Used to reset the display to it's default state, root menu, nothing being edited

◆ redrawRequirement()

void BaseMenuRenderer::redrawRequirement ( MenuRedrawState  state)

Sets the type of redraw that is needed

statethe required redraw

◆ menuValueToText()

void BaseMenuRenderer::menuValueToText ( MenuItem item,
MenuDrawJustification  justification 

Convert a menu item into a textual representation in the buffer

itemthe menu item
justificationuse either JUSTIFY_TEXT_LEFT or JUSTIFY_TEXT_RIGHT

◆ invalidateAll()

void BaseMenuRenderer::invalidateAll ( )

Completely invalidate all drawing and instigate a complete redraw of all elements.

◆ countdownToDefaulting()

void BaseMenuRenderer::countdownToDefaulting ( )

set up a countdown to default back to the submenu

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