mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-08-09 16:26:38 +08:00
Add Box::IsEmpty()
This commit is contained in:
parent
3d6c48e800
commit
0279bed8c4
@ -29,6 +29,9 @@ current (development)
|
||||
reflecting the current scroll position. Proposed by @ibrahimnasson in
|
||||
[issue 752](https://github.com/ArthurSonzogni/FTXUI/issues/752)
|
||||
|
||||
### Screen
|
||||
- Feature: Add `Box::IsEmpty()`.
|
||||
|
||||
### Build
|
||||
- Support for cmake's "unity/jumbo" builds. Fixed by @ClausKlein.
|
||||
|
||||
|
@ -15,7 +15,7 @@ struct Box {
|
||||
static auto Intersection(Box a, Box b) -> Box;
|
||||
static auto Union(Box a, Box b) -> Box;
|
||||
bool Contain(int x, int y) const;
|
||||
int Area() const noexcept;
|
||||
bool IsEmpty();
|
||||
bool operator==(const Box& other) const;
|
||||
bool operator!=(const Box& other) const;
|
||||
};
|
||||
|
@ -850,8 +850,9 @@ void Canvas::DrawImage(int x,
|
||||
y = 0;
|
||||
}
|
||||
|
||||
if (crop.Area() == 0)
|
||||
if (crop.IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto xend = x + crop.x_max - crop.x_min;
|
||||
const auto yend = y + crop.y_max - crop.y_min;
|
||||
|
@ -39,11 +39,10 @@ bool Box::Contain(int x, int y) const {
|
||||
y_max >= y;
|
||||
}
|
||||
|
||||
/// @return the are of the box
|
||||
/// @return whether the box is empty.
|
||||
/// @ingroup screen
|
||||
int Box::Area() const noexcept {
|
||||
const auto area = (x_max - x_min) * (y_max - y_min);
|
||||
return area < 0 ? 0 : area;
|
||||
bool Box::IsEmpty() {
|
||||
return x_min > x_max || y_min > y_max;
|
||||
}
|
||||
|
||||
/// @return whether |other| is the same as |this|
|
||||
|
Loading…
Reference in New Issue
Block a user