UiUiUi
A user interface library for micro controller sketches based on U8g2
UIDisplay.h
1 // SPDX-License-Identifier: BSD-2-Clause
2 // (C) 2022 Dirk Hillbrecht
3 
4 #pragma once
5 
6 #include "Arduino.h"
7 #include <U8g2lib.h>
8 
9 #include "UIArea.h"
10 #include "UIWidget.h"
11 #include "UIParent.h"
12 
24 class UIDisplay: public UIParent {
25 
26  public:
27 
46  UIDisplay(UIWidget* root);
47 
58  void init(U8G2* display,bool enable=true,bool render=true);
59 
75  void setUpdateTiles(uint16_t maxFirstUpdateTiles=0xffff,uint16_t maxFollowUpdateTiles=0xffff);
76 
84  void enable(U8G2* display,bool render=false,bool force=false);
85 
94  void disable(U8G2* display);
95 
109  void deactivate();
110 
120  void activate();
121 
123  void childNeedsRendering(UIWidget *child);
124 
135  void render(U8G2* display,bool force=false);
136 
143  bool isUpdatingDisplay();
144 
145  private:
146 
148  UIWidget* root;
149 
151  bool enabled;
152 
154  bool active;
155 
157  bool renderingNeeded;
158 
160  uint16_t maxFirstUpdateTiles;
161 
163  uint16_t maxFollowUpdateTiles;
164 
166  UIArea updateTiles;
167 
169  UIArea furtherUpdateTiles;
170 
177  void doUpdateTiles(U8G2 *display,uint16_t maxUpdateTiles);
178 
179 };
180 
181 // end of file
Area consisting of left, top, right, and bottom value.
Definition: UIArea.h:20
Representation of the display onto which UiUiUi renders its user interface.
Definition: UIDisplay.h:24
void setUpdateTiles(uint16_t maxFirstUpdateTiles=0xffff, uint16_t maxFollowUpdateTiles=0xffff)
Sets or changes the number of tiles to be sent to the display in one chunk.
Definition: UIDisplay.cpp:43
void enable(U8G2 *display, bool render=false, bool force=false)
Enable the UI: It presents itself on screen, display is turned on.
Definition: UIDisplay.cpp:49
void render(U8G2 *display, bool force=false)
Render the interface, update everything that has changed since the last render() call.
Definition: UIDisplay.cpp:112
void activate()
Activates the UI: Rendering will be performed if render() is called.
Definition: UIDisplay.cpp:72
void childNeedsRendering(UIWidget *child)
Called by the root widget to indicate that rendering must be performed.
Definition: UIDisplay.cpp:77
UIDisplay(UIWidget *root)
Setup the UIDisplay onto the given U8g2 instance and with the given root widget.
Definition: UIDisplay.cpp:14
void init(U8G2 *display, bool enable=true, bool render=true)
Initialize the whole user interface, layout the widgets.
Definition: UIDisplay.cpp:20
bool isUpdatingDisplay()
Returns whether the UI is updating the display due to some earlier call to render().
Definition: UIDisplay.cpp:133
void disable(U8G2 *display)
Disables the UI: No rendering and display is switched to powersaving mode.
Definition: UIDisplay.cpp:59
void deactivate()
Deactivates the UI: It will be shown but no rendering will be performed.
Definition: UIDisplay.cpp:67
Simple abstraction of elements which have at least one child.
Definition: UIParent.h:14
Basic widget class, ancestor of all UI widgets.
Definition: UIWidget.h:36