From 0fc7a6cfd4a76c03dee3faa10f96ca184d4808c7 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Wed, 23 Oct 2019 17:17:10 +0200 Subject: [PATCH] Merge BUTTON_NOFOCUS and FORM_NOFOCUS into NO_FOCUS --- radio/src/thirdparty/libopenui/src/button.cpp | 2 +- radio/src/thirdparty/libopenui/src/button.h | 9 ++++----- radio/src/thirdparty/libopenui/src/form.cpp | 2 +- radio/src/thirdparty/libopenui/src/form.h | 5 ++--- .../libopenui/src/keyboard_number.cpp | 14 +++++++------- radio/src/thirdparty/libopenui/src/window.h | 19 ++++++++----------- 6 files changed, 23 insertions(+), 28 deletions(-) diff --git a/radio/src/thirdparty/libopenui/src/button.cpp b/radio/src/thirdparty/libopenui/src/button.cpp index 83af6d83f..97ab5c371 100644 --- a/radio/src/thirdparty/libopenui/src/button.cpp +++ b/radio/src/thirdparty/libopenui/src/button.cpp @@ -50,7 +50,7 @@ bool Button::onTouchEnd(coord_t x, coord_t y) { if (enabled()) { onPress(); - if (!(windowFlags & BUTTON_NOFOCUS)) { + if (!(windowFlags & NO_FOCUS)) { setFocus(); } } diff --git a/radio/src/thirdparty/libopenui/src/button.h b/radio/src/thirdparty/libopenui/src/button.h index 075eb2f59..04ca3a8c8 100644 --- a/radio/src/thirdparty/libopenui/src/button.h +++ b/radio/src/thirdparty/libopenui/src/button.h @@ -25,9 +25,8 @@ constexpr WindowFlags BUTTON_BACKGROUND = FORM_FLAGS_LAST << 1; constexpr WindowFlags BUTTON_CHECKED = FORM_FLAGS_LAST << 2; -constexpr WindowFlags BUTTON_NOFOCUS = FORM_FLAGS_LAST << 3; -constexpr WindowFlags BUTTON_CHECKED_ON_FOCUS = FORM_FLAGS_LAST << 4; -constexpr WindowFlags BUTTON_DISABLED = FORM_FLAGS_LAST << 5; +constexpr WindowFlags BUTTON_CHECKED_ON_FOCUS = FORM_FLAGS_LAST << 3; +constexpr WindowFlags BUTTON_DISABLED = FORM_FLAGS_LAST << 4; class Button : public FormField { public: @@ -44,7 +43,7 @@ class Button : public FormField { } #endif - void enable(bool enabled=true) + void enable(bool enabled = true) { if (!enabled != bool(windowFlags & BUTTON_DISABLED)) { windowFlags ^= BUTTON_DISABLED; @@ -57,7 +56,7 @@ class Button : public FormField { enable(false); } - void check(bool checked=true) + void check(bool checked = true) { if (checked != bool(windowFlags & BUTTON_CHECKED)) { windowFlags ^= BUTTON_CHECKED; diff --git a/radio/src/thirdparty/libopenui/src/form.cpp b/radio/src/thirdparty/libopenui/src/form.cpp index c859a57e0..ffdd5b744 100644 --- a/radio/src/thirdparty/libopenui/src/form.cpp +++ b/radio/src/thirdparty/libopenui/src/form.cpp @@ -24,7 +24,7 @@ FormField::FormField(Window *parent, const rect_t & rect, WindowFlags windowFlags) : Window(parent, rect, windowFlags) { - if (!(windowFlags & FORM_NO_FOCUS)) { + if (!(windowFlags & NO_FOCUS)) { FormGroup * form = dynamic_cast(parent); if (form) { form->addField(this); diff --git a/radio/src/thirdparty/libopenui/src/form.h b/radio/src/thirdparty/libopenui/src/form.h index 3403845ed..ec4f8838d 100644 --- a/radio/src/thirdparty/libopenui/src/form.h +++ b/radio/src/thirdparty/libopenui/src/form.h @@ -22,9 +22,8 @@ #include "window.h" -constexpr WindowFlags FORM_NO_FOCUS = WINDOW_FLAGS_LAST << 1; -constexpr WindowFlags FORM_FORWARD_FOCUS = WINDOW_FLAGS_LAST << 2; -constexpr WindowFlags FORM_DETACHED = WINDOW_FLAGS_LAST << 3; +constexpr WindowFlags FORM_FORWARD_FOCUS = WINDOW_FLAGS_LAST << 1; +constexpr WindowFlags FORM_DETACHED = WINDOW_FLAGS_LAST << 2; constexpr WindowFlags FORM_FLAGS_LAST = FORM_DETACHED; class FormField: public Window { diff --git a/radio/src/thirdparty/libopenui/src/keyboard_number.cpp b/radio/src/thirdparty/libopenui/src/keyboard_number.cpp index 90767690a..df578ebe1 100644 --- a/radio/src/thirdparty/libopenui/src/keyboard_number.cpp +++ b/radio/src/thirdparty/libopenui/src/keyboard_number.cpp @@ -32,43 +32,43 @@ NumberKeyboard::NumberKeyboard() : [=]() -> uint8_t { putEvent(EVT_VIRTUAL_KEY_BACKWARD); return 0; - }, BUTTON_BACKGROUND | BUTTON_NOFOCUS); + }, BUTTON_BACKGROUND | NO_FOCUS); new TextButton(this, {LCD_W / 2 - 55, 10, 50, 30}, "-", [=]() -> uint8_t { putEvent(EVT_VIRTUAL_KEY_MINUS); return 0; - }, BUTTON_BACKGROUND | BUTTON_NOFOCUS); + }, BUTTON_BACKGROUND | NO_FOCUS); new TextButton(this, {LCD_W / 2 + 5, 10, 50, 30}, "+", [=]() -> uint8_t { putEvent(EVT_VIRTUAL_KEY_PLUS); return 0; - }, BUTTON_BACKGROUND | BUTTON_NOFOCUS); + }, BUTTON_BACKGROUND | NO_FOCUS); new TextButton(this, {LCD_W / 2 + 65, 10, 50, 30}, ">>", [=]() -> uint8_t { putEvent(EVT_VIRTUAL_KEY_FORWARD); return 0; - }, BUTTON_BACKGROUND | BUTTON_NOFOCUS); + }, BUTTON_BACKGROUND | NO_FOCUS); new TextButton(this, {LCD_W / 2 - 115, 50, 50, 30}, "MIN", [=]() -> uint8_t { putEvent(EVT_VIRTUAL_KEY_MIN); return 0; - }, BUTTON_BACKGROUND | BUTTON_NOFOCUS); + }, BUTTON_BACKGROUND | NO_FOCUS); new TextButton(this, {LCD_W / 2 + 65, 50, 50, 30}, "MAX", [=]() -> uint8_t { putEvent(EVT_VIRTUAL_KEY_MAX); return 0; - }, BUTTON_BACKGROUND | BUTTON_NOFOCUS); + }, BUTTON_BACKGROUND | NO_FOCUS); new TextButton(this, {LCD_W / 2 - 55, 50, 110, 30}, "DEFAULT", [=]() -> uint8_t { putEvent(EVT_VIRTUAL_KEY_DEFAULT); return 0; - }, BUTTON_BACKGROUND | BUTTON_NOFOCUS); + }, BUTTON_BACKGROUND | NO_FOCUS); } NumberKeyboard::~NumberKeyboard() diff --git a/radio/src/thirdparty/libopenui/src/window.h b/radio/src/thirdparty/libopenui/src/window.h index 14873ee55..e86d3111c 100644 --- a/radio/src/thirdparty/libopenui/src/window.h +++ b/radio/src/thirdparty/libopenui/src/window.h @@ -33,17 +33,14 @@ typedef uint32_t WindowFlags; -// OPAQUE/TRANSPARENT defined in WinGDI -#ifndef OPAQUE - #define OPAQUE 1 - #define TRANSPARENT 2 -#endif - -constexpr WindowFlags NO_SCROLLBAR = 4; -constexpr WindowFlags FORWARD_SCROLL = 8; -constexpr WindowFlags REFRESH_ALWAYS = 16; -constexpr WindowFlags BORDER_FOCUS_ONLY = 32; -constexpr WindowFlags PAINT_CHILDREN_FIRST = 64; +constexpr WindowFlags OPAQUE = 1 << 0; +constexpr WindowFlags TRANSPARENT = 1 << 1; +constexpr WindowFlags NO_SCROLLBAR = 1 << 2; +constexpr WindowFlags NO_FOCUS = 1 << 3; +constexpr WindowFlags FORWARD_SCROLL = 1 << 4; +constexpr WindowFlags REFRESH_ALWAYS = 1 << 5; +constexpr WindowFlags BORDER_FOCUS_ONLY = 1 << 6; +constexpr WindowFlags PAINT_CHILDREN_FIRST = 1 << 7; constexpr WindowFlags WINDOW_FLAGS_LAST = PAINT_CHILDREN_FIRST; enum SetFocusFlag {