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

#include <insets.h>

Public Member Functions

constexpr Insets ()
 
constexpr Insets (int all)
 
constexpr Insets (int vertical, int horizontal)
 
constexpr Insets (int top, int left, int bottom, int right)
 
constexpr int top () const
 
constexpr int left () const
 
constexpr int bottom () const
 
constexpr int right () const
 
constexpr int width () const
 
constexpr int height () const
 
constexpr Size size () const
 
bool IsEmpty () const
 
void set_top (int top)
 
void set_left (int left)
 
void set_bottom (int bottom)
 
void set_right (int right)
 
void Set (int top, int left, int bottom, int right)
 
bool operator== (const Insets &insets) const
 
bool operator!= (const Insets &insets) const
 
void operator+= (const Insets &insets)
 
void operator-= (const Insets &insets)
 
Insets operator- () const
 
Insets Scale (float scale) const
 
Insets Scale (float x_scale, float y_scale) const
 
Insets Offset (const gfx::Vector2d &vector) const
 
 operator InsetsF () const
 
std::string ToString () const
 

Detailed Description

Definition at line 26 of file insets.h.

Constructor & Destructor Documentation

◆ Insets() [1/4]

constexpr gfx::Insets::Insets ( )
inlineconstexpr

Definition at line 28 of file insets.h.

28: top_(0), left_(0), bottom_(0), right_(0) {}

◆ Insets() [2/4]

constexpr gfx::Insets::Insets ( int  all)
inlineexplicitconstexpr

Definition at line 29 of file insets.h.

30 : top_(all),
31 left_(all),
32 bottom_(GetClampedValue(all, all)),
33 right_(GetClampedValue(all, all)) {}

◆ Insets() [3/4]

constexpr gfx::Insets::Insets ( int  vertical,
int  horizontal 
)
inlineexplicitconstexpr

Definition at line 34 of file insets.h.

35 : top_(vertical),
36 left_(horizontal),
37 bottom_(GetClampedValue(vertical, vertical)),
38 right_(GetClampedValue(horizontal, horizontal)) {}

◆ Insets() [4/4]

constexpr gfx::Insets::Insets ( int  top,
int  left,
int  bottom,
int  right 
)
inlineconstexpr

Definition at line 39 of file insets.h.

40 : top_(top),
41 left_(left),
42 bottom_(GetClampedValue(top, bottom)),
43 right_(GetClampedValue(left, right)) {}
constexpr int right() const
Definition insets.h:48
constexpr int bottom() const
Definition insets.h:47
constexpr int top() const
Definition insets.h:45
constexpr int left() const
Definition insets.h:46

Member Function Documentation

◆ bottom()

constexpr int gfx::Insets::bottom ( ) const
inlineconstexpr

Definition at line 47 of file insets.h.

47{ return bottom_; }

◆ height()

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

Definition at line 56 of file insets.h.

56{ return top_ + bottom_; }

◆ IsEmpty()

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

Definition at line 63 of file insets.h.

63{ return width() == 0 && height() == 0; }
constexpr int width() const
Definition insets.h:52
constexpr int height() const
Definition insets.h:56

◆ left()

constexpr int gfx::Insets::left ( ) const
inlineconstexpr

Definition at line 46 of file insets.h.

46{ return left_; }

◆ Offset()

Insets gfx::Insets::Offset ( const gfx::Vector2d vector) const

Definition at line 17 of file insets.cc.

17 {
18 return gfx::Insets(base::ClampAdd(top(), vector.y()),
19 base::ClampAdd(left(), vector.x()),
20 base::ClampSub(bottom(), vector.y()),
21 base::ClampSub(right(), vector.x()));
22}
constexpr int x() const
Definition vector2d.h:27
constexpr int y() const
Definition vector2d.h:30

◆ operator InsetsF()

gfx::Insets::operator InsetsF ( ) const
inline

Definition at line 124 of file insets.h.

124 {
125 return InsetsF(static_cast<float>(top()), static_cast<float>(left()),
126 static_cast<float>(bottom()), static_cast<float>(right()));
127 }

◆ operator!=()

bool gfx::Insets::operator!= ( const Insets insets) const
inline

Definition at line 88 of file insets.h.

88{ return !(*this == insets); }

◆ operator+=()

