Merge BUTTON_NOFOCUS and FORM_NOFOCUS into NO_FOCUS

This commit is contained in:
Bertrand Songis
2019-10-23 17:17:10 +02:00
parent 7296241db0
commit 0fc7a6cfd4
6 changed files with 23 additions and 28 deletions
+1 -1
View File
@@ -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();
}
}
+4 -5
View File
@@ -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;
+1 -1
View File
@@ -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<FormGroup *>(parent);
if (form) {
form->addField(this);
+2 -3
View File
@@ -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 {
+7 -7
View File
@@ -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()
+8 -11
View File
@@ -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 {