Commit d6045205a5493e9d1509fa286cf9bc588e3529ac

Authored by Paul Wisbey
2 parents 6643fc70 f6dac5b4

Merge remote-tracking branch 'origin/tizen' into new_text

Change-Id: Ica8aad6d34fbebf441eb859fb716935aeaf0105f
demo/dali-table-view.cpp
... ... @@ -130,20 +130,19 @@ public:
130 130 {
131 131 }
132 132  
133   - Vector3 operator()( const Vector3& current, const PropertyInput& scrollProperty, const PropertyInput& parentSize )
  133 + void operator()( Vector3& position, const PropertyInputContainer& inputs )
134 134 {
135   - Vector3 pos( current );
136   - const float parentHeight = parentSize.GetVector3().height;
  135 + const Vector3& parentSize = inputs[1]->GetVector3();
137 136  
138   - // Wrap bubbles vertically
139   - if( pos.y + mShapeSize * 0.5f < -parentHeight * 0.5f )
  137 + // Wrap bubbles verically.
  138 + if( position.y + mShapeSize * 0.5f < -parentSize.y * 0.5f )
140 139 {
141   - pos.y = parentHeight * 0.5f + mShapeSize * 0.5f;
  140 + position.y = parentSize.y * 0.5f + mShapeSize * 0.5f;
142 141 }
143 142  
144   - // Bubbles X position moves parallax to horizontal panning by a scale factor unique to each bubble
145   - pos.x = mInitialX + ( scrollProperty.GetVector3().x * mScale );
146   - return pos;
  143 + // Bubbles X position moves parallax to horizontal
  144 + // panning by a scale factor unique to each bubble.
  145 + position.x = mInitialX + ( inputs[0]->GetVector3().x * mScale );
147 146 }
148 147  
149 148 private:
... ... @@ -756,11 +755,10 @@ void DaliTableView::InitialiseBackgroundActors( Actor actor )
756 755 child.SetPosition( childPos );
757 756  
758 757 // Define bubble horizontal parallax and vertical wrapping
759   - Constraint animConstraint = Constraint::New < Vector3 > ( Actor::Property::POSITION,
760   - Source( mScrollView, ScrollView::Property::SCROLL_POSITION ),
761   - Dali::ParentSource( Dali::Actor::Property::SIZE ),
762   - AnimateBubbleConstraint( childPos, Random::Range( -0.85f, 0.25f ), childSize.height ) );
763   - child.ApplyConstraint( animConstraint );
  758 + Constraint animConstraint = Constraint::New < Vector3 > ( child, Actor::Property::POSITION, AnimateBubbleConstraint( childPos, Random::Range( -0.85f, 0.25f ), childSize.height ) );
  759 + animConstraint.AddSource( Source( mScrollView, ScrollView::Property::SCROLL_POSITION ) );
  760 + animConstraint.AddSource( Dali::ParentSource( Dali::Actor::Property::SIZE ) );
  761 + animConstraint.Apply();
764 762  
765 763 // Kickoff animation
766 764 Animation animation = Animation::New( Random::Range( 40.0f, 80.0f ) );
... ...
examples/blocks/blocks-example.cpp
... ... @@ -73,65 +73,6 @@ const int TOTAL_LEVELS(3); ///&lt;
73 73 // constraints ////////////////////////////////////////////////////////////////
74 74  
75 75 /**
76   - * CollisionConstraint generates a collision vector
77   - * between two actors a and b, assuming they're rectangular
78   - * based on their size.
79   - */
80   -struct CollisionConstraint
81   -{
82   - /**
83   - * Collision Constraint constructor
84   - * The adjust (optional) parameter can be used to add a margin
85   - * to the actors. A +ve size will result in larger collisions,
86   - * while a -ve size will result in tighter collisions.
87   - *
88   - * @param[in] adjust (optional) Adjusts the rectangular size detection
89   - */
90   - CollisionConstraint(Vector3 adjust = Vector3::ZERO)
91   - : mAdjust(adjust)
92   - {
93   - }
94   -
95   - /**
96   - * Generates collision vector indicating whether Actor's A and B
97   - * have overlapped eachother, and the relative position of Actor B to A.
98   - *
99   - * @param[in] current The current collision-property (ignored)
100   - * @param[in] propertyA Actor A's Position property.
101   - * @param[in] propertyB Actor B's Position property.
102   - * @param[in] propertySizeA Actor A's Size property.
103   - * @param[in] propertySizeB Actor B's Size property.
104   - * @return The collision vector is returned.
105   - */
106   - Vector3 operator()(const Vector3& current,
107   - const PropertyInput& propertyA,
108   - const PropertyInput& propertyB,
109   - const PropertyInput& propertySizeA,
110   - const PropertyInput& propertySizeB)
111   - {
112   - const Vector3& a = propertyA.GetVector3();
113   - const Vector3& b = propertyB.GetVector3();
114   - const Vector3& sizeA = propertySizeA.GetVector3();
115   - const Vector3& sizeB = propertySizeB.GetVector3();
116   - const Vector3 sizeComb = (sizeA + sizeB + mAdjust) * 0.5f;
117   -
118   - // get collision relative to a.
119   - Vector3 delta = b - a;
120   -
121   - // Check if not overlapping Actors.
122   - if( (fabsf(delta.x) > sizeComb.width) ||
123   - (fabsf(delta.y) > sizeComb.height) )
124   - {
125   - delta = Vector3::ZERO; // not overlapping
126   - }
127   -
128   - return delta; // overlapping, return overlap vector relative to actor a.
129   - }
130   -
131   - const Vector3 mAdjust; ///< Size Adjustment value
132   -};
133   -
134   -/**
135 76 * CollisionCircleRectangleConstraint generates a collision vector
136 77 * between two actors a (circle) and b (rectangle)
137 78 */
... ... @@ -157,23 +98,20 @@ struct CollisionCircleRectangleConstraint
157 98 * Generates collision vector indicating whether Actor's A and B
158 99 * have overlapped eachother, and the relative position of Actor B to A.
159 100 *
160   - * @param[in] current The current collision-property (ignored)
161   - * @param[in] propertyA Actor A's Position property.
162   - * @param[in] propertyB Actor B's Position property.
163   - * @param[in] propertySizeA Actor A's Size property.
164   - * @param[in] propertySizeB Actor B's Size property.
  101 + * @param[in,out] current The current collision-property
  102 + * @param[in] inputs Contains:
  103 + * Actor A's Position property.
  104 + * Actor B's Position property.
  105 + * Actor A's Size property.
  106 + * Actor B's Size property.
