Padding adjustments & dialog autosize
This commit is contained in:
+17
-7
@@ -21,16 +21,26 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
|
|
||||||
static rect_t _get_form_rect(const rect_t& rect)
|
|
||||||
{
|
|
||||||
return {0, POPUP_HEADER_HEIGHT, rect.w,
|
|
||||||
coord_t(rect.h - POPUP_HEADER_HEIGHT)};
|
|
||||||
}
|
|
||||||
|
|
||||||
DialogWindowContent::DialogWindowContent(Dialog* parent, const rect_t& rect) :
|
DialogWindowContent::DialogWindowContent(Dialog* parent, const rect_t& rect) :
|
||||||
ModalWindowContent(parent, rect),
|
ModalWindowContent(parent, rect),
|
||||||
form(this, _get_form_rect(rect), FORM_NO_BORDER)
|
form(this, rect_t{})
|
||||||
{
|
{
|
||||||
|
form.setFlexLayout();
|
||||||
|
|
||||||
|
auto form_obj = form.getLvObj();
|
||||||
|
lv_obj_set_style_pad_all(form_obj, lv_dpx(8), 0);
|
||||||
|
|
||||||
|
lv_coord_t max_height = LCD_H * 0.8;
|
||||||
|
lv_obj_set_style_max_height(form_obj, max_height, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogWindowContent::setTitle(const std::string& text)
|
||||||
|
{
|
||||||
|
ModalWindowContent::setTitle(text);
|
||||||
|
if (title) {
|
||||||
|
lv_coord_t title_h = lv_obj_get_height(title);
|
||||||
|
lv_obj_set_y(form.getLvObj(), title_h);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogWindowContent::deleteLater(bool detach, bool trash)
|
void DialogWindowContent::deleteLater(bool detach, bool trash)
|
||||||
|
|||||||
+2
@@ -31,6 +31,8 @@ class DialogWindowContent : public ModalWindowContent
|
|||||||
public:
|
public:
|
||||||
DialogWindowContent(Dialog* parent, const rect_t& rect);
|
DialogWindowContent(Dialog* parent, const rect_t& rect);
|
||||||
|
|
||||||
|
void setTitle(const std::string& text) override;
|
||||||
|
|
||||||
void deleteLater(bool detach = true, bool trash = true) override;
|
void deleteLater(bool detach = true, bool trash = true) override;
|
||||||
void updateSize() override;
|
void updateSize() override;
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -47,9 +47,8 @@ class FlexGridLayout
|
|||||||
|
|
||||||
// padding
|
// padding
|
||||||
lv_obj_set_style_pad_all(obj, padding, LV_PART_MAIN);
|
lv_obj_set_style_pad_all(obj, padding, LV_PART_MAIN);
|
||||||
lv_obj_set_style_pad_left(obj, padding + PAGE_PADDING, LV_PART_MAIN);
|
|
||||||
lv_obj_set_style_pad_right(obj, padding + PAGE_PADDING, LV_PART_MAIN);
|
|
||||||
lv_obj_set_style_pad_row(obj, padding, LV_PART_MAIN);
|
lv_obj_set_style_pad_row(obj, padding, LV_PART_MAIN);
|
||||||
|
lv_obj_set_style_pad_column(obj, padding, LV_PART_MAIN);
|
||||||
|
|
||||||
// layout
|
// layout
|
||||||
lv_obj_set_layout(obj, LV_LAYOUT_GRID);
|
lv_obj_set_layout(obj, LV_LAYOUT_GRID);
|
||||||
|
|||||||
+2
-1
@@ -115,9 +115,10 @@ void FormGroup::setFlexLayout(lv_flex_flow_t flow, lv_coord_t padding)
|
|||||||
lv_obj_set_height(lvobj, LV_SIZE_CONTENT);
|
lv_obj_set_height(lvobj, LV_SIZE_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
FormGroup::Line* FormGroup::newLine(FlexGridLayout* layout)
|
FormGroup::Line* FormGroup::newLine(FlexGridLayout* layout, lv_coord_t left_padding)
|
||||||
{
|
{
|
||||||
if (layout) layout->resetPos();
|
if (layout) layout->resetPos();
|
||||||
auto lv_line = window_create(lvobj);
|
auto lv_line = window_create(lvobj);
|
||||||
|
if (left_padding) lv_obj_set_style_pad_left(lv_line, left_padding, 0);
|
||||||
return new Line(this, lv_line, layout);
|
return new Line(this, lv_line, layout);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -101,7 +101,7 @@ class FormGroup : public Window
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void setFlexLayout(lv_flex_flow_t flow = LV_FLEX_FLOW_COLUMN, lv_coord_t padding = 0);
|
void setFlexLayout(lv_flex_flow_t flow = LV_FLEX_FLOW_COLUMN, lv_coord_t padding = 0);
|
||||||
Line* newLine(FlexGridLayout* layout = nullptr);
|
Line* newLine(FlexGridLayout* layout = nullptr, lv_coord_t left_padding = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
class FormWindow : public FormGroup
|
class FormWindow : public FormGroup
|
||||||
|
|||||||
+1
-1
@@ -51,7 +51,7 @@ class ModalWindowContent : public Window
|
|||||||
std::string getName() const override { return "ModalWindowContent"; }
|
std::string getName() const override { return "ModalWindowContent"; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void setTitle(const std::string& text);
|
virtual void setTitle(const std::string& text);
|
||||||
std::string getTitle() const;
|
std::string getTitle() const;
|
||||||
|
|
||||||
void onClicked() override;
|
void onClicked() override;
|
||||||
|
|||||||
@@ -480,7 +480,6 @@ void Window::bringToTop()
|
|||||||
if (lvobj) lv_obj_move_foreground(lvobj);
|
if (lvobj) lv_obj_move_foreground(lvobj);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lvglPushEncoderEvent(event_t& evt);
|
|
||||||
void Window::checkEvents()
|
void Window::checkEvents()
|
||||||
{
|
{
|
||||||
auto copy = children;
|
auto copy = children;
|
||||||
|
|||||||
Reference in New Issue
Block a user