Base Framework
Public Member Functions | Static Public Member Functions | List of all members
Position Class Reference

A two-dimensional coordinate. More...

#include <base/ui/Position.h>

Inherits Object.

Public Member Functions

 Position () noexcept
 
 Position (int _x, int _y) noexcept
 
 Position (const Dimension &dimension) noexcept
 
 Position (const Position &copy) noexcept
 
Positionoperator= (const Position &assign) noexcept
 
bool isOrigin () const noexcept
 
bool isWithin (const Position &upperLeft, const Position &lowerRight) const noexcept
 
bool isWithin (const Position &position, const Dimension &dimension) const noexcept
 
bool isWithin (const Dimension &dimension) const noexcept
 
bool confineTo (const Position &a, const Position &b) noexcept
 
int getX () const noexcept
 
int getY () const noexcept
 
void setX (int x) noexcept
 
void setY (int y) noexcept
 
Positionnegate () noexcept
 
Positionadd (const Position &value) noexcept
 
Positionsubtract (const Position &value) noexcept
 
bool operator== (const Position &position) const noexcept
 
bool operator!= (const Position &position) const noexcept
 
Positionoperator+= (const Position &value) noexcept
 
Positionoperator-= (const Position &value) noexcept
 
Positionoperator- (const Position &position) noexcept
 
Positionoperator+ (const Position &position) noexcept
 
bool isAfter (const Position &position) const noexcept
 
bool isBefore (const Position &position) const noexcept
 
Dimension getDimension (const Position &position) const noexcept
 

Static Public Member Functions

static Dimension getDimension (const Position &upperLeft, const Position &lowerRight) noexcept
 

Detailed Description

A two-dimensional coordinate.

A two-dimensional discrete coordinate.

Version
1.1

Constructor & Destructor Documentation

◆ Position() [1/4]

Position::Position ( )
inlinenoexcept

Initializes position as (0, 0).

◆ Position() [2/4]

Position::Position ( int  _x,
int  _y 
)
inlinenoexcept

Initializes position with specified x and y values.

◆ Position() [3/4]

Position::Position ( const Dimension dimension)
inlinenoexcept

Initializes position from dimension (width, height) as (width - 1, height - 1).

◆ Position() [4/4]

Position::Position ( const Position copy)
inlinenoexcept

Initializes position from other position.

Member Function Documentation

◆ add()

Position& Position::add ( const Position value)
inlinenoexcept

Adds the specified position to this position.

◆ confineTo()

bool Position::confineTo ( const Position a,
const Position b 
)
inlinenoexcept

Confines the position to the specified rectangle.

Parameters
aCorner.
bCorner.
Returns
Returns true if position was NOT changed.

◆ getDimension() [1/2]

Dimension Position::getDimension ( const Position position) const
inlinenoexcept

Returns the dimension of the rectangle from this position (upper left) to the specified lower right corner.

Parameters
positionThe lower right corner.

◆ getDimension() [2/2]

static Dimension Position::getDimension ( const Position upperLeft,
const Position lowerRight 
)
inlinestaticnoexcept

Returns the dimension of the rectangle defined by the 2 positions.

Parameters
upperLeftThe upper left or lower right corner.
lowerRightThe upper left or lower right corner.

◆ getX()

int Position::getX ( ) const
inlinenoexcept

Returns the X coordinate.

◆ getY()

int Position::getY ( ) const
inlinenoexcept

Returns the Y coordinate.

◆ isAfter()

bool Position::isAfter ( const Position position) const
inlinenoexcept

Returns true if the position is after the specified position.

◆ isBefore()

bool Position::isBefore ( const Position position) const
inlinenoexcept

Returns true if the position is before the specified position.

◆ isOrigin()

bool Position::isOrigin ( ) const
inlinenoexcept

Returns true if position is (0, 0).

◆ isWithin() [1/3]

bool Position::isWithin ( const Dimension dimension) const
inlinenoexcept

Returns true if the position is contained in the bounding rectangle given by the upper left corner (0, 0) and the specified dimension.

Parameters
dimensionDimension of the bounding rectangle.

◆ isWithin() [2/3]

bool Position::isWithin ( const Position position,
const Dimension dimension 
) const
inlinenoexcept

Returns true if the position is contained in the bounding rectangle specified by the upper left corner and the dimension.

Parameters
positionUpper left corner of the bounding rectangle.
dimensionDimension of the bounding rectangle.

◆ isWithin() [3/3]

bool Position::isWithin ( const Position upperLeft,
const Position lowerRight 
) const
inlinenoexcept

Returns true if the position is contained in the bounding rectangle specified by the upper left and lower right corners.

Parameters
upperLeftThe upper left corner.
lowerRightThe lower right corner.

◆ negate()

Position& Position::negate ( )
inlinenoexcept

Negates this vector.

◆ operator!=()

bool Position::operator!= ( const Position position) const
inlinenoexcept

Returns true if the positions are different.

Parameters
positionThe position to be compared.

◆ operator+()

Position& Position::operator+ ( const Position position)
inlinenoexcept

Adds the position from this position.

◆ operator+=()

Position& Position::operator+= ( const Position value)
inlinenoexcept

Adds the specified position from this position.

Parameters
valueThe value to be added.

◆ operator-()

Position& Position::operator- ( const Position position)
inlinenoexcept

Subtracts the position from this position.

◆ operator-=()

Position& Position::operator-= ( const Position value)
inlinenoexcept

Subtracts the specified position from this position.

Parameters
valueThe value to be subtracted.

◆ operator=()

Position& Position::operator= ( const Position assign)
inlinenoexcept

Assignment of position by position.

◆ operator==()

bool Position::operator== ( const Position position) const
inlinenoexcept

Returns true if the positions are equal.

Parameters
positionThe position to be compared.

◆ setX()

void Position::setX ( int  x)
inlinenoexcept

Sets the X coordinate.

◆ setY()

void Position::setY ( int  y)
inlinenoexcept

Sets the Y coordinate.

◆ subtract()

Position& Position::subtract ( const Position value)
inlinenoexcept

Subtracts the specified position from this position.