165 107 * @return The collision vector is returned.
166 108 */
167   - Vector3 operator()(const Vector3& current,
168   - const PropertyInput& propertyA,
169   - const PropertyInput& propertyB,
170   - const PropertyInput& propertySizeA,
171   - const PropertyInput& propertySizeB)
  109 + void operator()( Vector3& current, const PropertyInputContainer& inputs )
172 110 {
173   - const Vector3& a = propertyA.GetVector3();
174   - const Vector3 b = propertyB.GetVector3() + mAdjustPosition;
175   - const Vector3& sizeA = propertySizeA.GetVector3();
176   - const Vector3& sizeB = propertySizeB.GetVector3();
  111 + const Vector3& a = inputs[0]->GetVector3();
  112 + const Vector3 b = inputs[1]->GetVector3() + mAdjustPosition;
  113 + const Vector3& sizeA = inputs[2]->GetVector3();
  114 + const Vector3& sizeB = inputs[3]->GetVector3();
177 115 const Vector3 sizeA2 = sizeA * 0.5f; // circle radius
178 116 const Vector3 sizeB2 = (sizeB + mAdjustSize) * 0.5f; // rectangle half rectangle.
179 117  
... ... @@ -211,10 +149,12 @@ struct CollisionCircleRectangleConstraint
211 149 if(delta.Length() < sizeA2.x)
212 150 {
213 151 delta.Normalize();
214   - return delta;
  152 + current = delta;
  153 + }
  154 + else
  155 + {
  156 + current = Vector3::ZERO;
215 157 }
216   -
217   - return Vector3::ZERO;
218 158 }
219 159  
220 160 const Vector3 mAdjustPosition; ///< Position Adjustment value
... ... @@ -243,20 +183,17 @@ struct WobbleConstraint
243 183 }
244 184  
245 185 /**
246   - * @param[in] current The current rotation property (ignored)
247   - * @param[in] propertyWobble The wobble property (value from 0.0f to 1.0f)
  186 + * @param[in,out] current The current rotation property
  187 + * @param[in] inputs Contains the wobble property (value from 0.0f to 1.0f)
248 188 * @return The rotation (quaternion) is generated.
249 189 */
250   - Quaternion operator()(const Quaternion& current,
251   - const PropertyInput& propertyWobble)
  190 + void operator()( Quaternion& current, const PropertyInputContainer& inputs )
252 191 {
253   - const float& wobble = propertyWobble.GetFloat();
  192 + const float& wobble = inputs[0]->GetFloat();
254 193  
255 194 float f = sinf(wobble * 10.0f) * (1.0f-wobble);
256 195  
257   - Quaternion q(mDeviation * f, Vector3::ZAXIS);
258   -
259   - return q;
  196 + current = Quaternion(mDeviation * f, Vector3::ZAXIS);
260 197 }
261 198  
262 199 const float mDeviation; ///< Deviation factor in radians.
... ... @@ -348,10 +285,9 @@ private:
348 285 mPaddleImage.SetSize( mPaddleFullSize );
349 286  
350 287 mWobbleProperty = mPaddle.RegisterProperty(WOBBLE_PROPERTY_NAME, 0.0f);
351   - Constraint wobbleConstraint = Constraint::New<Quaternion>( Actor::Property::ORIENTATION,
352   - LocalSource(mWobbleProperty),
353   - WobbleConstraint(10.0f));
354   - mPaddle.ApplyConstraint(wobbleConstraint);
  288 + Constraint wobbleConstraint = Constraint::New<Quaternion>( mPaddle, Actor::Property::ORIENTATION, WobbleConstraint(10.0f));
  289 + wobbleConstraint.AddSource( LocalSource(mWobbleProperty) );
  290 + wobbleConstraint.Apply();
