diff --git a/radio/src/thirdparty/libopenui/src/modal_window.cpp b/radio/src/thirdparty/libopenui/src/modal_window.cpp index 1ca084510..4be831de4 100644 --- a/radio/src/thirdparty/libopenui/src/modal_window.cpp +++ b/radio/src/thirdparty/libopenui/src/modal_window.cpp @@ -26,10 +26,8 @@ ModalWindow::ModalWindow(Window * parent, bool closeWhenClickOutside): Window(parent->getFullScreenWindow(), {0, 0, LCD_W, LCD_H}), closeWhenClickOutside(closeWhenClickOutside) { - lv_obj_set_parent(lvobj, lv_layer_top()); lv_obj_set_style_bg_color(lvobj, lv_color_black(), LV_PART_MAIN); lv_obj_set_style_bg_opa(lvobj, LV_OPA_50, LV_PART_MAIN); - lv_obj_add_flag(lv_layer_top(), LV_OBJ_FLAG_CLICKABLE); Layer::push(this); } @@ -38,7 +36,6 @@ void ModalWindow::deleteLater(bool detach, bool trash) if (_deleted) return; - lv_obj_clear_flag(lv_layer_top(), LV_OBJ_FLAG_CLICKABLE); Layer::pop(this); Window::deleteLater(detach, trash); @@ -55,15 +52,27 @@ bool ModalWindow::onTouchEnd(coord_t x, coord_t y) } #endif - -void ModalWindow::paint(BitmapBuffer * dc) +ModalWindowContent::ModalWindowContent(ModalWindow* parent, + const rect_t& rect) : + Window(parent, rect, OPAQUE) { - // dc->drawFilledRect(0, 0, width(), height(), SOLID, BLACK, OPACITY(6)); } -void ModalWindowContent::paint(BitmapBuffer * dc) +void ModalWindowContent::setTitle(const std::string& text) { - // dc->drawSolidFilledRect(0, 0, width(), POPUP_HEADER_HEIGHT, COLOR_THEME_SECONDARY1); - // dc->drawText(FIELD_PADDING_LEFT, (POPUP_HEADER_HEIGHT - getFontHeight(FONT(STD))) / 2, title.c_str(), COLOR_THEME_PRIMARY2); - // dc->drawSolidFilledRect(0, POPUP_HEADER_HEIGHT, width(), height() - POPUP_HEADER_HEIGHT, COLOR_THEME_SECONDARY3); + if (!title) { + title = lv_label_create(lvobj); + lv_obj_move_to_index(title, 0); + lv_obj_set_width(title, lv_pct(100)); + lv_obj_set_style_pad_all(title, PAGE_PADDING, LV_PART_MAIN); + // TODO: styling + // lv_obj_set_style_pad_left(title, FIELD_PADDING_LEFT, 0); + } + lv_label_set_text(title, text.c_str()); +} + +std::string ModalWindowContent::getTitle() const +{ + if (!title) return std::string(); + return lv_label_get_text(title); } diff --git a/radio/src/thirdparty/libopenui/src/modal_window.h b/radio/src/thirdparty/libopenui/src/modal_window.h index fedaeea77..381c96ea7 100644 --- a/radio/src/thirdparty/libopenui/src/modal_window.h +++ b/radio/src/thirdparty/libopenui/src/modal_window.h @@ -35,8 +35,6 @@ class ModalWindow: public Window void deleteLater(bool detach = true, bool trash = true) override; // NOLINT(google-default-arguments) - void paint(BitmapBuffer * dc) override; - #if defined(HARDWARE_TOUCH) bool onTouchEnd(coord_t x, coord_t y) override; #endif @@ -53,10 +51,7 @@ class ModalWindow: public Window class ModalWindowContent: public Window { public: - explicit ModalWindowContent(ModalWindow * parent, const rect_t & rect): - Window(parent, rect, OPAQUE) - { - } + explicit ModalWindowContent(ModalWindow * parent, const rect_t & rect); #if defined(DEBUG_WINDOWS) std::string getName() const override @@ -65,19 +60,10 @@ class ModalWindowContent: public Window } #endif - void setTitle(std::string text) - { - title = std::move(text); - } - - const std::string & getTitle() - { - return title; - } - - void paint(BitmapBuffer * dc) override; + void setTitle(const std::string& text); + std::string getTitle() const; protected: - std::string title; + lv_obj_t* title = nullptr; };