FTXUI
3.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 whether (x,y) is contained inside the box.
19
/// @ingroup screen
20
bool
Box::Contain
(
int
x,
int
y)
const
{
21
return
x_min
<= x &&
//
22
x_max
>= x &&
//
23
y_min
<= y &&
//
24
y_max
>= y;
25
}
26
27
/// @return whether |other| is the same as |this|
28
/// @ingroup screen
29
bool
Box::operator==
(
const
Box
& other)
const
{
30
return
(
x_min
== other.
x_min
) && (
x_max
== other.
x_max
) &&
31
(
y_min
== other.
y_min
) && (
y_max
== other.
y_max
);
32
}
33
34
/// @return whether |other| and |this| are different.
35
/// @ingroup screen
36
bool
Box::operator!=
(
const
Box
& other)
const
{
37
return
!
operator==
(other);
38
}
39
40
}
// namespace ftxui
41
42
// Copyright 2020 Arthur Sonzogni. All rights reserved.
43
// Use of this source code is governed by the MIT license that can be found in
44
// 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:36
ftxui::Box::Contain
bool Contain(int x, int y) const
Definition
box.cpp:20
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:29
ftxui::Box::x_min
int x_min
Definition
box.hpp:7