355 291  
356 292 mPaddle.SetPosition( stageSize * Vector3( PADDLE_START_POSITION ) );
357 293 mContentLayer.Add(mPaddle);
... ... @@ -377,13 +313,12 @@ private:
377 313 Actor delegate = Actor::New();
378 314 stage.Add(delegate);
379 315 Property::Index property = delegate.RegisterProperty(COLLISION_PROPERTY_NAME, Vector3::ZERO);
380   - Constraint constraint = Constraint::New<Vector3>( property,
381   - Source(mBall, Actor::Property::POSITION),
382   - Source(mPaddle, Actor::Property::POSITION),
383   - Source(mBall, Actor::Property::SIZE),
384   - Source(mPaddle, Actor::Property::SIZE),
385   - CollisionCircleRectangleConstraint( -Vector3(0.0f, mPaddleHitMargin.height * 0.575f, 0.0f),-Vector3(mPaddleHitMargin) ));
386   - delegate.ApplyConstraint(constraint);
  316 + Constraint constraint = Constraint::New<Vector3>( delegate, property, CollisionCircleRectangleConstraint( -Vector3(0.0f, mPaddleHitMargin.height * 0.575f, 0.0f),-Vector3(mPaddleHitMargin) ) );
  317 + constraint.AddSource( Source(mBall, Actor::Property::POSITION) );
  318 + constraint.AddSource( Source(mPaddle, Actor::Property::POSITION) );
  319 + constraint.AddSource( Source(mBall, Actor::Property::SIZE) );
  320 + constraint.AddSource( Source(mPaddle, Actor::Property::SIZE) );
  321 + constraint.Apply();
387 322  
388 323 PropertyNotification paddleNotification = delegate.AddPropertyNotification( property, GreaterThanCondition(0.0f) );
389 324 paddleNotification.NotifySignal().Connect( this, &ExampleController::OnHitPaddle );
... ... @@ -602,13 +537,12 @@ private:
602 537  
603 538 // Add a constraint on the brick between it and the ball generating a collision-property
604 539 Property::Index property = brick.RegisterProperty(COLLISION_PROPERTY_NAME, Vector3::ZERO);
605   - Constraint constraint = Constraint::New<Vector3>( property,
606   - Source(mBall, Actor::Property::POSITION),
607   - Source(brick, Actor::Property::POSITION),
608   - Source(mBall, Actor::Property::SIZE),
609   - Source(brick, Actor::Property::SIZE),
610   - CollisionCircleRectangleConstraint(BRICK_COLLISION_MARGIN));
611   - brick.ApplyConstraint(constraint);
  540 + Constraint constraint = Constraint::New<Vector3>( brick, property, CollisionCircleRectangleConstraint(BRICK_COLLISION_MARGIN) );
  541 + constraint.AddSource( Source(mBall, Actor::Property::POSITION) );
  542 + constraint.AddSource( Source(brick, Actor::Property::POSITION) );
  543 + constraint.AddSource( Source(mBall, Actor::Property::SIZE) );
  544 + constraint.AddSource( Source(brick, Actor::Property::SIZE) );
  545 + constraint.Apply();
612 546  
613 547 // Now add a notification on this collision-property
614 548  
... ...
examples/cluster/cluster-example.cpp
... ... @@ -183,15 +183,16 @@ struct CarouselEffectOrientationConstraint
183 183 * @param[in] current The object's current property value
184 184 * @return The object's new property value
185 185 */
186   - Vector2 operator()(const Vector2& current,
187   - const PropertyInput& propertyOrientation)
  186 + void operator()( Vector2& current, const PropertyInputContainer& inputs )
188 187 {
189 188 Vector3 axis;
190 189 float angle;
191   - propertyOrientation.GetQuaternion().ToAxisAngle( axis, angle );
192   - Vector2 direction( cosf(angle), sinf(angle) );
  190 + inputs[0]->GetQuaternion().ToAxisAngle( axis, angle );
  191 +
  192 + current.x = cosf(angle);
  193 + current.y = sinf(angle);
193 194  
194   - return mAngleSweep * direction;
  195 + current *= mAngleSweep;
195 196 }
196 197  
197 198 Vector2 mAngleSweep;
... ... @@ -220,16 +221,13 @@ struct ShearEffectConstraint
220 221 }
221 222  
222 223 /**
223   - * @param[in] current The current shear effect Angle.
224   - * @param[in] scrollOvershootProperty The overshoot property from ScrollView
225   - * @param[in] propertyViewOrientation The orientation of the view e.g. Portrait, Landscape.
  224 + * @param[in,out] current The current shear effect Angle.
  225 + * @param[in] inputs Contains the overshoot property from ScrollView and the orientation of the view e.g. Portrait, Landscape.
226 226 * @return angle to provide ShearShaderEffect
227 227 */
228   - float operator()(const float& current,
229   - const PropertyInput& scrollOvershootProperty,
230   - const PropertyInput& propertyViewOrientation)
  228 + void operator()( float& current, const PropertyInputContainer& inputs )
