From fcbb01da00317dab3e2ce9674ff78531eaeb6317 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Mon, 2 Dec 2019 11:40:29 +0100 Subject: [PATCH] Revert (MessageDialog and ConfirmDialog) --- radio/src/gui/colorlcd/CMakeLists.txt | 1 + radio/src/gui/colorlcd/message_dialog.cpp | 38 +++++++++++++++++++++++ radio/src/gui/colorlcd/message_dialog.h | 34 ++++++++++++++++++++ radio/src/thirdparty/libopenui | 2 +- 4 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 radio/src/gui/colorlcd/message_dialog.cpp create mode 100644 radio/src/gui/colorlcd/message_dialog.h diff --git a/radio/src/gui/colorlcd/CMakeLists.txt b/radio/src/gui/colorlcd/CMakeLists.txt index b2611f23d..4b8d8c7c1 100644 --- a/radio/src/gui/colorlcd/CMakeLists.txt +++ b/radio/src/gui/colorlcd/CMakeLists.txt @@ -96,6 +96,7 @@ foreach(LIBOPENUI_FILE ${LIBOPENUI_SRC}) endforeach() add_gui_src(fullscreen_dialog.cpp) +add_gui_src(message_dialog.cpp) add_gui_src(confirm_dialog.cpp) add_gui_src(timeedit.cpp) add_gui_src(curve.cpp) diff --git a/radio/src/gui/colorlcd/message_dialog.cpp b/radio/src/gui/colorlcd/message_dialog.cpp new file mode 100644 index 000000000..004be79f8 --- /dev/null +++ b/radio/src/gui/colorlcd/message_dialog.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (C) OpenTX + * + * Source: + * https://github.com/opentx/libopenui + * + * This file is a part of libopenui library. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + +#include "message_dialog.h" +#include "static.h" + +MessageDialog::MessageDialog(const char * title, const char * message): + Dialog(title, {50, 73, LCD_W - 100, LCD_H - 146}) +{ + new StaticText(this, {0, coord_t(height() - PAGE_LINE_HEIGHT) / 2, width(), PAGE_LINE_HEIGHT}, message, 0, CENTERED); +} + +#if defined(HARDWARE_KEYS) +void MessageDialog::onEvent(event_t event) +{ + TRACE_WINDOWS("%s received event 0x%X", getWindowDebugString().c_str(), event); + + if (event == EVT_KEY_BREAK(KEY_EXIT) || event == EVT_KEY_BREAK(KEY_ENTER)) { + deleteLater(); + } +} +#endif diff --git a/radio/src/gui/colorlcd/message_dialog.h b/radio/src/gui/colorlcd/message_dialog.h new file mode 100644 index 000000000..755a0fe1f --- /dev/null +++ b/radio/src/gui/colorlcd/message_dialog.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) OpenTX + * + * Source: + * https://github.com/opentx/libopenui + * + * This file is a part of libopenui library. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + +#ifndef _MESSAGE_DIALOG_H_ +#define _MESSAGE_DIALOG_H_ + +#include "dialog.h" + +class MessageDialog: public Dialog { + public: + MessageDialog(const char * title, const char * message); + +#if defined(HARDWARE_KEYS) + void onEvent(event_t event) override; +#endif +}; + +#endif // _MESSAGE_DIALOG_H_ diff --git a/radio/src/thirdparty/libopenui b/radio/src/thirdparty/libopenui index 7f3f2c964..56d396478 160000 --- a/radio/src/thirdparty/libopenui +++ b/radio/src/thirdparty/libopenui @@ -1 +1 @@ -Subproject commit 7f3f2c964bd648d6ddf04e18c172a021a4940716 +Subproject commit 56d3964785a20303450af352befaadda190885c6