dialog: add updateSize() method
This commit is contained in:
committed by
Raphael Coeffic
parent
aca4b074ab
commit
6c8e8e5f98
+35
-7
@@ -21,18 +21,46 @@
|
||||
#include "mainwindow.h"
|
||||
#include "theme.h"
|
||||
|
||||
DialogWindowContent::DialogWindowContent(Dialog * parent, const rect_t & rect):
|
||||
ModalWindowContent(parent, rect),
|
||||
form(this, {0, POPUP_HEADER_HEIGHT, rect.w, coord_t(rect.h - POPUP_HEADER_HEIGHT)}, FORM_NO_BORDER)
|
||||
DialogWindowContent::DialogWindowContent(Dialog* parent, const rect_t& rect) :
|
||||
ModalWindowContent(parent, rect),
|
||||
form(this,
|
||||
{ 0, POPUP_HEADER_HEIGHT, rect.w,
|
||||
coord_t(rect.h - POPUP_HEADER_HEIGHT) },
|
||||
FORM_NO_BORDER)
|
||||
{
|
||||
form.setFocus(SET_FOCUS_DEFAULT);
|
||||
}
|
||||
|
||||
void DialogWindowContent::updateSize()
|
||||
{
|
||||
lv_obj_set_height(lvobj, LV_SIZE_CONTENT);
|
||||
lv_obj_center(lvobj);
|
||||
lv_obj_update_layout(lvobj);
|
||||
|
||||
Dialog::Dialog(Window * parent, std::string title, const rect_t & rect):
|
||||
ModalWindow(parent),
|
||||
content(createDialogWindow(this, rect))
|
||||
rect.x = lv_obj_get_x(lvobj);
|
||||
rect.y = lv_obj_get_y(lvobj);
|
||||
rect.w = lv_obj_get_width(lvobj);
|
||||
rect.h = lv_obj_get_height(lvobj);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void DialogWindowContent::deleteLater(bool detach, bool trash)
|
||||
{
|
||||
if (_deleted) return;
|
||||
form.deleteLater(true, false);
|
||||
ModalWindowContent::deleteLater(detach, trash);
|
||||
}
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string DialogWindowContent::getName() const override
|
||||
{
|
||||
return "DialogWindowContent";
|
||||
}
|
||||
#endif
|
||||
|
||||
Dialog::Dialog(Window* parent, std::string title, const rect_t& rect) :
|
||||
ModalWindow(parent), content(new DialogWindowContent(this, rect))
|
||||
{
|
||||
bringToTop();
|
||||
content->setTitle(std::move(title));
|
||||
if (!title.empty()) content->setTitle(std::move(title));
|
||||
}
|
||||
|
||||
+14
-23
@@ -24,38 +24,29 @@
|
||||
|
||||
class Dialog;
|
||||
|
||||
class DialogWindowContent: public ModalWindowContent
|
||||
class DialogWindowContent : public ModalWindowContent
|
||||
{
|
||||
friend class Dialog;
|
||||
|
||||
public:
|
||||
DialogWindowContent(Dialog * parent, const rect_t & rect);
|
||||
public:
|
||||
DialogWindowContent(Dialog* parent, const rect_t& rect);
|
||||
|
||||
void deleteLater(bool detach = true, bool trash = true) override
|
||||
{
|
||||
if (_deleted)
|
||||
return;
|
||||
|
||||
form.deleteLater(true, false);
|
||||
ModalWindowContent::deleteLater(detach, trash);
|
||||
}
|
||||
void updateSize();
|
||||
void deleteLater(bool detach = true, bool trash = true) override;
|
||||
|
||||
#if defined(DEBUG_WINDOWS)
|
||||
std::string getName() const override
|
||||
{
|
||||
return "DialogWindowContent";
|
||||
}
|
||||
std::string getName() const override;
|
||||
#endif
|
||||
|
||||
public:
|
||||
FormGroup form;
|
||||
public:
|
||||
FormGroup form;
|
||||
};
|
||||
|
||||
class Dialog: public ModalWindow {
|
||||
public:
|
||||
Dialog(Window * parent, std::string title, const rect_t & rect);
|
||||
class Dialog : public ModalWindow
|
||||
{
|
||||
public:
|
||||
Dialog(Window* parent, std::string title, const rect_t& rect);
|
||||
|
||||
protected:
|
||||
DialogWindowContent * content;
|
||||
protected:
|
||||
DialogWindowContent* content;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user