From 0a3d78221e5a01189c6cc80e20bb95bff8f99c7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 27 Nov 2022 16:15:16 +0100 Subject: [PATCH] Fix drag-background-through-buttons problem by adding "touch exclusive" mode to viewgroups. Not using universally because I don't want to debug all the issues... --- Common/UI/View.cpp | 42 ++++++++++++++++--------- Common/UI/View.h | 16 +++++----- Common/UI/ViewGroup.cpp | 19 ++++++++--- Common/UI/ViewGroup.h | 6 ++-- UI/DisplayLayoutScreen.cpp | 8 ++++- UI/GamepadEmu.cpp | 56 ++++++++++++++++++++------------- UI/GamepadEmu.h | 18 +++++------ UI/MainScreen.cpp | 5 +-- UI/TouchControlLayoutScreen.cpp | 5 +-- 9 files changed, 111 insertions(+), 64 deletions(-) diff --git a/Common/UI/View.cpp b/Common/UI/View.cpp index efc8cd13e4..cf741f5884 100644 --- a/Common/UI/View.cpp +++ b/Common/UI/View.cpp @@ -226,11 +226,13 @@ void Clickable::FocusChanged(int focusFlags) { } } -void Clickable::Touch(const TouchInput &input) { +bool Clickable::Touch(const TouchInput &input) { + bool contains = bounds_.Contains(input.x, input.y); + if (!IsEnabled()) { dragging_ = false; down_ = false; - return; + return contains; } if (input.flags & TOUCH_DOWN) { @@ -255,6 +257,7 @@ void Clickable::Touch(const TouchInput &input) { downCountDown_ = 0; dragging_ = false; } + return contains; } static bool MatchesKeyDef(const std::vector &defs, const KeyInput &key) { @@ -350,21 +353,24 @@ bool Clickable::Key(const KeyInput &key) { return ret; } -void StickyChoice::Touch(const TouchInput &input) { +bool StickyChoice::Touch(const TouchInput &touch) { + bool contains = bounds_.Contains(touch.x, touch.y); dragging_ = false; if (!IsEnabled()) { down_ = false; - return; + return contains; } - if (input.flags & TOUCH_DOWN) { - if (bounds_.Contains(input.x, input.y)) { + if (touch.flags & TOUCH_DOWN) { + if (contains) { if (IsFocusMovementEnabled()) SetFocusedView(this); down_ = true; Click(); + return true; } } + return false; } bool StickyChoice::Key(const KeyInput &key) { @@ -1069,12 +1075,14 @@ static std::string FirstLine(const std::string &text) { return text; } -void TextEdit::Touch(const TouchInput &touch) { +bool TextEdit::Touch(const TouchInput &touch) { if (touch.flags & TOUCH_DOWN) { if (bounds_.Contains(touch.x, touch.y)) { SetFocusedView(this, true); + return true; } } + return false; } bool TextEdit::Key(const KeyInput &input) { @@ -1259,14 +1267,15 @@ void Spinner::Draw(UIContext &dc) { } } -void TriggerButton::Touch(const TouchInput &input) { +bool TriggerButton::Touch(const TouchInput &input) { + bool contains = bounds_.Contains(input.x, input.y); if (input.flags & TOUCH_DOWN) { - if (bounds_.Contains(input.x, input.y)) { + if (contains) { down_ |= 1 << input.id; } } if (input.flags & TOUCH_MOVE) { - if (bounds_.Contains(input.x, input.y)) + if (contains) down_ |= 1 << input.id; else down_ &= ~(1 << input.id); @@ -1281,6 +1290,8 @@ void TriggerButton::Touch(const TouchInput &input) { } else { *bitField_ &= ~bit_; } + + return contains; } void TriggerButton::Draw(UIContext &dc) { @@ -1344,9 +1355,10 @@ bool Slider::ApplyKey(int keyCode) { return true; } -void Slider::Touch(const TouchInput &input) { +bool Slider::Touch(const TouchInput &input) { // Calling it afterwards, so dragging_ hasn't been set false yet when checking it above. - Clickable::Touch(input); + bool contains = Clickable::Touch(input); + if (dragging_) { float relativeX = (input.x - (bounds_.x + paddingLeft_)) / (bounds_.w - paddingLeft_ - paddingRight_); *value_ = floorf(relativeX * (maxValue_ - minValue_) + minValue_ + 0.5f); @@ -1360,6 +1372,7 @@ void Slider::Touch(const TouchInput &input) { // Cancel any key repeat. repeat_ = -1; + return contains; } void Slider::Clamp() { @@ -1470,8 +1483,8 @@ bool SliderFloat::ApplyKey(int keyCode) { return true; } -void SliderFloat::Touch(const TouchInput &input) { - Clickable::Touch(input); +bool SliderFloat::Touch(const TouchInput &input) { + bool contains = Clickable::Touch(input); if (dragging_) { float relativeX = (input.x - (bounds_.x + paddingLeft_)) / (bounds_.w - paddingLeft_ - paddingRight_); *value_ = (relativeX * (maxValue_ - minValue_) + minValue_); @@ -1485,6 +1498,7 @@ void SliderFloat::Touch(const TouchInput &input) { // Cancel any key repeat. repeat_ = -1; + return contains; } void SliderFloat::Clamp() { diff --git a/Common/UI/View.h b/Common/UI/View.h index 6e29c6bdef..64c9cdacf8 100644 --- a/Common/UI/View.h +++ b/Common/UI/View.h @@ -375,7 +375,7 @@ public: // Can even be called on a different thread! This is to really minimize latency, and decouple // touch response from the frame rate. Same with Key and Axis. virtual bool Key(const KeyInput &input) { return false; } - virtual void Touch(const TouchInput &input) {} + virtual bool Touch(const TouchInput &input) { return true; } virtual void Axis(const AxisInput &input) {} virtual void Update(); @@ -501,7 +501,7 @@ public: : View(layoutParams) {} bool Key(const KeyInput &input) override { return false; } - void Touch(const TouchInput &input) override {} + bool Touch(const TouchInput &input) override { return false; } bool CanBeFocused() const override { return false; } }; @@ -512,7 +512,7 @@ public: Clickable(LayoutParams *layoutParams); bool Key(const KeyInput &input) override; - void Touch(const TouchInput &input) override; + bool Touch(const TouchInput &input) override; void FocusChanged(int focusFlags) override; @@ -602,7 +602,7 @@ public: void Draw(UIContext &dc) override; std::string DescribeText() const override; bool Key(const KeyInput &input) override; - void Touch(const TouchInput &input) override; + bool Touch(const TouchInput &input) override; void Update() override; void GetContentDimensions(const UIContext &dc, float &w, float &h) const override; void SetShowPercent(bool s) { showPercent_ = s; } @@ -633,7 +633,7 @@ public: void Draw(UIContext &dc) override; std::string DescribeText() const override; bool Key(const KeyInput &input) override; - void Touch(const TouchInput &input) override; + bool Touch(const TouchInput &input) override; void Update() override; void GetContentDimensions(const UIContext &dc, float &w, float &h) const override; @@ -661,7 +661,7 @@ public: TriggerButton(uint32_t *bitField, uint32_t bit, ImageID imageBackground, ImageID imageForeground, LayoutParams *layoutParams) : View(layoutParams), down_(0.0), bitField_(bitField), bit_(bit), imageBackground_(imageBackground), imageForeground_(imageForeground) {} - void Touch(const TouchInput &input) override; + bool Touch(const TouchInput &input) override; void Draw(UIContext &dc) override; void GetContentDimensions(const UIContext &dc, float &w, float &h) const override; @@ -755,7 +755,7 @@ public: : Choice(buttonImage, layoutParams) {} bool Key(const KeyInput &key) override; - void Touch(const TouchInput &touch) override; + bool Touch(const TouchInput &touch) override; void FocusChanged(int focusFlags) override; void Press() { down_ = true; dragging_ = false; } @@ -943,7 +943,7 @@ public: void Draw(UIContext &dc) override; std::string DescribeText() const override; bool Key(const KeyInput &key) override; - void Touch(const TouchInput &touch) override; + bool Touch(const TouchInput &touch) override; Event OnTextChange; Event OnEnter; diff --git a/Common/UI/ViewGroup.cpp b/Common/UI/ViewGroup.cpp index 556f664c9e..e69f6865c8 100644 --- a/Common/UI/ViewGroup.cpp +++ b/Common/UI/ViewGroup.cpp @@ -87,13 +87,20 @@ void ViewGroup::PersistData(PersistStatus status, std::string anonId, PersistMap } } -void ViewGroup::Touch(const TouchInput &input) { +bool ViewGroup::Touch(const TouchInput &input) { std::lock_guard guard(modifyLock_); + bool any = false; for (auto iter = views_.begin(); iter != views_.end(); ++iter) { // TODO: If there is a transformation active, transform input coordinates accordingly. - if ((*iter)->GetVisibility() == V_VISIBLE) - (*iter)->Touch(input); + if ((*iter)->GetVisibility() == V_VISIBLE) { + bool touch = (*iter)->Touch(input); + any = any || touch; + if (exclusiveTouch_ && touch) { + break; + } + } } + return any; } void ViewGroup::Query(float x, float y, std::vector &list) { @@ -850,7 +857,7 @@ bool ScrollView::Key(const KeyInput &input) { const float friction = 0.92f; const float stop_threshold = 0.1f; -void ScrollView::Touch(const TouchInput &input) { +bool ScrollView::Touch(const TouchInput &input) { if ((input.flags & TOUCH_DOWN) && scrollTouchId_ == -1) { scrollStart_ = scrollPos_; inertia_ = 0.0f; @@ -884,7 +891,9 @@ void ScrollView::Touch(const TouchInput &input) { } if (!(input.flags & TOUCH_DOWN) || bounds_.Contains(input.x, input.y)) { - ViewGroup::Touch(input2); + return ViewGroup::Touch(input2); + } else { + return false; } } diff --git a/Common/UI/ViewGroup.h b/Common/UI/ViewGroup.h index 5b552c5f0f..c5ee4032dd 100644 --- a/Common/UI/ViewGroup.h +++ b/Common/UI/ViewGroup.h @@ -28,7 +28,7 @@ public: // Pass through external events to children. virtual bool Key(const KeyInput &input) override; - virtual void Touch(const TouchInput &input) override; + virtual bool Touch(const TouchInput &input) override; virtual void Axis(const AxisInput &input) override; // By default, a container will layout to its own bounds. @@ -77,6 +77,7 @@ public: int GetNumSubviews() const { return (int)views_.size(); } void SetHasDropShadow(bool has) { hasDropShadow_ = has; } void SetDropShadowExpand(float s) { dropShadowExpand_ = s; } + void SetExclusiveTouch(bool exclusive) { exclusiveTouch_ = exclusive; } void Lock() { modifyLock_.lock(); } void Unlock() { modifyLock_.unlock(); } @@ -96,6 +97,7 @@ protected: float dropShadowExpand_ = 0.0f; bool hasDropShadow_ = false; bool clip_ = false; + bool exclusiveTouch_ = false; }; // A frame layout contains a single child view (normally). @@ -270,7 +272,7 @@ public: void Layout() override; bool Key(const KeyInput &input) override; - void Touch(const TouchInput &input) override; + bool Touch(const TouchInput &input) override; void Draw(UIContext &dc) override; std::string DescribeLog() const override { return "ScrollView: " + View::DescribeLog(); } diff --git a/UI/DisplayLayoutScreen.cpp b/UI/DisplayLayoutScreen.cpp index 4b3cfe02de..9e95b76e1c 100644 --- a/UI/DisplayLayoutScreen.cpp +++ b/UI/DisplayLayoutScreen.cpp @@ -59,7 +59,7 @@ class DisplayLayoutBackground : public UI::View { public: DisplayLayoutBackground(UI::ChoiceStrip *mode, UI::LayoutParams *layoutParams) : UI::View(layoutParams), mode_(mode) {} - void Touch(const TouchInput &touch) { + bool Touch(const TouchInput &touch) { int mode = mode_ ? mode_->GetSelection() : 0; const Bounds &screenBounds = bounds_; @@ -96,6 +96,8 @@ public: if ((touch.flags & TOUCH_UP) != 0 && dragging_) { dragging_ = false; } + + return true; } private: @@ -188,6 +190,10 @@ void DisplayLayoutScreen::CreateViews() { root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT)); + // Make it so that a touch can only affect one view. Makes manipulating the background through the buttons + // impossible. + root_->SetExclusiveTouch(true); + ScrollView *leftScrollView = new ScrollView(ORIENT_VERTICAL, new AnchorLayoutParams(300.0f, FILL_PARENT, 10.f, 10.f, NONE, 10.f, false)); ViewGroup *leftColumn = new LinearLayout(ORIENT_VERTICAL); leftScrollView->Add(leftColumn); diff --git a/UI/GamepadEmu.cpp b/UI/GamepadEmu.cpp index bb1eb01f3b..5a1450eba5 100644 --- a/UI/GamepadEmu.cpp +++ b/UI/GamepadEmu.cpp @@ -45,8 +45,9 @@ GamepadView::GamepadView(const char *key, UI::LayoutParams *layoutParams) : UI:: lastFrameTime_ = time_now_d(); } -void GamepadView::Touch(const TouchInput &input) { +bool GamepadView::Touch(const TouchInput &input) { secondsWithoutTouch_ = 0.0f; + return true; } void GamepadView::Update() { @@ -96,8 +97,8 @@ void MultiTouchButton::GetContentDimensions(const UIContext &dc, float &w, float } } -void MultiTouchButton::Touch(const TouchInput &input) { - GamepadView::Touch(input); +bool MultiTouchButton::Touch(const TouchInput &input) { + bool retval = GamepadView::Touch(input); if ((input.flags & TOUCH_DOWN) && bounds_.Contains(input.x, input.y)) { pointerDownMask_ |= 1 << input.id; usedPointerMask |= 1 << input.id; @@ -116,6 +117,7 @@ void MultiTouchButton::Touch(const TouchInput &input) { pointerDownMask_ = 0; usedPointerMask = 0; } + return retval; } void MultiTouchButton::Draw(UIContext &dc) { @@ -152,9 +154,9 @@ void MultiTouchButton::Draw(UIContext &dc) { dc.Draw()->DrawImageRotated(img_, bounds_.centerX(), y, scale, angle_ * (M_PI * 2 / 360.0f), color); } -void BoolButton::Touch(const TouchInput &input) { +bool BoolButton::Touch(const TouchInput &input) { bool lastDown = pointerDownMask_ != 0; - MultiTouchButton::Touch(input); + bool retval = MultiTouchButton::Touch(input); bool down = pointerDownMask_ != 0; if (down != lastDown) { @@ -163,11 +165,12 @@ void BoolButton::Touch(const TouchInput &input) { params.a = down; OnChange.Trigger(params); } + return retval; } -void PSPButton::Touch(const TouchInput &input) { +bool PSPButton::Touch(const TouchInput &input) { bool lastDown = pointerDownMask_ != 0; - MultiTouchButton::Touch(input); + bool retval = MultiTouchButton::Touch(input); bool down = pointerDownMask_ != 0; if (down && !lastDown) { if (g_Config.bHapticFeedback) { @@ -177,6 +180,7 @@ void PSPButton::Touch(const TouchInput &input) { } else if (lastDown && !down) { __CtrlButtonUp(pspButtonBit_); } + return retval; } bool ComboKey::IsDown() { @@ -192,10 +196,10 @@ void ComboKey::GetContentDimensions(const UIContext &dc, float &w, float &h) con } } -void ComboKey::Touch(const TouchInput &input) { +bool ComboKey::Touch(const TouchInput &input) { using namespace CustomKey; bool lastDown = pointerDownMask_ != 0; - MultiTouchButton::Touch(input); + bool retval = MultiTouchButton::Touch(input); bool down = pointerDownMask_ != 0; if (down && !lastDown) { @@ -220,6 +224,7 @@ void ComboKey::Touch(const TouchInput &input) { } on_ = false; } + return retval; } void ComboKey::Update() { @@ -272,8 +277,8 @@ void PSPDpad::GetContentDimensions(const UIContext &dc, float &w, float &h) cons } } -void PSPDpad::Touch(const TouchInput &input) { - GamepadView::Touch(input); +bool PSPDpad::Touch(const TouchInput &input) { + bool retval = GamepadView::Touch(input); if (input.flags & TOUCH_DOWN) { if (dragPointerId_ == -1 && bounds_.Contains(input.x, input.y)) { @@ -297,6 +302,7 @@ void PSPDpad::Touch(const TouchInput &input) { ProcessTouch(input.x, input.y, false); } } + return retval; } void PSPDpad::ProcessTouch(float x, float y, bool down) { @@ -438,8 +444,8 @@ void PSPStick::Draw(UIContext &dc) { dc.Draw()->DrawImage(stickImageIndex_, stickX + dx * stick_size_ * scale_, stickY - dy * stick_size_ * scale_, 1.0f * scale_ * headScale, colorBg, ALIGN_CENTER); } -void PSPStick::Touch(const TouchInput &input) { - GamepadView::Touch(input); +bool PSPStick::Touch(const TouchInput &input) { + bool retval = GamepadView::Touch(input); if (input.flags & TOUCH_RELEASE_ALL) { dragPointerId_ = -1; centerX_ = bounds_.centerX(); @@ -447,7 +453,7 @@ void PSPStick::Touch(const TouchInput &input) { __CtrlSetAnalogXY(stick_, 0.0f, 0.0f); usedPointerMask = 0; analogPointerMask = 0; - return; + return retval; } if (input.flags & TOUCH_DOWN) { float fac = 0.5f*(stick_ ? g_Config.fRightStickHeadScale : g_Config.fLeftStickHeadScale)-0.5f; @@ -463,11 +469,13 @@ void PSPStick::Touch(const TouchInput &input) { usedPointerMask |= 1 << input.id; analogPointerMask |= 1 << input.id; ProcessTouch(input.x, input.y, true); + retval = true; } } if (input.flags & TOUCH_MOVE) { if (input.id == dragPointerId_) { ProcessTouch(input.x, input.y, true); + retval = true; } } if (input.flags & TOUCH_UP) { @@ -478,8 +486,10 @@ void PSPStick::Touch(const TouchInput &input) { usedPointerMask &= ~(1 << input.id); analogPointerMask &= ~(1 << input.id); ProcessTouch(input.x, input.y, false); + retval = true; } } + return retval; } void PSPStick::ProcessTouch(float x, float y, bool down) { @@ -542,8 +552,8 @@ void PSPCustomStick::Draw(UIContext &dc) { dc.Draw()->DrawImage(stickImageIndex_, stickX + dx * stick_size_ * scale_, stickY - dy * stick_size_ * scale_, 1.0f*scale_*g_Config.fRightStickHeadScale, colorBg, ALIGN_CENTER); } -void PSPCustomStick::Touch(const TouchInput &input) { - GamepadView::Touch(input); +bool PSPCustomStick::Touch(const TouchInput &input) { + bool retval = GamepadView::Touch(input); if (input.flags & TOUCH_RELEASE_ALL) { dragPointerId_ = -1; centerX_ = bounds_.centerX(); @@ -552,7 +562,7 @@ void PSPCustomStick::Touch(const TouchInput &input) { posY_ = 0.0f; usedPointerMask = 0; analogPointerMask = 0; - return; + return false; } if (input.flags & TOUCH_DOWN) { float fac = 0.5f*g_Config.fRightStickHeadScale-0.5f; @@ -568,11 +578,13 @@ void PSPCustomStick::Touch(const TouchInput &input) { usedPointerMask |= 1 << input.id; analogPointerMask |= 1 << input.id; ProcessTouch(input.x, input.y, true); + retval = true; } } if (input.flags & TOUCH_MOVE) { if (input.id == dragPointerId_) { ProcessTouch(input.x, input.y, true); + retval = true; } } if (input.flags & TOUCH_UP) { @@ -583,8 +595,10 @@ void PSPCustomStick::Touch(const TouchInput &input) { usedPointerMask &= ~(1 << input.id); analogPointerMask &= ~(1 << input.id); ProcessTouch(input.x, input.y, false); + retval = true; } } + return true; } void PSPCustomStick::ProcessTouch(float x, float y, bool down) { @@ -890,17 +904,16 @@ UI::ViewGroup *CreatePadLayout(float xres, float yres, bool *pause, bool showPau return root; } - -void GestureGamepad::Touch(const TouchInput &input) { +bool GestureGamepad::Touch(const TouchInput &input) { if (usedPointerMask & (1 << input.id)) { if (input.id == dragPointerId_) dragPointerId_ = -1; - return; + return false; } if (input.flags & TOUCH_RELEASE_ALL) { dragPointerId_ = -1; - return; + return false; } if (input.flags & TOUCH_DOWN) { @@ -940,6 +953,7 @@ void GestureGamepad::Touch(const TouchInput &input) { } } } + return true; } void GestureGamepad::Update() { diff --git a/UI/GamepadEmu.h b/UI/GamepadEmu.h index bb8da30ea7..0eb2a7c60c 100644 --- a/UI/GamepadEmu.h +++ b/UI/GamepadEmu.h @@ -29,7 +29,7 @@ class GamepadView : public UI::View { public: GamepadView(const char *key, UI::LayoutParams *layoutParams); - void Touch(const TouchInput &input) override; + bool Touch(const TouchInput &input) override; bool Key(const KeyInput &input) override { return false; } @@ -50,7 +50,7 @@ public: : GamepadView(key, layoutParams), scale_(scale), bgImg_(bgImg), bgDownImg_(bgDownImg), img_(img) { } - void Touch(const TouchInput &input) override; + bool Touch(const TouchInput &input) override; void Draw(UIContext &dc) override; void GetContentDimensions(const UIContext &dc, float &w, float &h) const override; virtual bool IsDown() { return pointerDownMask_ != 0; } @@ -78,7 +78,7 @@ public: : MultiTouchButton(key, bgImg, bgDownImg, img, scale, layoutParams), value_(value) { } - void Touch(const TouchInput &input) override; + bool Touch(const TouchInput &input) override; bool IsDown() override { return *value_; } UI::Event OnChange; @@ -92,7 +92,7 @@ public: PSPButton(int pspButtonBit, const char *key, ImageID bgImg, ImageID bgDownImg, ImageID img, float scale, UI::LayoutParams *layoutParams) : MultiTouchButton(key, bgImg, bgDownImg, img, scale, layoutParams), pspButtonBit_(pspButtonBit) { } - void Touch(const TouchInput &input) override; + bool Touch(const TouchInput &input) override; bool IsDown() override; private: @@ -103,7 +103,7 @@ class PSPDpad : public GamepadView { public: PSPDpad(ImageID arrowIndex, const char *key, ImageID arrowDownIndex, ImageID overlayIndex, float scale, float spacing, UI::LayoutParams *layoutParams); - void Touch(const TouchInput &input) override; + bool Touch(const TouchInput &input) override; void Draw(UIContext &dc) override; void GetContentDimensions(const UIContext &dc, float &w, float &h) const override; @@ -124,7 +124,7 @@ class PSPStick : public GamepadView { public: PSPStick(ImageID bgImg, const char *key, ImageID stickImg, ImageID stickDownImg, int stick, float scale, UI::LayoutParams *layoutParams); - void Touch(const TouchInput &input) override; + bool Touch(const TouchInput &input) override; void Draw(UIContext &dc) override; void GetContentDimensions(const UIContext &dc, float &w, float &h) const override; @@ -149,7 +149,7 @@ class PSPCustomStick : public PSPStick { public: PSPCustomStick(ImageID bgImg, const char *key, ImageID stickImg, ImageID stickDownImg, float scale, UI::LayoutParams *layoutParams); - void Touch(const TouchInput &input) override; + bool Touch(const TouchInput &input) override; void Draw(UIContext &dc) override; private: @@ -172,7 +172,7 @@ public: ComboKey(uint64_t pspButtonBit, const char *key, bool toggle, bool repeat, ControlMapper* controllMapper, ImageID bgImg, ImageID bgDownImg, ImageID img, float scale, bool invertedContextDimension, UI::LayoutParams *layoutParams) : MultiTouchButton(key, bgImg, bgDownImg, img, scale, layoutParams), pspButtonBit_(pspButtonBit), toggle_(toggle), repeat_(repeat), controlMapper_(controllMapper), on_(false), invertedContextDimension_(invertedContextDimension) { } - void Touch(const TouchInput &input) override; + bool Touch(const TouchInput &input) override; void Update() override; bool IsDown() override; @@ -191,7 +191,7 @@ class GestureGamepad : public UI::View { public: GestureGamepad(ControlMapper* controllMapper) : controlMapper_(controllMapper) {}; - void Touch(const TouchInput &input) override; + bool Touch(const TouchInput &input) override; void Update() override; protected: diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index d5ed3ab0a4..cdd1fc4a0c 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -136,8 +136,8 @@ public: void SetHoldEnabled(bool hold) { holdEnabled_ = hold; } - void Touch(const TouchInput &input) override { - UI::Clickable::Touch(input); + bool Touch(const TouchInput &input) override { + bool retval = UI::Clickable::Touch(input); hovering_ = bounds_.Contains(input.x, input.y); if (hovering_ && (input.flags & TOUCH_DOWN)) { holdStart_ = time_now_d(); @@ -145,6 +145,7 @@ public: if (input.flags & TOUCH_UP) { holdStart_ = 0; } + return retval; } bool Key(const KeyInput &key) override { diff --git a/UI/TouchControlLayoutScreen.cpp b/UI/TouchControlLayoutScreen.cpp index 31fffd6ff4..12012332a1 100644 --- a/UI/TouchControlLayoutScreen.cpp +++ b/UI/TouchControlLayoutScreen.cpp @@ -359,7 +359,7 @@ public: : UI::AnchorLayout(layoutParams) { } - void Touch(const TouchInput &input) override; + bool Touch(const TouchInput &input) override; void CreateViews(); bool HasCreatedViews() const { return !controls_.empty(); @@ -384,7 +384,7 @@ static Point ClampTo(const Point &p, const Bounds &b) { return Point(clamp_value(p.x, b.x, b.x + b.w), clamp_value(p.y, b.y, b.y + b.h)); } -void ControlLayoutView::Touch(const TouchInput &touch) { +bool ControlLayoutView::Touch(const TouchInput &touch) { using namespace UI; if ((touch.flags & TOUCH_MOVE) && pickedControl_ != nullptr) { @@ -452,6 +452,7 @@ void ControlLayoutView::Touch(const TouchInput &touch) { pickedControl_->SavePosition(); pickedControl_ = 0; } + return true; } void ControlLayoutView::CreateViews() {