FTXUI  4.1.0
C++ functional terminal UI.
Loading...
Searching...
No Matches
box.cpp
Go to the documentation of this file.
2
3#include <algorithm>
4
5namespace ftxui {
6/// @return the biggest Box contained in both |a| and |b|.
7/// @ingroup screen
8// static
10 return Box{
11 std::max(a.x_min, b.x_min),
12 std::min(a.x_max, b.x_max),
13 std::max(a.y_min, b.y_min),
14 std::min(a.y_max, b.y_max),
15 };
16}
17
18/// @return the smallest Box containing both |a| and |b|.
19/// @ingroup screen
20// static
22 return Box{
23 std::min(a.x_min, b.x_min),
24 std::max(a.x_max, b.x_max),
25 std::min(a.y_min, b.y_min),
26 std::max(a.y_max, b.y_max),
27 };
28}
29
30/// @return whether (x,y) is contained inside the box.
31/// @ingroup screen
32bool Box::Contain(int x, int y) const {
33 return x_min <= x && //
34 x_max >= x && //
35 y_min <= y && //
36 y_max >= y;
37}
38
39/// @return whether |other| is the same as |this|
40/// @ingroup screen
41bool Box::operator==(const Box& other) const {
42 return (x_min == other.x_min) && (x_max == other.x_max) &&
43 (y_min == other.y_min) && (y_max == other.y_max);
44}
45
46/// @return whether |other| and |this| are different.
47/// @ingroup screen
48bool Box::operator!=(const Box& other) const {
49 return !operator==(other);
50}
51
52} // namespace ftxui
53
54// Copyright 2020 Arthur Sonzogni. All rights reserved.
55// Use of this source code is governed by the MIT license that can be found in
56// the LICENSE file.
bool operator!=(const Box &other) const
Definition box.cpp:48
bool Contain(int x, int y) const
Definition box.cpp:32
int x_max
Definition box.hpp:8
int y_min
Definition box.hpp:9
static auto Intersection(Box a, Box b) -> Box
Definition box.cpp:9
int y_max
Definition box.hpp:10
bool operator==(const Box &other) const
Definition box.cpp:41
static auto Union(Box a, Box b) -> Box
Definition box.cpp:21
int x_min
Definition box.hpp:7