X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Factors%2Factor-impl.cpp;h=147fcf838483f842393c7a99830c3464f1fda7ee;hb=7925fbd05ab1b79323b00497f62eebe5bbb154ef;hp=eb3ec859b845badc18d89ce07dbf01d620ad8c37;hpb=81bb4cb83cede27341dc55ffdd85ee6ce50b5340;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/actors/actor-impl.cpp b/dali/internal/event/actors/actor-impl.cpp index eb3ec85..147fcf8 100644 --- a/dali/internal/event/actors/actor-impl.cpp +++ b/dali/internal/event/actors/actor-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 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. @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -208,12 +207,12 @@ DALI_PROPERTY( "minimumSize", VECTOR2, true, false, false, Dali: DALI_PROPERTY( "maximumSize", VECTOR2, true, false, false, Dali::Actor::Property::MAXIMUM_SIZE ) DALI_PROPERTY( "inheritPosition", BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_POSITION ) DALI_PROPERTY( "clippingMode", STRING, true, false, false, Dali::Actor::Property::CLIPPING_MODE ) +DALI_PROPERTY( "layoutDirection", STRING, true, false, false, Dali::Actor::Property::LAYOUT_DIRECTION ) +DALI_PROPERTY( "inheritLayoutDirection", BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_LAYOUT_DIRECTION ) DALI_PROPERTY( "siblingOrder", INTEGER, true, false, false, Dali::DevelActor::Property::SIBLING_ORDER ) DALI_PROPERTY( "opacity", FLOAT, true, true, true, Dali::DevelActor::Property::OPACITY ) DALI_PROPERTY( "screenPosition", VECTOR2, false, false, false, Dali::DevelActor::Property::SCREEN_POSITION ) DALI_PROPERTY( "positionUsesAnchorPoint", BOOLEAN, true, false, false, Dali::DevelActor::Property::POSITION_USES_ANCHOR_POINT ) -DALI_PROPERTY( "layoutDirection", STRING, true, false, false, Dali::DevelActor::Property::LAYOUT_DIRECTION ) -DALI_PROPERTY( "inheritLayoutDirection", BOOLEAN, true, false, false, Dali::DevelActor::Property::INHERIT_LAYOUT_DIRECTION ) DALI_PROPERTY_TABLE_END( DEFAULT_ACTOR_PROPERTY_START_INDEX ) // Signals @@ -225,6 +224,10 @@ const char* const SIGNAL_ON_STAGE = "onStage"; const char* const SIGNAL_OFF_STAGE = "offStage"; const char* const SIGNAL_ON_RELAYOUT = "onRelayout"; const char* const SIGNAL_TOUCH = "touch"; +const char* const SIGNAL_VISIBILITY_CHANGED = "visibilityChanged"; +const char* const SIGNAL_LAYOUT_DIRECTION_CHANGED = "layoutDirectionChanged"; +const char* const SIGNAL_CHILD_ADDED = "childAdded"; +const char* const SIGNAL_CHILD_REMOVED = "childRemoved"; // Actions @@ -245,6 +248,10 @@ SignalConnectorType signalConnector4( mType, SIGNAL_ON_STAGE, &Actor::DoConnectS SignalConnectorType signalConnector5( mType, SIGNAL_OFF_STAGE, &Actor::DoConnectSignal ); SignalConnectorType signalConnector6( mType, SIGNAL_ON_RELAYOUT, &Actor::DoConnectSignal ); SignalConnectorType signalConnector7( mType, SIGNAL_TOUCH, &Actor::DoConnectSignal ); +SignalConnectorType signalConnector8( mType, SIGNAL_VISIBILITY_CHANGED, &Actor::DoConnectSignal ); +SignalConnectorType signalConnector9( mType, SIGNAL_LAYOUT_DIRECTION_CHANGED, &Actor::DoConnectSignal ); +SignalConnectorType signalConnector10( mType, SIGNAL_CHILD_ADDED, &Actor::DoConnectSignal ); +SignalConnectorType signalConnector11( mType, SIGNAL_CHILD_REMOVED, &Actor::DoConnectSignal ); TypeAction a1( mType, ACTION_SHOW, &Actor::DoAction ); TypeAction a2( mType, ACTION_HIDE, &Actor::DoAction ); @@ -310,8 +317,8 @@ DALI_ENUM_TO_STRING_WITH_SCOPE( ClippingMode, CLIP_CHILDREN ) DALI_ENUM_TO_STRING_TABLE_END( CLIPPING_MODE ) DALI_ENUM_TO_STRING_TABLE_BEGIN( LAYOUT_DIRECTION ) -DALI_ENUM_TO_STRING_WITH_SCOPE( DevelActor::LayoutDirection, LTR ) -DALI_ENUM_TO_STRING_WITH_SCOPE( DevelActor::LayoutDirection, RTL ) +DALI_ENUM_TO_STRING_WITH_SCOPE( LayoutDirection, LEFT_TO_RIGHT ) +DALI_ENUM_TO_STRING_WITH_SCOPE( LayoutDirection, RIGHT_TO_LEFT ) DALI_ENUM_TO_STRING_TABLE_END( LAYOUT_DIRECTION ) bool GetAnchorPointConstant( const std::string& value, Vector3& anchor ) @@ -474,7 +481,7 @@ void Actor::Add( Actor& child ) // if we already have parent, unparent us first if( oldParent ) { - oldParent->Remove( child ); // This causes OnChildRemove callback + oldParent->Remove( child ); // This causes OnChildRemove callback & ChildRemoved signal // Old parent may need to readjust to missing child if( oldParent->RelayoutDependentOnChildren() ) @@ -494,6 +501,7 @@ void Actor::Add( Actor& child ) // Notification for derived classes OnChildAdd( child ); + EmitChildAddedSignal( child ); InheritLayoutDirectionRecursively( ActorPtr( &child ), mLayoutDirection ); @@ -548,6 +556,7 @@ void Actor::Remove( Actor& child ) // Notification for derived classes OnChildRemove( child ); + EmitChildRemovedSignal( child ); } void Actor::Unparent() @@ -815,11 +824,14 @@ const Vector3& Actor::GetCurrentWorldPosition() const const Vector2 Actor::GetCurrentScreenPosition() const { - if( OnStage() && NULL != mNode ) + StagePtr stage = Stage::GetCurrent(); + if( stage && OnStage() && NULL != mNode ) { - StagePtr stage = Stage::GetCurrent(); Vector3 worldPosition = mNode->GetWorldPosition( GetEventThreadServices().GetEventBufferIndex() ); - Vector3 actorSize = GetCurrentSize() * GetCurrentScale(); + Vector3 cameraPosition = stage->GetDefaultCameraActor().mNode->GetWorldPosition( GetEventThreadServices().GetEventBufferIndex() ); + worldPosition -= cameraPosition; + + Vector3 actorSize = GetCurrentSize() * GetCurrentWorldScale(); Vector2 halfStageSize( stage->GetSize() * 0.5f ); // World position origin is center of stage Vector3 halfActorSize( actorSize * 0.5f ); Vector3 anchorPointOffSet = halfActorSize - actorSize * ( mPositionUsesAnchorPoint ? GetCurrentAnchorPoint() : AnchorPoint::TOP_LEFT ); @@ -1994,7 +2006,7 @@ void Actor::EmitVisibilityChangedSignal( bool visible, DevelActor::VisibilityCha } } -void Actor::EmitLayoutDirectionChangedSignal( DevelActor::LayoutDirection::Type type ) +void Actor::EmitLayoutDirectionChangedSignal( LayoutDirection::Type type ) { if( ! mLayoutDirectionChangedSignal.Empty() ) { @@ -2003,6 +2015,24 @@ void Actor::EmitLayoutDirectionChangedSignal( DevelActor::LayoutDirection::Type } } +void Actor::EmitChildAddedSignal( Actor& child ) +{ + if( ! mChildAddedSignal.Empty() ) + { + Dali::Actor handle( &child ); + mChildAddedSignal.Emit( handle ); + } +} + +void Actor::EmitChildRemovedSignal( Actor& child ) +{ + if( ! mChildRemovedSignal.Empty() ) + { + Dali::Actor handle( &child ); + mChildRemovedSignal.Emit( handle ); + } +} + Dali::Actor::TouchSignalType& Actor::TouchedSignal() { return mTouchedSignal; @@ -2043,11 +2073,26 @@ DevelActor::VisibilityChangedSignalType& Actor::VisibilityChangedSignal() return mVisibilityChangedSignal; } -DevelActor::LayoutDirectionChangedSignalType& Actor::LayoutDirectionChangedSignal() +Dali::Actor::LayoutDirectionChangedSignalType& Actor::LayoutDirectionChangedSignal() { return mLayoutDirectionChangedSignal; } +DevelActor::ChildChangedSignalType& Actor::ChildAddedSignal() +{ + return mChildAddedSignal; +} + +DevelActor::ChildChangedSignalType& Actor::ChildRemovedSignal() +{ + return mChildRemovedSignal; +} + +DevelActor::ChildOrderChangedSignalType& Actor::ChildOrderChangedSignal() +{ + return mChildOrderChangedSignal; +} + bool Actor::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ) { bool connected( true ); @@ -2081,6 +2126,22 @@ bool Actor::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tra { actor->TouchSignal().Connect( tracker, functor ); } + else if( 0 == signalName.compare( SIGNAL_VISIBILITY_CHANGED ) ) + { + actor->VisibilityChangedSignal().Connect( tracker, functor ); + } + else if( 0 == signalName.compare( SIGNAL_LAYOUT_DIRECTION_CHANGED ) ) + { + actor->LayoutDirectionChangedSignal().Connect( tracker, functor ); + } + else if( 0 == signalName.compare( SIGNAL_CHILD_ADDED ) ) + { + actor->ChildAddedSignal().Connect( tracker, functor ); + } + else if( 0 == signalName.compare( SIGNAL_CHILD_REMOVED ) ) + { + actor->ChildRemovedSignal().Connect( tracker, functor ); + } else { // signalName does not match any signal @@ -2099,6 +2160,18 @@ Actor::Actor( DerivedType derivedType ) mAnchorPoint( NULL ), mRelayoutData( NULL ), mGestureData( NULL ), + mTouchedSignal(), + mTouchSignal(), + mHoveredSignal(), + mWheelEventSignal(), + mOnStageSignal(), + mOffStageSignal(), + mOnRelayoutSignal(), + mVisibilityChangedSignal(), + mLayoutDirectionChangedSignal(), + mChildAddedSignal(), + mChildRemovedSignal(), + mChildOrderChangedSignal(), mTargetOrientation( Quaternion::IDENTITY ), mTargetColor( Color::WHITE ), mTargetSize( Vector3::ZERO ), @@ -2125,7 +2198,7 @@ Actor::Actor( DerivedType derivedType ) mPositionUsesAnchorPoint( true ), mVisible( true ), mInheritLayoutDirection( true ), - mLayoutDirection( DevelActor::LayoutDirection::LTR ), + mLayoutDirection( LayoutDirection::LEFT_TO_RIGHT ), mDrawMode( DrawMode::NORMAL ), mPositionInheritanceMode( Node::DEFAULT_POSITION_INHERITANCE_MODE ), mColorMode( Node::DEFAULT_COLOR_MODE ), @@ -2884,19 +2957,19 @@ void Actor::SetDefaultProperty( Property::Index index, const Property::Value& pr break; } - case Dali::DevelActor::Property::LAYOUT_DIRECTION: + case Dali::Actor::Property::LAYOUT_DIRECTION: { - Dali::DevelActor::LayoutDirection::Type direction = mLayoutDirection; + Dali::LayoutDirection::Type direction = mLayoutDirection; mInheritLayoutDirection = false; - if( Scripting::GetEnumerationProperty< DevelActor::LayoutDirection::Type >( property, LAYOUT_DIRECTION_TABLE, LAYOUT_DIRECTION_TABLE_COUNT, direction ) ) + if( Scripting::GetEnumerationProperty< LayoutDirection::Type >( property, LAYOUT_DIRECTION_TABLE, LAYOUT_DIRECTION_TABLE_COUNT, direction ) ) { InheritLayoutDirectionRecursively( this, direction, true ); } break; } - case Dali::DevelActor::Property::INHERIT_LAYOUT_DIRECTION: + case Dali::Actor::Property::INHERIT_LAYOUT_DIRECTION: { bool value = false; if( property.Get( value ) ) @@ -4148,13 +4221,13 @@ bool Actor::GetCachedPropertyValue( Property::Index index, Property::Value& valu break; } - case Dali::DevelActor::Property::LAYOUT_DIRECTION: + case Dali::Actor::Property::LAYOUT_DIRECTION: { value = mLayoutDirection; break; } - case Dali::DevelActor::Property::INHERIT_LAYOUT_DIRECTION: + case Dali::Actor::Property::INHERIT_LAYOUT_DIRECTION: { value = IsLayoutDirectionInherited(); break; @@ -5194,6 +5267,10 @@ void Actor::Raise() } } } + + Dali::Actor handle( this ); + mParent->mChildOrderChangedSignal.Emit( handle ); + RequestRebuildDepthTree(); } else @@ -5221,6 +5298,10 @@ void Actor::Lower() } } } + + Dali::Actor handle( this ); + mParent->mChildOrderChangedSignal.Emit( handle ); + RequestRebuildDepthTree(); } else @@ -5243,6 +5324,10 @@ void Actor::RaiseToTop() siblings.push_back(ActorPtr(this)); } } + + Dali::Actor handle( this ); + mParent->mChildOrderChangedSignal.Emit( handle ); + RequestRebuildDepthTree(); } else @@ -5267,6 +5352,10 @@ void Actor::LowerToBottom() siblings.insert(siblings.begin(), thisPtr); } } + + Dali::Actor handle( this ); + mParent->mChildOrderChangedSignal.Emit( handle ); + RequestRebuildDepthTree(); } else @@ -5295,6 +5384,10 @@ void Actor::RaiseAbove( Internal::Actor& target ) ++targetIter; siblings.insert(targetIter, thisPtr); } + + Dali::Actor handle( this ); + mParent->mChildOrderChangedSignal.Emit( handle ); + RequestRebuildDepthTree(); } } @@ -5321,6 +5414,10 @@ void Actor::LowerBelow( Internal::Actor& target ) siblings.erase(thisIter); // this only invalidates iterators at or after this point. siblings.insert(targetIter, thisPtr); } + + Dali::Actor handle( this ); + mParent->mChildOrderChangedSignal.Emit( handle ); + RequestRebuildDepthTree(); } } @@ -5348,7 +5445,7 @@ bool Actor::IsLayoutDirectionInherited() const return mInheritLayoutDirection; } -void Actor::InheritLayoutDirectionRecursively( ActorPtr actor, Dali::DevelActor::LayoutDirection::Type direction, bool set ) +void Actor::InheritLayoutDirectionRecursively( ActorPtr actor, Dali::LayoutDirection::Type direction, bool set ) { if( actor && ( actor->mInheritLayoutDirection || set ) ) {