UiUiUi
A user interface library for micro controller sketches based on U8g2
UIArea.h
1 // SPDX-License-Identifier: BSD-2-Clause
2 // (C) 2022 Dirk Hillbrecht
3 
4 #pragma once
5 
6 #include "Arduino.h"
7 #include "UIEnums.h"
8 #include "UIPoint.h"
9 #include "UISize.h"
10 
20 class UIArea final {
21  public:
22 
27  static UIArea EMPTY;
28 
30  UIArea(uint16_t left,uint16_t top,uint16_t right,uint16_t bottom);
31 
33  UIArea();
34 
36  UIArea(UIArea* area);
37 
39  UIArea(UIPoint *topLeft,UISize *size);
40 
42  UIArea(UIPoint *topLeft,uint16_t width,uint16_t height);
43 
45  void set(uint16_t left,uint16_t top,uint16_t right,uint16_t bottom);
46 
48  void set(const UIArea *source);
49 
51  void set(UIPoint *topLeft,UISize *size);
52 
54  void set(UIPoint *topLeft,uint16_t width,uint16_t height);
55 
57  void clear();
58 
60  bool hasArea();
61 
70  void uniteWith(UIArea* area);
71 
82  void intersectWith(UIArea* area);
83 
85  void shrink(UISize *diff);
86 
88  UIPoint alignedTopLeft(UIAlignment alignment,UISize *element);
89 
91  UISize getSize();
92 
94  void debugPrint(const char* label);
95 
97  uint16_t left;
98 
100  uint16_t top;
101 
103  uint16_t right;
104 
106  uint16_t bottom;
107 
108 };
109 
110 // end of file
Area consisting of left, top, right, and bottom value.
Definition: UIArea.h:20
void set(uint16_t left, uint16_t top, uint16_t right, uint16_t bottom)
Set values of this area from four distinct values.
Definition: UIArea.cpp:25
UIPoint alignedTopLeft(UIAlignment alignment, UISize *element)
Return the top-left point of an area of the given element if that element is aligned as stated in the...
Definition: UIArea.cpp:83
void uniteWith(UIArea *area)
Unite this area with the referenced one and write the result into this area.
Definition: UIArea.cpp:52
void debugPrint(const char *label)
Debug output of this area with some prepended label.
Definition: UIArea.cpp:97
uint16_t bottom
Bottom coordinate of the area, 0 is topmost, exclusive.
Definition: UIArea.h:106
static UIArea EMPTY
Static incarnation of an empty area.
Definition: UIArea.h:27
void shrink(UISize *diff)
Shrink this area by the given width and height on each side (so diff is applied twice in each directi...
Definition: UIArea.cpp:76
uint16_t right
Right coordinate of the area, 0 is leftmost, exclusive.
Definition: UIArea.h:103
void intersectWith(UIArea *area)
Intersect this with the other area and store the result here.
Definition: UIArea.cpp:65
void clear()
sets this area to (0,0,0,0) and make it "clear" this way.
Definition: UIArea.cpp:44
UISize getSize()
Return the size of this area.
Definition: UIArea.cpp:93
uint16_t left
Left coordinate of the area, 0 is leftmost, inclusive.
Definition: UIArea.h:97
bool hasArea()
Return whether the area has any area: right is greater then left AND bottom is greater than top.
Definition: UIArea.cpp:48
uint16_t top
Top coordinate of the area, 0 is topmost, inclusive.
Definition: UIArea.h:100
UIArea()
Initialize empty area: All values 0.
Definition: UIArea.cpp:14
Representation of a point on the display.
Definition: UIPoint.h:9
Representation of a size, i.e.
Definition: UISize.h:9