diff --git a/radio/src/gui/colorlcd/LvglWrapper.cpp b/radio/src/gui/colorlcd/LvglWrapper.cpp index 10ec3772c..fc0560ad5 100644 --- a/radio/src/gui/colorlcd/LvglWrapper.cpp +++ b/radio/src/gui/colorlcd/LvglWrapper.cpp @@ -22,10 +22,10 @@ #include "opentx.h" #include "LvglWrapper.h" +#include "view_main.h" LvglWrapper* LvglWrapper::_instance = nullptr; -static lv_disp_drv_t disp_drv; /*A variable to hold the drivers. Must be static or global.*/ lv_disp_t * disp; static lv_disp_draw_buf_t disp_buf; @@ -130,9 +130,11 @@ BitmapBuffer canBuf(BMP_RGB565, LCD_W, LCD_H, (uint16_t *)cbuf); extern BitmapBuffer * lcdFront; extern BitmapBuffer * lcd; -LvglWrapper::LvglWrapper() + +static lv_disp_drv_t disp_drv; + +static lv_disp_drv_t* init_disp_drv() { - lv_init(); lv_disp_draw_buf_init(&disp_buf, lcdFront->getData(), lcd->getData(), LCD_W*LCD_H); lv_disp_drv_init(&disp_drv); /*Basic initialization*/ disp_drv.draw_buf = &disp_buf; /*Set an initialized buffer*/ @@ -146,15 +148,15 @@ LvglWrapper::LvglWrapper() #endif disp_drv.sw_rotate = 1; - /*Register the driver in LVGL and save the created input device object*/ + return &disp_drv; +} +static void init_lvgl_drivers() +{ + // Register the driver and save the created display objects + disp = lv_disp_drv_register(init_disp_drv()); - disp = lv_disp_drv_register(&disp_drv); /*Register the driver and save the created display objects*/ - - // create a canvas as the drawing target for libopenui as a hack. This is going to be removed - canvas = lv_canvas_create(lv_scr_act()); - lv_canvas_set_buffer(canvas, cbuf, LCD_W, LCD_H, LV_IMG_CF_TRUE_COLOR); - + // Register the driver in LVGL and save the created input device object lv_indev_drv_init(&touchDriver); /*Basic initialization*/ touchDriver.type = LV_INDEV_TYPE_POINTER; /*See below.*/ touchDriver.read_cb = touchDriverRead; /*See below.*/ @@ -166,6 +168,25 @@ LvglWrapper::LvglWrapper() lv_indev_drv_register(&keyboard_drv); } +LvglWrapper::LvglWrapper() +{ + lv_init(); + init_lvgl_drivers(); + + // Create a canvas as the drawing target for libopenui as a hack. + // This is going to be removed + // + canvas = lv_canvas_create(lv_scr_act()); + lv_canvas_set_buffer(canvas, cbuf, LCD_W, LCD_H, LV_IMG_CF_TRUE_COLOR); + lv_obj_set_style_bg_opa(canvas, LV_OPA_MAX, LV_PART_MAIN); + + auto window = MainWindow::instance(); + lv_obj_set_parent(canvas, window->getLvObj()); + lv_obj_move_background(canvas); + lv_scr_load(window->getLvObj()); + lv_obj_invalidate(canvas); +} + void LvglWrapper::run() { tmr10ms_t tick = get_tmr10ms(); diff --git a/radio/src/gui/colorlcd/access_settings.cpp b/radio/src/gui/colorlcd/access_settings.cpp index 25b969a5e..5e4ce08ec 100644 --- a/radio/src/gui/colorlcd/access_settings.cpp +++ b/radio/src/gui/colorlcd/access_settings.cpp @@ -114,11 +114,9 @@ bool BindRxChoiceMenu::onTouchEnd(coord_t x, coord_t y) // Note: onCancel() is not called when the menu is discarded // by clicking outside the menu window and the onCancel // handler is not accessible from here - if (!Window::onTouchEnd(x, y)) { - moduleState[moduleIdx].mode = MODULE_MODE_NORMAL; - onKeyPress(); - deleteLater(); - } + moduleState[moduleIdx].mode = MODULE_MODE_NORMAL; + onKeyPress(); + deleteLater(); return true; } #endif diff --git a/radio/src/gui/colorlcd/radio_ghost_module_config.h b/radio/src/gui/colorlcd/radio_ghost_module_config.h index 42f209052..6069c7300 100644 --- a/radio/src/gui/colorlcd/radio_ghost_module_config.h +++ b/radio/src/gui/colorlcd/radio_ghost_module_config.h @@ -30,7 +30,7 @@ class RadioGhostModuleConfig: public Page #if defined(HARDWARE_KEYS) void onEvent(event_t event) override; - void checkEvents(); + void checkEvents() override; #endif protected: diff --git a/radio/src/gui/colorlcd/view_main.cpp b/radio/src/gui/colorlcd/view_main.cpp index 6c5cc24ab..9bcb4ce31 100644 --- a/radio/src/gui/colorlcd/view_main.cpp +++ b/radio/src/gui/colorlcd/view_main.cpp @@ -51,6 +51,8 @@ ViewMain::ViewMain(): lv_obj_add_flag(lvobj, LV_OBJ_FLAG_EVENT_BUBBLE); lv_obj_set_user_data(tile_view, this); + lv_obj_set_style_bg_opa(tile_view, LV_OPA_TRANSP, LV_PART_MAIN); + lv_obj_move_foreground(topbar->getLvObj()); } @@ -62,6 +64,7 @@ ViewMain::~ViewMain() void ViewMain::addMainView(Window* view, uint32_t viewId) { auto tile = lv_tileview_add_tile(tile_view, viewId, 0, LV_DIR_LEFT | LV_DIR_RIGHT); + lv_obj_add_flag(tile, LV_OBJ_FLAG_EVENT_BUBBLE); lv_obj_set_user_data(tile, view); view->setLeft(lv_obj_get_x(tile)); @@ -203,18 +206,16 @@ void ViewMain::setScrollPositionY(coord_t value) bool ViewMain::onTouchEnd(coord_t x, coord_t y) { - if (Window::onTouchEnd(x,y)) return true; - if (!hasFocus()) { - setFocus(); - } - else { - openMenu(); - int x1 = x; - int w1 = getParent()->width(); - while (x1 > w1) x1 -= w1; - if (x1 > w1 / 2) - pushEvent(EVT_ROTARY_LEFT); - } + openMenu(); + + // TODO: remove this hack to preset + // the scrolling on the main menu + int x1 = x; + int w1 = getParent()->width(); + while (x1 > w1) x1 -= w1; + if (x1 > w1 / 2) + pushEvent(EVT_ROTARY_LEFT); + return true; } #endif diff --git a/radio/src/gui/colorlcd/view_main_menu.cpp b/radio/src/gui/colorlcd/view_main_menu.cpp index f6b1eee7c..af81a4f07 100644 --- a/radio/src/gui/colorlcd/view_main_menu.cpp +++ b/radio/src/gui/colorlcd/view_main_menu.cpp @@ -34,9 +34,7 @@ #include "view_text.h" -LvglWidgetFactory viewMainFactory = LvglWidgetFactory([] (lv_obj_t *parent) { - return lv_obj_create(nullptr); -}); +static LvglWidgetFactory viewMainFactory = {lv_obj_create, nullptr}; ViewMainMenu::ViewMainMenu(Window* parent) : Window(parent->getFullScreenWindow(), {}, 0, 0, &viewMainFactory) diff --git a/radio/src/gui/colorlcd/view_main_menu.h b/radio/src/gui/colorlcd/view_main_menu.h index 472398c61..f4fcd6b69 100644 --- a/radio/src/gui/colorlcd/view_main_menu.h +++ b/radio/src/gui/colorlcd/view_main_menu.h @@ -34,10 +34,8 @@ public: bool onTouchStart(coord_t /*x*/, coord_t /*y*/) override { return true; } bool onTouchEnd(coord_t x, coord_t y) override { - if (!Window::onTouchEnd(x, y)) { - onKeyPress(); - deleteLater(); - } + onKeyPress(); + deleteLater(); return true; } bool onTouchSlide(coord_t x, coord_t y, coord_t startX, coord_t startY, diff --git a/radio/src/gui/colorlcd/widget.cpp b/radio/src/gui/colorlcd/widget.cpp index d6540add5..302ebb8da 100644 --- a/radio/src/gui/colorlcd/widget.cpp +++ b/radio/src/gui/colorlcd/widget.cpp @@ -76,16 +76,10 @@ bool Widget::onTouchEnd(coord_t x, coord_t y) TRACE_WINDOWS("Widget received touch end (%d) x=%d;y=%d", hasFocus(), x, y); - if (fullscreen) { - //TODO: forward to widget (lua for instance) - return true; - } - if (Window::onTouchEnd(x, y)) { - return true; - } - if (hasFocus()) { + + // TODO: find a better way if (touchState.tapCount == 0) onPress(); else if (touchState.tapCount > 1) @@ -94,6 +88,7 @@ bool Widget::onTouchEnd(coord_t x, coord_t y) else { setFocus(); } + return true; } diff --git a/radio/src/thirdparty/libopenui b/radio/src/thirdparty/libopenui index af5043082..fef30535c 160000 --- a/radio/src/thirdparty/libopenui +++ b/radio/src/thirdparty/libopenui @@ -1 +1 @@ -Subproject commit af50430828d7e309560bdafa58faf4242e687e15 +Subproject commit fef30535c61290dd1f5466aec51c625c82aabcb4