display: Add helper methods to Display::clip and Display::clamp_x/y_ (#5003)

* display: `Rect` make most of methods `const`

* display: add `clip` and `clamp_x/y_` methods for clipping to `Display`
This commit is contained in:
Kamil Trzciński
2023-07-15 05:30:19 +09:00
committed by GitHub
parent f8df694aa3
commit 1691c13b47
4 changed files with 57 additions and 15 deletions
+3 -3
View File
@@ -60,11 +60,11 @@ void Rect::shrink(Rect rect) {
}
}
bool Rect::equal(Rect rect) {
bool Rect::equal(Rect rect) const {
return (rect.x == this->x) && (rect.w == this->w) && (rect.y == this->y) && (rect.h == this->h);
}
bool Rect::inside(int16_t test_x, int16_t test_y, bool absolute) { // NOLINT
bool Rect::inside(int16_t test_x, int16_t test_y, bool absolute) const { // NOLINT
if (!this->is_set()) {
return true;
}
@@ -75,7 +75,7 @@ bool Rect::inside(int16_t test_x, int16_t test_y, bool absolute) { // NOLINT
}
}
bool Rect::inside(Rect rect, bool absolute) {
bool Rect::inside(Rect rect, bool absolute) const {
if (!this->is_set() || !rect.is_set()) {
return true;
}