UiUiUi
A user interface library for micro controller sketches based on U8g2
|
Basic widget class, ancestor of all UI widgets. More...
#include <UIWidget.h>
Public Member Functions | |
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... | |
Public Attributes | |
UIWidget * | next |
Pointer to the next widget on the same level. | |
Protected Member Functions | |
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. | |
Protected Attributes | |
UIArea | dim |
Actual area of this widget, set in layout(). | |
UIParent * | parent |
Reference to the group this widget is connected to. | |
Basic widget class, ancestor of all UI widgets.
A UIWidget has three basic operations which are called by the framework in that order:
A UIWidget may have a successor which is the next widget in the interface ON THE SAME LEVEL. Specialized UIWidgets bring certain semantics into such a chain of widgets.
The UIWidget class itself has only a tiny amount of business logic. The majority of it is spread through a number of derived classes representing all kinds of user interface elements.
|
protectedpure virtual |
Store preferred size of this widget into the preferredSize reference.
Implementations can be assured to be called only once and the passed preferredSize will be (0,0).
Implemented in UIBitmap, UICards, UICheckerboard, UIColumns, UIEnvelope, UIHorizontalLine, UIRows, UITextIcon, UITextLine, and UIVerticalLine.
|
virtual |
Layout widget in the given rectanglar area, will be called before first call to render().
Note that overloading implementation should invoke UIWidget::layout(), otherwise certain internal mechanisms will not work.
Reimplemented in UICards, UIColumns, UIEnvelope, and UIRows.
UISize UIWidget::preferredSize | ( | U8G2 * | display | ) |
Return the preferred size of this widget, will be called before a call to layout().
This method delegates the operation into computePreferredSize() if the preferred size has not yet been computed.
|
pure virtual |
Render component in the space given in layout().
If force is true, the component must render itself in its rectangle. Otherwise, it may refrain from doing anything if its internal state says that nothing has changed. Component returns the area which actually must be written to screen. This area may be smaller than the whole area of the component. If the component has not changed anything, it must return an empty area, e.g. UIArea::EMPTY().
Implemented in UIBitmap, UICards, UICheckerboard, UIEnvelope, UIHorizontalLine, UITextLine, UIVerticalLine, and UIWidgetGroup.
|
virtual |
Set the parent widget group (if it exists).
This method is called by the widget group this widget is assigned to during initialisation. It should not be called by anyone else.