Public Member Functions

glv::TRect< T > Class Template Reference

Rectangle shape. More...

#include <glv_rect.h>

List of all members.

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.
const TRectrect () const
 Returns self.
left () const
 Get left edge position.
top () const
 Get top edge position.
width () const
 Get width.
height () const
 Get height.
right () const
 Get right edge position.
bottom () const
 Get bottom edge position.
area () const
 Returns area (w x h).
void center (T &x, T &y) const
 Gets center point.
centerX () const
 Returns center along x axis.
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

Detailed Description

template<class T>
class glv::TRect< T >

Rectangle shape.

Knows how to calculate useful things such as centre, intersection areas with other rects, etc.


Constructor & Destructor Documentation

template<class T>
TEM glv::TRect< T >::TRect ( extent  ) 

Construct from square extent with position set to (0,0).

Parameters:
[in] extent initial width and height
template<class T>
TEM glv::TRect< T >::TRect ( width,
height 
)

Construct from width and height with position set to (0,0).

Parameters:
[in] width initial width
[in] height initial height
template<class T>
TEM glv::TRect< T >::TRect ( left,
top,
width,
height 
)
Parameters:
[in] left initial left edge position
[in] top initial top edge position
[in] width initial width
[in] height initial height
template<class T>
TEM glv::TRect< T >::TRect ( const TRect< T > &  other  ) 
Parameters:
[in] other other rectangle to set geometry from

Member Function Documentation

template<class T>
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.


The documentation for this class was generated from the following file: