From 44ee0cc4fac620903fdf198867f645a2d5dbf075 Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Tue, 24 Feb 2015 13:17:10 +0000 Subject: [PATCH] Merge Handle & Constrainable Change-Id: If27ef930044532021863a224199f4d37b92693e7 --- automated-tests/src/dali/CMakeLists.txt | 1 - .../src/dali/utc-Dali-Constrainable.cpp | 88 ----------- automated-tests/src/dali/utc-Dali-Handle.cpp | 51 +++++++ dali/internal/event/common/object-impl.cpp | 6 +- dali/internal/event/common/object-impl.h | 5 +- dali/public-api/actors/actor.cpp | 4 +- dali/public-api/actors/actor.h | 4 +- dali/public-api/dali-core.h | 1 - dali/public-api/file.list | 2 - dali/public-api/geometry/animatable-mesh.cpp | 4 +- dali/public-api/geometry/animatable-mesh.h | 4 +- dali/public-api/object/constrainable.cpp | 107 ------------- dali/public-api/object/constrainable.h | 168 --------------------- dali/public-api/object/handle.cpp | 56 ++++++- dali/public-api/object/handle.h | 76 +++++++++- dali/public-api/render-tasks/render-task.cpp | 4 +- dali/public-api/render-tasks/render-task.h | 4 +- dali/public-api/shader-effects/shader-effect.cpp | 4 +- dali/public-api/shader-effects/shader-effect.h | 4 +- 19 files changed, 199 insertions(+), 394 deletions(-) delete mode 100644 automated-tests/src/dali/utc-Dali-Constrainable.cpp delete mode 100644 dali/public-api/object/constrainable.cpp delete mode 100644 dali/public-api/object/constrainable.h diff --git a/automated-tests/src/dali/CMakeLists.txt b/automated-tests/src/dali/CMakeLists.txt index 072ad59..f1e3b36 100644 --- a/automated-tests/src/dali/CMakeLists.txt +++ b/automated-tests/src/dali/CMakeLists.txt @@ -18,7 +18,6 @@ SET(TC_SOURCES utc-Dali-BitmapImage.cpp utc-Dali-CameraActor.cpp utc-Dali-Character.cpp - utc-Dali-Constrainable.cpp utc-Dali-Constraint.cpp utc-Dali-Context.cpp utc-Dali-CustomActor.cpp diff --git a/automated-tests/src/dali/utc-Dali-Constrainable.cpp b/automated-tests/src/dali/utc-Dali-Constrainable.cpp deleted file mode 100644 index e62c67d..0000000 --- a/automated-tests/src/dali/utc-Dali-Constrainable.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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. - * - */ - -#include -#include - -#include -#include - -using namespace Dali; - -void utc_dali_constrainable_startup(void) -{ - test_return_value = TET_UNDEF; -} - -void utc_dali_constrainable_cleanup(void) -{ - test_return_value = TET_PASS; -} - -int UtcDaliConstrainableDownCast(void) -{ - TestApplication application; - - Handle handle = Constrainable::New(); - - Constrainable customHandle1 = Constrainable::DownCast( handle ); - DALI_TEST_CHECK( customHandle1 ); - - Constrainable customHandle2 = DownCast< Constrainable >( handle ); - DALI_TEST_CHECK( customHandle2 ); - END_TEST; -} - -int UtcDaliConstrainableDownCastNegative(void) -{ - TestApplication application; - - Image image = ResourceImage::New( "temp" ); - Constrainable customHandle1 = Constrainable::DownCast( image ); - DALI_TEST_CHECK( ! customHandle1 ); - - Constrainable empty; - Constrainable customHandle2 = Constrainable::DownCast( empty ); - DALI_TEST_CHECK( ! customHandle2 ); - END_TEST; -} - -int UtcDaliConstrainableCustomProperty(void) -{ - TestApplication application; - - Constrainable handle = Constrainable::New(); - - float startValue(1.0f); - Property::Index index = handle.RegisterProperty( "test-property", startValue ); - DALI_TEST_CHECK( handle.GetProperty(index) == startValue ); - - application.SendNotification(); - application.Render(0); - DALI_TEST_CHECK( handle.GetProperty(index) == startValue ); - application.Render(0); - DALI_TEST_CHECK( handle.GetProperty(index) == startValue ); - - handle.SetProperty( index, 5.0f ); - - application.SendNotification(); - application.Render(0); - DALI_TEST_CHECK( handle.GetProperty(index) == 5.0f ); - application.Render(0); - DALI_TEST_CHECK( handle.GetProperty(index) == 5.0f ); - END_TEST; -} diff --git a/automated-tests/src/dali/utc-Dali-Handle.cpp b/automated-tests/src/dali/utc-Dali-Handle.cpp index 0d7c5e3..cf49f4a 100644 --- a/automated-tests/src/dali/utc-Dali-Handle.cpp +++ b/automated-tests/src/dali/utc-Dali-Handle.cpp @@ -36,6 +36,15 @@ void handle_test_cleanup(void) namespace { +/// Allows the creation of a BaseObject +class BaseObjectType : public BaseObject +{ +public: + BaseObjectType() + { + } +}; + Handle ImplicitCopyConstructor(Handle passedByValue) { // object + copy + passedByValue, ref count == 3 @@ -772,6 +781,22 @@ int UtcDaliHandleDownCast(void) END_TEST; } +int UtcDaliHandleDownCastNegative(void) +{ + TestApplication application; + + // BaseObject is NOT an Object, so this DownCast should fail + BaseHandle handle( new BaseObjectType ); + Handle customHandle1 = Handle::DownCast( handle ); + DALI_TEST_CHECK( ! customHandle1 ); + + // A DownCast on an empty handle will also fail + Handle empty; + Handle customHandle2 = Handle::DownCast( empty ); + DALI_TEST_CHECK( ! customHandle2 ); + END_TEST; +} + int UtcDaliHandleCreateProperty(void) { TestApplication application; @@ -1018,3 +1043,29 @@ int UtcDaliHandleRegisterPropertyTypes(void) } END_TEST; } + +int UtcDaliHandleCustomProperty(void) +{ + TestApplication application; + + Handle handle = Handle::New(); + + float startValue(1.0f); + Property::Index index = handle.RegisterProperty( "test-property", startValue ); + DALI_TEST_CHECK( handle.GetProperty(index) == startValue ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( handle.GetProperty(index) == startValue ); + application.Render(0); + DALI_TEST_CHECK( handle.GetProperty(index) == startValue ); + + handle.SetProperty( index, 5.0f ); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( handle.GetProperty(index) == 5.0f ); + application.Render(0); + DALI_TEST_CHECK( handle.GetProperty(index) == 5.0f ); + END_TEST; +} diff --git a/dali/internal/event/common/object-impl.cpp b/dali/internal/event/common/object-impl.cpp index b49b7ce..09d5997 100644 --- a/dali/internal/event/common/object-impl.cpp +++ b/dali/internal/event/common/object-impl.cpp @@ -754,15 +754,15 @@ void Object::DisablePropertyNotifications() Dali::ActiveConstraint Object::ApplyConstraint( Constraint& constraint ) { - return Dali::ActiveConstraint( DoApplyConstraint( constraint, Dali::Constrainable() ) ); + return Dali::ActiveConstraint( DoApplyConstraint( constraint, Dali::Handle() ) ); } -Dali::ActiveConstraint Object::ApplyConstraint( Constraint& constraint, Dali::Constrainable weightObject ) +Dali::ActiveConstraint Object::ApplyConstraint( Constraint& constraint, Dali::Handle weightObject ) { return Dali::ActiveConstraint( DoApplyConstraint( constraint, weightObject ) ); } -ActiveConstraintBase* Object::DoApplyConstraint( Constraint& constraint, Dali::Constrainable weightObject ) +ActiveConstraintBase* Object::DoApplyConstraint( Constraint& constraint, Dali::Handle weightObject ) { ActiveConstraintBase* activeConstraintImpl = constraint.CreateActiveConstraint(); DALI_ASSERT_DEBUG( NULL != activeConstraintImpl ); diff --git a/dali/internal/event/common/object-impl.h b/dali/internal/event/common/object-impl.h index 270a73b..1949f09 100644 --- a/dali/internal/event/common/object-impl.h +++ b/dali/internal/event/common/object-impl.h @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -238,7 +237,7 @@ public: * @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 ); + Dali::ActiveConstraint ApplyConstraint( Constraint& constraint, Dali::Handle weightObject ); /** * Remove one constraint from a Object. @@ -459,7 +458,7 @@ private: * @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 ); + ActiveConstraintBase* DoApplyConstraint( Constraint& constraint, Dali::Handle weightObject ); /** * Helper to remove active constraints diff --git a/dali/public-api/actors/actor.cpp b/dali/public-api/actors/actor.cpp index f3beeb8..f2c07d6 100644 --- a/dali/public-api/actors/actor.cpp +++ b/dali/public-api/actors/actor.cpp @@ -67,7 +67,7 @@ Actor::~Actor() } Actor::Actor(const Actor& copy) -: Constrainable(copy) +: Handle(copy) { } @@ -610,7 +610,7 @@ DynamicsBody Actor::GetDynamicsBody() } Actor::Actor(Internal::Actor* internal) -: Constrainable(internal) +: Handle(internal) { } diff --git a/dali/public-api/actors/actor.h b/dali/public-api/actors/actor.h index fff15b4..248225a 100644 --- a/dali/public-api/actors/actor.h +++ b/dali/public-api/actors/actor.h @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include namespace Dali @@ -243,7 +243,7 @@ typedef ActorContainer::const_iterator ActorConstIter; ///< Const iterator for D * | show | %SetVisible( true ) | * | hide | %SetVisible( false ) | */ -class DALI_IMPORT_API Actor : public Constrainable +class DALI_IMPORT_API Actor : public Handle { public: diff --git a/dali/public-api/dali-core.h b/dali/public-api/dali-core.h index 35aa175..d321c74 100644 --- a/dali/public-api/dali-core.h +++ b/dali/public-api/dali-core.h @@ -126,7 +126,6 @@ #include #include #include -#include #include #include #include diff --git a/dali/public-api/file.list b/dali/public-api/file.list index 83d25a3..3b42263 100644 --- a/dali/public-api/file.list +++ b/dali/public-api/file.list @@ -87,7 +87,6 @@ public_api_src_files = \ $(public_api_src_dir)/modeling/model-data.cpp \ $(public_api_src_dir)/object/any.cpp \ $(public_api_src_dir)/object/base-handle.cpp \ - $(public_api_src_dir)/object/constrainable.cpp \ $(public_api_src_dir)/object/handle.cpp \ $(public_api_src_dir)/object/base-object.cpp \ $(public_api_src_dir)/object/object-registry.cpp \ @@ -254,7 +253,6 @@ public_api_core_object_header_files = \ $(public_api_src_dir)/object/any.h \ $(public_api_src_dir)/object/base-handle.h \ $(public_api_src_dir)/object/base-object.h \ - $(public_api_src_dir)/object/constrainable.h \ $(public_api_src_dir)/object/handle.h \ $(public_api_src_dir)/object/object-registry.h \ $(public_api_src_dir)/object/property-conditions.h \ diff --git a/dali/public-api/geometry/animatable-mesh.cpp b/dali/public-api/geometry/animatable-mesh.cpp index 1f678f4..d545f35 100644 --- a/dali/public-api/geometry/animatable-mesh.cpp +++ b/dali/public-api/geometry/animatable-mesh.cpp @@ -55,7 +55,7 @@ AnimatableMesh::~AnimatableMesh() } AnimatableMesh::AnimatableMesh(const AnimatableMesh& handle) -: Constrainable(handle) +: Handle(handle) { } @@ -93,7 +93,7 @@ Property AnimatableMesh::GetVertexProperty( unsigned int vertex, Property::Index AnimatableMesh::AnimatableMesh( Internal::AnimatableMesh* internal ) -: Constrainable(internal) +: Handle(internal) { } diff --git a/dali/public-api/geometry/animatable-mesh.h b/dali/public-api/geometry/animatable-mesh.h index 733891e..9f49dbe 100644 --- a/dali/public-api/geometry/animatable-mesh.h +++ b/dali/public-api/geometry/animatable-mesh.h @@ -20,7 +20,7 @@ // INTERNAL INCLUDES #include -#include +#include #include #include @@ -40,7 +40,7 @@ class AnimatableMesh; * It is recommended that the vertices of the mesh remain in the bounds -0.5 - 0.5, which * will match the actor size boundaries. The origin of the mesh matches the actor's position. */ -class DALI_IMPORT_API AnimatableMesh : public Constrainable +class DALI_IMPORT_API AnimatableMesh : public Handle { public: /** diff --git a/dali/public-api/object/constrainable.cpp b/dali/public-api/object/constrainable.cpp deleted file mode 100644 index 1404751..0000000 --- a/dali/public-api/object/constrainable.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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. - * - */ - -// CLASS HEADER -#include - -// INTERNAL INCLUDES -#include -#include -#include -#include -#include -#include - -namespace Dali -{ - -Constrainable Constrainable::New() -{ - return Constrainable( Internal::CustomObject::New() ); -} - -Constrainable::Constrainable(Dali::Internal::Object* handle) -: Handle(handle) -{ -} - -Constrainable::Constrainable() -{ -} - -Constrainable Constrainable::DownCast( BaseHandle handle ) -{ - return Constrainable( dynamic_cast(handle.GetObjectPtr()) ); -} - -Constrainable::~Constrainable() -{ -} - -Constrainable::Constrainable(const Constrainable& handle) -: Handle(handle) -{ -} - -Constrainable& Constrainable::operator=(const Constrainable& rhs) -{ - BaseHandle::operator=(rhs); - return *this; -} - -ActiveConstraint Constrainable::ApplyConstraint( Constraint constraint ) -{ - return GetImplementation(*this).ApplyConstraint( GetImplementation( constraint ) ); -} - -ActiveConstraint Constrainable::ApplyConstraint( Constraint constraint, Constrainable weightObject ) -{ - return GetImplementation(*this).ApplyConstraint( GetImplementation( constraint ), weightObject ); -} - -void Constrainable::RemoveConstraint(ActiveConstraint activeConstraint) -{ - GetImplementation(*this).RemoveConstraint( activeConstraint ); -} - -void Constrainable::RemoveConstraints() -{ - GetImplementation(*this).RemoveConstraints(); -} - -void Constrainable::RemoveConstraints( unsigned int tag ) -{ - GetImplementation(*this).RemoveConstraints( tag ); -} - -namespace WeightObject -{ - -const Property::Index WEIGHT = PROPERTY_CUSTOM_START_INDEX; - -Constrainable New() -{ - Constrainable handle = Constrainable::New(); - - handle.RegisterProperty( "weight", 0.0f ); - - return handle; -} - -} // namespace WeightObject - -} // namespace Dali diff --git a/dali/public-api/object/constrainable.h b/dali/public-api/object/constrainable.h deleted file mode 100644 index b09019d..0000000 --- a/dali/public-api/object/constrainable.h +++ /dev/null @@ -1,168 +0,0 @@ -#ifndef __DALI_CONSTRAINABLE_H__ -#define __DALI_CONSTRAINABLE_H__ - -/* - * 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. - * - */ - -// INTERNAL INCLUDES -#include -#include -#include - -namespace Dali DALI_IMPORT_API -{ - -namespace Internal -{ -class Object; -} - -class Constraint; - -/** - * @brief Dali::Constrainable is a handle to an internal property owning Dali object that - * can have constraints applied to it. - */ -class DALI_IMPORT_API Constrainable : public Handle -{ -public: - - /** - * @brief Create a constrainable object. - * - * @return A handle to a newly allocated object. - */ - static Constrainable New(); - - /** - * @brief This constructor provides an uninitialized Dali::Constrainable. - * - * This should be initialized with a Dali New() method before use. - * Methods called on an uninitialized Dali::Constrainable will assert. - * @code - * Constrainable handle; // uninitialized - * handle.SomeMethod(); // unsafe! This will assert - * - * handle = SomeClass::New(); // now initialized - * handle.SomeMethod(); // safe - * @endcode - */ - Constrainable(); - - /** - * @brief Downcast a handle to a custom object. - * - * @param[in] handle The handle to cast. - * @return A handle to a custom object or an empty handle. - */ - static Constrainable DownCast( BaseHandle handle ); - - /** - * @brief Dali::Constrainable is intended as a base class - * - * This is non-virtual since derived Handle types must not contain data or virtual methods. - */ - ~Constrainable(); - - /** - * @brief This copy constructor is required for (smart) pointer semantics. - * - * @param [in] handle A reference to the copied handle - */ - Constrainable(const Constrainable& handle); - - /** - * @brief This assignment operator is required for (smart) pointer semantics. - * - * @param [in] rhs A reference to the copied handle - * @return A reference to this - */ - Constrainable& operator=(const Constrainable& rhs); - - /** - * @brief Constrain one of the properties of an Actor. - * - * @note The constraint will be copied by the Actor. This means that modifying the apply-time etc. - * of the constraint, will not affect actors which are already being constrained. - * @pre The Actor has been initialized. - * @param[in] constraint The constraint to apply. - * @return The active-constraint being applied to the actor. - */ - ActiveConstraint ApplyConstraint( Constraint constraint ); - - /** - * @brief Constrain one of the properties of an Actor, using a custom weight property. - * - * This overload is intended to allow a single weight property to be shared by many constraints - * e.g. call WeightObject::New() once, and pass the return value into every call to ApplyConstraint(). - * @pre The Actor has been initialized. - * @param[in] constraint The constraint to apply. - * @param[in] weightObject An object which is expected to have a float property named "weight". - * @return The active-constraint being applied to the actor. - */ - ActiveConstraint ApplyConstraint( Constraint constraint, Constrainable weightObject ); - - /** - * @brief Remove one constraint from an Object. - * - * @pre The Object has been intialized. - * @param[in] activeConstraint The active-constraint to remove. - */ - void RemoveConstraint(ActiveConstraint activeConstraint); - - /** - * @brief Remove all constraints from an Object. - * - * @pre The object has been initialized. - */ - void RemoveConstraints(); - - /** - * @brief Remove all the constraint from the Object with a matching tag. - * - * @pre The Object has been intialized. - * @param[in] tag The tag of the constraints which will be removed - */ - void RemoveConstraints( unsigned int tag ); - -public: - - /** - * @brief This constructor is used by Dali New() methods. - * - * @param [in] handle A pointer to a newly allocated Dali resource - */ - explicit DALI_INTERNAL Constrainable(Dali::Internal::Object* handle); -}; - -namespace WeightObject -{ - -DALI_IMPORT_API extern const Property::Index WEIGHT; ///< name "weight", type FLOAT - -/** - * @brief Convenience function to create an object with a custom "weight" property. - * - * @return A handle to a newly allocated object. - */ -DALI_IMPORT_API Constrainable New(); - -} // namespace WeightObject - -} // namespace Dali - -#endif // __DALI_CONSTRAINABLE_H__ diff --git a/dali/public-api/object/handle.cpp b/dali/public-api/object/handle.cpp index 98fea25..34532ae 100644 --- a/dali/public-api/object/handle.cpp +++ b/dali/public-api/object/handle.cpp @@ -19,23 +19,34 @@ #include // INTERNAL INCLUDES +#include +#include #include +#include #include +#include #include +#include #include namespace Dali { -Handle::Handle(Dali::Internal::Object* handle) - : BaseHandle(handle) +Handle::Handle( Dali::Internal::Object* handle ) +: BaseHandle(handle) { } + Handle::Handle() { } +Handle Handle::New() +{ + return Handle( Internal::CustomObject::New() ); +} + Handle::~Handle() { } @@ -149,4 +160,45 @@ void Handle::RemovePropertyNotifications() GetImplementation(*this).RemovePropertyNotifications(); } +ActiveConstraint Handle::ApplyConstraint( Constraint constraint ) +{ + return GetImplementation(*this).ApplyConstraint( GetImplementation( constraint ) ); +} + +ActiveConstraint Handle::ApplyConstraint( Constraint constraint, Handle weightObject ) +{ + return GetImplementation(*this).ApplyConstraint( GetImplementation( constraint ), weightObject ); +} + +void Handle::RemoveConstraint(ActiveConstraint activeConstraint) +{ + GetImplementation(*this).RemoveConstraint( activeConstraint ); +} + +void Handle::RemoveConstraints() +{ + GetImplementation(*this).RemoveConstraints(); +} + +void Handle::RemoveConstraints( unsigned int tag ) +{ + GetImplementation(*this).RemoveConstraints( tag ); +} + +namespace WeightObject +{ + +const Property::Index WEIGHT = PROPERTY_CUSTOM_START_INDEX; + +Handle New() +{ + Handle handle = Handle::New(); + + handle.RegisterProperty( "weight", 0.0f ); + + return handle; +} + +} // namespace WeightObject + } // namespace Dali diff --git a/dali/public-api/object/handle.h b/dali/public-api/object/handle.h index 3718402..0dd7eb3 100644 --- a/dali/public-api/object/handle.h +++ b/dali/public-api/object/handle.h @@ -32,6 +32,8 @@ namespace Dali { +class ActiveConstraint; +class Constraint; class PropertyNotification; class PropertyCondition; @@ -41,7 +43,7 @@ class Object; } /** - * @brief Dali::Handle is a handle to an internal property owning Dali object. + * @brief Dali::Handle is a handle to an internal property owning Dali object that can have constraints applied to it. */ class DALI_IMPORT_API Handle : public BaseHandle { @@ -85,6 +87,13 @@ public: Handle(); /** + * @brief Create a new object. + * + * @return A handle to a newly allocated object. + */ + static Handle New(); + + /** * @brief Dali::Handle is intended as a base class * * This is non-virtual since derived Handle types must not contain data or virtual methods. @@ -115,8 +124,6 @@ public: */ static Handle DownCast( BaseHandle handle ); -public: - /** * @brief Query whether an handle supports a given capability. * @@ -125,6 +132,8 @@ public: */ bool Supports( Capability capability ) const; + // Properties + /** * @brief Query how many properties are provided by an handle. * @@ -307,8 +316,69 @@ public: */ void RemovePropertyNotifications(); + // Constraints + + /** + * @brief Constrain one of the properties of an Actor. + * + * @note The constraint will be copied by the Actor. This means that modifying the apply-time etc. + * of the constraint, will not affect actors which are already being constrained. + * @pre The Actor has been initialized. + * @param[in] constraint The constraint to apply. + * @return The active-constraint being applied to the actor. + */ + ActiveConstraint ApplyConstraint( Constraint constraint ); + + /** + * @brief Constrain one of the properties of an Actor, using a custom weight property. + * + * This overload is intended to allow a single weight property to be shared by many constraints + * e.g. call WeightObject::New() once, and pass the return value into every call to ApplyConstraint(). + * @pre The Actor has been initialized. + * @param[in] constraint The constraint to apply. + * @param[in] weightObject An object which is expected to have a float property named "weight". + * @return The active-constraint being applied to the actor. + */ + ActiveConstraint ApplyConstraint( Constraint constraint, Handle weightObject ); + + /** + * @brief Remove one constraint from an Object. + * + * @pre The Object has been initialized. + * @param[in] activeConstraint The active-constraint to remove. + */ + void RemoveConstraint( ActiveConstraint activeConstraint ); + + /** + * @brief Remove all constraints from an Object. + * + * @pre The object has been initialized. + */ + void RemoveConstraints(); + + /** + * @brief Remove all the constraint from the Object with a matching tag. + * + * @pre The Object has been intialized. + * @param[in] tag The tag of the constraints which will be removed + */ + void RemoveConstraints( unsigned int tag ); }; +namespace WeightObject +{ + +DALI_IMPORT_API extern const Property::Index WEIGHT; ///< name "weight", type FLOAT + +/** + * @brief Convenience function to create an object with a custom "weight" property. + * + * @return A handle to a newly allocated object. + */ +DALI_IMPORT_API Handle New(); + +} // namespace WeightObject + } // namespace Dali #endif // __DALI_HANDLE_H__ diff --git a/dali/public-api/render-tasks/render-task.cpp b/dali/public-api/render-tasks/render-task.cpp index 35fa83d..36045f8 100644 --- a/dali/public-api/render-tasks/render-task.cpp +++ b/dali/public-api/render-tasks/render-task.cpp @@ -62,7 +62,7 @@ RenderTask::~RenderTask() } RenderTask::RenderTask(const RenderTask& handle) -: Constrainable(handle) +: Handle(handle) { } @@ -241,7 +241,7 @@ bool RenderTask::GetInputEnabled() const } RenderTask::RenderTask( Internal::RenderTask* internal ) -: Constrainable(internal) +: Handle(internal) { } diff --git a/dali/public-api/render-tasks/render-task.h b/dali/public-api/render-tasks/render-task.h index 73bf6d3..8f71f52 100644 --- a/dali/public-api/render-tasks/render-task.h +++ b/dali/public-api/render-tasks/render-task.h @@ -20,7 +20,7 @@ // INTERNAL INCLUDES #include -#include +#include #include namespace Dali @@ -74,7 +74,7 @@ class RenderTask; * |--------------|-----------------------| * | finished | @ref FinishedSignal() | */ -class DALI_IMPORT_API RenderTask : public Constrainable +class DALI_IMPORT_API RenderTask : public Handle { public: /** diff --git a/dali/public-api/shader-effects/shader-effect.cpp b/dali/public-api/shader-effects/shader-effect.cpp index 6f440e1..39ad964 100644 --- a/dali/public-api/shader-effects/shader-effect.cpp +++ b/dali/public-api/shader-effects/shader-effect.cpp @@ -41,7 +41,7 @@ ShaderEffect::ShaderEffect() } ShaderEffect::ShaderEffect(Internal::ShaderEffect* internal) -: Constrainable(internal) +: Handle(internal) { } @@ -50,7 +50,7 @@ ShaderEffect::~ShaderEffect() } ShaderEffect::ShaderEffect(const ShaderEffect& handle) -: Constrainable(handle) +: Handle(handle) { } diff --git a/dali/public-api/shader-effects/shader-effect.h b/dali/public-api/shader-effects/shader-effect.h index 13ce2c2..446bb12 100644 --- a/dali/public-api/shader-effects/shader-effect.h +++ b/dali/public-api/shader-effects/shader-effect.h @@ -20,7 +20,7 @@ // INTERNAL INCLUDES #include -#include +#include namespace Dali { @@ -147,7 +147,7 @@ enum GeometryType * with the uniform color "uColor" of the node * */ -class DALI_IMPORT_API ShaderEffect : public Constrainable +class DALI_IMPORT_API ShaderEffect : public Handle { public: /** -- 2.7.4