UiUiUi
A user interface library for micro controller sketches based on U8g2
|
Widget group which shows nothing or exactly one of its sub-widgets. More...
#include <UICards.h>
Public Member Functions | |
UICards (UIWidget *firstChild, UIWidget *next=nullptr) | |
Initialize the cards widget with the first widget and a potential successor on the same level. | |
void | layout (U8G2 *display, UIArea *dim) |
Layout the cards widget. More... | |
void | setVisibleWidget (UIWidget *visible) |
Set the widget to show on the area of the cards widget group. More... | |
void | hide () |
Shortcut: Hide all widgets, clear the UICards area on the display. | |
void | showFirstWidget () |
Shortcut: Show first widget. | |
UIArea * | render (U8G2 *display, bool force) |
Render the cards widget group onto the display. More... | |
void | childNeedsRendering (UIWidget *child) |
UICards will consider the render request from the child only if it is the currently visible child. More... | |
![]() | |
UIWidgetGroup (UIWidget *firstChild, UIWidget *next=nullptr) | |
Create a widget group with a linked list of sub-widgets and a potential successor. | |
UIArea * | render (U8G2 *display, bool force) |
Default implementation of rendering a widget group is to render all of its sub-widgets. More... | |
virtual void | childNeedsRendering (UIWidget *child) |
Called by any child of this group to indicate that it wants to be rendered. More... | |
![]() | |
UISize | preferredSize (U8G2 *display) |
Return the preferred size of this widget, will be called before a call to layout(). More... | |
virtual void | layout (U8G2 *display, UIArea *area) |
Layout widget in the given rectanglar area, will be called before first call to render(). More... | |
virtual UIArea * | render (U8G2 *display, bool force)=0 |
Render component in the space given in layout(). More... | |
virtual void | setParent (UIParent *parent) |
Set the parent widget group (if it exists). More... | |
virtual void | childNeedsRendering (UIWidget *child)=0 |
Called by any child of this group to indicate that it wants to be rendered. More... | |
Protected Member Functions | |
void | computePreferredSize (U8G2 *display, UISize *preferredSize) |
Compute the preferred size as the maximum envelope of the preferred sizes of all subwidgets. More... | |
![]() | |
UIWidget (UIWidget *next=nullptr) | |
Initialize this widget and potentially set its successor. | |
void | clearBox (U8G2 *display, UIArea *dimm) |
Clear the given area. | |
void | clearFull (U8G2 *display) |
Clear the full area of this widget. | |
void | clip (U8G2 *display) |
Set U8g2's clip window to the area of this widget, should be called from render(). | |
virtual void | computePreferredSize (U8G2 *display, UISize *preferredSize)=0 |
Store preferred size of this widget into the preferredSize reference. More... | |
void | signalNeedsRendering () |
Called internally: Signals to parent that this widget needs to be rendered. | |
Additional Inherited Members | |
![]() | |
UIWidget * | next |
Pointer to the next widget on the same level. | |
![]() | |
UIWidget * | firstChild |
The first of the widgets grouped by this widget group. | |
bool | renderChildren |
Flag whether any child of this group needs to be rendered. | |
![]() | |
UIArea | dim |
Actual area of this widget, set in layout(). | |
UIParent * | parent |
Reference to the group this widget is connected to. | |
Widget group which shows nothing or exactly one of its sub-widgets.
UICards takes its widgets and shows exactly one of them covering the whole area. This is like a card stack (therefore the name). The widget to show is selected by setVisibleWidget().
If the visible widget is not set or set to null, nothing is shown.
Note that you can use UICards easily to make another widget visible or invisible: Just add the widget in question as first (and only) sub-widget to UICards. Then, if you make it the visible widget, it is shown, and if you set the visible widget to null, it is hidden.
The two methods hide()
and showFirstWidget()
act as syntactic sugar for this operation mode.
|
virtual |
UICards will consider the render request from the child only if it is the currently visible child.
Reimplemented from UIWidgetGroup.
|
protectedvirtual |
Compute the preferred size as the maximum envelope of the preferred sizes of all subwidgets.
Implements UIWidget.
|
virtual |
Layout the cards widget.
Reimplemented from UIWidget.
|
virtual |
Render the cards widget group onto the display.
Implements UIWidget.
void UICards::setVisibleWidget | ( | UIWidget * | visible | ) |
Set the widget to show on the area of the cards widget group.
If nullptr is given, nothing is shown. The parameter must be one of the sub-widgets of the group. If another widget is passed, the results are undefined.
Changing the visible widget leads to the cards widget group being completely re-rendered.