UiUiUi
A user interface library for micro controller sketches based on U8g2
UIEnvelope.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#include "UIEnums.h"
10#include "UIPoint.h"
11#include "UISize.h"
12#include "UIArea.h"
13#include "UIWidget.h"
14#include "UIParent.h"
15
16
27class UIEnvelope : public UIWidget, public UIParent {
28 public:
29
38 UIEnvelope(UIExpansion expansion,UIAlignment alignment,UISize borderSize=UISize(),UIWidget* content=nullptr,UIWidget* next=nullptr);
39
47 UIEnvelope(UIExpansion expansion,UIAlignment alignment,UIWidget* content,UIWidget* next=nullptr);
48
53 void layout(U8G2 *display,UIArea *dim);
54
56 UIArea* render(U8G2 *display,bool force);
57
59 void childNeedsRendering(UIWidget *child);
60
61 protected:
62
64 void computePreferredSize(U8G2 *display,UISize *preferredSize);
65
66 private:
67
69 UIExpansion expansion;
70
72 UIAlignment alignment;
73
75 UISize borderSize;
76
78 UIWidget* content;
79
80};
81
82// end of file
Area consisting of left, top, right, and bottom value.
Definition: UIArea.h:20
Envelope widget which contains exactly one other widget and changes its representation.
Definition: UIEnvelope.h:27
UIArea * render(U8G2 *display, bool force)
Render the envelope - which also renders the content if it exists.
Definition: UIEnvelope.cpp:46
void computePreferredSize(U8G2 *display, UISize *preferredSize)
Compute the preferred size which is determined by the content by may be changed by the envelope.
Definition: UIEnvelope.cpp:57
void childNeedsRendering(UIWidget *child)
Called by the child of this envelope to indicate that it wants to be rendered.
Definition: UIEnvelope.cpp:42
UIEnvelope(UIExpansion expansion, UIAlignment alignment, UISize borderSize=UISize(), UIWidget *content=nullptr, UIWidget *next=nullptr)
Create an envelope widget.
Definition: UIEnvelope.cpp:17
void layout(U8G2 *display, UIArea *dim)
Layout the envelope.
Definition: UIEnvelope.cpp:26
Simple abstraction of elements which have at least one child.
Definition: UIParent.h:14
Representation of a size, i.e.
Definition: UISize.h:9
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