From 1d7629dd9f67628c53841d137125833e3d5afe97 Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Tue, 28 Jul 2020 18:59:40 +0100 Subject: [PATCH] Changes after touch consumed behaviour change Change-Id: I789630deb72157ae4016eccc96636155fb7c3af4 --- .../internal/controls/buttons/button-impl.cpp | 9 +-- .../internal/controls/popup/popup-impl.cpp | 70 +++++++++++----------- dali-toolkit/internal/controls/popup/popup-impl.h | 8 ++- .../scrollable/item-view/item-view-impl.cpp | 2 +- .../scrollable/scroll-view/scroll-view-impl.cpp | 2 +- .../internal/controls/slider/slider-impl.cpp | 4 +- .../controls/text-controls/text-editor-impl.cpp | 2 +- .../controls/text-controls/text-field-impl.cpp | 2 +- .../drag-and-drop-detector-impl.cpp | 4 +- .../internal/text/decorator/text-decorator.cpp | 9 +-- dali-toolkit/public-api/controls/control-impl.cpp | 0 docs/content/example-code/properties.cpp | 2 +- 12 files changed, 57 insertions(+), 57 deletions(-) mode change 100755 => 100644 dali-toolkit/internal/controls/popup/popup-impl.h mode change 100755 => 100644 dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp mode change 100755 => 100644 dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp mode change 100755 => 100644 dali-toolkit/internal/controls/slider/slider-impl.cpp mode change 100755 => 100644 dali-toolkit/internal/drag-drop-detector/drag-and-drop-detector-impl.cpp mode change 100755 => 100644 dali-toolkit/public-api/controls/control-impl.cpp diff --git a/dali-toolkit/internal/controls/buttons/button-impl.cpp b/dali-toolkit/internal/controls/buttons/button-impl.cpp index 0305e8a3..40aa60c 100644 --- a/dali-toolkit/internal/controls/buttons/button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/button-impl.cpp @@ -630,11 +630,7 @@ bool Button::OnAccessibilityActivated() bool Button::OnTouch( Actor actor, const TouchData& touch ) { - - // Only events are processed when the button is not disabled - auto result( false ); - - if( !IsDisabled() ) + if( !IsDisabled() && (actor == touch.GetHitActor(0)) ) { if ( 1 == touch.GetPointCount() ) { @@ -675,9 +671,8 @@ bool Button::OnTouch( Actor actor, const TouchData& touch ) // Sets the button state to the default mButtonPressedState = UNPRESSED; } - result = true; } - return result; + return false; } bool Button::OnKeyboardEnter() diff --git a/dali-toolkit/internal/controls/popup/popup-impl.cpp b/dali-toolkit/internal/controls/popup/popup-impl.cpp index 1b4c3ab..7d4c2e3 100644 --- a/dali-toolkit/internal/controls/popup/popup-impl.cpp +++ b/dali-toolkit/internal/controls/popup/popup-impl.cpp @@ -330,14 +330,14 @@ void Popup::OnInitialize() mPopupLayout.SetFitHeight( 0 ); // Set row to fit. mPopupLayout.SetFitHeight( 1 ); // Set row to fit. - mPopupLayout.TouchSignal().Connect( this, &Popup::OnDialogTouched ); - mPopupContainer.Add( mPopupLayout ); // Any content after this point which is added to Self() will be re-parented to mContent. mAlterAddedChild = true; SetAsKeyboardFocusGroup( true ); + + SetupTouch(); } Popup::~Popup() @@ -593,9 +593,6 @@ void Popup::SetPopupBackgroundImage( Actor image ) mPopupBackgroundImage.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER ); mPopupBackgroundImage.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); - // OnDialogTouched only consumes the event. It prevents the touch event to be caught by the backing. - mPopupBackgroundImage.TouchSignal().Connect( this, &Popup::OnDialogTouched ); - // Set the popup border to be slightly larger than the layout contents. UpdateBackgroundPositionAndSize(); @@ -938,7 +935,6 @@ Toolkit::Control Popup::CreateBacking() // Default to being transparent. backing.SetProperty( Actor::Property::COLOR_ALPHA, 0.0f ); - backing.TouchSignal().Connect( this, &Popup::OnBackingTouched ); backing.WheelEventSignal().Connect( this, &Popup::OnBackingWheelEvent ); return backing; } @@ -1119,7 +1115,11 @@ const std::string& Popup::GetTailRightImage() const void Popup::SetTouchTransparent( bool enabled ) { - mTouchTransparent = enabled; + if( mTouchTransparent != enabled ) + { + mTouchTransparent = enabled; + SetupTouch(); + } } const bool Popup::IsTouchTransparent() const @@ -1534,26 +1534,18 @@ bool Popup::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tra bool Popup::OnBackingTouched( Actor actor, const TouchData& touch ) { - // Allow events to pass through if touch transparency is enabled. - if( mTouchTransparent ) + // Allow events to pass through if the backing isn't the hit-actor + if( (touch.GetHitActor(0) == actor) && + (touch.GetPointCount() > 0) && + (touch.GetState( 0 ) == PointState::DOWN)) { - return false; - } - - if( touch.GetPointCount() > 0 ) - { - if( touch.GetState( 0 ) == PointState::DOWN ) - { - // Guard against destruction during signal emission. - Toolkit::Popup handle( GetOwner() ); + // Guard against destruction during signal emission. + Toolkit::Popup handle( GetOwner() ); - mTouchedOutsideSignal.Emit(); - } + mTouchedOutsideSignal.Emit(); } - // Block anything behind backing becoming touched. - mLayer.SetProperty( Layer::Property::CONSUMES_TOUCH, true ); - return true; + return false; } bool Popup::OnBackingWheelEvent( Actor actor, const WheelEvent& event ) @@ -1564,22 +1556,13 @@ bool Popup::OnBackingWheelEvent( Actor actor, const WheelEvent& event ) return false; } - // Consume wheel event in dimmed backing actor. - mLayer.SetProperty( Layer::Property::CONSUMES_TOUCH, true ); return true; } bool Popup::OnDialogTouched( Actor actor, const TouchData& touch ) { - // Allow events to pass through if touch transparency is enabled. - if( mTouchTransparent ) - { - return false; - } - - // Consume event (stops backing actor receiving touch events) - mLayer.SetProperty( Layer::Property::CONSUMES_TOUCH, true ); - return true; + // Only connecting this so the backing does not become the default hit-actor and inadvertently closes the popup + return false; } void Popup::OnStageConnection( int depth ) @@ -1975,6 +1958,25 @@ Actor Popup::GetNextKeyboardFocusableActor( Actor currentFocusedActor, Toolkit:: return nextFocusableActor; } +void Popup::SetupTouch() +{ + if( ! mTouchTransparent ) + { + // Connect all the signals and set us up to consume all touch events + mBacking.TouchSignal().Connect( this, &Popup::OnBackingTouched ); + mPopupBackgroundImage.TouchSignal().Connect( this, &Popup::OnDialogTouched ); + mPopupLayout.TouchSignal().Connect( this, &Popup::OnDialogTouched ); + mLayer.SetProperty( Layer::Property::CONSUMES_TOUCH, true ); + } + else + { + // We are touch transparent so disconnect all signals and ensure our layer does not consumed all touch events + mBacking.TouchSignal().Disconnect( this, &Popup::OnBackingTouched ); + mPopupBackgroundImage.TouchSignal().Disconnect( this, &Popup::OnDialogTouched ); + mPopupLayout.TouchSignal().Disconnect( this, &Popup::OnDialogTouched ); + mLayer.SetProperty( Layer::Property::CONSUMES_TOUCH, false ); + } +} } // namespace Internal diff --git a/dali-toolkit/internal/controls/popup/popup-impl.h b/dali-toolkit/internal/controls/popup/popup-impl.h old mode 100755 new mode 100644 index 7903998..127aac6 --- a/dali-toolkit/internal/controls/popup/popup-impl.h +++ b/dali-toolkit/internal/controls/popup/popup-impl.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_INTERNAL_POPUP_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -499,6 +499,12 @@ private: */ void AddFocusableChildrenRecursive( Actor parent, std::vector< Actor >& focusableActors ); + /** + * Sets up the touch signals connections as required. + * @note This must be called after all the members have been created. + */ + void SetupTouch(); + private: // Undefined. diff --git a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp old mode 100755 new mode 100644 index 8492234..0d40921 --- a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp @@ -1142,7 +1142,7 @@ bool ItemView::OnTouch( Actor actor, const TouchData& touch ) RemoveAnimation(mScrollAnimation); } - return true; // consume since we're potentially scrolling + return false; // Do not consume as we're potentially scrolling (detecting pan gestures) } void ItemView::OnPan( const PanGesture& gesture ) diff --git a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp old mode 100755 new mode 100644 index 65f4e7b..fe8923f --- a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp @@ -2125,7 +2125,7 @@ bool ScrollView::OnTouch( Actor actor, const TouchData& touch ) mScrollInterrupted = false; } - return true; + return false; } bool ScrollView::OnWheelEvent(const WheelEvent& event) diff --git a/dali-toolkit/internal/controls/slider/slider-impl.cpp b/dali-toolkit/internal/controls/slider/slider-impl.cpp old mode 100755 new mode 100644 index 9f8d513..7fa1551 --- a/dali-toolkit/internal/controls/slider/slider-impl.cpp +++ b/dali-toolkit/internal/controls/slider/slider-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -240,7 +240,7 @@ bool Slider::OnTouch(Actor actor, const TouchData& touch) } } - return true; + return false; } void Slider::OnPan( Actor actor, const PanGesture& gesture ) diff --git a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp index fa8f3c7..0ee3bac 100644 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp @@ -1820,7 +1820,7 @@ void TextEditor::OnStageConnection( int depth ) bool TextEditor::OnTouched( Actor actor, const TouchData& touch ) { - return true; + return false; } void TextEditor::OnIdleSignal() diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp index ab00733..21a2e28 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -1868,7 +1868,7 @@ void TextField::OnStageConnection( int depth ) bool TextField::OnTouched( Actor actor, const TouchData& touch ) { - return true; + return false; } void TextField::OnIdleSignal() diff --git a/dali-toolkit/internal/drag-drop-detector/drag-and-drop-detector-impl.cpp b/dali-toolkit/internal/drag-drop-detector/drag-and-drop-detector-impl.cpp old mode 100755 new mode 100644 index f1aec26..34be65a --- a/dali-toolkit/internal/drag-drop-detector/drag-and-drop-detector-impl.cpp +++ b/dali-toolkit/internal/drag-drop-detector/drag-and-drop-detector-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -209,7 +209,7 @@ bool DragAndDropDetector::OnDrag(Dali::Actor actor, const Dali::TouchData& data) } mPointDown = false; } - return true; + return false; } const std::string& DragAndDropDetector::GetContent() const diff --git a/dali-toolkit/internal/text/decorator/text-decorator.cpp b/dali-toolkit/internal/text/decorator/text-decorator.cpp index 470c46c..56948c5 100644 --- a/dali-toolkit/internal/text/decorator/text-decorator.cpp +++ b/dali-toolkit/internal/text/decorator/text-decorator.cpp @@ -1386,8 +1386,7 @@ struct Decorator::Impl : public ConnectionTracker SetHandleImage( GRAB_HANDLE ); } - // Consume to avoid pop-ups accidentally closing, when handle is outside of pop-up area - return true; + return false; } bool OnHandleOneTouched( Actor actor, const TouchData& touch ) @@ -1417,8 +1416,7 @@ struct Decorator::Impl : public ConnectionTracker SetHandleImage( LEFT_SELECTION_HANDLE ); } - // Consume to avoid pop-ups accidentally closing, when handle is outside of pop-up area - return true; + return false; } bool OnHandleTwoTouched( Actor actor, const TouchData& touch ) @@ -1448,8 +1446,7 @@ struct Decorator::Impl : public ConnectionTracker SetHandleImage( RIGHT_SELECTION_HANDLE ); } - // Consume to avoid pop-ups accidentally closing, when handle is outside of pop-up area - return true; + return false; } void HandleResetPosition( PropertyNotification& source ) diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp old mode 100755 new mode 100644 diff --git a/docs/content/example-code/properties.cpp b/docs/content/example-code/properties.cpp index bbf5ae0..f421be2 100644 --- a/docs/content/example-code/properties.cpp +++ b/docs/content/example-code/properties.cpp @@ -113,7 +113,7 @@ public: valueText << touchedCount; mTagText.SetProperty( TextLabel::Property::TEXT, valueText.str() ); - return true; // Consumed + return true; // Consumed meaning any gestures will be cancelled } // C++ EXAMPLE END -- 2.7.4