X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fpopup%2Fpopup-impl.cpp;h=94a0eade5434d43195974cf332cff6c01fc14ca3;hp=66e63508330a3d4a0a4c5ef9975fb2b6ae4c974d;hb=f546dd5d83a968e573f8f053a01ce43df32c71a0;hpb=ad110f27c01af7e617df158891eef5cf60bf22e6 diff --git a/dali-toolkit/internal/controls/popup/popup-impl.cpp b/dali-toolkit/internal/controls/popup/popup-impl.cpp index 66e6350..94a0ead 100644 --- a/dali-toolkit/internal/controls/popup/popup-impl.cpp +++ b/dali-toolkit/internal/controls/popup/popup-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. @@ -26,9 +26,9 @@ #include #include #include -#include +#include #include -#include +#include #include #include #include @@ -39,10 +39,10 @@ #include #include #include -#include #include #include #include +#include using namespace Dali; @@ -330,18 +330,25 @@ 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(); + + DevelControl::SetAccessibilityConstructor( self, []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new Control::Impl::AccessibleImpl( actor, Dali::Accessibility::Role::DIALOG, true ) ); + } ); } Popup::~Popup() { + if( DevelControl::GetBoundAccessibilityObject( Self() ) ) + Accessibility::Bridge::GetCurrentBridge()->RemovePopup( DevelControl::GetBoundAccessibilityObject( Self() ) ); mEntryAnimationData.Clear(); mExitAnimationData.Clear(); } @@ -361,7 +368,7 @@ void Popup::LayoutAnimation() case Toolkit::Popup::FADE: { // Fade animations start transparent. - mPopupContainer.SetProperty( DevelActor::Property::OPACITY, 0.0f ); + mPopupContainer.SetProperty( Actor::Property::OPACITY, 0.0f ); break; } @@ -456,7 +463,7 @@ void Popup::StartTransitionAnimation( bool transitionIn, bool instantaneous /* f } else { - mPopupContainer.SetProperty( DevelActor::Property::OPACITY, transitionIn ? 1.0f : 0.0f ); + mPopupContainer.SetProperty( Actor::Property::OPACITY, transitionIn ? 1.0f : 0.0f ); } break; } @@ -593,9 +600,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(); @@ -747,16 +751,16 @@ void Popup::SetDisplayState( Toolkit::Popup::DisplayState displayState ) { mPreviousFocusedActor = keyboardFocusManager.GetCurrentFocusActor(); - if( Self().IsKeyboardFocusable() ) + if( Self().GetProperty< bool >( Actor::Property::KEYBOARD_FOCUSABLE ) ) { // Setup the actgor to start focus from. Actor focusActor; - if( mContent && mContent.IsKeyboardFocusable() ) + if( mContent && mContent.GetProperty< bool >( Actor::Property::KEYBOARD_FOCUSABLE ) ) { // If the content is focusable, move the focus to the content. focusActor = mContent; } - else if( mFooter && mFooter.IsKeyboardFocusable() ) + else if( mFooter && mFooter.GetProperty< bool >( Actor::Property::KEYBOARD_FOCUSABLE ) ) { // If the footer is focusable, move the focus to the footer. focusActor = mFooter; @@ -779,7 +783,7 @@ void Popup::SetDisplayState( Toolkit::Popup::DisplayState displayState ) ClearKeyInputFocus(); // Restore the keyboard focus when popup is hidden. - if( mPreviousFocusedActor && mPreviousFocusedActor.IsKeyboardFocusable() ) + if( mPreviousFocusedActor && mPreviousFocusedActor.GetProperty< bool >( Actor::Property::KEYBOARD_FOCUSABLE ) ) { Dali::Toolkit::KeyboardFocusManager keyboardFocusManager = Dali::Toolkit::KeyboardFocusManager::Get(); if( keyboardFocusManager ) @@ -938,7 +942,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 +1122,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 @@ -1532,28 +1539,20 @@ bool Popup::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tra return connected; } -bool Popup::OnBackingTouched( Actor actor, const TouchData& touch ) +bool Popup::OnBackingTouched( Actor actor, const TouchEvent& 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.SetTouchConsumed( true ); - return true; + return false; } bool Popup::OnBackingWheelEvent( Actor actor, const WheelEvent& event ) @@ -1564,30 +1563,30 @@ bool Popup::OnBackingWheelEvent( Actor actor, const WheelEvent& event ) return false; } - // Consume wheel event in dimmed backing actor. - mLayer.SetTouchConsumed( true ); return true; } -bool Popup::OnDialogTouched( Actor actor, const TouchData& touch ) +bool Popup::OnDialogTouched( Actor actor, const TouchEvent& touch ) { - // Allow events to pass through if touch transparency is enabled. - if( mTouchTransparent ) - { - return false; - } + // Only connecting this so the backing does not become the default hit-actor and inadvertently closes the popup + return false; +} - // Consume event (stops backing actor receiving touch events) - mLayer.SetTouchConsumed( true ); - return true; +void Popup::OnSceneDisconnection() +{ + auto p = Dali::Accessibility::Accessible::Get(Self()); + Accessibility::Bridge::GetCurrentBridge()->RemovePopup( p ); + Control::OnSceneDisconnection(); } -void Popup::OnStageConnection( int depth ) +void Popup::OnSceneConnection( int depth ) { mLayoutDirty = true; RelayoutRequest(); - Control::OnStageConnection( depth ); + Control::OnSceneConnection( depth ); + auto p = Dali::Accessibility::Accessible::Get(Self()); + Accessibility::Bridge::GetCurrentBridge()->AddPopup( p ); } void Popup::OnChildAdd( Actor& child ) @@ -1812,9 +1811,9 @@ bool Popup::OnKeyEvent( const KeyEvent& event ) bool consumed = false; - if( event.state == KeyEvent::Down ) + if( event.GetState() == KeyEvent::DOWN ) { - if (event.keyCode == Dali::DALI_KEY_ESCAPE || event.keyCode == Dali::DALI_KEY_BACK) + if (event.GetKeyCode() == Dali::DALI_KEY_ESCAPE || event.GetKeyCode() == Dali::DALI_KEY_BACK) { SetDisplayState( Toolkit::Popup::HIDDEN ); consumed = true; @@ -1831,7 +1830,7 @@ void Popup::AddFocusableChildrenRecursive( Actor parent, std::vector< Actor >& f Toolkit::Control control = Toolkit::Control::DownCast( parent ); bool layoutControl = control && GetImplementation( control ).IsKeyboardNavigationSupported(); - if( parent.IsKeyboardFocusable() || layoutControl ) + if( parent.GetProperty< bool >( Actor::Property::KEYBOARD_FOCUSABLE ) || layoutControl ) { focusableActors.push_back( parent ); @@ -1889,12 +1888,12 @@ Actor Popup::GetNextKeyboardFocusableActor( Actor currentFocusedActor, Toolkit:: ( currentFocusedActor && ( ( !mContent || ( currentFocusGroup != mContent ) ) && ( !mFooter || ( currentFocusGroup != mFooter ) ) ) ) ) { // The current focused actor is not within popup. - if( mContent && mContent.IsKeyboardFocusable() ) + if( mContent && mContent.GetProperty< bool >( Actor::Property::KEYBOARD_FOCUSABLE ) ) { // If the content is focusable, move the focus to the content. nextFocusableActor = mContent; } - else if( mFooter && mFooter.IsKeyboardFocusable() ) + else if( mFooter && mFooter.GetProperty< bool >( Actor::Property::KEYBOARD_FOCUSABLE ) ) { // If the footer is focusable, move the focus to the footer. nextFocusableActor = mFooter; @@ -1975,6 +1974,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.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