#include <glv_rect.h>
Public Member Functions | |
TRect (T extent) | |
Construct from square extent with position set to (0,0). | |
TRect (T width, T height) | |
Construct from width and height with position set to (0,0). | |
TRect (T left, T top, T width, T height) | |
TRect (const TRect &other) | |
void | extent (T v) |
Set extent to be square. | |
void | extent (T w, T h) |
Set extent. | |
void | fitSquare (T v) |
Set extent to fit in square. | |
void | fixNegativeExtent () |
Fixes negative width or height to be positive. | |
void | insetFrom (const TRect< T > &from, T inset) |
Make TRect relative inset from 'from'. | |
void | pos (T left, T top) |
Set left-top position. | |
void | posAdd (T x, T y) |
Translate by [x, y] units. | |
void | posRelTo (const TRect< T > &r, float rxf, float ryf, float xf, float yf, float x=0, float y=0) |
Position myself relative to another rect. | |
void | resizeLeftTo (T v) |
Resize by moving left edge to value. | |
void | resizeTopTo (T v) |
Resize by moving top edge to value. | |
void | resizeRightTo (T v) |
Resize by moving right edge to value. | |
void | resizeBottomTo (T v) |
Resize by moving bottom edge to value. | |
void | resizeEdgesBy (T v) |
Resize by moving edges by value. | |
void | set (T left, T top, T width, T height) |
Set components. | |
void | set (const TRect< T > &r) |
Set components from other TRect. | |
void | transpose () |
Swaps width and height. | |
void | left (T v) |
Set left position. | |
void | top (T v) |
Set top position. | |
void | width (T v) |
Set width. | |
void | height (T v) |
Set height. | |
void | bottom (T v) |
Set bottom edge preserving height. | |
void | right (T v) |
Set right edge preserving width. | |
T | left () const |
Get left edge position. | |
T | top () const |
Get top edge position. | |
T | width () const |
Get width. | |
T | height () const |
Get height. | |
T | right () const |
Get right edge position. | |
T | bottom () const |
Get bottom edge position. | |
T | area () const |
Returns area (w x h). | |
void | center (T &x, T &y) const |
Gets center point. | |
T | centerX () const |
Returns center along x axis. | |
T | centerY () const |
Returns center along y axis. | |
bool | containsPoint (T x, T y) const |
Returns whether the point is inside the TRect. | |
void | intersection (const TRect< T > &check, TRect< T > &intersection) const |
Calculates the intersection of the two Rects. | |
bool | intersects (const TRect< T > &rect) const |
Returns whether the two Rects intersect. | |
bool | isVertical () const |
Returns true if h > w, false otherwise. | |
bool | withinXBounds (T xmin, T xmax) const |
Returns whether the TRect is within the x range. | |
bool | withinYBounds (T ymin, T ymax) const |
Returns whether the TRect is within the y range. | |
virtual void | onResize (T dx, T dy) |
Called when the width or height change. Changes in extent are passed in. | |
void | print (FILE *fp=stdout) |
write about TRect to a file | |
Public Attributes | |
T | l |
Left edge position. | |
T | t |
Top edge position. | |
T | w |
Width. | |
T | h |
Height. |
Knows how to calculate useful things such as centre, intersection areas with other rects, etc.
TEM glv::TRect< T >::TRect | ( | T | extent | ) |
Construct from square extent with position set to (0,0).
[in] | extent | initial width and height |
TEM glv::TRect< T >::TRect | ( | T | width, | |
T | height | |||
) |
Construct from width and height with position set to (0,0).
[in] | width | initial width |
[in] | height | initial height |
TEM glv::TRect< T >::TRect | ( | T | left, | |
T | top, | |||
T | width, | |||
T | height | |||
) |
[in] | left | initial left edge position |
[in] | top | initial top edge position |
[in] | width | initial width |
[in] | height | initial height |
TEM glv::TRect< T >::TRect | ( | const TRect< T > & | other | ) |
[in] | other | other rectangle to set geometry from |
TEM void glv::TRect< T >::posRelTo | ( | const TRect< T > & | r, | |
float | rxf, | |||
float | ryf, | |||
float | xf, | |||
float | yf, | |||
float | x = 0 , |
|||
float | y = 0 | |||
) | [inline] |
Position myself relative to another rect.
rxf and ryf determine the fractional position along the source r. xf and xy determine the fractional position along this rect. x and y are absolute offsets.