X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fcommon%2Fproperty-notification-impl.cpp;h=2d8778762eecce8c278382a565549c3d2d0008b5;hb=4c773b86f987f400fe0a630aacb933d301bd93f0;hp=14536a14f01fa8650fb7fd424d061d67b75d17fe;hpb=9ff918e3bbc5b9d668dd428a43ce223a65360b92;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/common/property-notification-impl.cpp b/dali/internal/event/common/property-notification-impl.cpp index 14536a1..2d87787 100644 --- a/dali/internal/event/common/property-notification-impl.cpp +++ b/dali/internal/event/common/property-notification-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -19,81 +19,73 @@ #include // INTERNAL INCLUDES -#include -#include -#include #include -#include #include +#include #include -#include -#include #include +#include +#include +#include +#include +#include +#include using Dali::Internal::SceneGraph::UpdateManager; namespace Dali { - namespace Internal { - -PropertyNotificationPtr PropertyNotification::New(Property& target, - int componentIndex, +PropertyNotificationPtr PropertyNotification::New(Property& target, + int componentIndex, const Dali::PropertyCondition& condition) { ThreadLocalStorage& tls = ThreadLocalStorage::Get(); UpdateManager& updateManager = tls.GetUpdateManager(); - StagePtr stage = Stage::GetCurrent(); - if( stage ) - { - PropertyNotificationManager& propertyNotificationManager = stage->GetPropertyNotificationManager(); - PropertyNotificationPtr propertyNotification = new PropertyNotification(updateManager, - propertyNotificationManager, - target, - componentIndex, - condition); - return propertyNotification; - } - else - { - return NULL; - } -} - -PropertyNotification::PropertyNotification( UpdateManager& updateManager, - PropertyNotificationManager& propertyNotificationManager, - Property& target, - int componentIndex, - const Dali::PropertyCondition& condition ) -: mUpdateManager( updateManager ), - mPropertyNotification( NULL ), - mPropertyNotificationManager( propertyNotificationManager ), - mObjectPropertyIndex( target.propertyIndex ), - mPropertyType( Property::NONE ), - mComponentIndex( componentIndex ), - mCondition( condition ), - mNotifyMode( Dali::PropertyNotification::NotifyOnTrue ), - mNotifyResult( false ) -{ - const Internal::PropertyCondition& conditionImpl = GetImplementation( condition ); + PropertyNotificationManager& propertyNotificationManager = tls.GetPropertyNotificationManager(); + PropertyNotificationPtr propertyNotification = new PropertyNotification(updateManager, + propertyNotificationManager, + target, + componentIndex, + condition); + return propertyNotification; +} + +PropertyNotification::PropertyNotification(UpdateManager& updateManager, + PropertyNotificationManager& propertyNotificationManager, + Property& target, + int componentIndex, + const Dali::PropertyCondition& condition) +: mUpdateManager(updateManager), + mPropertyNotification(nullptr), + mPropertyNotificationManager(propertyNotificationManager), + mObjectPropertyIndex(target.propertyIndex), + mPropertyType(Property::NONE), + mComponentIndex(componentIndex), + mCondition(condition), + mNotifyMode(Dali::PropertyNotification::NOTIFY_ON_TRUE), + mNotifyResult(false), + mCompare(false) +{ + const Internal::PropertyCondition& conditionImpl = GetImplementation(condition); Dali::Vector::SizeType count = conditionImpl.arguments.Count(); - for( Dali::Vector::SizeType index = 0; index < count; ++index ) + for(Dali::Vector::SizeType index = 0; index < count; ++index) { - mRawConditionArgs.PushBack( conditionImpl.arguments[ index ] ); + mRawConditionArgs.PushBack(conditionImpl.arguments[index]); } // Observe target object and create/destroy notification scene object accordingly. - mObject = dynamic_cast( &GetImplementation(target.object) ); - if ( mObject ) + mObject = dynamic_cast(&GetImplementation(target.object)); + if(mObject) { mPropertyType = mObject->GetPropertyType(mObjectPropertyIndex); int internalComponentIndex = mObject->GetPropertyComponentIndex(mObjectPropertyIndex); - if( internalComponentIndex != Property::INVALID_COMPONENT_INDEX ) + if(internalComponentIndex != Property::INVALID_COMPONENT_INDEX) { // override the one passed in mComponentIndex = internalComponentIndex; @@ -101,25 +93,28 @@ PropertyNotification::PropertyNotification( UpdateManager& updateManager, if(mComponentIndex != Property::INVALID_COMPONENT_INDEX) { Property::Type type = mObject->GetPropertyType(mObjectPropertyIndex); - if( type == Property::VECTOR2 - || type == Property::VECTOR3 - || type == Property::VECTOR4 ) + if(type == Property::VECTOR2 || type == Property::VECTOR3 || type == Property::VECTOR4) { mPropertyType = Property::FLOAT; } } - // Check if target scene-object already present, and if so create our notification - // scene-object - const SceneGraph::PropertyOwner* object = mObject->GetSceneObject(); - if (object) + // To cover swapping components, previous and current components should be compared. + if(mObject->GetPropertyType(mObjectPropertyIndex) == Property::VECTOR3) { - CreateSceneObject(); + mCompare = true; + for(int i = 0; i < 3; ++i) + { + mRawConditionArgs.PushBack(0.0f); + } } + + // all objects always have scene object + CreateSceneObject(); } // Connect to the property notification manager - mPropertyNotificationManager.PropertyNotificationCreated( *this ); + mPropertyNotificationManager.PropertyNotificationCreated(*this); } PropertyNotification::~PropertyNotification() @@ -127,10 +122,10 @@ PropertyNotification::~PropertyNotification() Disable(); // Guard to disallow use of PropertyNotificationManager after Core has been destroyed - if ( Stage::IsInstalled() ) + if(Stage::IsInstalled()) { // Disconnect from the property notification manager - mPropertyNotificationManager.PropertyNotificationDestroyed( *this ); + mPropertyNotificationManager.PropertyNotificationDestroyed(*this); } } @@ -143,7 +138,7 @@ void PropertyNotification::EmitSignalNotify() { Dali::PropertyNotification source(this); - mNotifySignal.Emit( source ); + mNotifySignal.Emit(source); } void PropertyNotification::Enable() @@ -154,14 +149,14 @@ void PropertyNotification::Enable() void PropertyNotification::Disable() { // Guard to allow handle destruction after Core has been destroyed - if ( Stage::IsInstalled() ) + if(Stage::IsInstalled()) { // Stop scene-graph from monitoring the target's properties. DestroySceneObject(); } } -void PropertyNotification::SetNotifyResult( bool result ) +void PropertyNotification::SetNotifyResult(bool result) { mNotifyResult = result; } @@ -183,12 +178,12 @@ Property::Index PropertyNotification::GetTargetProperty() const return mObjectPropertyIndex; } -void PropertyNotification::SetNotifyMode( NotifyMode mode ) +void PropertyNotification::SetNotifyMode(NotifyMode mode) { mNotifyMode = mode; - if( mPropertyNotification ) + if(mPropertyNotification) { - PropertyNotificationSetNotifyModeMessage( mUpdateManager, mPropertyNotification, mode ); + PropertyNotificationSetNotifyModeMessage(mUpdateManager, mPropertyNotification, mode); } } @@ -202,7 +197,7 @@ bool PropertyNotification::GetNotifyResult() const return mNotifyResult; } -bool PropertyNotification::CompareSceneObject( const SceneGraph::PropertyNotification* sceneObject ) +bool PropertyNotification::CompareSceneObject(const SceneGraph::PropertyNotification* sceneObject) { return sceneObject && sceneObject == mPropertyNotification; } @@ -210,31 +205,31 @@ bool PropertyNotification::CompareSceneObject( const SceneGraph::PropertyNotific void PropertyNotification::CreateSceneObject() { // this method can be called from constructor and on stage connection - if( !mPropertyNotification ) + if(!mPropertyNotification) { - // Create a new PropertyNotification, temporarily owned - SceneGraph::PropertyNotification* propertyNotification = SceneGraph::PropertyNotification::New( *mObject, - mObjectPropertyIndex, - mPropertyType, - mComponentIndex, - GetImplementation(mCondition).type, - mRawConditionArgs, - mNotifyMode ); - // Keep a const pointer to the PropertyNotification. - mPropertyNotification = propertyNotification; - - // Transfer scene object ownership to the update manager through a message - AddPropertyNotificationMessage( mUpdateManager, propertyNotification ); + const PropertyInputImpl* property = mObject->GetSceneObjectInputProperty(mObjectPropertyIndex); + + // Create a new PropertyNotification, keep a const pointer to it + mPropertyNotification = SceneGraph::PropertyNotification::New(property, + mObjectPropertyIndex, + mPropertyType, + mComponentIndex, + GetImplementation(mCondition).type, + mRawConditionArgs, + mNotifyMode, + mCompare); + OwnerPointer transferOwnership(const_cast(mPropertyNotification)); + AddPropertyNotificationMessage(mUpdateManager, transferOwnership); } } void PropertyNotification::DestroySceneObject() { - if ( mPropertyNotification != NULL ) + if(mPropertyNotification != nullptr) { // Remove PropertyNotification using a message to the update manager - RemovePropertyNotificationMessage( mUpdateManager, *mPropertyNotification ); - mPropertyNotification = NULL; + RemovePropertyNotificationMessage(mUpdateManager, *mPropertyNotification); + mPropertyNotification = nullptr; } }