Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
gfx::Size Class Reference

#include <size.h>

Public Member Functions

constexpr Size ()
 
constexpr Size (int width, int height)
 
void operator+= (const Size &size)
 
void operator-= (const Size &size)
 
constexpr int width () const
 
constexpr int height () const
 
void set_width (int width)
 
void set_height (int height)
 
int GetArea () const
 
base::CheckedNumeric< intGetCheckedArea () const
 
void SetSize (int width, int height)
 
void Enlarge (int grow_width, int grow_height)
 
void SetToMin (const Size &other)
 
void SetToMax (const Size &other)
 
bool IsEmpty () const
 
std::string ToString () const
 

Detailed Description

Definition at line 26 of file size.h.

Constructor & Destructor Documentation

◆ Size() [1/2]

constexpr gfx::Size::Size ( )
inlineconstexpr

Definition at line 28 of file size.h.

28: width_(0), height_(0) {}

◆ Size() [2/2]

constexpr gfx::Size::Size ( int  width,
int  height 
)
inlineconstexpr

Definition at line 29 of file size.h.

30 : width_(std::max(0, width)), height_(std::max(0, height)) {}
constexpr int height() const
Definition size.h:50
constexpr int width() const
Definition size.h:49

Member Function Documentation

◆ Enlarge()

void gfx::Size::Enlarge ( int  grow_width,
int  grow_height 
)

Definition at line 65 of file size.cc.

65 {
66 SetSize(base::ClampAdd(width(), grow_width),
67 base::ClampAdd(height(), grow_height));
68}
void SetSize(int width, int height)
Definition size.h:60

◆ GetArea()

int gfx::Size::GetArea ( ) const

Definition at line 55 of file size.cc.

55 {
56 return GetCheckedArea().ValueOrDie();
57}
base::CheckedNumeric< int > GetCheckedArea() const
Definition size.cc:59

◆ GetCheckedArea()

base::CheckedNumeric< int > gfx::Size::GetCheckedArea ( ) const

Definition at line 59 of file size.cc.

59 {
60 base::CheckedNumeric<int> checked_area = width();
61 checked_area *= height();
62 return checked_area;
63}

◆ height()

constexpr int gfx::Size::height ( ) const
inlineconstexpr

Definition at line 50 of file size.h.

50{ return height_; }

◆ IsEmpty()

bool gfx::Size::IsEmpty ( ) const
inline

Definition at line 70 of file size.h.

70{ return !width() || !height(); }

◆ operator+=()

void gfx::Size::operator+= ( const Size size)

Definition at line 34 of file size.cc.

34 {
35 Enlarge(size.width(), size.height());
36}
void Enlarge(int grow_width, int grow_height)
Definition size.cc:65
constexpr size_t size(const T(&array)[N]) noexcept

◆ operator-=()

void gfx::Size::operator-= ( const Size size)

Definition at line 38 of file size.cc.

38 {
39 Enlarge(-size.width(), -size.height());
40}

◆ set_height()

void gfx::Size::set_height ( int  height)
inline

Definition at line 53 of file size.h.

53{ height_ = std::max(0, height); }

◆ set_width()

void gfx::Size::set_width ( int  width)
inline

Definition at line 52 of file size.h.

52{ width_ = std::max(0, width); }

◆ SetSize()

void gfx::Size::SetSize ( int  width,
int  height 
)
inline

Definition at line 60 of file size.h.

60 {
63 }
void set_height(int height)
Definition size.h:53
void set_width(int width)
Definition size.h:52

◆ SetToMax()

void gfx::Size::SetToMax ( const Size other)

Definition at line 75 of file size.cc.

75 {
76 width_ = width() >= other.width() ? width() : other.width();
77 height_ = height() >= other.height() ? height() : other.height();
78}

◆ SetToMin()

void gfx::Size::SetToMin ( const Size other)

Definition at line 70 of file size.cc.

70 {
71 width_ = width() <= other.width() ? width() : other.width();
72 height_ = height() <= other.height() ? height() : other.height();
73}

◆ ToString()

std::string gfx::Size::ToString ( ) const

Definition at line 80 of file size.cc.

80 {
81 return base::StringPrintf("%dx%d", width(), height());
82}
std::string StringPrintf(const std::string &format, Args... args)

◆ width()

constexpr int gfx::Size::width ( ) const
inlineconstexpr

Definition at line 49 of file size.h.

49{ return width_; }

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