All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Nimble::SizeT< T > Class Template Reference

This class defines the size of a two-dimensional object. More...

#include <Nimble/Size.hpp>

Public Member Functions

SizeT boundedTo (const SizeT &size) const
 Returns a size holding the minimum width and height of this and the given size. More...
 
template<typename S >
Nimble::SizeT< S > cast () const
 Cast the vector to another type.
 
template<typename S >
SizeT< S > cast () const
 
SizeT expandedTo (const SizeT &size) const
 Returns a size holding the maximum width and height of this and the given size. More...
 
void fit (T width, T height, Qt::AspectRatioMode mode)
 Fits the size to the given size. More...
 
void fit (const SizeT &size, Qt::AspectRatioMode mode)
 Fits the size to the given size. More...
 
height () const
 Get the height. More...
 
bool isEmpty () const
 Check if the size is empty. More...
 
bool isNull () const
 Check if the size is zero. More...
 
bool isValid () const
 Check if the size is invalid. More...
 
void make (T width, T height)
 Set the width and height of the size. More...
 
maximum () const
 
minimum () const
 
bool operator!= (const SizeT< T > &o) const
 Compare if two sizes are not equal. More...
 
SizeT< T > operator+ (const SizeT< T > &o) const
 Return the sum of two sizes. More...
 
SizeT< T > & operator+= (const SizeT< T > &s)
 Add the given size to this size. More...
 
SizeT< T > operator- (const SizeT< T > &o) const
 Return the subtraction of two sizes. More...
 
SizeT< T > & operator-= (const SizeT< T > &s)
 Subtract the given size from this size. More...
 
bool operator== (const SizeT< T > &o) const
 Compare if two sizes are equal. More...
 
operator[] (int index) const
 Index an element in the size object. More...
 
void setHeight (T height)
 Set the height of the size. More...
 
void setWidth (T width)
 Set the width of the size. More...
 
 SizeT ()
 Constructs a size with invalid width and height (i.e. isValid() returns false)
 
 SizeT (const Nimble::Vector2T< T > &v)
 Construct a size defined by a 2D vector. More...
 
 SizeT (T width, T height)
 Constructs a size with the given width and height. More...
 
 SizeT (const SizeT &other)
 Copy constructor.
 
Vector2T< T > toVector () const
 Convert the size to a vector. More...
 
void transpose ()
 Transpose the size, i.e. swap the width and height.
 
width () const
 Get the width. More...
 

Detailed Description

Constructor & Destructor Documentation

template<typename T >
Nimble::SizeT< T >::SizeT ( const Nimble::Vector2T< T > &  v)
explicit

Construct a size defined by a 2D vector.

Parameters
vvector whose components define the size
template<typename T >
Nimble::SizeT< T >::SizeT ( width,
height 
)

Constructs a size with the given width and height.

Parameters
widthwidth to initialize the size to
heightheight to initialize the size to

Member Function Documentation

template<typename T >
SizeT< T > Nimble::SizeT< T >::boundedTo ( const SizeT< T > &  size) const

Returns a size holding the minimum width and height of this and the given size.

Parameters
sizesize to compare to
Returns
bounded size
template<typename T >
SizeT< T > Nimble::SizeT< T >::expandedTo ( const SizeT< T > &  size) const

Returns a size holding the maximum width and height of this and the given size.

Parameters
sizesize to compare to
Returns
expanded size
template<typename T >
void Nimble::SizeT< T >::fit ( width,
height,
Qt::AspectRatioMode  mode 
)

Fits the size to the given size.

Parameters
widthwidth to fit to
heightheight to fit to
modeeither Qt::IgnoreAspectRatio or Qt::KeepAspectRatio
template<typename T >
void Nimble::SizeT< T >::fit ( const SizeT< T > &  size,
Qt::AspectRatioMode  mode 
)

Fits the size to the given size.

Parameters
sizesize to fit to
modeeither Qt::IgnoreAspectRatio or Qt::KeepAspectRatio
template<typename T >
T Nimble::SizeT< T >::height ( ) const
inline

Get the height.

Returns
height of the size
template<typename T >
bool Nimble::SizeT< T >::isEmpty ( ) const

Check if the size is empty.

Returns
true if either of the width and height is less than or equal to 0; otherwise false
template<typename T >
bool Nimble::SizeT< T >::isNull ( ) const

Check if the size is zero.

Returns
true if both the width and height is 0; otherwise false
template<typename T >
bool Nimble::SizeT< T >::isValid ( ) const

Check if the size is invalid.

Returns
true if both the width and height is equal to or greater than 0; otherwise false
template<typename T >
void Nimble::SizeT< T >::make ( width,
height 
)

Set the width and height of the size.

Parameters
width,heightnew width and height
template<typename T >
T Nimble::SizeT< T >::maximum ( ) const
Returns
the larger component
template<typename T >
T Nimble::SizeT< T >::minimum ( ) const
Returns
the smaller component
template<typename T >
bool Nimble::SizeT< T >::operator!= ( const SizeT< T > &  o) const

Compare if two sizes are not equal.

Parameters
osize to compare
Returns
true if the sizes are not equal; otherwise false
template<typename T >
SizeT< T > Nimble::SizeT< T >::operator+ ( const SizeT< T > &  o) const

Return the sum of two sizes.

Each component is added separately.

Parameters
osize to add
Returns
sum of sizes
template<typename T >
SizeT< T > & Nimble::SizeT< T >::operator+= ( const SizeT< T > &  s)

Add the given size to this size.

Parameters
ssize to add
Returns
reference to this size
template<typename T >
SizeT< T > Nimble::SizeT< T >::operator- ( const SizeT< T > &  o) const

Return the subtraction of two sizes.

Each component is subtracted separately.

Parameters
osize to add
Returns
subtraction of two sizes
template<typename T >
SizeT< T > & Nimble::SizeT< T >::operator-= ( const SizeT< T > &  s)

Subtract the given size from this size.

Parameters
ssize to subtract
Returns
reference to this size
template<typename T >
bool Nimble::SizeT< T >::operator== ( const SizeT< T > &  o) const

Compare if two sizes are equal.

Parameters
osize to compare
Returns
true if the sizes are equal; otherwise false
template<typename T >
T Nimble::SizeT< T >::operator[] ( int  index) const
inline

Index an element in the size object.

This method does not check that the argument value is valid

template<typename T >
void Nimble::SizeT< T >::setHeight ( height)

Set the height of the size.

Parameters
heightnew height
template<typename T >
void Nimble::SizeT< T >::setWidth ( width)

Set the width of the size.

Parameters
widthnew width
template<typename T >
Vector2T< T > Nimble::SizeT< T >::toVector ( ) const

Convert the size to a vector.

Returns
vector representing the size with the components set to width and height of the size
Examples:
DropHandlerExample.cpp, and PositionalSoundsExample.cpp.
template<typename T >
T Nimble::SizeT< T >::width ( ) const
inline

Get the width.

Returns
width of the size