X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fcommon%2Fproxy-object.h;h=0ae1e31fc66741585796a0199fabf3acea5e9210;hb=62a036e95cc8447bba0ef068948c8feb15de76b2;hp=f409117a703637557269a84f74880de1a7c804ea;hpb=644cd157117a2c9f316f10a4daec79da6f268745;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/common/proxy-object.h b/dali/internal/event/common/proxy-object.h index f409117..0ae1e31 100644 --- a/dali/internal/event/common/proxy-object.h +++ b/dali/internal/event/common/proxy-object.h @@ -1,34 +1,36 @@ #ifndef __DALI_INTERNAL_PROXY_OBJECT_H__ #define __DALI_INTERNAL_PROXY_OBJECT_H__ -// -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://floralicense.org/license/ -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// +/* + * Copyright (c) 2014 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ // EXTERNAL INCLUDES #include // INTERNAL INCLUDES -#include -#include #include -#include #include +#include +#include #include +#include #include #include +#include #include #include #include @@ -46,6 +48,18 @@ class ProxyObject; class Constraint; 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; @@ -106,24 +120,17 @@ public: ProxyObject(); /** - * Query whether the proxy object removes (& re-adds) its associated scene-object. - * Otherwise the scene-object lifetime is expected to match that of the proxy. - * @return True if scene-objects are removed. - */ - virtual bool IsSceneObjectRemovable() const = 0; - - /** * Add an observer to the proxy. * @param[in] observer The observer to add. */ - virtual void AddObserver(Observer& observer); + virtual void AddObserver( Observer& observer ); /** * Remove an observer from the proxy * @pre The observer has already been added. * @param[in] observer The observer to remove. */ - virtual void RemoveObserver(Observer& observer); + virtual void RemoveObserver( Observer& observer ); /** * Retrieve the scene-graph object added by this proxy. @@ -170,42 +177,42 @@ public: // Property system interface from Internal::Object /** * @copydoc Dali::Internal::Object::GetPropertyName() */ - virtual const std::string& GetPropertyName( Property::Index index ) const; + virtual std::string GetPropertyName( Property::Index index ) const; /** * @copydoc Dali::Internal::Object::GetPropertyIndex() */ - virtual Property::Index GetPropertyIndex(const std::string& name) const; + virtual Property::Index GetPropertyIndex( const std::string& name ) const; /** * @copydoc Dali::Internal::Object::IsPropertyWritable() */ - virtual bool IsPropertyWritable(Property::Index index) const; + virtual bool IsPropertyWritable( Property::Index index ) const; /** * @copydoc Dali::Internal::Object::IsPropertyAnimatable() */ - virtual bool IsPropertyAnimatable(Property::Index index) const; + virtual bool IsPropertyAnimatable( Property::Index index ) const; /** * @copydoc Dali::Internal::Object::IsPropertyAConstraintInput() */ - virtual bool IsPropertyAConstraintInput(Property::Index index) const; + virtual bool IsPropertyAConstraintInput( Property::Index index ) const; /** * @copydoc Dali::Internal::Object::GetPropertyType() */ - virtual Property::Type GetPropertyType(Property::Index index) const; + virtual Property::Type GetPropertyType( Property::Index index ) const; /** * @copydoc Dali::Internal::Object::SetProperty() */ - virtual void SetProperty(Property::Index index, const Property::Value& propertyValue); + virtual void SetProperty( Property::Index index, const Property::Value& propertyValue ); /** * @copydoc Dali::Internal::Object::GetProperty() */ - virtual Property::Value GetProperty(Property::Index index) const; + virtual Property::Value GetProperty( Property::Index index ) const; /** * @copydoc Dali::Handle::GetPropertyIndices() @@ -215,31 +222,32 @@ public: // Property system interface from Internal::Object /** * @copydoc Dali::Internal::Object::RegisterProperty() */ - virtual Property::Index RegisterProperty(std::string name, const Property::Value& propertyValue); + virtual Property::Index RegisterProperty( const std::string& name, const Property::Value& propertyValue ); /** - * @copydoc Dali::Handle::RegisterProperty(std::string name, Property::Value propertyValue, Property::AccessMode accessMode) + * @copydoc Dali::Internal::Object::RegisterProperty(std::string name, Property::Value propertyValue, Property::AccessMode accessMode) */ - virtual Property::Index RegisterProperty(std::string name, const Property::Value& propertyValue, Property::AccessMode accessMode); + virtual Property::Index RegisterProperty( const std::string& name, const Property::Value& propertyValue, Property::AccessMode accessMode ); /** - * @copydoc Dali::Handle::AddPropertyNotification() + * @copydoc Dali::Internal::Object::AddPropertyNotification() */ - virtual Dali::PropertyNotification AddPropertyNotification(Property::Index index, - int componentIndex, - const Dali::PropertyCondition& condition); + virtual Dali::PropertyNotification AddPropertyNotification( Property::Index index, + int componentIndex, + const Dali::PropertyCondition& condition ); /** - * @copydoc Dali::Handle::RemovePropertyNotification() + * @copydoc Dali::Internal::Object::RemovePropertyNotification() */ - virtual void RemovePropertyNotification(Dali::PropertyNotification propertyNotification); + virtual void RemovePropertyNotification( Dali::PropertyNotification propertyNotification ); /** - * @copydoc Dali::Handle::RemovePropertyNotifications() + * @copydoc Dali::Internal::Object::RemovePropertyNotifications() */ void RemovePropertyNotifications(); private: + /** * Enable property notifications in scene graph */ @@ -281,13 +289,21 @@ public: // Constraints */ void RemoveConstraints( unsigned int tag ); -public: // Called by TypeInfo +public: /** * Called by TypeInfo to set the type-info that this proxy-object is created by. * @param[in] typeInfo The TypeInfo that creates this proxy-object. */ - void SetTypeInfo( TypeInfo* typeInfo ); + void SetTypeInfo( const TypeInfo* typeInfo ); + + /** + * @return the index from which custom properties start + */ + unsigned int CustomPropertyStartIndex() + { + return PROPERTY_CUSTOM_START_INDEX; + } protected: @@ -309,10 +325,10 @@ protected: private: // Undefined - ProxyObject(const ProxyObject&); + ProxyObject( const ProxyObject& ); // Undefined - ProxyObject& operator=(const ProxyObject& rhs); + ProxyObject& operator=( const ProxyObject& rhs ); /** * Helper for ApplyConstraint overloads. @@ -323,15 +339,17 @@ private: ActiveConstraintBase* DoApplyConstraint( Constraint& constraint, Dali::Constrainable weightObject ); /** - * Helper to delete removed constraints - */ - void DeleteRemovedConstraints(); - - /** * Helper to remove active constraints */ void RemoveConstraint( ActiveConstraint& constraint, bool isInScenegraph ); + /** + * 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] value The new value of the property. + */ + virtual void SetSceneGraphProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value ); private: // Default property extensions for derived classes @@ -352,7 +370,7 @@ private: // Default property extensions for derived classes * Query how many default properties the derived class supports. * @return The number of default properties. */ - virtual const std::string& GetDefaultPropertyName( Property::Index index ) const = 0; + virtual const char* GetDefaultPropertyName( Property::Index index ) const = 0; /** * Query the index of a default property. @@ -400,14 +418,6 @@ private: // Default property extensions for derived classes virtual void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue ) = 0; /** - * Set the value of custom property. - * @param [in] index The index of the property. - * @param [in] entry An entry from the CustomPropertyLookup. - * @param [in] value The new value of the property. - */ - virtual void SetCustomProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value ); - - /** * Retrieve a default property value. * @param [in] index The index of the property. * @return The property value. @@ -415,40 +425,59 @@ private: // Default property extensions for derived classes virtual Property::Value GetDefaultProperty( Property::Index index ) const = 0; /** - * Install a newly allocated scene-object property. - * The derived class is responsible for this, since the type of scene-object is not known to this base class. - * @param [in] newProperty A newly allocated scene-object property. + * @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 proxy. + * @return A pointer to the object, or NULL if no object has been added to the scene-graph. + */ + virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const + { + return GetSceneObject(); + } + + /** + * Notify derived class of installation of a new scene-object property. + * This method is called after the message is to sent to install the property + * @param [in] newProperty A newly allocated scene-object property. Ownership is obviously not passed. * @param [in] name The name allocated to this custom property. * @param [in] index The index allocated to this custom property. */ - virtual void InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index ) = 0; + virtual void NotifyScenePropertyInstalled( const SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index ) + { } protected: /** - * Not all proxy objects will have custom properties so we want to only create the lookup when its actually needed - * @return the custom property lookup + * For use in derived classes. + * This is called after a non animatable custom property is set. + * @param [in] index The index of the property. + * @param [in] propertyValue The value of the property. */ - CustomPropertyLookup& GetCustomPropertyLookup() const; + virtual void OnPropertySet( Property::Index index, Property::Value propertyValue ) {} /** * Retrieves the TypeInfo for this object. Only retrieves it from the type-registry once and then stores a pointer * to it locally there-after. The type info will not change during the life-time of the application. * @return The type-info for this object (Can be NULL) */ - TypeInfo* GetTypeInfo() const; + const TypeInfo* GetTypeInfo() const; -private: + /** + * Helper to find custom property + * @param index + * @return pointer to the property + */ + CustomProperty* FindCustomProperty( Property::Index index ) const; - Property::Index mNextCustomPropertyIndex; ///< The ID of the next custom property to be registered +private: - mutable CustomPropertyLookup* mCustomProperties; ///< Used for accessing custom Node properties, mutable so it can be lazy initialized from const function - mutable TypeInfo* mTypeInfo; ///< The type-info for this object, mutable so it can be lazy initialized from const method if it is required + typedef OwnerContainer CustomPropertyLookup; + CustomPropertyLookup mCustomProperties; ///< Used for accessing custom 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. - ActiveConstraintContainer* mRemovedConstraints; ///< Container of owned active-constraints, which are being removed. typedef std::vector< Dali::PropertyNotification > PropertyNotificationContainer; typedef PropertyNotificationContainer::iterator PropertyNotificationContainerIter;