From b951dbf9de53a65c4fe17cc31ceb7c22481289ee Mon Sep 17 00:00:00 2001 From: eshifri Date: Mon, 19 Jul 2021 15:17:31 -0700 Subject: [PATCH 1/2] fix for #444: Accidentally altering a checkbox. --- radio/src/thirdparty/libopenui/src/checkbox.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/radio/src/thirdparty/libopenui/src/checkbox.cpp b/radio/src/thirdparty/libopenui/src/checkbox.cpp index 9dd22bcfd..33f08aa52 100644 --- a/radio/src/thirdparty/libopenui/src/checkbox.cpp +++ b/radio/src/thirdparty/libopenui/src/checkbox.cpp @@ -44,11 +44,15 @@ void CheckBox::onEvent(event_t event) #if defined(HARDWARE_TOUCH) bool CheckBox::onTouchEnd(coord_t x, coord_t y) { - if (enabled) { - onKeyPress(); - _setValue(!getValue()); - setFocus(SET_FOCUS_DEFAULT); - invalidate(); + if (enabled) + { + if (x < (rect.w >> 2)) + { + onKeyPress(); + _setValue(!getValue()); + setFocus(SET_FOCUS_DEFAULT); + invalidate(); + } } return true; } From 9b061261e9ba8dd2e9837d8f34a05ae829cffd5d Mon Sep 17 00:00:00 2001 From: eshifri Date: Tue, 20 Jul 2021 14:02:56 -0700 Subject: [PATCH 2/2] Force checkbox to be square. --- radio/src/thirdparty/libopenui/src/checkbox.cpp | 14 +++++--------- radio/src/thirdparty/libopenui/src/checkbox.h | 3 +++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/radio/src/thirdparty/libopenui/src/checkbox.cpp b/radio/src/thirdparty/libopenui/src/checkbox.cpp index 33f08aa52..9dd22bcfd 100644 --- a/radio/src/thirdparty/libopenui/src/checkbox.cpp +++ b/radio/src/thirdparty/libopenui/src/checkbox.cpp @@ -44,15 +44,11 @@ void CheckBox::onEvent(event_t event) #if defined(HARDWARE_TOUCH) bool CheckBox::onTouchEnd(coord_t x, coord_t y) { - if (enabled) - { - if (x < (rect.w >> 2)) - { - onKeyPress(); - _setValue(!getValue()); - setFocus(SET_FOCUS_DEFAULT); - invalidate(); - } + if (enabled) { + onKeyPress(); + _setValue(!getValue()); + setFocus(SET_FOCUS_DEFAULT); + invalidate(); } return true; } diff --git a/radio/src/thirdparty/libopenui/src/checkbox.h b/radio/src/thirdparty/libopenui/src/checkbox.h index 444d7f381..8bdd51756 100644 --- a/radio/src/thirdparty/libopenui/src/checkbox.h +++ b/radio/src/thirdparty/libopenui/src/checkbox.h @@ -29,6 +29,9 @@ class CheckBox : public FormField { _getValue(std::move(getValue)), _setValue(std::move(setValue)) { + coord_t size = min(rect.w, rect.h); + setWidth(size); + setHeight(size); } #if defined(DEBUG_WINDOWS)