+ mDisplayState = Toolkit::Popup::HIDING;
+ ClearKeyInputFocus();
+
+ // Restore the keyboard focus when popup is hidden.
+ if( mPreviousFocusedActor && mPreviousFocusedActor.IsKeyboardFocusable() )
+ {
+ Dali::Toolkit::KeyboardFocusManager keyboardFocusManager = Dali::Toolkit::KeyboardFocusManager::Get();
+ if( keyboardFocusManager )
+ {
+ keyboardFocusManager.SetCurrentFocusActor( mPreviousFocusedActor );
+ }
+ }
+ }
+
+ // Perform animation.
+ StartTransitionAnimation( display );
+}
+
+Toolkit::Popup::DisplayState Popup::GetDisplayState() const
+{
+ return mDisplayState;
+}
+
+void Popup::LayoutPopup()
+{
+ mLayoutDirty = false;
+
+ /* When animating in, we want to respect the origin applied to Self().
+ * For example, if zooming, not only will the final result be anchored to the
+ * selected point, but the zoom will originate from this point also.
+ *
+ * EG: ParentOrigin::TOP_LEFT, AnchorPoint::TOP_LEFT :
+ *
+ * -------- --------
+ * |X| |XXX|
+ * |`` Animates |XXX|
+ * | to: |XXX|
+ * | |````
+ * | |
+ */
+ mPopupContainer.SetParentOrigin( Self().GetCurrentParentOrigin() );
+ mPopupContainer.SetAnchorPoint( Self().GetCurrentAnchorPoint() );
+
+ // If there is only a title, use less padding.
+ if( mTitle )
+ {
+ if( !mContent && !mFooter )
+ {
+ mTitle.SetPadding( DEFAULT_TITLE_ONLY_PADDING );
+ }
+ else
+ {
+ mTitle.SetPadding( DEFAULT_TITLE_PADDING );
+ }
+ }
+
+ // Allow derived classes to perform any layout they may need to do.
+ OnLayoutSetup();
+
+ // Update background visibility.
+ mPopupContainer.SetVisible( !( !mFooter && mPopupLayout.GetChildCount() == 0 ) );
+
+ // Create / destroy / position the tail as needed.
+ LayoutTail();
+
+ // Setup any layout and initialisation required for the selected animation.
+ LayoutAnimation();
+
+ RelayoutRequest();
+}
+
+void Popup::LayoutTail()
+{
+ // Removes the tail actor.
+ if( mTailImage && mTailImage.GetParent() )
+ {
+ mTailImage.GetParent().Remove( mTailImage );
+ mTailImage.Reset();
+ }
+
+ if( !mTailVisible )
+ {
+ return;
+ }
+
+ const Vector3& parentOrigin = GetTailPosition();
+ Vector3 position;
+ std::string image;
+ Vector3 anchorPoint;
+
+ // depending on position of tail around ParentOrigin, a different tail image is used...
+ if( parentOrigin.y < Math::MACHINE_EPSILON_1 )
+ {
+ image = mTailUpImage;
+ anchorPoint = AnchorPoint::BOTTOM_CENTER;
+ position.y = mBackgroundBorder.top;
+ }
+ else if( parentOrigin.y > ( 1.0f - Math::MACHINE_EPSILON_1 ) )
+ {
+ image = mTailDownImage;
+ anchorPoint = AnchorPoint::TOP_CENTER;
+ position.y = - mBackgroundBorder.bottom;
+ }
+ else if( parentOrigin.x < Math::MACHINE_EPSILON_1 )
+ {
+ image = mTailLeftImage;
+ anchorPoint = AnchorPoint::CENTER_RIGHT;
+ position.x = mBackgroundBorder.left;
+ }
+ else if( parentOrigin.x > ( 1.0f - Math::MACHINE_EPSILON_1 ) )
+ {
+ image = mTailRightImage;
+ anchorPoint = AnchorPoint::CENTER_LEFT;
+ position.x = - mBackgroundBorder.right;
+ }
+
+ if( !image.empty() )
+ {
+ // Adds the tail actor.
+ mTailImage = Toolkit::ImageView::New( image );
+ mTailImage.SetName( "tailImage" );
+ mTailImage.SetParentOrigin( parentOrigin );
+ mTailImage.SetAnchorPoint( anchorPoint );
+ mTailImage.SetPosition( position );
+
+ if( mPopupBackgroundImage )
+ {
+ mPopupBackgroundImage.Add( mTailImage );
+ }
+ }
+}
+
+void Popup::SetContextualMode( Toolkit::Popup::ContextualMode mode )
+{
+ mContextualMode = mode;
+ mLayoutDirty = true;
+}
+
+Toolkit::Popup::ContextualMode Popup::GetContextualMode() const
+{
+ return mContextualMode;
+}
+
+Toolkit::Control Popup::CreateBacking()
+{
+ Toolkit::Control backing = Control::New();
+ backing.SetProperty( Toolkit::Control::Property::BACKGROUND,
+ Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR )
+ .Add( Toolkit::ColorVisual::Property::MIX_COLOR, Vector4( mBackingColor.r, mBackingColor.g, mBackingColor.b, 1.0f ) ) );
+ backing.SetName( "popupBacking" );
+
+ // Must always be positioned top-left of stage, regardless of parent.
+ backing.SetInheritPosition(false);
+
+ // Always the full size of the stage.
+ backing.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
+ backing.SetSize( Stage::GetCurrent().GetSize() );
+
+ // Catch events.
+ backing.SetSensitive( true );
+
+ // 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;
+}
+
+Toolkit::Popup::TouchedOutsideSignalType& Popup::OutsideTouchedSignal()
+{
+ return mTouchedOutsideSignal;
+}
+
+Toolkit::Popup::DisplayStateChangeSignalType& Popup::ShowingSignal()
+{
+ return mShowingSignal;
+}
+
+Toolkit::Popup::DisplayStateChangeSignalType& Popup::ShownSignal()
+{
+ return mShownSignal;
+}
+
+Toolkit::Popup::DisplayStateChangeSignalType& Popup::HidingSignal()
+{
+ return mHidingSignal;
+}
+
+Toolkit::Popup::DisplayStateChangeSignalType& Popup::HiddenSignal()
+{
+ return mHiddenSignal;
+}
+
+void Popup::SetTailVisibility( bool visible )
+{
+ mTailVisible = visible;
+ mLayoutDirty = true;
+}
+
+const bool Popup::IsTailVisible() const
+{
+ return mTailVisible;
+}
+
+void Popup::SetTailPosition( Vector3 position )
+{
+ mTailPosition = position;
+ mLayoutDirty = true;
+}
+
+const Vector3& Popup::GetTailPosition() const
+{
+ return mTailPosition;
+}
+
+void Popup::SetAnimationDuration( float duration )
+{
+ mAnimationDuration = duration;
+ mLayoutDirty = true;
+}
+
+float Popup::GetAnimationDuration() const
+{
+ return mAnimationDuration;
+}
+
+void Popup::SetAnimationMode( Toolkit::Popup::AnimationMode animationMode )
+{
+ mAnimationMode = animationMode;
+ mLayoutDirty = true;
+}
+
+Toolkit::Popup::AnimationMode Popup::GetAnimationMode() const
+{
+ return mAnimationMode;
+}
+
+void Popup::SetEntryAnimationData( const Property::Map& map )
+{
+ mEntryAnimationData.Clear();
+ Scripting::NewAnimation( map, mEntryAnimationData );
+}
+
+void Popup::SetExitAnimationData( const Property::Map& map )
+{
+ mExitAnimationData.Clear();
+ Scripting::NewAnimation( map, mExitAnimationData );
+}
+
+void Popup::UpdateBackgroundPositionAndSize()
+{
+ if( mPopupBackgroundImage )
+ {
+ mPopupBackgroundImage.SetResizePolicy( ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT, Dimension::ALL_DIMENSIONS );
+ mPopupBackgroundImage.SetSizeModeFactor( Vector3( mBackgroundBorder.left + mBackgroundBorder.right, mBackgroundBorder.top + mBackgroundBorder.bottom, 0.0f ) );
+
+ // Adjust the position of the background so the transparent areas are set appropriately
+ mPopupBackgroundImage.SetPosition( ( mBackgroundBorder.right - mBackgroundBorder.left ) * 0.5f, ( mBackgroundBorder.bottom - mBackgroundBorder.top ) * 0.5f );
+ }
+}
+
+void Popup::SetAutoHideDelay( int delay )
+{
+ mAutoHideDelay = delay;
+}
+
+int Popup::GetAutoHideDelay() const
+{
+ return mAutoHideDelay;
+}
+
+void Popup::SetBackingEnabled( bool enabled )
+{
+ mBackingEnabled = enabled;
+ mLayoutDirty = true;
+}
+
+const bool Popup::IsBackingEnabled() const
+{
+ return mBackingEnabled;
+}
+
+void Popup::SetBackingColor( Vector4 color )
+{
+ mBackingColor = color;
+ mBacking.SetBackgroundColor( Vector4( color.r, color.g, color.b, 1.0f ) );
+ mLayoutDirty = true;
+}
+
+const Vector4& Popup::GetBackingColor() const
+{
+ return mBackingColor;
+}
+
+void Popup::SetTailUpImage( std::string image )
+{
+ mTailUpImage = image;
+ mLayoutDirty = true;
+ LayoutTail();
+}
+
+const std::string& Popup::GetTailUpImage() const
+{
+ return mTailUpImage;
+}
+
+void Popup::SetTailDownImage( std::string image )
+{
+ mTailDownImage = image;
+ mLayoutDirty = true;
+ LayoutTail();
+}
+
+const std::string& Popup::GetTailDownImage() const
+{
+ return mTailDownImage;
+}
+
+void Popup::SetTailLeftImage( std::string image )
+{
+ mTailLeftImage = image;
+ mLayoutDirty = true;
+ LayoutTail();
+}
+
+const std::string& Popup::GetTailLeftImage() const
+{
+ return mTailLeftImage;
+}
+
+void Popup::SetTailRightImage( std::string image )
+{
+ mTailRightImage = image;
+ mLayoutDirty = true;
+ LayoutTail();
+}
+
+const std::string& Popup::GetTailRightImage() const
+{
+ return mTailRightImage;
+}
+
+void Popup::SetTouchTransparent( bool enabled )
+{
+ mTouchTransparent = enabled;
+}
+
+const bool Popup::IsTouchTransparent() const
+{
+ return mTouchTransparent;
+}
+
+void Popup::SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )
+{
+ Toolkit::Popup popup = Toolkit::Popup::DownCast( Dali::BaseHandle( object ) );
+
+ if ( popup )
+ {
+ Popup& popupImpl( GetImpl( popup ) );
+
+ switch ( propertyIndex )