put files in right place
This commit is contained in:
+3
-3
@@ -76,9 +76,9 @@ void MainWindow::checkEvents()
|
||||
touchState.lastDeltaY += SLIDE_SPEED_REDUCTION;
|
||||
else
|
||||
touchState.lastDeltaY = 0;
|
||||
if (touchState.lastDeltaX || touchState.lastDeltaY) {
|
||||
onTouchSlide(touchState.x, touchState.y, touchState.startX, touchState.startY, touchState.lastDeltaX, touchState.lastDeltaY);
|
||||
}
|
||||
|
||||
onTouchSlide(touchState.x, touchState.y, touchState.startX, touchState.startY, touchState.lastDeltaX, touchState.lastDeltaY);
|
||||
slidingWindow = nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
+27
@@ -22,6 +22,7 @@
|
||||
|
||||
Window * Window::focusWindow = nullptr;
|
||||
Window * Window::slidingWindow = nullptr;
|
||||
Window * Window::touchedWindow = nullptr;
|
||||
std::list<Window *> Window::trash;
|
||||
|
||||
Window::Window(Window * parent, const rect_t & rect, WindowFlags windowFlags, LcdFlags textFlags):
|
||||
@@ -411,6 +412,12 @@ bool Window::onTouchStart(coord_t x, coord_t y)
|
||||
auto child = *it;
|
||||
if (child->rect.contains(x, y)) {
|
||||
if (child->onTouchStart(x - child->rect.x + child->scrollPositionX, y - child->rect.y + child->scrollPositionY)) {
|
||||
// remember the first window that processed the touch start event. We will give that window
|
||||
// the opportunity to process the touchend first, and also after a slide end so the touched window
|
||||
// always gets a touchEnd if it processed the touch start.
|
||||
if (touchedWindow == nullptr) {
|
||||
touchedWindow = child;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -421,6 +428,26 @@ bool Window::onTouchStart(coord_t x, coord_t y)
|
||||
|
||||
bool Window::forwardTouchEnd(coord_t x, coord_t y)
|
||||
{
|
||||
// give the touched window the opportunity to process the touch first before it is
|
||||
// forwarded: See on touchstart
|
||||
if (touchedWindow != nullptr) {
|
||||
auto savedTouchWindow = touchedWindow;
|
||||
touchedWindow = nullptr;
|
||||
// transalte x and y through the parent hierarchy
|
||||
auto myParent = savedTouchWindow->parent;
|
||||
while(myParent != nullptr) {
|
||||
x = x - myParent->rect.x + myParent->scrollPositionX;
|
||||
y = y - myParent->rect.y + myParent->scrollPositionY;
|
||||
myParent = myParent->parent;
|
||||
}
|
||||
|
||||
if (savedTouchWindow->onTouchEnd(
|
||||
x - savedTouchWindow->rect.x + savedTouchWindow->scrollPositionX,
|
||||
y - savedTouchWindow->rect.y + savedTouchWindow->scrollPositionY)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it = children.rbegin(); it != children.rend(); ++it) {
|
||||
auto child = *it;
|
||||
if (child->rect.contains(x, y)) {
|
||||
|
||||
+1
@@ -395,6 +395,7 @@ class Window
|
||||
|
||||
static Window * focusWindow;
|
||||
static Window * slidingWindow;
|
||||
static Window * touchedWindow;
|
||||
static std::list<Window *> trash;
|
||||
|
||||
std::function<void()> closeHandler;
|
||||
|
||||
Reference in New Issue
Block a user