Small refactoring
This commit is contained in:
@@ -28,6 +28,11 @@ struct point_t
|
||||
{
|
||||
coord_t x;
|
||||
coord_t y;
|
||||
|
||||
bool operator != (const point_t & b) const
|
||||
{
|
||||
return x != b.x || y != b.y;
|
||||
}
|
||||
};
|
||||
|
||||
struct rect_t
|
||||
@@ -53,6 +58,11 @@ struct rect_t
|
||||
{
|
||||
return y + h;
|
||||
}
|
||||
|
||||
bool contains(coord_t x, coord_t y) const
|
||||
{
|
||||
return (x >= this->x && x < this->x + this->w && y >= this->y && y < this->y + this->h);
|
||||
}
|
||||
};
|
||||
|
||||
typedef uint32_t LcdFlags;
|
||||
|
||||
+3
-3
@@ -331,7 +331,7 @@ bool Window::onTouchStart(coord_t x, coord_t y)
|
||||
{
|
||||
for (auto it = children.rbegin(); it != children.rend(); ++it) {
|
||||
auto child = *it;
|
||||
if (pointInRect(x, y, child->rect)) {
|
||||
if (child->rect.contains(x, y)) {
|
||||
if (child->onTouchStart(x - child->rect.x + child->scrollPositionX, y - child->rect.y + child->scrollPositionY)) {
|
||||
return true;
|
||||
}
|
||||
@@ -345,7 +345,7 @@ bool Window::forwardTouchEnd(coord_t x, coord_t y)
|
||||
{
|
||||
for (auto it = children.rbegin(); it != children.rend(); ++it) {
|
||||
auto child = *it;
|
||||
if (pointInRect(x, y, child->rect)) {
|
||||
if (child->rect.contains(x, y)) {
|
||||
if (child->onTouchEnd(x - child->rect.x + child->scrollPositionX, y - child->rect.y + child->scrollPositionY)) {
|
||||
return true;
|
||||
}
|
||||
@@ -364,7 +364,7 @@ bool Window::onTouchSlide(coord_t x, coord_t y, coord_t startX, coord_t startY,
|
||||
{
|
||||
for (auto it = children.rbegin(); it != children.rend(); ++it) {
|
||||
auto child = *it;
|
||||
if (pointInRect(startX, startY, child->rect)) {
|
||||
if (child->rect.contains(startX, startY)) {
|
||||
if (child->onTouchSlide(x - child->rect.x, y - child->rect.y, startX - child->rect.x, startY - child->rect.y, slideX, slideY)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
-5
@@ -297,11 +297,6 @@ class Window {
|
||||
|
||||
void drawVerticalScrollbar(BitmapBuffer * dc);
|
||||
|
||||
static bool pointInRect(coord_t x, coord_t y, rect_t & rect)
|
||||
{
|
||||
return (x >= rect.x && x < rect.x + rect.w && y >= rect.y && y < rect.y + rect.h);
|
||||
}
|
||||
|
||||
virtual void onEvent(event_t event);
|
||||
|
||||
void adjustInnerHeight();
|
||||
|
||||
Reference in New Issue
Block a user