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 "mainwindow.h"
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
|
|
||||||
DialogWindowContent::DialogWindowContent(Dialog * parent, const rect_t & rect):
|
DialogWindowContent::DialogWindowContent(Dialog* parent, const rect_t& rect) :
|
||||||
ModalWindowContent(parent, rect),
|
ModalWindowContent(parent, rect),
|
||||||
form(this, {0, POPUP_HEADER_HEIGHT, rect.w, coord_t(rect.h - POPUP_HEADER_HEIGHT)}, FORM_NO_BORDER)
|
form(this,
|
||||||
|
{ 0, POPUP_HEADER_HEIGHT, rect.w,
|
||||||
|
coord_t(rect.h - POPUP_HEADER_HEIGHT) },
|
||||||
|
FORM_NO_BORDER)
|
||||||
{
|
{
|
||||||
form.setFocus(SET_FOCUS_DEFAULT);
|
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):
|
rect.x = lv_obj_get_x(lvobj);
|
||||||
ModalWindow(parent),
|
rect.y = lv_obj_get_y(lvobj);
|
||||||
content(createDialogWindow(this, rect))
|
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();
|
bringToTop();
|
||||||
content->setTitle(std::move(title));
|
if (!title.empty()) content->setTitle(std::move(title));
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-23
@@ -24,38 +24,29 @@
|
|||||||
|
|
||||||
class Dialog;
|
class Dialog;
|
||||||
|
|
||||||
class DialogWindowContent: public ModalWindowContent
|
class DialogWindowContent : public ModalWindowContent
|
||||||
{
|
{
|
||||||
friend class Dialog;
|
friend class Dialog;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DialogWindowContent(Dialog * parent, const rect_t & rect);
|
DialogWindowContent(Dialog* parent, const rect_t& rect);
|
||||||
|
|
||||||
void deleteLater(bool detach = true, bool trash = true) override
|
void updateSize();
|
||||||
{
|
void deleteLater(bool detach = true, bool trash = true) override;
|
||||||
if (_deleted)
|
|
||||||
return;
|
|
||||||
|
|
||||||
form.deleteLater(true, false);
|
|
||||||
ModalWindowContent::deleteLater(detach, trash);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(DEBUG_WINDOWS)
|
#if defined(DEBUG_WINDOWS)
|
||||||
std::string getName() const override
|
std::string getName() const override;
|
||||||
{
|
|
||||||
return "DialogWindowContent";
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FormGroup form;
|
FormGroup form;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Dialog: public ModalWindow {
|
class Dialog : public ModalWindow
|
||||||
public:
|
{
|
||||||
Dialog(Window * parent, std::string title, const rect_t & rect);
|
public:
|
||||||
|
Dialog(Window* parent, std::string title, const rect_t& rect);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DialogWindowContent * content;
|
DialogWindowContent* content;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user