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 color_t overallScreenBgColor = RGB(0, 0, 0);
66 bool redrawNeeded = false;
67 public:
68 GraphicsDeviceRenderer(int bufferSize, const char *appTitle, DeviceDrawable *drawable);
69
70 void drawWidget(Coord where, TitleWidget *widget, color_t colorFg, color_t colorBg) override;
71 void drawMenuItem(GridPositionRowCacheEntry *entry, Coord where, Coord areaSize, const DrawingFlags& drawingFlags) override;
72 void drawingCommand(RenderDrawingCommand command) override;
73
74 void fillWithBackgroundTo(int endPoint) override;
75
84 int heightForFontPadding(const void *font, int mag, MenuPadding &padding, const MenuBorder &border);
85
92 void setGraphicsConfiguration(void* gfxConfig);
93
101 void prepareDisplay(bool monoPalette, const void *itemFont, int magItem, const void *titleFont, int magTitle, bool needEditingIcons);
102
108 ItemDisplayPropertiesFactory &getDisplayPropertiesFactory() override { return propertiesFactory; }
109
115
122 DeviceDrawable* getDeviceDrawable() { return rootDrawable; }
123
128 void enableTcUnicode() { rootDrawable->enableTcUnicode(); }
129
141 void enableCardLayout(const DrawableIcon& left, const DrawableIcon& right, MenuTouchScreenManager* touchManager, bool monoDisplay);
142
150 void setCardLayoutStatusForSubMenu(MenuItem* root, bool onOrOff);
151
152 LayoutMode getLayoutMode(MenuItem* rootItem) override;
153
159 void setDrawable(DeviceDrawable* drawable);
160
161 protected:
169 void subMenuRender(MenuItem* rootItem, uint8_t& locRedrawMode, bool& forceDrawWidgets) override;
170 bool isActiveOrEditing(MenuItem* pItem, const DrawingFlags& drawingFlags) const;
171 private:
172 int calculateSpaceBetween(const void* font, uint8_t mag, const char* buffer, int start, int end);
173 void internalDrawText(GridPositionRowCacheEntry* pEntry, const Coord& where, const Coord& size, const DrawingFlags& drawingFlags);
174 void drawCoreLineItem(GridPositionRowCacheEntry* entry, DrawableIcon* icon, Coord &where, Coord &size,
175 const DrawingFlags& drawingFlags, bool drawBg);
176 void drawTextualItem(GridPositionRowCacheEntry* entry, Coord& where, Coord& size, const DrawingFlags& drawingFlags);
177 void drawCheckbox(GridPositionRowCacheEntry *entry, Coord& where, Coord& size, const DrawingFlags& drawingFlags);
178 void drawSlider(GridPositionRowCacheEntry* entry, AnalogMenuItem* pItem, Coord& where, Coord& size, const DrawingFlags& drawingFlags);
179 void drawUpDownItem(GridPositionRowCacheEntry* entry, Coord& where, Coord& size, const DrawingFlags& drawingFlags);
180 void drawIconItem(GridPositionRowCacheEntry *pEntry, Coord& where, Coord& size, const DrawingFlags& drawingFlags);
181 void drawBorderAndAdjustSize(Coord &where, Coord &size, MenuBorder &border);
182 void roundCornerLeft(int16_t direction, int radius, Coord where);
183 void roundCornerRight(int16_t direction, int radius, Coord where);
184
185 DrawableIcon *getStateIndicatorIcon(GridPositionRowCacheEntry *entry);
186 };
187} // namespace tcgfx
188
189#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:493
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:178
Definition BaseGraphicalRenderer.h:37
void setCardLayoutStatusForSubMenu(MenuItem *root, bool onOrOff)
Definition GraphicsDeviceRenderer.cpp:633
void setDrawable(DeviceDrawable *drawable)
Definition GraphicsDeviceRenderer.cpp:647
void setGraphicsConfiguration(void *gfxConfig)
Definition GraphicsDeviceRenderer.cpp:563
void enableCardLayout(const DrawableIcon &left, const DrawableIcon &right, MenuTouchScreenManager *touchManager, bool monoDisplay)
Definition GraphicsDeviceRenderer.cpp:625
void subMenuRender(MenuItem *rootItem, uint8_t &locRedrawMode, bool &forceDrawWidgets) override
Definition GraphicsDeviceRenderer.cpp:588
void enableTcUnicode()
Definition GraphicsDeviceRenderer.h:128
void fillWithBackgroundTo(int endPoint) override
Definition GraphicsDeviceRenderer.cpp:582
void drawWidget(Coord where, TitleWidget *widget, color_t colorFg, color_t colorBg) override
Definition GraphicsDeviceRenderer.cpp:56
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:62
DeviceDrawable * getDeviceDrawable()
Definition GraphicsDeviceRenderer.h:122
int heightForFontPadding(const void *font, int mag, MenuPadding &padding, const MenuBorder &border)
Definition GraphicsDeviceRenderer.cpp:550
ConfigurableItemDisplayPropertiesFactory & getGraphicsPropertiesFactory()
Definition GraphicsDeviceRenderer.h:114
void drawingCommand(RenderDrawingCommand command) override
Definition GraphicsDeviceRenderer.cpp:38
LayoutMode getLayoutMode(MenuItem *rootItem) override
Definition GraphicsDeviceRenderer.cpp:641
ItemDisplayPropertiesFactory & getDisplayPropertiesFactory() override
Definition GraphicsDeviceRenderer.h:108
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:149
Definition DrawingPrimitives.h:107
Definition DrawingPrimitives.h:56
The menu manager is responsible for managing a set of menu items, and is configured with a renderer a...