17#ifndef MIR_GEOMETRY_RECTANGLE_H_
18#define MIR_GEOMETRY_RECTANGLE_H_
66 if (
size.width ==
decltype(
size.width){} ||
size.height ==
decltype(
size.height){})
70 return p.
x >=
left() && p.
x < br.x &&
71 p.
y >=
top() && p.
y < br.y;
94 ||
size.width ==
decltype(
size.width){}
95 ||
size.height ==
decltype(
size.height){}
96 || r.
size.width ==
decltype(r.
size.width){}
97 || r.
size.height ==
decltype(r.
size.height){};
113 auto const max_left = std::max(a.
left(), b.
left());
114 auto const min_right = std::min(a.
right(), b.
right());
115 auto const max_top = std::max(a.
top(), b.
top());
116 auto const min_bottom = std::min(a.
bottom(), b.
bottom());
118 if (max_left < min_right && max_top < min_bottom)
119 return {{max_left, max_top},
120 {(min_right - max_left).as_value(),
121 (min_bottom - max_top).as_value()}};
141 out <<
'(' << value.
top_left <<
", " << value.
size <<
')';
std::ostream & operator<<(std::ostream &out, Value< T, Tag > const &value)
Definition dimensions.h:118
Rectangle< T > intersection_of(Rectangle< T > const &a, Rectangle< T > const &b)
Definition rectangle.h:111
constexpr bool operator==(Displacement< T > const &lhs, Displacement< T > const &rhs)
Definition displacement.h:75
constexpr Displacement< T > as_displacement(Size< T > const &size)
Definition displacement.h:166
constexpr bool operator!=(Displacement< T > const &lhs, Displacement< T > const &rhs)
Definition displacement.h:81
constexpr generic::DeltaX< T > as_delta(generic::X< T > const &x)
Definition dimensions.h:243
Definition splash_session.h:22
X< T > x
Definition point.h:54
Y< T > y
Definition point.h:55
Definition rectangle.h:35
Y< T > bottom() const
Definition rectangle.h:104
constexpr Rectangle(Point< T > const &top_left, Size< T > const &size)
Definition rectangle.h:38
Point< T > top_left
Definition rectangle.h:106
X< T > right() const
Definition rectangle.h:102
Point< T > bottom_right() const
The bottom right boundary point of the rectangle.
Definition rectangle.h:49
bool contains(Point< T > const &p) const
Definition rectangle.h:64
X< T > left() const
Definition rectangle.h:101
Size< T > size
Definition rectangle.h:107
Point< T > bottom_left() const
Definition rectangle.h:59
constexpr Rectangle()=default
bool contains(Rectangle< T > const &r) const
Test if the rectangle contains another.
Definition rectangle.h:80
bool overlaps(Rectangle< T > const &r) const
Definition rectangle.h:88
Y< T > top() const
Definition rectangle.h:103
Point< T > top_right() const
Definition rectangle.h:54
Wraps a geometry value and prevents it from being accidentally used for invalid operations (such as s...
Definition dimensions.h:37