231 229 {
232   - float f = scrollOvershootProperty.GetVector3().x;
  230 + float f = inputs[0]->GetVector3().x;
233 231  
234 232 float mag = fabsf(f);
235 233 float halfWidth = mStageSize.x * 0.5f;
... ... @@ -245,11 +243,11 @@ struct ShearEffectConstraint
245 243 // the component mask passed in.
246 244 Vector3 axis;
247 245 float angle;
248   - propertyViewOrientation.GetQuaternion().ToAxisAngle( axis, angle );
  246 + inputs[1]->GetQuaternion().ToAxisAngle( axis, angle );
249 247 Vector2 direction( cosf(angle), sinf(angle) );
250 248 float yield = direction.x * mComponentMask.x + direction.y * mComponentMask.y;
251 249  
252   - return overshoot * mMaxOvershoot * yield;
  250 + current = overshoot * mMaxOvershoot * yield;
253 251 }
254 252  
255 253 Vector2 mStageSize;
... ... @@ -276,15 +274,15 @@ struct ShearEffectCenterConstraint
276 274 }
277 275  
278 276 /**
279   - * @param[in] current The current center
280   - * @param[in] propertyViewSize The current view size
  277 + * @param[in,out] current The current center
  278 + * @param[in] inputs Contains the current view size
281 279 * @return vector to provide ShearShaderEffect
282 280 */
283   - Vector2 operator()(const Vector2& current,
284   - const PropertyInput& propertyViewSize)
  281 + void operator()( Vector2& current, const PropertyInputContainer& inputs )
285 282 {
286   - float f = propertyViewSize.GetVector3().width / mStageSize.width;
287   - return Vector2( f * mCenter.x, mCenter.y );
  283 + float f = inputs[0]->GetVector3().width / mStageSize.width;
  284 + current.x = f * mCenter.x;
  285 + current.y = mCenter.y;
288 286 }
289 287  
290 288 Vector2 mStageSize;
... ... @@ -313,9 +311,9 @@ struct SphereEffectOffsetConstraint
313 311 * @param[in] propertyViewSize The current view size
314 312 * @return vector to provide SphereShaderEffect
315 313 */
316   - float operator()(const float& current)
  314 + void operator()( float& current, const PropertyInputContainer& /* inputs */ )
317 315 {
318   - return current + mOffset;
  316 + current += mOffset;
319 317 }
320 318  
321 319 float mOffset;
... ... @@ -375,11 +373,11 @@ struct ClusterInfo
375 373 }
376 374  
377 375  
378   - Cluster mCluster; ///< Cluster instance
379   - int mIndex; ///< Cluster index
380   - Vector3 mPosition; ///< Cluster original position
381   - Vector3 mSize; ///< Cluster original size
382   - ActiveConstraint mEffectConstraint; ///< Cluster constraint
  376 + Cluster mCluster; ///< Cluster instance
  377 + int mIndex; ///< Cluster index
  378 + Vector3 mPosition; ///< Cluster original position
  379 + Vector3 mSize; ///< Cluster original size
  380 + Constraint mEffectConstraint; ///< Cluster constraint
