2019-01-20 05:06:05 +08:00
|
|
|
#include "ftxui/screen/box.hpp"
|
2020-03-23 05:32:44 +08:00
|
|
|
|
2019-02-02 08:59:48 +08:00
|
|
|
#include <algorithm>
|
2019-01-20 05:06:05 +08:00
|
|
|
|
|
|
|
namespace ftxui {
|
2020-08-16 08:24:50 +08:00
|
|
|
/// @return the biggest Box contained in both |a| and |b|.
|
|
|
|
/// @ingroup screen
|
2019-01-20 05:06:05 +08:00
|
|
|
// static
|
|
|
|
Box Box::Intersection(Box a, Box b) {
|
|
|
|
return Box{
|
|
|
|
std::max(a.x_min, b.x_min),
|
|
|
|
std::min(a.x_max, b.x_max),
|
|
|
|
std::max(a.y_min, b.y_min),
|
|
|
|
std::min(a.y_max, b.y_max),
|
|
|
|
};
|
|
|
|
}
|
2021-04-19 04:33:41 +08:00
|
|
|
|
|
|
|
/// @return whether (x,y) is contained inside the box.
|
|
|
|
/// @ingroup screen
|
|
|
|
bool Box::Contain(int x, int y) {
|
|
|
|
return x_min <= x && //
|
|
|
|
x_max >= x && //
|
|
|
|
y_min <= y && //
|
|
|
|
y_max >= y;
|
|
|
|
}
|
|
|
|
|
2019-01-20 05:06:05 +08:00
|
|
|
} // namespace ftxui
|
2020-08-16 06:24:18 +08:00
|
|
|
|
|
|
|
// Copyright 2020 Arthur Sonzogni. All rights reserved.
|
|
|
|
// Use of this source code is governed by the MIT license that can be found in
|
|
|
|
// the LICENSE file.
|