lecui 1.0.0-alpha.20
lecui C++ user interface library
|
Rectangle class. More...
#include <lecui.h>
Public Types | |
enum class | snap_type { bottom_left , bottom , bottom_right , top_left , top , top_right , right_top , right , right_bottom , left_top , left , left_bottom } |
Snap type, used to position a rectangle next to another (reference) rectangle. More... | |
Public Member Functions | |
rect () | |
Rectangle constructor. Makes a zero size rectangle with zero width and height. | |
rect (const lecui::size size) | |
Rectangle constructor. More... | |
rect (const float left, const float right, const float top, const float bottom) | |
Rectangle constructor. More... | |
float & | left () |
Get or set the left coordinate. More... | |
float | get_left () const |
Get the left coordinate. More... | |
rect & | left (const float &left) |
Set the left coordinate. More... | |
float & | right () |
Get or set the right coordinate. More... | |
float | get_right () const |
Get the right coordinate. More... | |
rect & | right (const float &right) |
Set the right coordinate. More... | |
float & | top () |
Get or set the top coordinate. More... | |
float | get_top () const |
Get the top coordinate. More... | |
rect & | top (const float &top) |
Set the top coordinate. More... | |
float & | bottom () |
Get or set the bottom coordinate. More... | |
float | get_bottom () const |
Get the bottom coordinate. More... | |
rect & | bottom (const float &bottom) |
Set the bottom coordinate. More... | |
float | width () const |
Get the rectangle's width. More... | |
float | height () const |
Get the rectangle's height. More... | |
size | size () const |
Get the rectangle's size. More... | |
rect & | width (float width) |
Set the rectangle's width. More... | |
rect & | height (float height) |
Set the rectangle's height. More... | |
rect & | size (lecui::size size) |
Set the rectangle's size (both width and height). More... | |
rect & | size (float width, float height) |
Set the rectangle's size (both width and height). More... | |
rect & | set (float x, float y, float cx, float cy) |
Set the rectangle dimensions and position. More... | |
rect & | move (float x, float y) |
Move the rectangle using it's top left corner. More... | |
rect & | place (const rect &rect_reference, const float &perc_h, const float &perc_v) |
Place this rectangle within or over another. More... | |
rect & | snap_to (const rect &rect_reference, snap_type type, const float &clearance) |
Snap this rectangle to another, for quick positioning. More... | |
rect & | clip_to (const rect &rect_reference, const float &clearance) |
Clip a rectangle within another, to prevent a rectangle going beyond stipulated confines. More... | |
bool | operator== (const rect ¶m) |
Check whether two rectangles are equal. All properties are considered. More... | |
bool | operator!= (const rect ¶m) |
Check whether two rectangles are NOT equal. All properties are considered. More... | |
Rectangle class.
|
strong |
Snap type, used to position a rectangle next to another (reference) rectangle.
liblec::lecui::rect::rect | ( | const lecui::size | size | ) |
Rectangle constructor.
size | The size of the rectangle, in pixels. |
liblec::lecui::rect::rect | ( | const float | left, |
const float | right, | ||
const float | top, | ||
const float | bottom | ||
) |
Rectangle constructor.
left | The left coordinate, in pixels. |
right | The right coordinate, in pixels. |
top | The top coordinate, in pixels. |
bottom | The bottom coordinate, in pixels. |
float & liblec::lecui::rect::bottom | ( | ) |
Get or set the bottom coordinate.
rect & liblec::lecui::rect::bottom | ( | const float & | bottom | ) |
Set the bottom coordinate.
bottom | The bottom coordinate, in pixels. |
Clip a rectangle within another, to prevent a rectangle going beyond stipulated confines.
rect_reference | The rectangle to clip to. |
clearance | The clearance to use in the clipping operation. |
This is a handy method for simpler failsafe coding. Note that if any clipping occurs the dimensions of the rectangle will get smaller.
float liblec::lecui::rect::get_bottom | ( | ) | const |
Get the bottom coordinate.
float liblec::lecui::rect::get_left | ( | ) | const |
Get the left coordinate.
float liblec::lecui::rect::get_right | ( | ) | const |
Get the right coordinate.
float liblec::lecui::rect::get_top | ( | ) | const |
Get the top coordinate.
float liblec::lecui::rect::height | ( | ) | const |
Get the rectangle's height.
rect & liblec::lecui::rect::height | ( | float | height | ) |
Set the rectangle's height.
height | The height to set it to. |
The top left corner is used as an anchor.
float & liblec::lecui::rect::left | ( | ) |
Get or set the left coordinate.
rect & liblec::lecui::rect::left | ( | const float & | left | ) |
Set the left coordinate.
left | The left coordinate, in pixels. |
rect & liblec::lecui::rect::move | ( | float | x, |
float | y | ||
) |
Move the rectangle using it's top left corner.
x | The new x-coordinate of the top-left corner. |
y | The new y-coordinate of the top-left corner. |
The size of the rectangle remains unchanged. The rectangle is effectively translated to the new coodinates.
bool liblec::lecui::rect::operator!= | ( | const rect & | param | ) |
Check whether two rectangles are NOT equal. All properties are considered.
param | The rectangle to compare to. |
bool liblec::lecui::rect::operator== | ( | const rect & | param | ) |
Check whether two rectangles are equal. All properties are considered.
param | The rectangle to compare to. |
rect & liblec::lecui::rect::place | ( | const rect & | rect_reference, |
const float & | perc_h, | ||
const float & | perc_v | ||
) |
Place this rectangle within or over another.
rect_reference | The rectangle to place it on or over. |
perc_h | How far along vertically to place it, as a percentage. 50% means this rectangle will be centered vertically. |
perc_v | How far along horizontally to place it, as a percentage. 50% means this rectangle will be centered horizontally. |
This is a handy method for faster coding and easier maintenance.
float & liblec::lecui::rect::right | ( | ) |
Get or set the right coordinate.
rect & liblec::lecui::rect::right | ( | const float & | right | ) |
Set the right coordinate.
right | The right coordinate, in pixels. |
rect & liblec::lecui::rect::set | ( | float | x, |
float | y, | ||
float | cx, | ||
float | cy | ||
) |
Set the rectangle dimensions and position.
x | The x-coordinate. |
y | The y-coordinate. |
cx | The width. |
cy | The height. |
size liblec::lecui::rect::size | ( | ) | const |
Get the rectangle's size.
rect & liblec::lecui::rect::size | ( | float | width, |
float | height | ||
) |
Set the rectangle's size (both width and height).
width | The width to set. |
height | The height to set. |
The top left corner is used as an anchor.
rect & liblec::lecui::rect::size | ( | lecui::size | size | ) |
Set the rectangle's size (both width and height).
size | The size to set it to. |
The top left corner is used as an anchor.
rect & liblec::lecui::rect::snap_to | ( | const rect & | rect_reference, |
snap_type | type, | ||
const float & | clearance | ||
) |
Snap this rectangle to another, for quick positioning.
rect_reference | The rectangle to snap to. |
type | The snap type. |
clearance | The clearance to use in the snapping operation. |
This is a handy method for faster coding and easier maintenance.
float & liblec::lecui::rect::top | ( | ) |
Get or set the top coordinate.
rect & liblec::lecui::rect::top | ( | const float & | top | ) |
Set the top coordinate.
top | The top coordinate, in pixels. |
float liblec::lecui::rect::width | ( | ) | const |
Get the rectangle's width.
rect & liblec::lecui::rect::width | ( | float | width | ) |
Set the rectangle's width.
width | The width to set it to. |
The top left corner is used as an anchor.