383 381 };
384 382  
385 383 /**
... ... @@ -691,7 +689,7 @@ public:
691 689 RemoveShaderEffectRecursively( cluster );
692 690 if( i->mEffectConstraint )
693 691 {
694   - cluster.RemoveConstraint(i->mEffectConstraint);
  692 + i->mEffectConstraint.Remove();
695 693 i->mEffectConstraint.Reset();
696 694 }
697 695 }
... ... @@ -721,10 +719,10 @@ public:
721 719  
722 720 Vector2 shearCenter( Vector2(position.x + size.width * shearAnchor.x, position.y + size.height * shearAnchor.y) );
723 721 Property::Index centerProperty = shaderEffect.GetPropertyIndex(shaderEffect.GetCenterPropertyName());
724   - Constraint constraint = Constraint::New<Vector2>( centerProperty,
725   - Source(mView, Actor::Property::SIZE),
726   - ShearEffectCenterConstraint(stageSize, shearCenter) );
727   - shaderEffect.ApplyConstraint(constraint);
  722 + Constraint constraint = Constraint::New<Vector2>( shaderEffect, centerProperty, ShearEffectCenterConstraint(stageSize, shearCenter) );
  723 + constraint.AddSource( Source(mView, Actor::Property::SIZE) );
  724 +
  725 + constraint.Apply();
728 726  
729 727 SetShaderEffectRecursively( cluster,shaderEffect );
730 728  
... ... @@ -733,16 +731,15 @@ public:
733 731 Property::Index angleXAxisProperty = shaderEffect.GetPropertyIndex(shaderEffect.GetAngleXAxisPropertyName());
734 732 Property::Index angleYAxisProperty = shaderEffect.GetPropertyIndex(shaderEffect.GetAngleYAxisPropertyName());
735 733  
736   - constraint = Constraint::New<float>( angleXAxisProperty,
737   - Source(mScrollView, scrollOvershootProperty),
738   - Source(mView, Actor::Property::ORIENTATION),
739   - ShearEffectConstraint(stageSize, SHEAR_EFFECT_MAX_OVERSHOOT, Vector2::XAXIS) );
740   - shaderEffect.ApplyConstraint(constraint);
741   - constraint = Constraint::New<float>( angleYAxisProperty,
742   - Source(mScrollView, scrollOvershootProperty),
743   - Source(mView, Actor::Property::ORIENTATION),
744   - ShearEffectConstraint(stageSize, SHEAR_EFFECT_MAX_OVERSHOOT, Vector2::YAXIS) );
745   - shaderEffect.ApplyConstraint(constraint);
  734 + constraint = Constraint::New<float>( shaderEffect, angleXAxisProperty, ShearEffectConstraint(stageSize, SHEAR_EFFECT_MAX_OVERSHOOT, Vector2::XAXIS) );
  735 + constraint.AddSource( Source(mScrollView, scrollOvershootProperty) );
  736 + constraint.AddSource( Source(mView, Actor::Property::ORIENTATION) );
  737 + constraint.Apply();
  738 +
  739 + constraint = Constraint::New<float>( shaderEffect, angleYAxisProperty, ShearEffectConstraint(stageSize, SHEAR_EFFECT_MAX_OVERSHOOT, Vector2::YAXIS ) );
  740 + constraint.AddSource( Source(mScrollView, scrollOvershootProperty) );
  741 + constraint.AddSource( Source(mView, Actor::Property::ORIENTATION) );
  742 + constraint.Apply();
746 743  
747 744  
748 745 }
... ... @@ -766,9 +763,9 @@ public:
766 763 CAROUSEL_EFFECT_ANGLE_SWEEP / stageSize.width );
767 764  
768 765 Property::Index anglePerUnit = shaderEffect.GetPropertyIndex( shaderEffect.GetAnglePerUnitPropertyName() );
769   - shaderEffect.ApplyConstraint( Constraint::New<Vector2>( anglePerUnit,
770   - Source(mView, Actor::Property::ORIENTATION),
771   - CarouselEffectOrientationConstraint( angleSweep ) ) );
  766 + Constraint constraint = Constraint::New<Vector2>( shaderEffect, anglePerUnit, CarouselEffectOrientationConstraint( angleSweep ) );
  767 + constraint.AddSource( Source(mView, Actor::Property::ORIENTATION) );
  768 + constraint.Apply();
772 769  
773 770 break;
774 771 }
... ... @@ -794,11 +791,11 @@ public:
794 791 // dont apply shader effect to scrollview as it might override internal shaders for bounce effect etc
795 792 for( std::vector<ClusterInfo>::iterator i = mClusterInfo.begin(); i != mClusterInfo.end(); ++i )
796 793 {
797   - Constraint constraint = Constraint::New<float>(Actor::Property::POSITION_Z, SphereEffectOffsetConstraint(SPHERE_EFFECT_POSITION_Z));
798   - constraint.SetRemoveAction(Constraint::Discard);
799 794 Cluster cluster = i->mCluster;
  795 + i->mEffectConstraint = Constraint::New<float>( cluster, Actor::Property::POSITION_Z, SphereEffectOffsetConstraint( SPHERE_EFFECT_POSITION_Z ) );
  796 + i->mEffectConstraint.SetRemoveAction(Constraint::Discard);
800 797 SetShaderEffectRecursively( cluster, shaderEffect );
801   - i->mEffectConstraint = cluster.ApplyConstraint(constraint);
  798 + i->mEffectConstraint.Apply();
802 799 }
803 800 break;
804 801 }
... ...
examples/magnifier/magnifier-example.cpp
... ... @@ -57,20 +57,16 @@ struct MagnifierPathConstraint
57 57 {
58 58 }
59 59  
60   - Vector3 operator()(const Vector3& current,
61   - const PropertyInput& sizeProperty,
62   - const PropertyInput& animationTimeProperty)
  60 + void operator()( Vector3& current, const PropertyInputContainer& inputs )
63 61 {
64   - float time = animationTimeProperty.GetFloat();
65   - const Vector3& size = sizeProperty.GetVector3();
  62 + float time = inputs[1]->GetFloat();
  63 + const Vector3& size = inputs[0]->GetVector3();
66 64  
67   - Vector3 range(mStageSize - size - Vector3::ONE * MAGNIFIER_INDENT * 2.0f);
68   - Vector3 position(mOffset);
  65 + current = mOffset;
69 66  
70   - position.x += 0.5f * sinf(time * 0.471f) * range.width;
71   - position.y += 0.5f * sinf(time * 0.8739f) * range.height;
72   -
73   - return position;
  67 + Vector3 range( mStageSize - size - Vector3::ONE * MAGNIFIER_INDENT * 2.0f );
  68 + current.x += 0.5f * sinf(time * 0.471f) * range.width;
  69 + current.y += 0.5f * sinf(time * 0.8739f) * range.height;
74 70 }
75 71  
76 72 Vector3 mStageSize; ///< Keep track of the stage size for determining path within stage bounds
... ... @@ -103,23 +99,19 @@ struct ConfinementConstraint
103 99 {
104 100 }
105 101  
106   - Vector3 operator()(const Vector3& constPosition,
107   - const PropertyInput& sizeProperty,
108   - const PropertyInput& parentOriginProperty,
109   - const PropertyInput& anchorPointProperty,
110   - const PropertyInput& referenceSizeProperty)
  102 + void operator()( Vector3& current, const PropertyInputContainer& inputs )
111 103 {
112   - const Vector3& size = sizeProperty.GetVector3();
113   - const Vector3 origin = parentOriginProperty.GetVector3();
114   - const Vector3& anchor = anchorPointProperty.GetVector3();
115   - const Vector3& referenceSize = referenceSizeProperty.GetVector3();
  104 + const Vector3& size = inputs[0]->GetVector3();
  105 + const Vector3 origin = inputs[1]->GetVector3();
  106 + const Vector3& anchor = inputs[2]->GetVector3();
  107 + const Vector3& referenceSize = inputs[3]->GetVector3();
116 108  
117 109 Vector3 offset(mOffsetOrigin * referenceSize);
118 110  
119   - Vector3 newPosition( constPosition + offset );
120   -
121 111 // Get actual position of Actor relative to parent's Top-Left.
122   - Vector3 position(constPosition + offset + origin * referenceSize);
  112 + Vector3 position(current + offset + origin * referenceSize);
  113 +
  114 + current += offset;
123 115  
124 116 // if top-left corner is outside of Top-Left bounds, then push back in screen.
125 117 Vector3 corner(position - size * anchor - mMinIndent);
... ... @@ -127,17 +119,17 @@ struct ConfinementConstraint
127 119 if(mFlipHorizontal && corner.x < 0.0f)
128 120 {
129 121 corner.x = 0.0f;
130   - newPosition.x += size.width;
  122 + current.x += size.width;
131 123 }
132 124  
133 125 if(mFlipVertical && corner.y < 0.0f)
134 126 {
135 127 corner.y = 0.0f;
136   - newPosition.y += size.height;
  128 + current.y += size.height;
137 129 }
138 130  
139   - newPosition.x -= std::min(corner.x, 0.0f);
140   - newPosition.y -= std::min(corner.y, 0.0f);
  131 + current.x -= std::min(corner.x, 0.0f);
  132 + current.y -= std::min(corner.y, 0.0f);
141 133  
142 134 // if bottom-right corner is outside of Bottom-Right bounds, then push back in screen.
143 135 corner += size - referenceSize + mMinIndent + mMaxIndent;
... ... @@ -145,19 +137,17 @@ struct ConfinementConstraint
145 137 if(mFlipHorizontal && corner.x > 0.0f)
146 138 {
147 139 corner.x = 0.0f;
148   - newPosition.x -= size.width;
  140 + current.x -= size.width;
149 141 }
150 142  
151 143 if(mFlipVertical && corner.y > 0.0f)
152 144 {
153 145 corner.y = 0.0f;
154   - newPosition.y -= size.height;
  146 + current.y -= size.height;
155 147 }
156 148  
157   - newPosition.x -= std::max(corner.x, 0.0f);
158   - newPosition.y -= std::max(corner.y, 0.0f);
159   -
160   - return newPosition;
  149 + current.x -= std::max(corner.x, 0.0f);
  150 + current.y -= std::max(corner.y, 0.0f);
161 151 }
162 152  
163 153 Vector3 mOffsetOrigin; ///< Manual Parent Offset Origin.
... ... @@ -244,14 +234,13 @@ public:
244 234 overlay.Add( mMagnifier );
245 235  
246 236 // Apply constraint to animate the position of the magnifier.
247   - Constraint constraint = Constraint::New<Vector3>(Actor::Property::POSITION,
248   - LocalSource(Actor::Property::SIZE),
249   - LocalSource(Actor::Property::PARENT_ORIGIN),
250   - LocalSource(Actor::Property::ANCHOR_POINT),
251   - ParentSource(Actor::Property::SIZE),
252   - ConfinementConstraint(ParentOrigin::CENTER, Vector2::ONE * MAGNIFIER_INDENT, Vector2::ONE * MAGNIFIER_INDENT));
  237 + Constraint constraint = Constraint::New<Vector3>( mMagnifier, Actor::Property::POSITION, ConfinementConstraint(ParentOrigin::CENTER, Vector2::ONE * MAGNIFIER_INDENT, Vector2::ONE * MAGNIFIER_INDENT) );
  238 + constraint.AddSource( LocalSource(Actor::Property::SIZE) );
  239 + constraint.AddSource( LocalSource(Actor::Property::PARENT_ORIGIN) );
  240 + constraint.AddSource( LocalSource(Actor::Property::ANCHOR_POINT) );
  241 + constraint.AddSource( ParentSource(Actor::Property::SIZE) );
253 242 constraint.SetRemoveAction(Constraint::Discard);
254   - mMagnifier.ApplyConstraint( constraint );
  243 + constraint.Apply();
255 244  
256 245 // Create bouncing magnifier automatically bounces around screen.
257 246 mBouncingMagnifier = Toolkit::Magnifier::New();
... ... @@ -265,18 +254,16 @@ public:
265 254 ContinueAnimation();
266 255  
267 256 // Apply constraint to animate the position of the magnifier.
268   - constraint = Constraint::New<Vector3>(Actor::Property::POSITION,
269   - LocalSource(Actor::Property::SIZE),
270   - LocalSource(mAnimationTimeProperty),
271   - MagnifierPathConstraint(mStageSize, mStageSize * 0.5f));
272   - mBouncingMagnifier.ApplyConstraint( constraint );
  257 + constraint = Constraint::New<Vector3>( mBouncingMagnifier, Actor::Property::POSITION, MagnifierPathConstraint(mStageSize, mStageSize * 0.5f) );
  258 + constraint.AddSource( LocalSource(Actor::Property::SIZE) );
  259 + constraint.AddSource( LocalSource(mAnimationTimeProperty) );
  260 + constraint.Apply();
273 261  
274 262 // Apply constraint to animate the source of the magnifier.
275   - constraint = Constraint::New<Vector3>(mBouncingMagnifier.GetPropertyIndex( Toolkit::Magnifier::SOURCE_POSITION_PROPERTY_NAME ),
276   - LocalSource(Actor::Property::SIZE),
277   - LocalSource(mAnimationTimeProperty),
278   - MagnifierPathConstraint(mStageSize));
279   - mBouncingMagnifier.ApplyConstraint( constraint );
  263 + constraint = Constraint::New<Vector3>( mBouncingMagnifier, mBouncingMagnifier.GetPropertyIndex( Toolkit::Magnifier::SOURCE_POSITION_PROPERTY_NAME ), MagnifierPathConstraint(mStageSize) );
  264 + constraint.AddSource( LocalSource(Actor::Property::SIZE) );
  265 + constraint.AddSource( LocalSource(mAnimationTimeProperty) );
  266 + constraint.Apply();
280 267 }
281 268  
282 269 /**
... ...
examples/radial-menu/radial-sweep-view-impl.cpp
... ... @@ -26,9 +26,8 @@ namespace
26 26 * Method to project a point on a circle of radius halfSide at given
27 27 * angle onto a square of side 2 * halfSide
28 28 */
29   -Vector3 CircleSquareProjection( Degree angle, float halfSide )
  29 +void CircleSquareProjection( Vector3& position, Degree angle, float halfSide )
