Fix confirmation dialog
This commit is contained in:
committed by
Raphael Coeffic
parent
cd4d3a28ee
commit
ba757bd41f
@@ -24,30 +24,35 @@
|
|||||||
#include "static.h"
|
#include "static.h"
|
||||||
#include "gridlayout.h"
|
#include "gridlayout.h"
|
||||||
|
|
||||||
ConfirmDialog::ConfirmDialog(Window * parent, const char * title, const char * message, std::function<void(void)> confirmHandler) :
|
ConfirmDialog::ConfirmDialog(Window* parent, const char* title,
|
||||||
Dialog(parent, title, {LCD_W / 10 , LCD_H / 4, LCD_W - 2 * LCD_W / 10, LCD_H - 2 * LCD_H / 4}),
|
const char* message,
|
||||||
confirmHandler(std::move(confirmHandler))
|
std::function<void(void)> confirmHandler) :
|
||||||
|
Dialog(parent, title, rect_t{}),
|
||||||
|
confirmHandler(std::move(confirmHandler))
|
||||||
{
|
{
|
||||||
auto form = &content->form;
|
auto form = &content->form;
|
||||||
FormGridLayout grid(content->form.width());
|
auto msg = new StaticText(form, rect_t{}, message);
|
||||||
form->clear();
|
msg->padAll(lv_dpx(16));
|
||||||
|
|
||||||
new StaticText(form, grid.getCenteredSlot(), message);
|
auto box = new FormGroup(form, rect_t{});
|
||||||
grid.setLabelWidth(15);
|
box->setFlexLayout(LV_FLEX_FLOW_ROW);
|
||||||
grid.setMarginRight(15);
|
|
||||||
grid.nextLine();
|
|
||||||
grid.nextLine();
|
|
||||||
|
|
||||||
auto noButton = new TextButton(form, grid.getFieldSlot(2, 0), STR_NO, [=]() -> int8_t {
|
auto box_obj = box->getLvObj();
|
||||||
this->deleteLater();
|
lv_obj_set_style_flex_main_place(box_obj, LV_FLEX_ALIGN_SPACE_EVENLY, 0);
|
||||||
return 0;
|
|
||||||
|
auto btn = new TextButton(box, rect_t{}, STR_NO, [=]() -> int8_t {
|
||||||
|
this->deleteLater();
|
||||||
|
return 0;
|
||||||
});
|
});
|
||||||
|
lv_obj_set_width(btn->getLvObj(), LV_DPI_DEF);
|
||||||
|
|
||||||
new TextButton(form, grid.getFieldSlot(2, 1), STR_YES, [=]() -> int8_t {
|
btn = new TextButton(box, rect_t{}, STR_YES, [=]() -> int8_t {
|
||||||
this->deleteLater();
|
this->deleteLater();
|
||||||
this->confirmHandler();
|
this->confirmHandler();
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
|
lv_obj_set_width(btn->getLvObj(), LV_DPI_DEF);
|
||||||
|
|
||||||
// noButton->setFocus(SET_FOCUS_DEFAULT);
|
content->setWidth(LCD_W * 0.8);
|
||||||
|
content->updateSize();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,12 +24,14 @@
|
|||||||
|
|
||||||
#include "dialog.h"
|
#include "dialog.h"
|
||||||
|
|
||||||
class ConfirmDialog: public Dialog {
|
class ConfirmDialog : public Dialog
|
||||||
public:
|
{
|
||||||
ConfirmDialog(Window * parent, const char * title, const char * message, std::function<void(void)> confirmHandler);
|
public:
|
||||||
|
ConfirmDialog(Window* parent, const char* title, const char* message,
|
||||||
|
std::function<void(void)> confirmHandler);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::function<void(void)> confirmHandler;
|
std::function<void(void)> confirmHandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _CONFIRM_DIALOG_H_
|
#endif // _CONFIRM_DIALOG_H_
|
||||||
|
|||||||
@@ -633,6 +633,7 @@ class ModelCategoryPage : public PageTab
|
|||||||
|
|
||||||
void build(FormWindow *window) override
|
void build(FormWindow *window) override
|
||||||
{
|
{
|
||||||
|
window->padAll(0);
|
||||||
new ModelCategoryPageBody(window, category);
|
new ModelCategoryPageBody(window, category);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -679,6 +680,7 @@ class CategoryEditPage : public PageTab
|
|||||||
grid.setMarginRight(15);
|
grid.setMarginRight(15);
|
||||||
grid.setLabelWidth(0);
|
grid.setLabelWidth(0);
|
||||||
grid.spacer();
|
grid.spacer();
|
||||||
|
window->padAll(0);
|
||||||
|
|
||||||
coord_t y = 2;
|
coord_t y = 2;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user