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;
82 return r.left() >= left() &&
83 r.left() + as_delta(r.size.width) <= left() + as_delta(size.width) &&
85 r.top() + as_delta(r.size.height) <= top() + as_delta(size.height);
90 bool disjoint = r.left() >= right()
91 || r.right() <= left()
92 || r.top() >= bottom()
93 || r.bottom() <= top()
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()}};
127 inline constexpr bool operator == (Rectangle<T>
const& lhs, Rectangle<T>
const& rhs)
129 return lhs.top_left == rhs.top_left && lhs.size == rhs.size;
133 inline constexpr bool operator != (Rectangle<T>
const& lhs, Rectangle<T>
const& rhs)
135 return lhs.top_left != rhs.top_left || lhs.size != rhs.size;
139 std::ostream& operator<<(std::ostream& out, Rectangle<T>
const& value)
141 out <<
'(' << value.top_left <<
", " << value.size <<
')';