30 30 {
31   - Vector3 position(0.0f, 0.0f, 0.0f);
32 31 Radian angleInRadians(angle);
33 32  
34 33 // 135 90 45
... ... @@ -58,7 +57,8 @@ Vector3 CircleSquareProjection( Degree angle, float halfSide )
58 57 position.x = halfSide;
59 58 position.y = -halfSide * sinf(angleInRadians) / cosf(angleInRadians);
60 59 }
61   - return position;
  60 +
  61 + position.z = 0.0f;
62 62 }
63 63  
64 64 float HoldZeroFastEaseInOutHoldOne(float progress)
... ... @@ -88,9 +88,9 @@ struct SquareFanConstraint
88 88 {
89 89 }
90 90  
91   - Vector3 operator()( const Vector3& current, const PropertyInput& start, const PropertyInput& rotation )
  91 + void operator()( Vector3& current, const PropertyInputContainer& inputs )
92 92 {
93   - float degree = fmodf((start.GetFloat() + rotation.GetFloat()), 360.0f);
  93 + float degree = fmodf((inputs[0]->GetFloat() + inputs[1]->GetFloat()), 360.0f);
94 94 if(degree < 0.0f)
95 95 {
96 96 degree += 360.0f;
... ... @@ -100,15 +100,17 @@ struct SquareFanConstraint
100 100 float endAngle = (90.0f*mSideIndex)+45.0f;
101 101 if(degree < startAngle)
102 102 {
103   - return Vector3::ZERO;
  103 + current = Vector3::ZERO;
104 104 }
105   - else if( degree >= endAngle )
  105 + else
106 106 {
107   - degree = endAngle;
  107 + if( degree >= endAngle )
  108 + {
  109 + degree = endAngle;
  110 + }
  111 + CircleSquareProjection( current, Degree(degree), 0.5f );
  112 + current.x = -current.x; // Inverting X makes the animation go anti clockwise from left center
108 113 }
109   - Vector3 pos = CircleSquareProjection(Degree(degree), 0.5f);
110   - pos.x = -pos.x; // Inverting X makes the animation go anti clockwise from left center
111   - return pos;
112 114 }
113 115  
114 116 int mSideIndex;
... ... @@ -362,18 +364,35 @@ void RadialSweepViewImpl::CreateStencil( Degree initialSector )
362 364  
363 365 // Constrain the vertices of the square mesh to sweep out a sector as the
364 366 // rotation angle is animated.
365   - mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(1, AnimatableVertex::Property::POSITION),
366   - srcStart, srcStart, SquareFanConstraint(0)));
367   - mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(2, AnimatableVertex::Property::POSITION),
368   - srcStart, srcRot, SquareFanConstraint(0)));
369   - mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(3, AnimatableVertex::Property::POSITION),
370   - srcStart, srcRot, SquareFanConstraint(1)));
371   - mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(4, AnimatableVertex::Property::POSITION),
372   - srcStart, srcRot, SquareFanConstraint(2)));
373   - mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(5, AnimatableVertex::Property::POSITION),
374   - srcStart, srcRot, SquareFanConstraint(3)));
375   - mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(6, AnimatableVertex::Property::POSITION),
376   - srcStart, srcRot, SquareFanConstraint(4)));
  367 + Constraint constraint = Constraint::New<Vector3>( mMesh, mMesh.GetPropertyIndex(1, AnimatableVertex::Property::POSITION), SquareFanConstraint(0) );
  368 + constraint.AddSource( srcStart );
  369 + constraint.AddSource( srcStart );
  370 + constraint.Apply();
  371 +
  372 + constraint = Constraint::New<Vector3>( mMesh, mMesh.GetPropertyIndex(2, AnimatableVertex::Property::POSITION), SquareFanConstraint(0) );
  373 + constraint.AddSource( srcStart );
  374 + constraint.AddSource( srcRot );
  375 + constraint.Apply();
  376 +
  377 + constraint = Constraint::New<Vector3>( mMesh, mMesh.GetPropertyIndex(3, AnimatableVertex::Property::POSITION), SquareFanConstraint(1) );
  378 + constraint.AddSource( srcStart );
  379 + constraint.AddSource( srcRot );
  380 + constraint.Apply();
  381 +
  382 + constraint = Constraint::New<Vector3>( mMesh, mMesh.GetPropertyIndex(4, AnimatableVertex::Property::POSITION), SquareFanConstraint(2) );
  383 + constraint.AddSource( srcStart );
  384 + constraint.AddSource( srcRot );
  385 + constraint.Apply();
  386 +
  387 + constraint = Constraint::New<Vector3>( mMesh, mMesh.GetPropertyIndex(5, AnimatableVertex::Property::POSITION), SquareFanConstraint(3) );
  388 + constraint.AddSource( srcStart );
  389 + constraint.AddSource( srcRot );
  390 + constraint.Apply();
  391 +
  392 + constraint = Constraint::New<Vector3>( mMesh, mMesh.GetPropertyIndex(6, AnimatableVertex::Property::POSITION), SquareFanConstraint(4) );
  393 + constraint.AddSource( srcStart );
  394 + constraint.AddSource( srcRot );
  395 + constraint.Apply();
