X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=dali-toolkit%2Finternal%2Fcontrols%2Fpopup%2Fpopup-impl.cpp;h=8e18342f9512addb6d0a26a2520418220c29acfa;hb=e4bed7b8660bd201c33c27c4b774c74ec6e031b9;hp=2941c0e2f1cc53f5e1209e63a05ff248e0fbc413;hpb=da6b7205afe6a54fb1caf7a765008948a57f45eb;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/controls/popup/popup-impl.cpp b/dali-toolkit/internal/controls/popup/popup-impl.cpp index 2941c0e..8e18342 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,14 +330,19 @@ 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(new AccessibleImpl(actor, Dali::Accessibility::Role::DIALOG, true)); + }); } Popup::~Popup() @@ -563,8 +568,11 @@ void Popup::DisplayStateChangeComplete() bool Popup::OnAutoHideTimeReached() { - // Display timer has expired, auto hide the popup exactly as if the user had clicked outside. - SetDisplayState( Toolkit::Popup::HIDDEN ); + if (!Dali::Accessibility::IsUp() || true) // TODO: remove 'true' in sync with EFL (UX change) + { + // Display timer has expired, auto hide the popup exactly as if the user had clicked outside. + SetDisplayState( Toolkit::Popup::HIDDEN ); + } if( mAutoHideTimer ) { @@ -593,9 +601,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(); @@ -716,6 +721,18 @@ void Popup::SetDisplayState( Toolkit::Popup::DisplayState displayState ) return; } + auto *accessible = Dali::Accessibility::Accessible::Get(Self()); + if (display) + { + Dali::Accessibility::Bridge::GetCurrentBridge()->AddPopup(accessible); + accessible->EmitStateChanged(Dali::Accessibility::State::SHOWING, 1, 0); + } + else + { + accessible->EmitStateChanged(Dali::Accessibility::State::SHOWING, 0, 0); + Dali::Accessibility::Bridge::GetCurrentBridge()->RemovePopup(accessible); + } + // Convert the bool state to the actual display state to use. mDisplayState = display ? Toolkit::Popup::SHOWING : Toolkit::Popup::HIDING; @@ -938,7 +955,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 +1135,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 +1552,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.SetProperty( Layer::Property::CONSUMES_TOUCH, true ); - return true; + return false; } bool Popup::OnBackingWheelEvent( Actor actor, const WheelEvent& event ) @@ -1564,30 +1576,21 @@ 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 ) +bool Popup::OnDialogTouched( Actor actor, const TouchEvent& 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 ) +void Popup::OnSceneConnection( int depth ) { mLayoutDirty = true; RelayoutRequest(); - Control::OnStageConnection( depth ); + Control::OnSceneConnection( depth ); } void Popup::OnChildAdd( Actor& child ) @@ -1812,9 +1815,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; @@ -1975,6 +1978,36 @@ 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 ); + } +} + +Dali::Accessibility::States Popup::AccessibleImpl::CalculateStates() +{ + auto states = Control::Impl::AccessibleImpl::CalculateStates(); + auto popup = Toolkit::Popup::DownCast(self); + auto displayState = popup.GetProperty(Toolkit::Popup::Property::DISPLAY_STATE); + + states[Dali::Accessibility::State::SHOWING] = (displayState == "SHOWN" || displayState == "SHOWING"); + + return states; +} } // namespace Internal