tcMenu
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 LiquidCrystalRenderer tcgfx::BaseGraphicalRenderer tcgfx::GraphicsDeviceRenderer

Public Types

enum  DisplayTakeoverMode { NOT_TAKEN_OVER, TAKEN_OVER_FN, START_CUSTOM_DRAW, RUNNING_CUSTOM_DRAW }
 

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
 
void setFirstWidget (TitleWidget *widget)
 
void menuAltered ()
 
void takeOverDisplay (RendererCallbackFn displayFn=nullptr)
 
void giveBackDisplay ()
 
void resetToDefault ()
 
void prepareNewSubmenu ()
 
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
 
TitleWidgetfirstWidget
 
union {
ResetCallbackFn resetCallback
 
CustomDrawingcustomDrawing
 
}; 
 
bool isCustomDrawing
 
DisplayTakeoverMode displayTakenMode
 
BaseDialogdialog
 
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

Parameters
bufferSizesize of text buffer to create

◆ ~BaseMenuRenderer()

BaseMenuRenderer::~BaseMenuRenderer ( )
inlineoverride

Destructs the class removing the allocated buffer

Member Function Documentation

◆ initialise()

void BaseMenuRenderer::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

Implements MenuRenderer.

Reimplemented in LiquidCrystalRenderer.

◆ setUpdatesPerSecond()

void BaseMenuRenderer::setUpdatesPerSecond ( int  updatesSec)
inline

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

Parameters
updatesSecthe number of updates.

◆ setResetIntervalTimeSeconds()

void BaseMenuRenderer::setResetIntervalTimeSeconds ( uint16_t  interval)
inline

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.

Parameters
resetTime

◆ setResetCallback()

void BaseMenuRenderer::setResetCallback ( ResetCallbackFn  resetFn)
inline

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)
inline

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 ( )
override

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, and LiquidCrystalRenderer.

◆ tryTakeSelectIfNeeded()

bool BaseMenuRenderer::tryTakeSelectIfNeeded ( int  currentReading,
RenderPressMode  pressMode 
)
overridevirtual

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

Parameters
editorthe current editor
Returns
Ah it

Implements MenuRenderer.

◆ setFirstWidget()

void BaseMenuRenderer::setFirstWidget ( TitleWidget widget)

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

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

◆ menuAltered()

void BaseMenuRenderer::menuAltered ( )
inline

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.

Parameters
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

◆ prepareNewSubmenu()

void BaseMenuRenderer::prepareNewSubmenu ( )

Used to set up a new submenu for display on the renderer

Parameters
newItemsthe new submenu

◆ redrawRequirement()

void BaseMenuRenderer::redrawRequirement ( MenuRedrawState  state)
inline

Sets the type of redraw that is needed

Parameters
statethe required redraw

◆ menuValueToText()

void BaseMenuRenderer::menuValueToText ( MenuItem item,
MenuDrawJustification  justification 
)

Convert a menu item into a textual representation in the buffer

Parameters
itemthe menu item
justificationuse either JUSTIFY_TEXT_LEFT or JUSTIFY_TEXT_RIGHT

◆ invalidateAll()

void BaseMenuRenderer::invalidateAll ( )
inline

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

◆ countdownToDefaulting()

void BaseMenuRenderer::countdownToDefaulting ( )
protected

set up a countdown to default back to the submenu


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