void gfx::Insets::operator+= ( const Insets insets)
inline

Definition at line 90 of file insets.h.

90 {
91 top_ = base::ClampAdd(top_, insets.top_);
92 left_ = base::ClampAdd(left_, insets.left_);
93 bottom_ = GetClampedValue(top_, base::ClampAdd(bottom_, insets.bottom_));
94 right_ = GetClampedValue(left_, base::ClampAdd(right_, insets.right_));
95 }

◆ operator-()

Insets gfx::Insets::operator- ( ) const
inline

Definition at line 104 of file insets.h.

104 {
105 return Insets(-base::MakeClampedNum(top_), -base::MakeClampedNum(left_),
106 -base::MakeClampedNum(bottom_),
107 -base::MakeClampedNum(right_));
108 }
constexpr Insets()
Definition insets.h:28

◆ operator-=()

void gfx::Insets::operator-= ( const Insets insets)
inline

Definition at line 97 of file insets.h.

97 {
98 top_ = base::ClampSub(top_, insets.top_);
99 left_ = base::ClampSub(left_, insets.left_);
100 bottom_ = GetClampedValue(top_, base::ClampSub(bottom_, insets.bottom_));
101 right_ = GetClampedValue(left_, base::ClampSub(right_, insets.right_));
102 }

◆ operator==()

bool gfx::Insets::operator== ( const Insets insets) const
inline

Definition at line 83 of file insets.h.

83 {
84 return top_ == insets.top_ && left_ == insets.left_ &&
85 bottom_ == insets.bottom_ && right_ == insets.right_;
86 }

◆ right()

constexpr int gfx::Insets::right ( ) const
inlineconstexpr

Definition at line 48 of file insets.h.

48{ return right_; }

◆ Scale() [1/2]

Insets gfx::Insets::Scale ( float  scale) const
inline

Definition at line 110 of file insets.h.

110{ return Scale(scale, scale); }
const Scalar scale

◆ Scale() [2/2]

Insets gfx::Insets::Scale ( float  x_scale,
float  y_scale 
) const
inline

Definition at line 112 of file insets.h.

112 {
113 return Insets(static_cast<int>(base::ClampMul(top(), y_scale)),
114 static_cast<int>(base::ClampMul(left(), x_scale)),
115 static_cast<int>(base::ClampMul(bottom(), y_scale)),
116 static_cast<int>(base::ClampMul(right(), x_scale)));
117 }

◆ Set()

void gfx::Insets::Set ( int  top,
int  left,
int  bottom,
int  right 
)
inline

Definition at line 76 of file insets.h.

76 {
77 top_ = top;
78 left_ = left;
79 bottom_ = GetClampedValue(top_, bottom);
80 right_ = GetClampedValue(left_, right);
81 }

◆ set_bottom()

void gfx::Insets::set_bottom ( int  bottom)
inline

Definition at line 73 of file insets.h.

73{ bottom_ = GetClampedValue(top_, bottom); }

◆ set_left()

void gfx::Insets::set_left ( int  left)
inline

Definition at line 69 of file insets.h.

69 {
70 left_ = left;
71 right_ = GetClampedValue(left_, right_);
72 }

◆ set_right()

void gfx::Insets::set_right ( int  right)
inline

Definition at line 74 of file insets.h.

74{ right_ = GetClampedValue(left_, right); }

◆ set_top()

void gfx::Insets::set_top ( int  top)
inline

Definition at line 65 of file insets.h.

65 {
66 top_ = top;
67 bottom_ = GetClampedValue(top_, bottom_);
68 }

◆ size()

constexpr Size gfx::Insets::size ( ) const
inlineconstexpr

Definition at line 60 of file insets.h.

60{ return Size(width(), height()); }
TSize< Scalar > Size
Definition size.h:137

◆ top()

constexpr int gfx::Insets::top ( ) const
inlineconstexpr

Definition at line 45 of file insets.h.

45{ return top_; }

◆ ToString()

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

Definition at line 12 of file insets.cc.

12 {
13 // Print members in the same order of the constructor parameters.
14 return base::StringPrintf("%d,%d,%d,%d", top(), left(), bottom(), right());
15}
std::string StringPrintf(const std::string &format, Args... args)

◆ width()

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

Definition at line 52 of file insets.h.

52{ return left_ + right_; }

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