main window: remove last rest of touch handling

This commit is contained in:
Raphael Coeffic
2022-06-13 21:02:24 +02:00
committed by Raphael Coeffic
parent 7679077632
commit 6f15104bb4
2 changed files with 9 additions and 72 deletions
+9 -47
View File
@@ -22,73 +22,34 @@
#include "lvgl/lvgl.h"
#if defined(HARDWARE_TOUCH)
#include "touch.h"
#endif
#if defined(HARDWARE_TOUCH)
TouchState touchState;
#endif
MainWindow * MainWindow::_instance = nullptr;
MainWindow::MainWindow() :
Window(nullptr, {0, 0, LCD_W, LCD_H}, OPAQUE),
invalidatedRect(rect)
Window(nullptr, {0, 0, LCD_W, LCD_H}, OPAQUE), invalidatedRect(rect)
{
}
void MainWindow::emptyTrash()
{
for (auto window: trash) {
for (auto window : trash) {
delete window;
}
trash.clear();
}
#if defined(HARDWARE_TOUCH)
void MainWindow::setTouchEnabled(bool enable)
{
switch(touchEnableState)
{
case TouchOn:
if(!enable)
touchEnableState = TouchOff;
break;
case TouchOn_Touching:
if(!enable)
touchEnableState = TouchOnToOff_Touching;
break;
case TouchOnToOff_Touching:
if(enable)
touchEnableState = TouchOn_Touching;
break;
case TouchOff:
if(enable)
touchEnableState = TouchOn;
break;
case TouchOff_Touching:
if(enable)
touchEnableState = TouchOffToOn_Touching;
break;
case TouchOffToOn_Touching:
if(!enable)
touchEnableState = TouchOff_Touching;
break;
}
}
#endif
void MainWindow::invalidate(const rect_t & rect)
void MainWindow::invalidate(const rect_t& rect)
{
if (invalidatedRect.w) {
auto left = limit<coord_t>(0, rect.left(), invalidatedRect.left());
auto right = limit<coord_t>(invalidatedRect.right(), rect.right(), LCD_W);
auto top = limit<coord_t>(0, rect.top(), invalidatedRect.top());
auto bottom = limit<coord_t>(rect.bottom(), invalidatedRect.bottom(), LCD_H);
auto bottom =
limit<coord_t>(rect.bottom(), invalidatedRect.bottom(), LCD_H);
invalidatedRect = {left, top, right - left, bottom - top};
}
else {
} else {
invalidatedRect = rect;
}
}
@@ -101,9 +62,10 @@ void MainWindow::run(bool trash)
if (opaque) opaque->checkEvents();
if (trash) emptyTrash();
auto delta = ticksNow() - start;
if (delta > 10 * SYSTEM_TICKS_1MS) {
TRACE_WINDOWS("MainWindow::run took %dms", (ticksNow() - start) / SYSTEM_TICKS_1MS);
TRACE_WINDOWS("MainWindow::run took %dms",
(ticksNow() - start) / SYSTEM_TICKS_1MS);
}
}
-25
View File
@@ -62,17 +62,6 @@ class MainWindow: public Window
}
#endif
#if defined(HARDWARE_TOUCH)
void setTouchEnabled(bool enable);
bool touchEventOccured() {
if(_touchEventOccured)
{
_touchEventOccured = false;
return true;
}
return false;
}
#endif
void setActiveScreen() {
lv_scr_load(lvobj);
@@ -99,18 +88,4 @@ class MainWindow: public Window
static void emptyTrash();
rect_t invalidatedRect;
const char * shutdown = nullptr;
#if defined(HARDWARE_TOUCH)
bool lastTouchState = false;
bool _touchEventOccured = false;
enum TouchEnableState {
TouchOn,
TouchOn_Touching,
TouchOnToOff_Touching,
TouchOff,
TouchOff_Touching,
TouchOffToOn_Touching
};
TouchEnableState touchEnableState = TouchOn;
#endif
};