FTXUI
6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
box.cpp
Go to the documentation of this file.
1
// Copyright 2020 Arthur Sonzogni. All rights reserved.
2
// このソースコードの使用は、LICENSE ファイルに見つかる MIT ライセンスによって管理されています。
3
#include "
ftxui/screen/box.hpp
"
4
5
#include <algorithm>
6
7
namespace
ftxui
{
8
/// @return |a| と |b| の両方に含まれる最大のBoxを返します。
9
// static
10
Box
Box::Intersection
(
Box
a,
Box
b) {
11
return
Box
{
12
std::max(a.
x_min
, b.
x_min
),
13
std::min(a.
x_max
, b.
x_max
),
14
std::max(a.
y_min
, b.
y_min
),
15
std::min(a.
y_max
, b.
y_max
),
16
};
17
}
18
19
/// @return |a| と |b| の両方を含む最小のBoxを返します。
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
/// Boxを (x,y) だけシフトします。
31
/// @param x 水平シフト。
32
/// @param y 垂直シフト。
33
void
Box::Shift
(
int
x,
int
y) {
34
x_min
+= x;
35
x_max
+= x;
36
y_min
+= y;
37
y_max
+= y;
38
}
39
40
/// @return (x,y) がBox内に含まれているかどうか。
41
bool
Box::Contain
(
int
x,
int
y)
const
{
42
return
x_min
<= x &&
//
43
x_max
>= x &&
//
44
y_min
<= y &&
//
45
y_max
>= y;
46
}
47
48
/// @return Boxが空かどうか。
49
bool
Box::IsEmpty
()
const
{
50
return
x_min
>
x_max
||
y_min
>
y_max
;
51
}
52
53
/// @return |other| が |this| と同じかどうか。
54
bool
Box::operator==
(
const
Box
& other)
const
{
55
return
(
x_min
== other.
x_min
) && (
x_max
== other.
x_max
) &&
56
(
y_min
== other.
y_min
) && (
y_max
== other.
y_max
);
57
}
58
59
/// @return |other| と |this| が異なるかどうか。
60
bool
Box::operator!=
(
const
Box
& other)
const
{
61
return
!
operator==
(other);
62
}
63
64
}
// namespace ftxui
box.hpp
ftxui::Box::operator!=
bool operator!=(const Box &other) const
Definition
box.cpp:60
ftxui::Box::Contain
bool Contain(int x, int y) const
Definition
box.cpp:41
ftxui::Box::Shift
void Shift(int x, int y)
Definition
box.cpp:33
ftxui::Box::x_max
int x_max
Definition
box.hpp:16
ftxui::Box::y_min
int y_min
Definition
box.hpp:17
ftxui::Box::Intersection
static auto Intersection(Box a, Box b) -> Box
Definition
box.cpp:10
ftxui::Box::IsEmpty
bool IsEmpty() const
Definition
box.cpp:49
ftxui::Box::y_max
int y_max
Definition
box.hpp:18
ftxui::Box::operator==
bool operator==(const Box &other) const
Definition
box.cpp:54
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:15
ftxui::Box
Boxは、2D空間における矩形領域を表す構造体です。
Definition
box.hpp:14
ftxui
FTXUI ftxui:: 名前空間
Definition
animation.hpp:9