modal_window: implement title label
This commit is contained in:
committed by
Raphael Coeffic
parent
8761b423c6
commit
a0e97c001d
+19
-10
@@ -26,10 +26,8 @@ ModalWindow::ModalWindow(Window * parent, bool closeWhenClickOutside):
|
|||||||
Window(parent->getFullScreenWindow(), {0, 0, LCD_W, LCD_H}),
|
Window(parent->getFullScreenWindow(), {0, 0, LCD_W, LCD_H}),
|
||||||
closeWhenClickOutside(closeWhenClickOutside)
|
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_color(lvobj, lv_color_black(), LV_PART_MAIN);
|
||||||
lv_obj_set_style_bg_opa(lvobj, LV_OPA_50, 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);
|
Layer::push(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,7 +36,6 @@ void ModalWindow::deleteLater(bool detach, bool trash)
|
|||||||
if (_deleted)
|
if (_deleted)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lv_obj_clear_flag(lv_layer_top(), LV_OBJ_FLAG_CLICKABLE);
|
|
||||||
Layer::pop(this);
|
Layer::pop(this);
|
||||||
|
|
||||||
Window::deleteLater(detach, trash);
|
Window::deleteLater(detach, trash);
|
||||||
@@ -55,15 +52,27 @@ bool ModalWindow::onTouchEnd(coord_t x, coord_t y)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
ModalWindowContent::ModalWindowContent(ModalWindow* parent,
|
||||||
void ModalWindow::paint(BitmapBuffer * dc)
|
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);
|
if (!title) {
|
||||||
// dc->drawText(FIELD_PADDING_LEFT, (POPUP_HEADER_HEIGHT - getFontHeight(FONT(STD))) / 2, title.c_str(), COLOR_THEME_PRIMARY2);
|
title = lv_label_create(lvobj);
|
||||||
// dc->drawSolidFilledRect(0, POPUP_HEADER_HEIGHT, width(), height() - POPUP_HEADER_HEIGHT, COLOR_THEME_SECONDARY3);
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-18
@@ -35,8 +35,6 @@ class ModalWindow: public Window
|
|||||||
|
|
||||||
void deleteLater(bool detach = true, bool trash = true) override; // NOLINT(google-default-arguments)
|
void deleteLater(bool detach = true, bool trash = true) override; // NOLINT(google-default-arguments)
|
||||||
|
|
||||||
void paint(BitmapBuffer * dc) override;
|
|
||||||
|
|
||||||
#if defined(HARDWARE_TOUCH)
|
#if defined(HARDWARE_TOUCH)
|
||||||
bool onTouchEnd(coord_t x, coord_t y) override;
|
bool onTouchEnd(coord_t x, coord_t y) override;
|
||||||
#endif
|
#endif
|
||||||
@@ -53,10 +51,7 @@ class ModalWindow: public Window
|
|||||||
class ModalWindowContent: public Window
|
class ModalWindowContent: public Window
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ModalWindowContent(ModalWindow * parent, const rect_t & rect):
|
explicit ModalWindowContent(ModalWindow * parent, const rect_t & rect);
|
||||||
Window(parent, rect, OPAQUE)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(DEBUG_WINDOWS)
|
#if defined(DEBUG_WINDOWS)
|
||||||
std::string getName() const override
|
std::string getName() const override
|
||||||
@@ -65,19 +60,10 @@ class ModalWindowContent: public Window
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void setTitle(std::string text)
|
void setTitle(const std::string& text);
|
||||||
{
|
std::string getTitle() const;
|
||||||
title = std::move(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string & getTitle()
|
|
||||||
{
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
void paint(BitmapBuffer * dc) override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string title;
|
lv_obj_t* title = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user