tcMenu
Loading...
Searching...
No Matches
GraphicsDeviceRenderer.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 https://www.thecoderscorner.com (Dave Cherry).
3 * This product is licensed under an Apache license, see the LICENSE file in the top-level directory.
4 */
5
10
11#ifndef TCLIBRARYDEV_GRAPHICSDEVICERENDERER_H
12#define TCLIBRARYDEV_GRAPHICSDEVICERENDERER_H
13
14#include <PlatformDetermination.h>
15#include "../tcMenu.h"
17#include "GfxMenuConfig.h"
18#include "DeviceDrawable.h"
20#include "TcDrawableButton.h"
22
23#ifndef MINIMUM_CURSOR_SIZE
24#define MINIMUM_CURSOR_SIZE 6
25#endif // MINIMUM_CURSOR_SIZE
26
27namespace tcgfx {
28
29 class CardLayoutPane;
30
35 class DrawableTextPlotPipeline : public TextPlotPipeline {
36 private:
37 DeviceDrawable *drawable;
38 Coord cursor;
39 public:
40 explicit DrawableTextPlotPipeline(DeviceDrawable *drawable) : drawable(drawable) {}
41 void drawPixel(uint16_t x, uint16_t y, uint32_t color) override {
42 drawable->setDrawColor(color);
43 drawable->drawPixel(x, y);
44 }
45 void setCursor(const Coord& where) override { cursor = where; }
46 Coord getCursor() override { return cursor; }
47 Coord getDimensions() override { return drawable->getDisplayDimensions(); }
48 };
49
59 class GraphicsDeviceRenderer : public BaseGraphicalRenderer {
60 private:
61 DeviceDrawable* rootDrawable;
64 CardLayoutPane* cardLayoutPane = nullptr;
65 bool redrawNeeded = false;
66 public:
67 GraphicsDeviceRenderer(int bufferSize, const char *appTitle, DeviceDrawable *drawable);
68
69 void drawWidget(Coord where, TitleWidget *widget, color_t colorFg, color_t colorBg) override;
70 void drawMenuItem(GridPositionRowCacheEntry *entry, Coord where, Coord areaSize, const DrawingFlags& drawingFlags) override;
71 void drawingCommand(RenderDrawingCommand command) override;
72
73 void fillWithBackgroundTo(int endPoint) override;
74
82 int heightForFontPadding(const void *font, int mag, MenuPadding &padding);
83
90 void setGraphicsConfiguration(void* gfxConfig);
91
99 void prepareDisplay(bool monoPalette, const void *itemFont, int magItem, const void *titleFont, int magTitle, bool needEditingIcons);
100
106 ItemDisplayPropertiesFactory &getDisplayPropertiesFactory() override { return propertiesFactory; }
107
113
120 DeviceDrawable* getDeviceDrawable() { return rootDrawable; }
121
126 void enableTcUnicode() { rootDrawable->enableTcUnicode(); }
127
139 void enableCardLayout(const DrawableIcon& left, const DrawableIcon& right, MenuTouchScreenManager* touchManager, bool monoDisplay);
140
148 void setCardLayoutStatusForSubMenu(MenuItem* root, bool onOrOff);
149
150 LayoutMode getLayoutMode(MenuItem* rootItem) override;
151
157 void setDrawable(DeviceDrawable* drawable);
158
159 protected:
167 void subMenuRender(MenuItem* rootItem, uint8_t& locRedrawMode, bool& forceDrawWidgets) override;
168 bool isActiveOrEditing(MenuItem* pItem, const DrawingFlags& drawingFlags);
169 private:
170 int calculateSpaceBetween(const void* font, uint8_t mag, const char* buffer, int start, int end);
171 void internalDrawText(GridPositionRowCacheEntry* pEntry, const Coord& where, const Coord& size, const DrawingFlags& drawingFlags);
172 void drawCoreLineItem(GridPositionRowCacheEntry* entry, DrawableIcon* icon, Coord &where, Coord &size,
173 const DrawingFlags& drawingFlags, bool drawBg);
174 void drawTextualItem(GridPositionRowCacheEntry* entry, Coord& where, Coord& size, const DrawingFlags& drawingFlags);
175 void drawCheckbox(GridPositionRowCacheEntry *entry, Coord& where, Coord& size, const DrawingFlags& drawingFlags);
176 void drawSlider(GridPositionRowCacheEntry* entry, AnalogMenuItem* pItem, Coord& where, Coord& size, const DrawingFlags& drawingFlags);
177 void drawUpDownItem(GridPositionRowCacheEntry* entry, Coord& where, Coord& size, const DrawingFlags& drawingFlags);
178 void drawIconItem(GridPositionRowCacheEntry *pEntry, Coord& where, Coord& size, const DrawingFlags& drawingFlags);
179 void drawBorderAndAdjustSize(Coord &where, Coord &size, MenuBorder &border);
180
181 DrawableIcon *getStateIndicatorIcon(GridPositionRowCacheEntry *entry);
182 };
183} // namespace tcgfx
184
185#endif //TCLIBRARYDEV_GRAPHICSDEVICERENDERER_H
Contains the base functionality for all graphical renderers.
LayoutMode
Definition BaseGraphicalRenderer.h:89
A few helper classes that provides useful functions on top of a tcMenu device drawable.
uint32_t color_t
Definition DrawingPrimitives.h:29
contains the interface between the touch screen and tcMenu.
a button that can be rendered onto any drawable, remembers it's position, and can integrate with touc...
Definition MenuItems.h:485
Definition MenuItems.h:338
Definition BaseRenderers.h:126
RenderDrawingCommand
Definition BaseGraphicalRenderer.h:147
Definition CardLayoutPanel.h:54
Definition DeviceDrawableHelper.h:116
Definition DeviceDrawable.h:34
Definition DrawingPrimitives.h:152
Definition BaseGraphicalRenderer.h:37
void setCardLayoutStatusForSubMenu(MenuItem *root, bool onOrOff)
Definition GraphicsDeviceRenderer.cpp:504
void setDrawable(DeviceDrawable *drawable)
Definition GraphicsDeviceRenderer.cpp:518
void setGraphicsConfiguration(void *gfxConfig)
Definition GraphicsDeviceRenderer.cpp:433
void enableCardLayout(const DrawableIcon &left, const DrawableIcon &right, MenuTouchScreenManager *touchManager, bool monoDisplay)
Definition GraphicsDeviceRenderer.cpp:496
void subMenuRender(MenuItem *rootItem, uint8_t &locRedrawMode, bool &forceDrawWidgets) override
Definition GraphicsDeviceRenderer.cpp:459
void enableTcUnicode()
Definition GraphicsDeviceRenderer.h:126
int heightForFontPadding(const void *font, int mag, MenuPadding &padding)
Definition GraphicsDeviceRenderer.cpp:424
void fillWithBackgroundTo(int endPoint) override
Definition GraphicsDeviceRenderer.cpp:452
void drawWidget(Coord where, TitleWidget *widget, color_t colorFg, color_t colorBg) override
Definition GraphicsDeviceRenderer.cpp:51
void prepareDisplay(bool monoPalette, const void *itemFont, int magItem, const void *titleFont, int magTitle, bool needEditingIcons)
void drawMenuItem(GridPositionRowCacheEntry *entry, Coord where, Coord areaSize, const DrawingFlags &drawingFlags) override
Definition GraphicsDeviceRenderer.cpp:57
DeviceDrawable * getDeviceDrawable()
Definition GraphicsDeviceRenderer.h:120
ConfigurableItemDisplayPropertiesFactory & getGraphicsPropertiesFactory()
Definition GraphicsDeviceRenderer.h:112
void drawingCommand(RenderDrawingCommand command) override
Definition GraphicsDeviceRenderer.cpp:35
LayoutMode getLayoutMode(MenuItem *rootItem) override
Definition GraphicsDeviceRenderer.cpp:512
ItemDisplayPropertiesFactory & getDisplayPropertiesFactory() override
Definition GraphicsDeviceRenderer.h:106
Definition BaseGraphicalRenderer.h:60
Definition GfxMenuConfig.h:358
Definition MenuTouchScreenEncoder.h:84
This file contains the base drawing structures and helper methods for drawing onto graphical screens,...
Definition DrawingPrimitives.h:123
Definition DrawingPrimitives.h:92
Definition DrawingPrimitives.h:56
The menu manager is responsible for managing a set of menu items, and is configured with a renderer a...