X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Factors%2Factor-impl.cpp;h=ba7e1cb3a503a936f9cdda42e0127aff16126d91;hb=43688ad2b758a275556de107f45337bc8a651c62;hp=f4590fc6a45d1a784f05a6d8b0d1496ebf62452a;hpb=9aa1524146da93e1696e96bfc7f3792bd2748a39;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 f4590fc..ba7e1cb 100644 --- a/dali/internal/event/actors/actor-impl.cpp +++ b/dali/internal/event/actors/actor-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 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. @@ -193,13 +193,13 @@ DALI_PROPERTY( "sensitive", BOOLEAN, true, false, false, Dali: DALI_PROPERTY( "leaveRequired", BOOLEAN, true, false, false, Dali::Actor::Property::LEAVE_REQUIRED ) DALI_PROPERTY( "inheritOrientation", BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_ORIENTATION ) DALI_PROPERTY( "inheritScale", BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_SCALE ) -DALI_PROPERTY( "colorMode", STRING, true, false, false, Dali::Actor::Property::COLOR_MODE ) +DALI_PROPERTY( "colorMode", INTEGER, true, false, false, Dali::Actor::Property::COLOR_MODE ) DALI_PROPERTY( "reservedProperty01", STRING, true, false, false, Dali::Actor::Property::RESERVED_PROPERTY_01 ) // This property was removed, but to keep binary compatibility and TypeRegister test app, remain it here. -DALI_PROPERTY( "drawMode", STRING, true, false, false, Dali::Actor::Property::DRAW_MODE ) +DALI_PROPERTY( "drawMode", INTEGER, true, false, false, Dali::Actor::Property::DRAW_MODE ) DALI_PROPERTY( "sizeModeFactor", VECTOR3, true, false, false, Dali::Actor::Property::SIZE_MODE_FACTOR ) DALI_PROPERTY( "widthResizePolicy", STRING, true, false, false, Dali::Actor::Property::WIDTH_RESIZE_POLICY ) DALI_PROPERTY( "heightResizePolicy", STRING, true, false, false, Dali::Actor::Property::HEIGHT_RESIZE_POLICY ) -DALI_PROPERTY( "sizeScalePolicy", STRING, true, false, false, Dali::Actor::Property::SIZE_SCALE_POLICY ) +DALI_PROPERTY( "sizeScalePolicy", INTEGER, true, false, false, Dali::Actor::Property::SIZE_SCALE_POLICY ) DALI_PROPERTY( "widthForHeight", BOOLEAN, true, false, false, Dali::Actor::Property::WIDTH_FOR_HEIGHT ) DALI_PROPERTY( "heightForWidth", BOOLEAN, true, false, false, Dali::Actor::Property::HEIGHT_FOR_WIDTH ) DALI_PROPERTY( "padding", VECTOR4, true, false, false, Dali::Actor::Property::PADDING ) @@ -1154,6 +1154,8 @@ void Actor::SetWidth( float width ) SceneGraph::NodeTransformComponentMessage::Send( GetEventThreadServices(), &GetNode(), &GetNode().mSize, &SceneGraph::TransformManagerPropertyHandler::BakeX, width ); } + mUseAnimatedSize &= ~AnimatedSizeFlag::WIDTH; + RelayoutRequest(); } @@ -1172,6 +1174,8 @@ void Actor::SetHeight( float height ) SceneGraph::NodeTransformComponentMessage::Send( GetEventThreadServices(), &GetNode(), &GetNode().mSize, &SceneGraph::TransformManagerPropertyHandler::BakeY, height ); } + mUseAnimatedSize &= ~AnimatedSizeFlag::HEIGHT; + RelayoutRequest(); } @@ -1179,6 +1183,8 @@ void Actor::SetDepth( float depth ) { mTargetSize.depth = depth; + mUseAnimatedSize &= ~AnimatedSizeFlag::DEPTH; + // node is being used in a separate thread; queue a message to set the value & base value SceneGraph::NodeTransformComponentMessage::Send( GetEventThreadServices(), &GetNode(), &GetNode().mSize, &SceneGraph::TransformManagerPropertyHandler::BakeZ, depth ); } @@ -1187,14 +1193,35 @@ Vector3 Actor::GetTargetSize() const { Vector3 size = mTargetSize; - // Should return preferred size if size is fixed as set by SetSize - if( GetResizePolicy( Dimension::WIDTH ) == ResizePolicy::FIXED ) + if( mUseAnimatedSize & AnimatedSizeFlag::WIDTH ) + { + // Should return animated size if size is animated + size.width = mAnimatedSize.width; + } + else + { + // Should return preferred size if size is fixed as set by SetSize + if( GetResizePolicy( Dimension::WIDTH ) == ResizePolicy::FIXED ) + { + size.width = GetPreferredSize().width; + } + } + + if( mUseAnimatedSize & AnimatedSizeFlag::HEIGHT ) { - size.width = GetPreferredSize().width; + size.height = mAnimatedSize.height; + } + else + { + if( GetResizePolicy( Dimension::HEIGHT ) == ResizePolicy::FIXED ) + { + size.height = GetPreferredSize().height; + } } - if( GetResizePolicy( Dimension::HEIGHT ) == ResizePolicy::FIXED ) + + if( mUseAnimatedSize & AnimatedSizeFlag::DEPTH ) { - size.height = GetPreferredSize().height; + size.depth = mAnimatedSize.depth; } return size; @@ -1314,6 +1341,9 @@ void Actor::SetSizeScalePolicy( SizeScalePolicy::Type policy ) EnsureRelayoutData(); mRelayoutData->sizeSetPolicy = policy; + + // Trigger relayout on this control + RelayoutRequest(); } SizeScalePolicy::Type Actor::GetSizeScalePolicy() const @@ -1779,7 +1809,7 @@ ActorGestureData& Actor::GetGestureData() return *mGestureData; } -bool Actor::IsGestureRequred( Gesture::Type type ) const +bool Actor::IsGestureRequred( DevelGesture::Type type ) const { return mGestureData && mGestureData->IsGestureRequred( type ); } @@ -2028,9 +2058,11 @@ Actor::Actor( DerivedType derivedType, const SceneGraph::Node& node ) mTargetSize( Vector3::ZERO ), mTargetPosition( Vector3::ZERO ), mTargetScale( Vector3::ONE ), + mAnimatedSize( Vector3::ZERO ), mName(), mSortedDepth( 0u ), mDepth( 0u ), + mUseAnimatedSize( AnimatedSizeFlag::CLEAR ), mIsRoot( ROOT_LAYER == derivedType ), mIsLayer( LAYER == derivedType || ROOT_LAYER == derivedType ), mIsOnStage( false ), @@ -2493,7 +2525,16 @@ void Actor::SetDefaultProperty( Property::Index index, const Property::Value& pr case Dali::Actor::Property::COLOR: { - SetColor( property.Get< Vector4 >() ); + Property::Type type = property.GetType(); + if( type == Property::VECTOR3 ) + { + Vector3 color = property.Get< Vector3 >(); + SetColor( Vector4( color.r, color.g, color.b, 1.0f ) ); + } + else if( type == Property::VECTOR4 ) + { + SetColor( property.Get< Vector4 >() ); + } break; } @@ -2611,7 +2652,7 @@ void Actor::SetDefaultProperty( Property::Index index, const Property::Value& pr case Dali::Actor::Property::SIZE_SCALE_POLICY: { SizeScalePolicy::Type type = GetSizeScalePolicy(); - if( Scripting::GetEnumeration< SizeScalePolicy::Type >( property.Get< std::string >().c_str(), SIZE_SCALE_POLICY_TABLE, SIZE_SCALE_POLICY_TABLE_COUNT, type ) ) + if( Scripting::GetEnumerationProperty< SizeScalePolicy::Type >( property, SIZE_SCALE_POLICY_TABLE, SIZE_SCALE_POLICY_TABLE_COUNT, type ) ) { SetSizeScalePolicy( type ); } @@ -2918,6 +2959,9 @@ void Actor::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::In { if( value.Get( mTargetSize ) ) { + mAnimatedSize = mTargetSize; + mUseAnimatedSize = AnimatedSizeFlag::WIDTH | AnimatedSizeFlag::HEIGHT | AnimatedSizeFlag::DEPTH; + // Notify deriving classes OnSizeAnimation( animation, mTargetSize ); } @@ -2928,6 +2972,9 @@ void Actor::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::In { if( value.Get( mTargetSize.width ) ) { + mAnimatedSize.width = mTargetSize.width; + mUseAnimatedSize |= AnimatedSizeFlag::WIDTH; + // Notify deriving classes OnSizeAnimation( animation, mTargetSize ); } @@ -2938,6 +2985,9 @@ void Actor::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::In { if( value.Get( mTargetSize.height ) ) { + mAnimatedSize.height = mTargetSize.height; + mUseAnimatedSize |= AnimatedSizeFlag::HEIGHT; + // Notify deriving classes OnSizeAnimation( animation, mTargetSize ); } @@ -2948,6 +2998,9 @@ void Actor::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::In { if( value.Get( mTargetSize.depth ) ) { + mAnimatedSize.depth = mTargetSize.depth; + mUseAnimatedSize |= AnimatedSizeFlag::DEPTH; + // Notify deriving classes OnSizeAnimation( animation, mTargetSize ); } @@ -3062,6 +3115,9 @@ void Actor::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::In { if( AdjustValue< Vector3 >( mTargetSize, value ) ) { + mAnimatedSize = mTargetSize; + mUseAnimatedSize = AnimatedSizeFlag::WIDTH | AnimatedSizeFlag::HEIGHT | AnimatedSizeFlag::DEPTH; + // Notify deriving classes OnSizeAnimation( animation, mTargetSize ); } @@ -3072,6 +3128,9 @@ void Actor::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::In { if( AdjustValue< float >( mTargetSize.width, value ) ) { + mAnimatedSize.width = mTargetSize.width; + mUseAnimatedSize |= AnimatedSizeFlag::WIDTH; + // Notify deriving classes OnSizeAnimation( animation, mTargetSize ); } @@ -3082,6 +3141,9 @@ void Actor::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::In { if( AdjustValue< float >( mTargetSize.height, value ) ) { + mAnimatedSize.height = mTargetSize.height; + mUseAnimatedSize |= AnimatedSizeFlag::HEIGHT; + // Notify deriving classes OnSizeAnimation( animation, mTargetSize ); } @@ -3092,6 +3154,9 @@ void Actor::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::In { if( AdjustValue< float >( mTargetSize.depth, value ) ) { + mAnimatedSize.depth = mTargetSize.depth; + mUseAnimatedSize |= AnimatedSizeFlag::DEPTH; + // Notify deriving classes OnSizeAnimation( animation, mTargetSize ); } @@ -3469,6 +3534,15 @@ bool Actor::DoAction( BaseObject* object, const std::string& actionName, const P return done; } +Rect<> Actor::CalculateScreenExtents( ) const +{ + auto screenPosition = GetCurrentScreenPosition(); + Vector3 size = GetCurrentSize() * GetCurrentWorldScale(); + Vector3 anchorPointOffSet = size * ( mPositionUsesAnchorPoint ? GetCurrentAnchorPoint() : AnchorPoint::TOP_LEFT ); + Vector2 position = Vector2( screenPosition.x - anchorPointOffSet.x, screenPosition.y - anchorPointOffSet.y ); + return { position.x, position.y, size.x, size.y }; +} + bool Actor::GetCachedPropertyValue( Property::Index index, Property::Value& value ) const { bool valueSet = true; @@ -3676,13 +3750,13 @@ bool Actor::GetCachedPropertyValue( Property::Index index, Property::Value& valu case Dali::Actor::Property::COLOR_MODE: { - value = Scripting::GetLinearEnumerationName< ColorMode >( GetColorMode(), COLOR_MODE_TABLE, COLOR_MODE_TABLE_COUNT ); + value = GetColorMode(); break; } case Dali::Actor::Property::DRAW_MODE: { - value = Scripting::GetEnumerationName< DrawMode::Type >( GetDrawMode(), DRAW_MODE_TABLE, DRAW_MODE_TABLE_COUNT ); + value = GetDrawMode(); break; } @@ -3706,7 +3780,7 @@ bool Actor::GetCachedPropertyValue( Property::Index index, Property::Value& valu case Dali::Actor::Property::SIZE_SCALE_POLICY: { - value = Scripting::GetLinearEnumerationName< SizeScalePolicy::Type >( GetSizeScalePolicy(), SIZE_SCALE_POLICY_TABLE, SIZE_SCALE_POLICY_TABLE_COUNT ); + value = GetSizeScalePolicy(); break; } @@ -4178,12 +4252,12 @@ float Actor::CalculateChildSizeBase( const Dali::Actor& child, Dimension::Type d case ResizePolicy::SIZE_RELATIVE_TO_PARENT: { - return GetLatestSize( dimension ) * GetDimensionValue( child.GetSizeModeFactor(), dimension ); + return GetLatestSize( dimension ) * GetDimensionValue( child.GetProperty< Vector3 >( Dali::Actor::Property::SIZE_MODE_FACTOR ), dimension ); } case ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT: { - return GetLatestSize( dimension ) + GetDimensionValue( child.GetSizeModeFactor(), dimension ); + return GetLatestSize( dimension ) + GetDimensionValue( child.GetProperty< Vector3 >( Dali::Actor::Property::SIZE_MODE_FACTOR ), dimension ); } default: @@ -4626,6 +4700,10 @@ void Actor::SetPreferredSize( const Vector2& size ) { EnsureRelayoutData(); + // If valid width or height, then set the resize policy to FIXED + // A 0 width or height may also be required so if the resize policy has not been changed, i.e. is still set to DEFAULT, + // then change to FIXED as well + if( size.width > 0.0f ) { SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH ); @@ -4638,6 +4716,8 @@ void Actor::SetPreferredSize( const Vector2& size ) mRelayoutData->preferredSize = size; + mUseAnimatedSize = AnimatedSizeFlag::CLEAR; + RelayoutRequest(); }