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. 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.
 
UIArearender (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...
 
- 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. More...
 
virtual void childNeedsRendering (UIWidget *child)
 Called by any child of this group to indicate that it wants to be rendered. More...
 
- 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 layout (U8G2 *display, UIArea *area)
 Layout widget in the given rectanglar area, will be called before first call to render(). More...
 
virtual UIArearender (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...
 
- 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().
 
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

- 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

◆ childNeedsRendering()

void UICards::childNeedsRendering ( UIWidget child)
virtual

UICards will consider the render request from the child only if it is the currently visible child.

Reimplemented from UIWidgetGroup.

◆ computePreferredSize()

void UICards::computePreferredSize ( U8G2 *  display,
UISize preferredSize 
)
protectedvirtual

Compute the preferred size as the maximum envelope of the preferred sizes of all subwidgets.

Implements UIWidget.

◆ layout()

void UICards::layout ( U8G2 *  display,
UIArea dim 
)
virtual

Layout the cards widget.

Reimplemented from UIWidget.

◆ render()

UIArea * UICards::render ( U8G2 *  display,
bool  force 
)
virtual

Render the cards widget group onto the display.

Implements UIWidget.

◆ 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: