Slide fixes
This commit is contained in:
+14
-5
@@ -48,21 +48,23 @@ void MainWindow::checkEvents()
|
|||||||
|
|
||||||
if (touchState.event == TE_DOWN) {
|
if (touchState.event == TE_DOWN) {
|
||||||
onTouchStart(touchState.x + scrollPositionX, touchState.y + scrollPositionY);
|
onTouchStart(touchState.x + scrollPositionX, touchState.y + scrollPositionY);
|
||||||
|
slidingWindow = nullptr;
|
||||||
}
|
}
|
||||||
else if (touchState.event == TE_UP) {
|
else if (touchState.event == TE_UP) {
|
||||||
onTouchEnd(touchState.startX + scrollPositionX, touchState.startY + scrollPositionY);
|
onTouchEnd(touchState.startX + scrollPositionX, touchState.startY + scrollPositionY);
|
||||||
touchState.event = TE_NONE;
|
touchState.event = TE_NONE;
|
||||||
|
slidingWindow = nullptr;
|
||||||
}
|
}
|
||||||
else if (touchState.event == TE_SLIDE) {
|
else if (touchState.event == TE_SLIDE) {
|
||||||
if (touchState.deltaX) {
|
if (touchState.deltaX || touchState.deltaY) {
|
||||||
onTouchSlide(touchState.x, touchState.y, touchState.startX, touchState.startY, touchState.deltaX, 0);
|
onTouchSlide(touchState.x, touchState.y, touchState.startX, touchState.startY, touchState.deltaX, touchState.deltaY);
|
||||||
touchState.deltaX = 0;
|
touchState.deltaX = 0;
|
||||||
}
|
|
||||||
else if (touchState.deltaY) {
|
|
||||||
onTouchSlide(touchState.x, touchState.y, touchState.startX, touchState.startY, 0, touchState.deltaY);
|
|
||||||
touchState.deltaY = 0;
|
touchState.deltaY = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
slidingWindow = nullptr;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Window::checkEvents();
|
Window::checkEvents();
|
||||||
@@ -108,6 +110,8 @@ bool MainWindow::refresh()
|
|||||||
|
|
||||||
void MainWindow::run(bool trash)
|
void MainWindow::run(bool trash)
|
||||||
{
|
{
|
||||||
|
auto start = ticksNow();
|
||||||
|
|
||||||
checkEvents();
|
checkEvents();
|
||||||
|
|
||||||
if (trash) {
|
if (trash) {
|
||||||
@@ -117,4 +121,9 @@ void MainWindow::run(bool trash)
|
|||||||
if (refresh()) {
|
if (refresh()) {
|
||||||
lcdRefresh();
|
lcdRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto delta = ticksNow() - start;
|
||||||
|
if (delta > 10 * SYSTEM_TICKS_1MS) {
|
||||||
|
TRACE_WINDOWS("MainWindow::run took %dms", (ticksNow() - start) / SYSTEM_TICKS_1MS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+28
-3
@@ -21,6 +21,7 @@
|
|||||||
#include "touch.h"
|
#include "touch.h"
|
||||||
|
|
||||||
Window * Window::focusWindow = nullptr;
|
Window * Window::focusWindow = nullptr;
|
||||||
|
Window * Window::slidingWindow = nullptr;
|
||||||
std::list<Window *> Window::trash;
|
std::list<Window *> Window::trash;
|
||||||
|
|
||||||
Window::Window(Window * parent, const rect_t & rect, WindowFlags windowFlags, LcdFlags textFlags):
|
Window::Window(Window * parent, const rect_t & rect, WindowFlags windowFlags, LcdFlags textFlags):
|
||||||
@@ -191,24 +192,42 @@ void Window::scrollTo(const rect_t & rect)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Window::hasOpaqueRect(const rect_t & rect)
|
||||||
|
{
|
||||||
|
if (!this->rect.contains(rect))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (windowFlags & OPAQUE) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto child: children) {
|
||||||
|
if (child->hasOpaqueRect(rect))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void Window::fullPaint(BitmapBuffer * dc)
|
void Window::fullPaint(BitmapBuffer * dc)
|
||||||
{
|
{
|
||||||
bool paintNeeded = true;
|
bool paintNeeded = true;
|
||||||
|
|
||||||
|
coord_t xmin, xmax, ymin, ymax;
|
||||||
|
dc->getClippingRect(xmin, xmax, ymin, ymax);
|
||||||
|
|
||||||
auto firstChild = children.end();
|
auto firstChild = children.end();
|
||||||
while (firstChild != children.begin()) {
|
while (firstChild != children.begin()) {
|
||||||
auto child = *(--firstChild);
|
auto child = *(--firstChild);
|
||||||
if ((child->windowFlags & OPAQUE) && isChildFullSize(child)) {
|
if (child->hasOpaqueRect({xmin, ymin, xmax - xmin, ymax - ymin})) {
|
||||||
paintNeeded = false;
|
paintNeeded = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (windowFlags & PAINT_CHILDREN_FIRST) {
|
if (windowFlags & PAINT_CHILDREN_FIRST) {
|
||||||
coord_t xmin, xmax, ymin, ymax;
|
|
||||||
coord_t x = dc->getOffsetX();
|
coord_t x = dc->getOffsetX();
|
||||||
coord_t y = dc->getOffsetY();
|
coord_t y = dc->getOffsetY();
|
||||||
dc->getClippingRect(xmin, xmax, ymin, ymax);
|
|
||||||
paintChildren(dc, firstChild);
|
paintChildren(dc, firstChild);
|
||||||
dc->setOffset(x, y);
|
dc->setOffset(x, y);
|
||||||
dc->setClippingRect(xmin, xmax, ymin, ymax);
|
dc->setClippingRect(xmin, xmax, ymin, ymax);
|
||||||
@@ -374,13 +393,19 @@ bool Window::onTouchSlide(coord_t x, coord_t y, coord_t startX, coord_t startY,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (slidingWindow && slidingWindow != this) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (slideY && innerHeight > rect.h) {
|
if (slideY && innerHeight > rect.h) {
|
||||||
setScrollPositionY(scrollPositionY - slideY);
|
setScrollPositionY(scrollPositionY - slideY);
|
||||||
|
slidingWindow = this;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slideX && innerWidth > rect.w) {
|
if (slideX && innerWidth > rect.w) {
|
||||||
setScrollPositionX(scrollPositionX - slideX);
|
setScrollPositionX(scrollPositionX - slideX);
|
||||||
|
slidingWindow = this;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
@@ -334,6 +334,7 @@ class Window {
|
|||||||
LcdFlags textFlags;
|
LcdFlags textFlags;
|
||||||
|
|
||||||
static Window * focusWindow;
|
static Window * focusWindow;
|
||||||
|
static Window * slidingWindow;
|
||||||
static std::list<Window *> trash;
|
static std::list<Window *> trash;
|
||||||
|
|
||||||
std::function<void()> closeHandler;
|
std::function<void()> closeHandler;
|
||||||
@@ -380,6 +381,8 @@ class Window {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool forwardTouchEnd(coord_t x, coord_t y);
|
bool forwardTouchEnd(coord_t x, coord_t y);
|
||||||
|
|
||||||
|
bool hasOpaqueRect(const rect_t & rect);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _WINDOW_H_
|
#endif // _WINDOW_H_
|
||||||
|
|||||||
Reference in New Issue
Block a user