From 746ebfed348c504b732dcb3f55c92a39b5643414 Mon Sep 17 00:00:00 2001 From: Daekwang Ryu Date: Tue, 6 Oct 2020 13:12:49 +0900 Subject: [PATCH] [Tizen] Revert "Changes after touch consumed behaviour change" This reverts commit 1642a4474eb7a3bfdfcef7b6eada308e5d287533. --- .../internal/controls/buttons/button-impl.cpp | 9 ++- .../internal/controls/popup/popup-impl.cpp | 71 +++++++++++----------- 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(+), 58 deletions(-) mode change 100644 => 100755 dali-toolkit/internal/controls/popup/popup-impl.h mode change 100644 => 100755 dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp mode change 100644 => 100755 dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp mode change 100644 => 100755 dali-toolkit/internal/controls/slider/slider-impl.cpp mode change 100644 => 100755 dali-toolkit/internal/drag-drop-detector/drag-and-drop-detector-impl.cpp mode change 100644 => 100755 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 d840e96..f102a19 100644 --- a/dali-toolkit/internal/controls/buttons/button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/button-impl.cpp @@ -630,7 +630,11 @@ bool Button::OnAccessibilityActivated() bool Button::OnTouch( Actor actor, const TouchEvent& touch ) { - if( !IsDisabled() && (actor == touch.GetHitActor(0)) ) + + // Only events are processed when the button is not disabled + auto result( false ); + + if( !IsDisabled() ) { if ( 1 == touch.GetPointCount() ) { @@ -671,8 +675,9 @@ bool Button::OnTouch( Actor actor, const TouchEvent& touch ) // Sets the button state to the default mButtonPressedState = UNPRESSED; } + result = true; } - return false; + return result; } bool Button::OnKeyboardEnter() diff --git a/dali-toolkit/internal/controls/popup/popup-impl.cpp b/dali-toolkit/internal/controls/popup/popup-impl.cpp index b95e648..eb16bab 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.TouchedSignal().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,6 +593,9 @@ 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.TouchedSignal().Connect( this, &Popup::OnDialogTouched ); + // Set the popup border to be slightly larger than the layout contents. UpdateBackgroundPositionAndSize(); @@ -935,6 +938,7 @@ Toolkit::Control Popup::CreateBacking() // Default to being transparent. backing.SetProperty( Actor::Property::COLOR_ALPHA, 0.0f ); + backing.TouchedSignal().Connect( this, &Popup::OnBackingTouched ); backing.WheelEventSignal().Connect( this, &Popup::OnBackingWheelEvent ); return backing; } @@ -1115,11 +1119,7 @@ const std::string& Popup::GetTailRightImage() const void Popup::SetTouchTransparent( bool enabled ) { - if( mTouchTransparent != enabled ) - { - mTouchTransparent = enabled; - SetupTouch(); - } + mTouchTransparent = enabled; } const bool Popup::IsTouchTransparent() const @@ -1534,18 +1534,26 @@ bool Popup::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tra bool Popup::OnBackingTouched( Actor actor, const TouchEvent& touch ) { - // 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)) + // Allow events to pass through if touch transparency is enabled. + if( mTouchTransparent ) { - // Guard against destruction during signal emission. - Toolkit::Popup handle( GetOwner() ); + return false; + } + + if( touch.GetPointCount() > 0 ) + { + if( touch.GetState( 0 ) == PointState::DOWN ) + { + // Guard against destruction during signal emission. + Toolkit::Popup handle( GetOwner() ); - mTouchedOutsideSignal.Emit(); + mTouchedOutsideSignal.Emit(); + } } - return false; + // Block anything behind backing becoming touched. + mLayer.SetProperty( Layer::Property::CONSUMES_TOUCH, true ); + return true; } bool Popup::OnBackingWheelEvent( Actor actor, const WheelEvent& event ) @@ -1556,13 +1564,22 @@ 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 TouchEvent& touch ) { - // Only connecting this so the backing does not become the default hit-actor and inadvertently closes the popup - return false; + // 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; } void Popup::OnSceneConnection( int depth ) @@ -1958,26 +1975,6 @@ 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.TouchedSignal().Connect( this, &Popup::OnBackingTouched ); - mPopupBackgroundImage.TouchedSignal().Connect( this, &Popup::OnDialogTouched ); - mPopupLayout.TouchedSignal().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.TouchedSignal().Disconnect( this, &Popup::OnBackingTouched ); - mPopupBackgroundImage.TouchedSignal().Disconnect( this, &Popup::OnDialogTouched ); - mPopupLayout.TouchedSignal().Disconnect( this, &Popup::OnDialogTouched ); - mLayer.SetProperty( Layer::Property::CONSUMES_TOUCH, false ); - } -} - } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/controls/popup/popup-impl.h b/dali-toolkit/internal/controls/popup/popup-impl.h old mode 100644 new mode 100755 index a7f7120..dc99f93 --- 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) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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,12 +499,6 @@ 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 100644 new mode 100755 index 12bd0c3..8bc37d6 --- a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp @@ -1145,7 +1145,7 @@ bool ItemView::OnTouch( Actor actor, const TouchEvent& touch ) RemoveAnimation(mScrollAnimation); } - return false; // Do not consume as we're potentially scrolling (detecting pan gestures) + return true; // consume since we're potentially scrolling } 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 100644 new mode 100755 index 01c5731..9fc9176 --- a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp @@ -2129,7 +2129,7 @@ bool ScrollView::OnTouch( Actor actor, const TouchEvent& touch ) mScrollInterrupted = false; } - return false; + return true; } bool ScrollView::OnWheelEvent( Actor actor, 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 100644 new mode 100755 index 742311a..638f115 --- a/dali-toolkit/internal/controls/slider/slider-impl.cpp +++ b/dali-toolkit/internal/controls/slider/slider-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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 TouchEvent& touch) } } - return false; + return true; } 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 4224df2..d42e379 100644 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp @@ -1749,7 +1749,7 @@ void TextEditor::OnSceneConnection( int depth ) bool TextEditor::OnTouched( Actor actor, const TouchEvent& touch ) { - return false; + return true; } 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 eedc821..7f218f2 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -1782,7 +1782,7 @@ void TextField::OnSceneConnection( int depth ) bool TextField::OnTouched( Actor actor, const TouchEvent& touch ) { - return false; + return true; } 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 100644 new mode 100755 index 994932e..d1ad520 --- 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) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -211,7 +211,7 @@ bool DragAndDropDetector::OnDrag(Dali::Actor actor, const Dali::TouchEvent& data } mPointDown = false; } - return false; + return true; } 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 7016759..09d29d5 100644 --- a/dali-toolkit/internal/text/decorator/text-decorator.cpp +++ b/dali-toolkit/internal/text/decorator/text-decorator.cpp @@ -1389,7 +1389,8 @@ struct Decorator::Impl : public ConnectionTracker SetHandleImage( GRAB_HANDLE ); } - return false; + // Consume to avoid pop-ups accidentally closing, when handle is outside of pop-up area + return true; } bool OnHandleOneTouched( Actor actor, const TouchEvent& touch ) @@ -1419,7 +1420,8 @@ struct Decorator::Impl : public ConnectionTracker SetHandleImage( LEFT_SELECTION_HANDLE ); } - return false; + // Consume to avoid pop-ups accidentally closing, when handle is outside of pop-up area + return true; } bool OnHandleTwoTouched( Actor actor, const TouchEvent& touch ) @@ -1449,7 +1451,8 @@ struct Decorator::Impl : public ConnectionTracker SetHandleImage( RIGHT_SELECTION_HANDLE ); } - return false; + // Consume to avoid pop-ups accidentally closing, when handle is outside of pop-up area + return true; } 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 100644 new mode 100755 diff --git a/docs/content/example-code/properties.cpp b/docs/content/example-code/properties.cpp index 61be376..c840964 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 meaning any gestures will be cancelled + return true; // Consumed } // C++ EXAMPLE END -- 2.7.4