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