Layers are only meant to backup the focus window
This commit is contained in:
committed by
Raphael Coeffic
parent
684a004f9e
commit
4fc2fc8ae6
-13
@@ -37,20 +37,12 @@ class Layer
|
||||
|
||||
static void push(Window * window)
|
||||
{
|
||||
if (window->getLvObj()->parent != nullptr) {
|
||||
TRACE("Layers must have lvgl parent to be null");
|
||||
}
|
||||
|
||||
if (!stack.empty()) {
|
||||
Layer & parentLayer = stack.back();
|
||||
parentLayer.focus = Window::getFocus();
|
||||
}
|
||||
|
||||
// layers are screens in lvgl
|
||||
lv_obj_set_parent(canvas, window->getLvObj());
|
||||
lv_obj_move_background(canvas);
|
||||
lv_scr_load(window->getLvObj());
|
||||
lv_obj_invalidate(canvas);
|
||||
|
||||
stack.emplace_back(Layer(window));
|
||||
|
||||
@@ -67,9 +59,6 @@ class Layer
|
||||
if (stack.back().main == window) {
|
||||
stack.pop_back();
|
||||
const auto & back = stack.back();
|
||||
lv_obj_set_parent(canvas, back.main->getLvObj());
|
||||
lv_obj_move_background(canvas);
|
||||
lv_scr_load(back.main->getLvObj()); // load the screen.
|
||||
if (back.focus) {
|
||||
back.focus->setFocus(SET_FOCUS_DEFAULT);
|
||||
}
|
||||
@@ -78,8 +67,6 @@ class Layer
|
||||
// TODO it would be better to do it in reverse order
|
||||
for (auto it = stack.begin(); it != stack.end(); it++) {
|
||||
if (it->main == window) {
|
||||
lv_obj_set_parent(canvas, it->main->getLvObj());
|
||||
lv_scr_load(it->main->getLvObj());
|
||||
stack.erase(it);
|
||||
break;
|
||||
}
|
||||
|
||||
+11
-7
@@ -24,17 +24,21 @@
|
||||
#include "touch.h"
|
||||
#endif
|
||||
|
||||
MainWindow * MainWindow::_instance = nullptr;
|
||||
|
||||
LvglWidgetFactory mainWindowFactory = LvglWidgetFactory([] (lv_obj_t *parent) {
|
||||
return lv_obj_create(nullptr);
|
||||
});
|
||||
|
||||
|
||||
#if defined(HARDWARE_TOUCH)
|
||||
TouchState touchState;
|
||||
#endif
|
||||
|
||||
static LvglWidgetFactory mainWindowFactory = { lv_obj_create, nullptr };
|
||||
|
||||
MainWindow * MainWindow::_instance = nullptr;
|
||||
|
||||
MainWindow::MainWindow() :
|
||||
Window(nullptr, {0, 0, LCD_W, LCD_H}, 0, 0, &mainWindowFactory),
|
||||
invalidatedRect(rect)
|
||||
{
|
||||
Layer::push(this);
|
||||
}
|
||||
|
||||
void MainWindow::emptyTrash()
|
||||
{
|
||||
for (auto window: trash) {
|
||||
|
||||
+1
-8
@@ -23,18 +23,11 @@
|
||||
#include "layer.h"
|
||||
#include "bitmapbuffer.h"
|
||||
|
||||
extern LvglWidgetFactory mainWindowFactory;
|
||||
|
||||
class MainWindow: public Window
|
||||
{
|
||||
protected:
|
||||
// singleton
|
||||
MainWindow():
|
||||
Window(nullptr, {0, 0, LCD_W, LCD_H}, 0, 0, &mainWindowFactory),
|
||||
invalidatedRect(rect)
|
||||
{
|
||||
Layer::push(this);
|
||||
}
|
||||
MainWindow();
|
||||
|
||||
public:
|
||||
~MainWindow() override
|
||||
|
||||
Reference in New Issue
Block a user