FTXUI
6.0.2
C++ functional terminal UI.
Toggle main menu visibility
Tutorial
Examples
File List
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Loading...
Searching...
No Matches
box.cpp
Go to the documentation of this file.
1
// Copyright 2020 Arthur Sonzogni. All rights reserved.
2
// Use of this source code is governed by the MIT license that can be found in
3
// the LICENSE file.
4
#include "
ftxui/screen/box.hpp
"
5
6
#include <algorithm>
7
8
namespace
ftxui
{
9
/// @return the biggest Box contained in both |a| and |b|.
10
/// @ingroup screen
11
// static
12
Box
Box::Intersection
(
Box
a,
Box
b) {
13
return
Box
{
14
std::max(a.
x_min
, b.
x_min
),
15
std::min(a.
x_max
, b.
x_max
),
16
std::max(a.
y_min
, b.
y_min
),
17
std::min(a.
y_max
, b.
y_max
),
18
};
19
}
12
Box
Box::Intersection
(
Box
a,
Box
b) {
…
}
20
21
/// @return the smallest Box containing both |a| and |b|.
22
/// @ingroup screen
23
// static
24
Box
Box::Union
(
Box
a,
Box
b) {
25
return
Box
{
26
std::min(a.
x_min
, b.
x_min
),
27
std::max(a.
x_max
, b.
x_max
),
28
std::min(a.
y_min
, b.
y_min
),
29
std::max(a.
y_max
, b.
y_max
),
30
};
31
}
24
Box
Box::Union
(
Box
a,
Box
b) {
…
}
32
33
/// Shift the box by (x,y).
34
/// @param x horizontal shift.
35
/// @param y vertical shift.
36
/// @ingroup screen
37
void
Box::Shift
(
int
x,
int
y) {
38
x_min
+= x;
39
x_max
+= x;
40
y_min
+= y;
41
y_max
+= y;
42
}
37
void
Box::Shift
(
int
x,
int
y) {
…
}
43
44
/// @return whether (x,y) is contained inside the box.
45
/// @ingroup screen
46
bool
Box::Contain
(
int
x,
int
y)
const
{
47
return
x_min
<= x &&
//
48
x_max
>= x &&
//
49
y_min
<= y &&
//
50
y_max
>= y;
51
}
46
bool
Box::Contain
(
int
x,
int
y)
const
{
…
}
52
53
/// @return whether the box is empty.
54
/// @ingroup screen
55
bool
Box::IsEmpty
()
const
{
56
return
x_min
>
x_max
||
y_min
>
y_max
;
57
}
55
bool
Box::IsEmpty
()
const
{
…
}
58
59
/// @return whether |other| is the same as |this|
60
/// @ingroup screen
61
bool
Box::operator==
(
const
Box
&
other
)
const
{
62
return
(
x_min
==
other
.x_min) && (
x_max
==
other
.x_max) &&
63
(
y_min
==
other
.y_min) && (
y_max
==
other
.y_max);
64
}
61
bool
Box::operator==
(
const
Box
&
other
)
const
{
…
}
65
66
/// @return whether |other| and |this| are different.
67
/// @ingroup screen
68
bool
Box::operator!=
(
const
Box
&
other
)
const
{
69
return
!
operator==
(
other
);
70
}
68
bool
Box::operator!=
(
const
Box
&
other
)
const
{
…
}
71
72
}
// namespace ftxui
box.hpp
ftxui
Definition
animation.hpp:10
ftxui::Make
std::shared_ptr< T > Make(Args &&... args)
Definition
component.hpp:26
ftxui::Box
Definition
box.hpp:9
ftxui::Box::operator!=
bool operator!=(const Box &other) const
Definition
box.cpp:68
ftxui::Box::Contain
bool Contain(int x, int y) const
Definition
box.cpp:46
ftxui::Box::Shift
void Shift(int x, int y)
Definition
box.cpp:37
ftxui::Box::x_max
int x_max
Definition
box.hpp:11
ftxui::Box::y_min
int y_min
Definition
box.hpp:12
ftxui::Box::Intersection
static auto Intersection(Box a, Box b) -> Box
Definition
box.cpp:12
ftxui::Box::IsEmpty
bool IsEmpty() const
Definition
box.cpp:55
ftxui::Box::y_max
int y_max
Definition
box.hpp:13
ftxui::Box::operator==
bool operator==(const Box &other) const
Definition
box.cpp:61
ftxui::Box::Union
static auto Union(Box a, Box b) -> Box
Definition
box.cpp:24
ftxui::Box::x_min
int x_min
Definition
box.hpp:10