FTXUI 6.1.9
C++ functional terminal UI.
Chargement...
Recherche...
Aucune correspondance
box.cpp
Aller à la documentation de ce fichier.
1// Copyright 2020 Arthur Sonzogni. Tous droits réservés.
2// L'utilisation de ce code source est régie par la licence MIT qui peut être trouvée dans
3// le fichier LICENSE.
5
6#include <algorithm>
7
8namespace ftxui {
9/// @return la plus grande Box contenue dans |a| et |b|.
10// static
12 return Box{
13 std::max(a.x_min, b.x_min),
14 std::min(a.x_max, b.x_max),
15 std::max(a.y_min, b.y_min),
16 std::min(a.y_max, b.y_max),
17 };
18}
19
20/// @return la plus petite Box contenant à la fois |a| et |b|.
21// static
23 return Box{
24 std::min(a.x_min, b.x_min),
25 std::max(a.x_max, b.x_max),
26 std::min(a.y_min, b.y_min),
27 std::max(a.y_max, b.y_max),
28 };
29}
30
31/// Décale la boîte de (x,y).
32/// @param x décalage horizontal.
33/// @param y décalage vertical.
34void Box::Shift(int x, int y) {
35 x_min += x;
36 x_max += x;
37 y_min += y;
38 y_max += y;
39}
40
41/// @return si (x,y) est contenu dans la boîte.
42bool Box::Contain(int x, int y) const {
43 return x_min <= x && //
44 x_max >= x && //
45 y_min <= y && //
46 y_max >= y;
47}
48
49/// @return si la boîte est vide.
50bool Box::IsEmpty() const {
51 return x_min > x_max || y_min > y_max;
52}
53
54/// @return si |other| est identique à |this|
55bool Box::operator==(const Box& other) const {
56 return (x_min == other.x_min) && (x_max == other.x_max) &&
57 (y_min == other.y_min) && (y_max == other.y_max);
58}
59
60/// @return si |other| et |this| sont différents.
61bool Box::operator!=(const Box& other) const {
62 return !operator==(other);
63}
64
65} // namespace ftxui
bool operator!=(const Box &other) const
Definition box.cpp:61
bool Contain(int x, int y) const
Definition box.cpp:42
void Shift(int x, int y)
Definition box.cpp:34
int x_max
Definition box.hpp:18
int y_min
Definition box.hpp:19
static auto Intersection(Box a, Box b) -> Box
Definition box.cpp:11
bool IsEmpty() const
Definition box.cpp:50
int y_max
Definition box.hpp:20
bool operator==(const Box &other) const
Definition box.cpp:55
static auto Union(Box a, Box b) -> Box
Definition box.cpp:22
int x_min
Definition box.hpp:17
Box est une structure qui représente une zone rectangulaire dans un espace 2D.
Definition box.hpp:16
L'espace de noms FTXUI ftxui::
Definition animation.hpp:10