377 396  
378 397 mStencilActor.SetDrawMode( DrawMode::STENCIL );
379 398 mStencilActor.SetPositionInheritanceMode(USE_PARENT_POSITION);
... ...
examples/refraction-effect/refraction-effect-example.cpp
... ... @@ -56,10 +56,13 @@ struct LightOffsetConstraint
56 56 {
57 57 }
58 58  
59   - Vector2 operator()( const Vector2& current, const PropertyInput& spinAngleProperty)
  59 + void operator()( Vector2& current, const PropertyInputContainer& inputs )
60 60 {
61   - float spinAngle = spinAngleProperty.GetFloat();
62   - return Vector2( cos(spinAngle ), sin( spinAngle ) ) * mRadius;
  61 + float spinAngle = inputs[0]->GetFloat();
  62 + current.x = cos( spinAngle );
  63 + current.y = sin( spinAngle );
  64 +
  65 + current *= mRadius;
63 66 }
64 67  
65 68 float mRadius;
... ... @@ -254,10 +257,9 @@ public:
254 257 handle.SetUniform( "uLightIntensity", 2.5f );
255 258  
256 259 Dali::Property::Index index = handle.RegisterProperty( "uSpinAngle", 0.f );
257   - Constraint constraint = Constraint::New<Vector2>( handle.GetPropertyIndex("uLightSpinOffset"),
258   - LocalSource(index),
259   - LightOffsetConstraint(stageSize.x*0.1f));
260   - handle.ApplyConstraint( constraint );
  260 + Constraint constraint = Constraint::New<Vector2>( handle, handle.GetPropertyIndex("uLightSpinOffset"), LightOffsetConstraint(stageSize.x*0.1f) );
  261 + constraint.AddSource( LocalSource(index) );
  262 + constraint.Apply();
