X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fcommon%2Fobject-impl.h;h=035e7eed1a7f93617de576a70ef54156c525d7be;hb=462cbee2270984cdca45488f3733d664dcf49187;hp=270a73b48ee92ee9e325474bf708c375f127f08f;hpb=f8a75318dd2950c20fb8c6c9a6523fdb0e106030;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/common/object-impl.h b/dali/internal/event/common/object-impl.h index 270a73b..035e7ee 100644 --- a/dali/internal/event/common/object-impl.h +++ b/dali/internal/event/common/object-impl.h @@ -2,7 +2,7 @@ #define __DALI_INTERNAL_OBJECT_H__ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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,24 +19,21 @@ */ // INTERNAL INCLUDES -#include #include #include #include #include -#include #include #include -#include +#include #include #include -#include -#include -#include +#include +#include #include +#include #include - namespace Dali { @@ -44,34 +41,25 @@ class PropertyNotification; namespace Internal { -class Constraint; +class Animation; +class ConstraintBase; +class EventThreadServices; class Handle; class PropertyCondition; class PropertyInputImpl; class Stage; class TypeInfo; -/** - * @brief Structure for setting up default properties and their details. - */ -struct PropertyDetails -{ - const char* name; ///< The name of the property. - Property::Type type; ///< The property type. - bool writable:1; ///< Whether the property is writable - bool animatable:1; ///< Whether the property is animatable. - bool constraintInput:1; ///< Whether the property can be used as an input to a constraint. -}; - namespace SceneGraph { class PropertyBase; class PropertyOwner; } -typedef std::vector< Dali::ActiveConstraint > ActiveConstraintContainer; -typedef ActiveConstraintContainer::iterator ActiveConstraintIter; -typedef ActiveConstraintContainer::const_iterator ActiveConstraintConstIter; +typedef std::vector< Dali::Constraint > ConstraintContainer; +typedef ConstraintContainer::iterator ConstraintIter; +typedef ConstraintContainer::const_iterator ConstraintConstIter; + /** * A base class for objects which optionally provide properties. @@ -164,6 +152,16 @@ public: virtual Property::Index GetPropertyIndex( const std::string& name ) const; /** + * @copydoc Dali::Handle::GetPropertyIndex() + */ + virtual Property::Index GetPropertyIndex( Property::Index key ) const; + + /** + * @copydoc Dali::Handle::GetPropertyIndex() + */ + virtual Property::Index GetPropertyIndex( Property::Key key ) const; + + /** * @copydoc Dali::Handle::IsPropertyWritable() */ virtual bool IsPropertyWritable( Property::Index index ) const; @@ -194,6 +192,13 @@ public: virtual Property::Value GetProperty( Property::Index index ) const; /** + * @brief Retrieves the latest value of the property on the scene-graph. + * @param[in] index The index of the property required. + * @return The latest value of the property on the scene-graph. + */ + virtual Property::Value GetCurrentProperty( Property::Index index ) const; + + /** * @copydoc Dali::Handle::GetPropertyIndices() */ virtual void GetPropertyIndices( Property::IndexContainer& indices ) const; @@ -204,11 +209,21 @@ public: virtual Property::Index RegisterProperty( const std::string& name, const Property::Value& propertyValue ); /** + * @copydoc Dali::Handle::RegisterProperty() + */ + virtual Property::Index RegisterProperty( const std::string& name, Property::Index key, const Property::Value& propertyValue ); + + /** * @copydoc Dali::Handle::RegisterProperty(std::string name, Property::Value propertyValue, Property::AccessMode accessMode) */ virtual Property::Index RegisterProperty( const std::string& name, const Property::Value& propertyValue, Property::AccessMode accessMode ); /** + * @brief Implementing method for this override + */ + virtual Property::Index RegisterProperty( const std::string& name, Property::Index key, const Property::Value& propertyValue, Property::AccessMode accessMode ); + + /** * @copydoc Dali::Handle::AddPropertyNotification() */ virtual Dali::PropertyNotification AddPropertyNotification( Property::Index index, @@ -225,26 +240,39 @@ public: */ virtual void RemovePropertyNotifications(); - // Constraints + /** + * Notifies that a property is being animated. + * @param[in] animation The animation animating the property. + * @param[in] index The index of the property. + * @param[in] value The value of the property after the animation. + */ + void NotifyPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value ); + + /******************************** Uniform Mappings ********************************/ /** - * Apply a constraint to a Object. - * @param[in] constraint The constraint to apply. + * @copydoc Dali::Handle::AddUniformMapping() */ - Dali::ActiveConstraint ApplyConstraint( Constraint& constraint ); + void AddUniformMapping( Property::Index propertyIndex, const std::string& uniformName ) const; /** - * Apply a constraint to a Object. + * @copydoc Dali::Handle::RemoveUniformMapping( ) + */ + void RemoveUniformMapping( const std::string& uniformName ); + + /******************************** Constraints ********************************/ + + /** + * Apply a constraint to an Object. * @param[in] constraint The constraint to apply. - * @param[in] weightObject An object with a "weight" float property. */ - Dali::ActiveConstraint ApplyConstraint( Constraint& constraint, Dali::Constrainable weightObject ); + void ApplyConstraint( ConstraintBase& constraint ); /** - * Remove one constraint from a Object. - * @param[in] activeConstraint The active constraint to remove. + * Remove one constraint from an Object. + * @param[in] constraint The constraint to remove. */ - void RemoveConstraint( Dali::ActiveConstraint activeConstraint ); + void RemoveConstraint( ConstraintBase& constraint ); /** * Remove all constraints from a Object. @@ -270,7 +298,7 @@ public: return PROPERTY_CUSTOM_START_INDEX; } - // To be overridden by deriving classes + /******************** To be overridden by deriving classes ********************/ /** * Retrieve the scene-graph object added by this object. @@ -287,7 +315,7 @@ public: virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const = 0; /** - * Retrieve an constraint input-property owned by the scene-graph object. + * Retrieve a constraint input-property owned by the scene-graph object. * @pre -1 < index < GetPropertyCount(). * @param[in] index The index of the property. * @return A dereferenceable pointer to an input property, or NULL if a scene-object does not exist with this property. @@ -320,8 +348,17 @@ protected: void OnSceneObjectRemove(); /** + * For overriding by derived classes to return the parent of this object. + */ + virtual Object* GetParentObject() const + { + // By default the Object does not have a parent + return NULL; + }; + + /** * For use in derived classes. - * This is called after a non animatable custom property is set. + * This is called after a property is set. * @param [in] index The index of the property. * @param [in] propertyValue The value of the property. */ @@ -339,7 +376,36 @@ protected: * @param index * @return pointer to the property */ - CustomProperty* FindCustomProperty( Property::Index index ) const; + CustomPropertyMetadata* FindCustomProperty( Property::Index index ) const; + + /** + * Helper to find animatable property + * @param index + * @return pointer to the property + */ + AnimatablePropertyMetadata* FindAnimatableProperty( Property::Index index ) const; + + /** + * Helper to register a scene-graph property + * @param [in] name The name of the property. + * @param [in] key The key of the property + * @param [in] index The index of the property + * @param [in] value The value of the property. + * @return The index of the registered property or Property::INVALID_INDEX if registration failed. + */ + Property::Index RegisterSceneGraphProperty(const std::string& name, Property::Index key, Property::Index index, const Property::Value& propertyValue) const; + + /** + * Check whether the animatable property is registered already, if not then register one. + * @param [in] index The index of the property + * @return pointer to the property. + */ + AnimatablePropertyMetadata* RegisterAnimatableProperty(Property::Index index) const; + + /** + * Resolve the index and name of child properties if any. + */ + void ResolveChildProperties(); private: // Default property extensions for derived classes @@ -415,6 +481,22 @@ private: // Default property extensions for derived classes virtual Property::Value GetDefaultProperty( Property::Index index ) const = 0; /** + * Retrieve the latest scene-graph value of a default property. + * @param[in] index The index of the property. + * @return The latest scene-graph value of a default property. + */ + virtual Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const = 0; + + /** + * Notifies that a default property is being animated so the deriving class should update the cached value. + * @param[in] animation The animation animating the property. + * @param[in] index The index of the property. + * @param[in] value The value of the property after the animation. + */ + virtual void OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value ) + { } + + /** * @todo this is virtual so that for now actor can override it, * it needs to be removed and only have GetSceneObject but that requires changing actor and constraint logic * Retrieve the scene-graph object added by this object. @@ -432,7 +514,7 @@ private: // Default property extensions for derived classes * @param [in] name The name allocated to this custom property. * @param [in] index The index allocated to this custom property. */ - virtual void NotifyScenePropertyInstalled( const SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index ) + virtual void NotifyScenePropertyInstalled( const SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index ) const { } private: @@ -454,42 +536,66 @@ private: void DisablePropertyNotifications(); /** - * Helper for ApplyConstraint overloads. - * @param[in] constraint The constraint to apply. - * @param[in] weightObject An object with a "weight" float property, or an empty handle. - * @return The new active-constraint which is owned by Object. - */ - ActiveConstraintBase* DoApplyConstraint( Constraint& constraint, Dali::Constrainable weightObject ); - - /** - * Helper to remove active constraints + * Get the latest value of the property on the scene-graph. + * @param[in] entry An entry from the property lookup container. + * @return The latest value of the property. */ - void RemoveConstraint( ActiveConstraint& constraint, bool isInScenegraph ); + Property::Value GetCurrentPropertyValue( const PropertyMetadata* entry ) const; /** * Set the value of scene graph property. * @param [in] index The index of the property. - * @param [in] entry An entry from the CustomPropertyLookup. + * @param [in] entry An entry from the property lookup container. * @param [in] value The new value of the property. */ - virtual void SetSceneGraphProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value ); + virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value ); + +protected: + /** + * Get the event thread services object - used for sending messages to the scene graph + * Assert if called from the wrong thread. + * This is intentionally inline for performance reasons. + * + * @return The event thread services object + */ + inline EventThreadServices& GetEventThreadServices() + { + DALI_ASSERT_DEBUG( EventThreadServices::IsCoreRunning() ); + return mEventThreadServices; + } + + /** + * Get the event thread services object - used for sending messages to the scene graph + * Assert if called from the wrong thread + * This is intentionally inline for performance reasons. + * + * @return The event thread services object + */ + inline const EventThreadServices& GetEventThreadServices() const + { + DALI_ASSERT_DEBUG( EventThreadServices::IsCoreRunning() ); + return mEventThreadServices; + } + +private: + EventThreadServices& mEventThreadServices; private: - typedef OwnerContainer CustomPropertyLookup; - CustomPropertyLookup mCustomProperties; ///< Used for accessing custom Node properties + typedef OwnerContainer PropertyMetadataLookup; + mutable PropertyMetadataLookup mCustomProperties; ///< Used for accessing custom Node properties + mutable PropertyMetadataLookup mAnimatableProperties; ///< Used for accessing animatable Node properties mutable TypeInfo const * mTypeInfo; ///< The type-info for this object, mutable so it can be lazy initialized from const method if it is required Dali::Vector mObservers; - ActiveConstraintContainer* mConstraints; ///< Container of owned active-constraints. + ConstraintContainer* mConstraints; ///< Container of owned -constraints. typedef std::vector< Dali::PropertyNotification > PropertyNotificationContainer; typedef PropertyNotificationContainer::iterator PropertyNotificationContainerIter; typedef PropertyNotificationContainer::const_iterator PropertyNotificationContainerConstIter; PropertyNotificationContainer* mPropertyNotifications; ///< Container of owned property notifications. }; - } // namespace Internal // Helpers for public-api forwarding methods @@ -515,4 +621,3 @@ inline const Internal::Object& GetImplementation(const Dali::Handle& object) } // namespace Dali #endif // __DALI_INTERNAL_OBJECT_H__ -