UiUiUi
A user interface library for micro controller sketches based on U8g2
UICards.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 // Basic helper classes and definitions
10 #include "UIEnums.h"
11 #include "UIPoint.h"
12 #include "UISize.h"
13 #include "UIArea.h"
14 
15 // Simple widgets
16 #include "UIWidget.h"
17 #include "UIWidgetGroup.h"
18 
19 
35 class UICards: public UIWidgetGroup {
36 
37  public:
38 
41 
43  void layout(U8G2* display,UIArea* dim);
44 
53  void setVisibleWidget(UIWidget *visible);
54 
56  void hide();
57 
59  void showFirstWidget();
60 
62  UIArea* render(U8G2 *display,bool force);
63 
65  void childNeedsRendering(UIWidget *child);
66 
67  protected:
68 
70  void computePreferredSize(U8G2 *display,UISize *preferredSize);
71 
72  private:
73 
75  UIWidget *visible;
76 
78  bool forceInternally;
79 
80 };
81 
82 // end of file
Area consisting of left, top, right, and bottom value.
Definition: UIArea.h:20
Widget group which shows nothing or exactly one of its sub-widgets.
Definition: UICards.h:35
void layout(U8G2 *display, UIArea *dim)
Layout the cards widget.
Definition: UICards.cpp:24
void showFirstWidget()
Shortcut: Show first widget.
Definition: UICards.cpp:45
void setVisibleWidget(UIWidget *visible)
Set the widget to show on the area of the cards widget group.
Definition: UICards.cpp:33
void computePreferredSize(U8G2 *display, UISize *preferredSize)
Compute the preferred size as the maximum envelope of the preferred sizes of all subwidgets.
Definition: UICards.cpp:68
void childNeedsRendering(UIWidget *child)
UICards will consider the render request from the child only if it is the currently visible child.
Definition: UICards.cpp:77
UIArea * render(U8G2 *display, bool force)
Render the cards widget group onto the display.
Definition: UICards.cpp:49
void hide()
Shortcut: Hide all widgets, clear the UICards area on the display.
Definition: UICards.cpp:41
UICards(UIWidget *firstChild, UIWidget *next=nullptr)
Initialize the cards widget with the first widget and a potential successor on the same level.
Definition: UICards.cpp:21
Representation of a size, i.e.
Definition: UISize.h:9
Main abstraction of a group of interface widgets.
Definition: UIWidgetGroup.h:29
UIWidget * firstChild
The first of the widgets grouped by this widget group.
Definition: UIWidgetGroup.h:45
Basic widget class, ancestor of all UI widgets.
Definition: UIWidget.h:36
UIArea dim
Actual area of this widget, set in layout().
Definition: UIWidget.h:80
UISize preferredSize(U8G2 *display)
Return the preferred size of this widget, will be called before a call to layout().
Definition: UIWidget.cpp:16
UIWidget * next
Pointer to the next widget on the same level.
Definition: UIWidget.h:65