2 #ifndef TCMENU_DRAWABLE_DASHBOARD_H
3 #define TCMENU_DRAWABLE_DASHBOARD_H
11 #include <tcUnicodeHelper.h>
26 TITLE_LEFT_VALUE_LEFT, TITLE_LEFT_VALUE_RIGHT,
27 NO_TITLE_VALUE_LEFT, NO_TITLE_VALUE_RIGHT,
28 TITLE_RIGHT_VALUE_LEFT, TITLE_RIGHT_VALUE_RIGHT,
34 DeviceFontDrawingMode fontMode;
67 bool isTitleDrawn() {
return alignment != NO_TITLE_VALUE_LEFT && alignment != NO_TITLE_VALUE_RIGHT; }
71 bool isTitleLeftAlign() {
return alignment == TITLE_LEFT_VALUE_LEFT || alignment == TITLE_LEFT_VALUE_RIGHT; }
75 bool isValueLeftAlign() {
return alignment == TITLE_RIGHT_VALUE_LEFT || alignment == TITLE_LEFT_VALUE_LEFT || alignment == NO_TITLE_VALUE_LEFT; }
80 const DeviceFontDrawingMode&
getFontMode()
const {
return fontMode; }
110 color_t fgUpdateColor;
111 color_t bgUpdateColor;
114 const GFXfont* font_,
DashAlign align = TITLE_RIGHT_VALUE_RIGHT) :
116 bgUpdateColor(bgUpdateColor_) {}
118 const UnicodeFont* font_,
DashAlign align = TITLE_RIGHT_VALUE_RIGHT) :
120 bgUpdateColor(bgUpdateColor_) {}
122 const NativeFontDesc& font_,
DashAlign align = TITLE_RIGHT_VALUE_RIGHT) :
124 bgUpdateColor(bgUpdateColor_) {}
126 color_t
getBgColor(
MenuItem* item,
bool updated)
override {
return updated ? bgUpdateColor : bgColor; }
128 color_t
getFgColor(
MenuItem* item,
bool updated)
override {
return updated ? fgUpdateColor : fgColor; }
152 const GFXfont *font_,
const IntColorRange colorRanges_[],
int numberRanges,
153 DashAlign align = TITLE_RIGHT_VALUE_RIGHT) :
155 colorRanges(colorRanges_), numOfRanges(numberRanges), useUpdateColor(fgColor_ != fgUpdateColor_ || bgColor_ != bgUpdateColor_) { }
158 const UnicodeFont *font_,
const IntColorRange colorRanges_[],
int numberRanges,
159 DashAlign align = TITLE_RIGHT_VALUE_RIGHT) :
161 colorRanges(colorRanges_), numOfRanges(numberRanges), useUpdateColor(fgColor_ != fgUpdateColor_ || bgColor_ != bgUpdateColor_) { }
164 const NativeFontDesc& font_,
const IntColorRange colorRanges_[],
int numberRanges,
165 DashAlign align = TITLE_RIGHT_VALUE_RIGHT) :
167 colorRanges(colorRanges_), numOfRanges(numberRanges), useUpdateColor(fgColor_ != fgUpdateColor_ || bgColor_ != bgUpdateColor_) { }
169 int findIndexForChoice(
MenuItem* item);
194 const GFXfont *font_,
const TextColorOverride colorOverrides_[],
int numberRanges,
195 DashAlign align = TITLE_RIGHT_VALUE_RIGHT) :
196 DashDrawParametersUpdate(fgColor_, bgColor_, fgUpdateColor_, bgUpdateColor_, font_, align), colorOverrides(colorOverrides_),
197 numOfRanges(numberRanges), useUpdateColor(fgColor_ != fgUpdateColor_ || bgColor_ != bgUpdateColor_) {}
200 const UnicodeFont *font_,
const TextColorOverride colorOverrides_[],
int numberRanges,
201 DashAlign align = TITLE_RIGHT_VALUE_RIGHT) :
202 DashDrawParametersUpdate(fgColor_, bgColor_, fgUpdateColor_, bgUpdateColor_, font_, align), colorOverrides(colorOverrides_),
203 numOfRanges(numberRanges), useUpdateColor(fgColor_ != fgUpdateColor_ || bgColor_ != bgUpdateColor_) {}
206 const NativeFontDesc &font_,
const TextColorOverride colorOverrides_[],
int numberRanges,
207 DashAlign align = TITLE_RIGHT_VALUE_RIGHT) :
208 DashDrawParametersUpdate(fgColor_, bgColor_, fgUpdateColor_, bgUpdateColor_, font_, align), colorOverrides(colorOverrides_),
209 numOfRanges(numberRanges), useUpdateColor(fgColor_ != fgUpdateColor_ || bgColor_ != bgUpdateColor_) {}
211 int findIndexForChoice(
MenuItem* item);
237 DashMenuItem() : dashboard(
nullptr), item(
nullptr), screenLoc(0, 0), parameters(
nullptr), updateCountDown(0), titleExtents(0, 0),
238 numChars(0), valueWidth(0), countDownTicks(0), baseline(0), titleText() {}
243 uint16_t getKey()
const {
244 return item !=
nullptr ? item->
getId() : 0;
247 bool needsPainting();
248 void paintTitle(DeviceDrawable* canvasDrawable);
249 void paintItem(DeviceDrawable* canvasDrawable);
300 enum DashboardMode: uint8_t { DASH_ON_RESET_CLICK_EXIT, DASH_ON_RESET_MANUAL_EXIT, DASH_FULLY_MANUAL, DASH_MANUAL_START_CLICK_EXIT };
304 BaseGraphicalRenderer *renderer;
305 DeviceDrawable *drawable;
306 BtreeList<uint16_t, DashMenuItem> drawingItems;
307 color_t screenBg = 0;
308 color_t coreItemFg = 0;
313 : firstWidget(widgets), renderer(renderer), drawable(device), drawingItems(), drawingMode(drawingMode), running(false) { }
315 void setBaseColors(color_t screenBgCol, color_t coreFgCol) {
316 screenBg = screenBgCol;
317 coreItemFg = coreFgCol;
321 void clearItems() { drawingItems.clear(); }
323 const char* titleOverrideText =
nullptr,
int updateTicks = 5);
325 void reset()
override;
336 void drawWidgets(
bool force);
338 uint8_t getDisplayNumber() {
return renderer->getDisplayNumber(); }
The base definitions and classes shared by all TcMenu renderers.
RenderPressMode
Definition: BaseRenderers.h:50
A few helper classes that provides useful functions on top of a tcMenu device drawable.
uint32_t color_t
Definition: DrawingPrimitives.h:29
the interface that all graphics devices should implement to do the actual graphics rendering.
Definition: BaseRenderers.h:76
Definition: DrawableDashboard.h:20
DashDrawParameters(color_t fgColor_, color_t bgColor_, const GFXfont *font_, DashAlign align=TITLE_RIGHT_VALUE_RIGHT)
Creates a dash parameter that has a background, foreground, font, and alignment. In this case the fon...
DashDrawParameters(color_t fgColor_, color_t bgColor_, const NativeFontDesc &font_, DashAlign align=TITLE_RIGHT_VALUE_RIGHT)
Creates a dash parameter that has a background, foreground, font, and alignment. In this case the fon...
bool isValueLeftAlign()
Definition: DrawableDashboard.h:75
DashAlign
Definition: DrawableDashboard.h:25
virtual color_t getFgColor(MenuItem *item, bool updated)
Definition: DrawableDashboard.h:91
DashDrawParameters(color_t fgColor_, color_t bgColor_, const UnicodeFont *font_, DashAlign align=TITLE_RIGHT_VALUE_RIGHT)
Creates a dash parameter that has a background, foreground, font, and alignment. In this case the fon...
virtual color_t getTitleFgColor(MenuItem *item, bool updated)
Definition: DrawableDashboard.h:102
bool isTitleLeftAlign()
Definition: DrawableDashboard.h:71
virtual color_t getTitleBgColor(MenuItem *item, bool updated)
Definition: DrawableDashboard.h:97
virtual color_t getBgColor(MenuItem *item, bool updated)
Definition: DrawableDashboard.h:86
bool isTitleDrawn()
Definition: DrawableDashboard.h:67
const DeviceFontDrawingMode & getFontMode() const
Definition: DrawableDashboard.h:80
Definition: DrawableDashboard.h:138
Definition: DrawableDashboard.h:140
Definition: DrawableDashboard.h:181
Definition: DrawableDashboard.h:183
Definition: DrawableDashboard.h:108
color_t getFgColor(MenuItem *item, bool updated) override
Definition: DrawableDashboard.h:128
color_t getBgColor(MenuItem *item, bool updated) override
Definition: DrawableDashboard.h:126
Definition: DrawableDashboard.h:258
virtual void dashboardDidOpen(BaseMenuRenderer *)
Definition: DrawableDashboard.h:272
virtual void dashboardWillDraw(unsigned int, RenderPressMode)
Definition: DrawableDashboard.h:277
virtual void dashboardDidDraw(unsigned int, RenderPressMode)
Definition: DrawableDashboard.h:282
virtual bool dashboardWillOpen(BaseMenuRenderer *)
Definition: DrawableDashboard.h:268
virtual void dashboardDidClose()
Definition: DrawableDashboard.h:263
virtual void displayDidReset()
Definition: DrawableDashboard.h:286
Definition: DrawableDashboard.h:297
DashboardMode
Definition: DrawableDashboard.h:300
void renderLoop(unsigned int currentValue, RenderPressMode userClick) override
Definition: DrawableDashboard.cpp:53
void started(BaseMenuRenderer *currentRenderer) override
Definition: DrawableDashboard.cpp:26
void reset() override
Definition: DrawableDashboard.cpp:19