FTXUI
4.0.0
C++ functional terminal UI.
Loading...
Searching...
No Matches
box.cpp
Go to the documentation of this file.
1
#include "
ftxui/screen/box.hpp
"
2
3
#include <algorithm>
4
5
namespace
ftxui
{
6
/// @return the biggest Box contained in both |a| and |b|.
7
/// @ingroup screen
8
// static
9
Box
Box::Intersection
(
Box
a,
Box
b) {
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
21
Box
Box::Union
(
Box
a,
Box
b) {
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
32
bool
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
41
bool
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
48
bool
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.
box.hpp
ftxui
Definition
animation.hpp:9
ftxui::Box
Definition
box.hpp:6
ftxui::Box::operator!=
bool operator!=(const Box &other) const
Definition
box.cpp:48
ftxui::Box::Contain
bool Contain(int x, int y) const
Definition
box.cpp:32
ftxui::Box::x_max
int x_max
Definition
box.hpp:8
ftxui::Box::y_min
int y_min
Definition
box.hpp:9
ftxui::Box::Intersection
static auto Intersection(Box a, Box b) -> Box
Definition
box.cpp:9
ftxui::Box::y_max
int y_max
Definition
box.hpp:10
ftxui::Box::operator==
bool operator==(const Box &other) const
Definition
box.cpp:41
ftxui::Box::Union
static auto Union(Box a, Box b) -> Box
Definition
box.cpp:21
ftxui::Box::x_min
int x_min
Definition
box.hpp:7