261 263  
262 264 return handle;
263 265 }
... ...
examples/shadow-bone-lighting/shadow-bone-lighting-example.cpp
... ... @@ -100,23 +100,10 @@ public:
100 100 {
101 101 }
102 102  
103   - Vector3 operator()( const Vector3& current, const PropertyInput& property )
  103 + void operator()( Vector3& current, const PropertyInputContainer& inputs )
104 104 {
105   - Vector3 position = property.GetVector3();
106   - position.z += 1.0f;
107   - return position;
108   - }
109   - };
110   -
111   - struct QuaternionEqualToConstraint
112   - {
113   - QuaternionEqualToConstraint()
114   - {
115   - }
116   -
117   - Quaternion operator()( const Quaternion& current, const PropertyInput& property )
118   - {
119   - return property.GetQuaternion();
  105 + current = inputs[0]->GetVector3();
  106 + current.z += 1.0f;
120 107 }
121 108 };
122 109  
... ... @@ -127,10 +114,10 @@ public:
127 114 {
128 115 }
129 116  
130   - Quaternion operator()( const Quaternion& current, const PropertyInput& property )
  117 + void operator()( Quaternion& current, const PropertyInputContainer& inputs )
131 118 {
132   - Degree angle(property.GetFloat());
133   - return Quaternion( Radian(angle) * mSign, Vector3::YAXIS );
  119 + Degree angle( inputs[0]->GetFloat() );
  120 + current = Quaternion( Radian(angle) * mSign, Vector3::YAXIS );
134 121 }
135 122  
136 123 float mSign;
... ... @@ -284,10 +271,14 @@ public:
284 271  
285 272 Property::Index angleIndex = mImageActor2.RegisterProperty("angle", Property::Value(30.0f));
286 273 Source angleSrc( mImageActor2, angleIndex );
287   - mImageActor1.ApplyConstraint(Constraint::New<Quaternion>( Actor::Property::ORIENTATION, angleSrc,
288   - RotationConstraint(-1.0f)));
289   - mImageActor3.ApplyConstraint(Constraint::New<Quaternion>( Actor::Property::ORIENTATION, angleSrc,
290   - RotationConstraint(+1.0f)));
  274 +
  275 + Constraint constraint = Constraint::New<Quaternion>( mImageActor1, Actor::Property::ORIENTATION, RotationConstraint(-1.0f) );
  276 + constraint.AddSource( angleSrc );
  277 + constraint.Apply();
  278 +
  279 + constraint = Constraint::New<Quaternion>( mImageActor3, Actor::Property::ORIENTATION, RotationConstraint(+1.0f) );
  280 + constraint.AddSource( angleSrc );
  281 + constraint.Apply();
291 282  
292 283 mSceneAnimation = Animation::New(2.5f);
293 284  
... ...