This commit is contained in:
3djc
2021-04-04 10:19:30 +02:00
parent c5b8ec7707
commit 3ce9ffd846
16 changed files with 45 additions and 13 deletions
+15 -13
View File
@@ -18,33 +18,35 @@
* GNU General Public License for more details.
*/
#include "opentx.h"
#include "confirm_dialog.h"
#include "static.h"
#include "gridlayout.h"
ConfirmDialog::ConfirmDialog(Window * parent, const char * title, const char * message, std::function<void(void)> confirmHandler) :
Dialog(parent, title, {50, 73, LCD_W - 100, LCD_H - 146}),
Dialog(parent, title, {LCD_W / 10 , LCD_H / 4, LCD_W - 2 * LCD_W / 10, LCD_H - 2 * LCD_H / 4}),
confirmHandler(std::move(confirmHandler))
{
auto form = &content->form;
FormGridLayout grid(content->form.width());
form->clear();
new StaticText(form, grid.getCenteredSlot(), message);
grid.setLabelWidth(15);
grid.setMarginRight(15);
grid.nextLine();
grid.nextLine();
auto noButton = new TextButton(form, grid.getSlot(2, 0), "NO",
[=]() -> int8_t {
this->deleteLater();
return 0;
});
auto noButton = new TextButton(form, grid.getFieldSlot(2, 0), STR_NO, [=]() -> int8_t {
this->deleteLater();
return 0;
});
new TextButton(form, grid.getSlot(2, 1), "YES",
[=]() -> int8_t {
this->deleteLater();
this->confirmHandler();
return 0;
});
new TextButton(form, grid.getFieldSlot(2, 1), STR_YES, [=]() -> int8_t {
this->deleteLater();
this->confirmHandler();
return 0;
});
noButton->setFocus(SET_FOCUS_DEFAULT);
}