UiUiUi
A user interface library for micro controller sketches based on U8g2
Public Member Functions | Protected Member Functions | List of all members
UICards Class Reference

Widget group which shows nothing or exactly one of its sub-widgets. More...

#include <UICards.h>

Inheritance diagram for UICards:
Inheritance graph
[legend]
Collaboration diagram for UICards:
Collaboration graph
[legend]

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.
 
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.
 
UIArearender (U8G2 *display, bool force)
 Render the cards widget group onto the display.
 
void childNeedsRendering (UIWidget *child)
 UICards will consider the render request from the child only if it is the currently visible child.
 
- Public Member Functions inherited from UIWidgetGroup
 UIWidgetGroup (UIWidget *firstChild, UIWidget *next=nullptr)
 Create a widget group with a linked list of sub-widgets and a potential successor.
 
UIArearender (U8G2 *display, bool force)
 Default implementation of rendering a widget group is to render all of its sub-widgets.
 
- Public Member Functions inherited from UIWidget
UISize preferredSize (U8G2 *display)
 Return the preferred size of this widget, will be called before a call to layout(). More...
 
virtual void setParent (UIParent *parent)
 Set the parent widget group (if it exists). 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.
 
- Protected Member Functions inherited from UIWidget
 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().
 
void signalNeedsRendering ()
 Called internally: Signals to parent that this widget needs to be rendered.
 

Additional Inherited Members

- Public Attributes inherited from UIWidget
UIWidgetnext
 Pointer to the next widget on the same level.
 
- Protected Attributes inherited from UIWidgetGroup
UIWidgetfirstChild
 The first of the widgets grouped by this widget group.
 
bool renderChildren
 Flag whether any child of this group needs to be rendered.
 
- Protected Attributes inherited from UIWidget
UIArea dim
 Actual area of this widget, set in layout().
 
UIParentparent
 Reference to the group this widget is connected to.
 

Detailed Description

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.

Member Function Documentation

◆ setVisibleWidget()

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.


The documentation for this class was generated from the following files: