UiUiUi
A user interface library for micro controller sketches based on U8g2
|
Area consisting of left, top, right, and bottom value. More...
#include <UIArea.h>
Public Member Functions | |
UIArea (uint16_t left, uint16_t top, uint16_t right, uint16_t bottom) | |
Initialize area from four explicit values. More... | |
UIArea () | |
Initialize empty area: All values 0. | |
UIArea (UIArea *area) | |
Initialize area from another referenced area. | |
UIArea (UIPoint *topLeft, UISize *size) | |
Initialize area with top left point and a size. | |
UIArea (UIPoint *topLeft, uint16_t width, uint16_t height) | |
Initialize area with top left point and a size. | |
void | set (uint16_t left, uint16_t top, uint16_t right, uint16_t bottom) |
Set values of this area from four distinct values. | |
void | set (const UIArea *source) |
Set values of this area from given other referenced area. | |
void | set (UIPoint *topLeft, UISize *size) |
Set this area from the top-left point and a size containing width and height. | |
void | set (UIPoint *topLeft, uint16_t width, uint16_t height) |
Set this area from the top-left point and a width and a height given directly. | |
void | clear () |
sets this area to (0,0,0,0) and make it "clear" this way. | |
bool | hasArea () |
Return whether the area has any area: right is greater then left AND bottom is greater than top. | |
void | uniteWith (UIArea *area) |
Unite this area with the referenced one and write the result into this area. More... | |
void | intersectWith (UIArea *area) |
Intersect this with the other area and store the result here. More... | |
void | shrink (UISize *diff) |
Shrink this area by the given width and height on each side (so diff is applied twice in each direction). | |
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 alignment. | |
UISize | getSize () |
Return the size of this area. | |
void | debugPrint (const char *label) |
Debug output of this area with some prepended label. | |
Static Public Attributes | |
static UIArea | EMPTY =UIArea() |
Static incarnation of an empty area. More... | |
Area consisting of left, top, right, and bottom value.
Areas describe a rectangular - well - area. Left and top coordinate are usually assumed to be inclusive, right and bottom coordinate are assumed exclusive to the described area.
An area is empty if right is not larger than left OR bottom is not larger than top. The actual coordinate values do not matter.
UIArea::UIArea | ( | uint16_t | left, |
uint16_t | top, | ||
uint16_t | right, | ||
uint16_t | bottom | ||
) |
Initialize area from four explicit values.
Dimension consisting of left, top, right, and bottom value.
void UIArea::intersectWith | ( | UIArea * | area | ) |
Intersect this with the other area and store the result here.
This method performs also an overflow check: If left is larger than right, it is set to dim->left, if top is larger than bottom it is set to dim->top. This can happen if an underflow occurs and the value which would be smaller than 0 flips to some 65500 values.
area | Other area with which this area is intersected. |
void UIArea::uniteWith | ( | UIArea * | area | ) |
Unite this area with the referenced one and write the result into this area.
The united area is the smallest possible enclosure of both original areas. It can be relatively large, however, if the two originals are not connected. The unification of (1,15,4,17) (size 6) and (19,2,22,3) (size 3) is (1,2,22,17) (size 315).
area | The area to unite with. |
Static incarnation of an empty area.
This area instance has all four values set to 0.