DUDS
Distributed Update of Data from Something
duds::ui::graphics::ImageDimensions Struct Reference

Stores the dimensions of an image. More...

#include <BppImage.hpp>

Public Member Functions

 ImageDimensions ()=default
 Construct uninitialized. More...
 
template<typename Int0 , typename Int1 , std::enable_if_t< std::is_integral< Int0 >::value, bool > = true, std::enable_if_t< std::is_integral< Int1 >::value, bool > = true>
constexpr ImageDimensions (Int0 dw, Int1 dh)
 Construct with the given dimensions. More...
 
void clear ()
 Set the dimensions to zero area. More...
 
constexpr ImageDimensions clip (const ImageDimensions &dim, const ImageLocation &loc=ImageLocation(0, 0)) const
 Returns a region clipped to fit within this object's dimensions. More...
 
constexpr bool empty () const
 True if the dimensions indicate zero area. More...
 
constexpr bool fits (const ImageDimensions &id) const
 Returns true if the given dimensions are not larger than this object's dimensions. More...
 
constexpr bool fits (const ImageLocation &loc, const ImageDimensions &id) const
 Returns true if the given dimensions at the given location relative to this object can fit within this object's dimentions. More...
 
constexpr ImageDimensions maxExtent (const ImageDimensions &dim) const
 Returns new dimensions that are minimally large enough to fit this dimension and the given dimension. More...
 
constexpr ImageDimensions minExtent (const ImageDimensions &dim) const
 Returns new dimensions that only cover the union of this dimension and the given dimension. More...
 
constexpr bool operator!= (const ImageDimensions &id) const
 Obvious inequality operator. More...
 
constexpr bool operator== (const ImageDimensions &id) const
 Obvious equality operator. More...
 
void swapAxes ()
 Swaps the dimensions's axes. More...
 
constexpr ImageDimensions swappedAxes () const
 Returns new dimensions with swapped axes. More...
 
constexpr bool withinBounds (const ImageLocation &loc) const
 Returns true if the given location is within the bounds specified by this object. More...
 

Public Attributes

std::int16_t h
 Height. More...
 
std::int16_t w
 Width. More...
 

Detailed Description

Stores the dimensions of an image.

Author
Jeff Jackowski
Examples:
bppmenu.cpp, and rendertext.cpp.

Definition at line 125 of file BppImage.hpp.

Constructor & Destructor Documentation

◆ ImageDimensions() [1/2]

duds::ui::graphics::ImageDimensions::ImageDimensions ( )
default

Construct uninitialized.

◆ ImageDimensions() [2/2]

template<typename Int0 , typename Int1 , std::enable_if_t< std::is_integral< Int0 >::value, bool > = true, std::enable_if_t< std::is_integral< Int1 >::value, bool > = true>
constexpr duds::ui::graphics::ImageDimensions::ImageDimensions ( Int0  dw,
Int1  dh 
)
inline

Construct with the given dimensions.

The template avoids warnings when the integer type is not std::int16_t. If a value is the result of a computation, it will likely be an int unless explicitly made otherwise, which is annoying.

Parameters
dwThe width.
dhThe height.

Definition at line 152 of file BppImage.hpp.

Member Function Documentation

◆ clear()

void duds::ui::graphics::ImageDimensions::clear ( )
inline

Set the dimensions to zero area.

Definition at line 175 of file BppImage.hpp.

◆ clip()

constexpr ImageDimensions duds::ui::graphics::ImageDimensions::clip ( const ImageDimensions dim,
const ImageLocation loc = ImageLocation(0, 0) 
) const
inline

Returns a region clipped to fit within this object's dimensions.

Parameters
dimThe region that may need to be clipped to fit.
locThe offset location into this object's area. The offset may be negative. The default is no offset.
Returns
The dimensions of dim that fit within this object. If either dimension value is zero (empty() is true), the regions do not overlap.

Definition at line 234 of file BppImage.hpp.

Referenced by duds::ui::graphics::BppImage::write().

◆ empty()

◆ fits() [1/2]

constexpr bool duds::ui::graphics::ImageDimensions::fits ( const ImageDimensions id) const
inline

Returns true if the given dimensions are not larger than this object's dimensions.

Definition at line 189 of file BppImage.hpp.

Referenced by duds::ui::graphics::PriorityGridLayout::layout().

◆ fits() [2/2]

constexpr bool duds::ui::graphics::ImageDimensions::fits ( const ImageLocation loc,
const ImageDimensions id 
) const
inline

Returns true if the given dimensions at the given location relative to this object can fit within this object's dimentions.

Definition at line 196 of file BppImage.hpp.

◆ maxExtent()

constexpr ImageDimensions duds::ui::graphics::ImageDimensions::maxExtent ( const ImageDimensions dim) const
inline

Returns new dimensions that are minimally large enough to fit this dimension and the given dimension.

Definition at line 222 of file BppImage.hpp.

Referenced by duds::ui::graphics::BppFont::estimatedMaxCharacterSize(), and duds::ui::graphics::MaxExtent().

◆ minExtent()

constexpr ImageDimensions duds::ui::graphics::ImageDimensions::minExtent ( const ImageDimensions dim) const
inline

Returns new dimensions that only cover the union of this dimension and the given dimension.

Definition at line 215 of file BppImage.hpp.

Referenced by duds::ui::menu::renderers::BppMenuRenderer::render().

◆ operator!=()

constexpr bool duds::ui::graphics::ImageDimensions::operator!= ( const ImageDimensions id) const
inline

Obvious inequality operator.

Definition at line 163 of file BppImage.hpp.

◆ operator==()

constexpr bool duds::ui::graphics::ImageDimensions::operator== ( const ImageDimensions id) const
inline

Obvious equality operator.

Definition at line 157 of file BppImage.hpp.

◆ swapAxes()

void duds::ui::graphics::ImageDimensions::swapAxes ( )
inline

Swaps the dimensions's axes.

Definition at line 202 of file BppImage.hpp.

Referenced by duds::ui::graphics::BppPositionIndicator::render(), and duds::ui::graphics::BppImage::write().

◆ swappedAxes()

constexpr ImageDimensions duds::ui::graphics::ImageDimensions::swappedAxes ( ) const
inline

Returns new dimensions with swapped axes.

Definition at line 208 of file BppImage.hpp.

Referenced by duds::ui::graphics::BppImage::write().

◆ withinBounds()

Member Data Documentation

◆ h

◆ w


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