Commit 024c72f63456636f025a4771231a0e20e19ffe0b

Authored by Tom Robinson
1 parent 4757ec2b

Dali-demo: Replace constraints with SizeMode

Change-Id: I7a7f59aa5f557a8a57385e876fd881d87c101a28
demo/dali-table-view.cpp
... ... @@ -258,8 +258,9 @@ void DaliTableView::Initialize( Application& application )
258 258  
259 259 mScrollView.SetAnchorPoint( AnchorPoint::CENTER );
260 260 mScrollView.SetParentOrigin( ParentOrigin::CENTER );
261   - mScrollView.ApplyConstraint( Dali::Constraint::New<Dali::Vector3>( Dali::Actor::SIZE, Dali::ParentSource( Dali::Actor::SIZE ),
262   - Dali::RelativeToConstraint( SCROLLVIEW_RELATIVE_SIZE ) ) );
  261 + // Note: Currently, changing mScrollView to use SizeMode RELATIVE_TO_PARENT
  262 + // will cause scroll ends to appear in the wrong position.
  263 + mScrollView.ApplyConstraint( Dali::Constraint::New<Dali::Vector3>( Dali::Actor::SIZE, Dali::ParentSource( Dali::Actor::SIZE ), Dali::RelativeToConstraint( SCROLLVIEW_RELATIVE_SIZE ) ) );
263 264 mScrollView.SetAxisAutoLock( true );
264 265 mScrollView.ScrollCompletedSignal().Connect( this, &DaliTableView::OnScrollComplete );
265 266 mScrollView.ScrollStartedSignal().Connect( this, &DaliTableView::OnScrollStart );
... ... @@ -356,7 +357,7 @@ void DaliTableView::Populate()
356 357  
357 358 page.SetAnchorPoint( AnchorPoint::CENTER );
358 359 page.SetParentOrigin( ParentOrigin::CENTER );
359   - page.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
  360 + page.SetSizeMode( SIZE_EQUAL_TO_PARENT );
360 361  
361 362 // add cells to table
362 363 const float margin = 4.0f;
... ... @@ -465,7 +466,7 @@ Actor DaliTableView::CreateTile( const std::string&amp; name, const std::string&amp; tit
465 466 image.SetAnchorPoint( AnchorPoint::CENTER );
466 467 image.SetParentOrigin( ParentOrigin::CENTER );
467 468 // make the image 100% of tile
468   - image.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
  469 + image.SetSizeMode( SIZE_EQUAL_TO_PARENT );
469 470 // move image back to get text appear in front
470 471 image.SetZ( -1 );
471 472 image.SetStyle( ImageActor::STYLE_NINE_PATCH );
... ... @@ -474,7 +475,7 @@ Actor DaliTableView::CreateTile( const std::string&amp; name, const std::string&amp; tit
474 475  
475 476 // Add stencil
476 477 ImageActor stencil = NewStencilImage();
477   - stencil.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
  478 + stencil.SetSizeMode( SIZE_EQUAL_TO_PARENT );
478 479 image.Add( stencil );
479 480 }
480 481  
... ... @@ -733,7 +734,7 @@ void DaliTableView::AddBackgroundActors( Actor layer, int count, BitmapImage dis
733 734 Constraint animConstraint = Constraint::New < Vector3 > ( Actor::POSITION,
734 735 Source( mScrollView, mScrollView.GetPropertyIndex( ScrollView::SCROLL_POSITION_PROPERTY_NAME ) ),
735 736 Dali::ParentSource( Dali::Actor::SIZE ),
736   - AnimateBubbleConstraint( actorPos, Random::Range( -0.85f, 0.35f ), randSize ) );
  737 + AnimateBubbleConstraint( actorPos, Random::Range( -0.85f, 0.25f ), randSize ) );
737 738 dfActor.ApplyConstraint( animConstraint );
738 739  
739 740 // Kickoff animation
... ...
examples/blocks/blocks-example.cpp
... ... @@ -423,7 +423,7 @@ private:
423 423 mLevelContainer = Actor::New();
424 424 mLevelContainer.SetAnchorPoint( AnchorPoint::CENTER );
425 425 mLevelContainer.SetParentOrigin( ParentOrigin::CENTER );
426   - mLevelContainer.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
  426 + mLevelContainer.SetSizeMode( SIZE_EQUAL_TO_PARENT );
427 427 mContentLayer.Add( mLevelContainer );
428 428  
429 429 mBrickCount = 0;
... ...
examples/cluster/cluster-example.cpp
... ... @@ -199,33 +199,6 @@ struct CarouselEffectOrientationConstraint
199 199 };
200 200  
201 201 /**
202   - * RescaleConstraint
203   - * Rescales the inputer scale by the ratio of the height:width of it's parent.
204   - */
205   -struct RescaleConstraint
206   -{
207   - /**
208   - * Constructor
209   - * @param[in] value0 Constant multiplication operand (K).
210   - */
211   - RescaleConstraint()
212   - {
213   - }
214   -
215   - /**
216   - * @param[in] current The object's current property value
217   - * @param[in] property0 The first property to multiplication operand
218   - * @return The object's new property value
219   - */
220   - Vector3 operator()(const Vector3& current,
221   - const PropertyInput& property0)
222   - {
223   - return current * Vector3( property0.GetVector3().y / property0.GetVector3().x, 1.0f, 1.0f );
224   - }
225   -
226   -};
227   -
228   -/**
229 202 * ShearEffectConstraint
230 203 *
231 204 * Constrains ShearEffect's tilt to be a function of scrollview's
... ... @@ -514,12 +487,8 @@ public:
514 487 mScrollView.SetAnchorPoint(AnchorPoint::CENTER);
515 488 mScrollView.SetParentOrigin(ParentOrigin::CENTER);
516 489  
517   - // Scale ScrollView to fit within parent (mContentLayer)
518   - Constraint constraint = Constraint::New<Vector3>( Actor::SCALE,
519   - LocalSource( Actor::SIZE ),
520   - ParentSource( Actor::SIZE ),
521   - ScaleToFitConstraint() );
522   - mScrollView.ApplyConstraint(constraint);
  490 + // Scale ScrollView to fit parent (mContentLayer)
  491 + mScrollView.SetSizeMode( SIZE_EQUAL_TO_PARENT );
523 492  
524 493 // Add the scroll view to the content layer
525 494 mContentLayer.Add(mScrollView);
... ... @@ -649,14 +618,7 @@ public:
649 618 mScrollView.Add(pageView);
650 619 pageView.SetParentOrigin(ParentOrigin::CENTER);
651 620 pageView.SetPosition(Vector3(stageSize.width * column, 0.0f, 0.0f));
652   - pageView.SetSize(stageSize);
653   -
654   - // Resize pageView (which contains a Cluster)
655   - Constraint constraintScale = Constraint::New<Vector3>( Actor::SCALE,
656   - ParentSource( Actor::SCALE ),
657   - RescaleConstraint() );
658   - constraintScale.SetRemoveAction(Constraint::Discard);
659   - pageView.ApplyConstraint(constraintScale);
  621 + pageView.SetSizeMode( SIZE_EQUAL_TO_PARENT );
660 622  
661 623 // Create cluster actors, add them to scroll view, and set the shear effect with the given center point.
662 624 Cluster cluster = CreateClusterActor(clusterType, style);
... ...
examples/image/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp
... ... @@ -416,7 +416,7 @@ public:
416 416 // coordinates in a frame defined by a parent actor:
417 417  
418 418 Actor gridActor = Actor::New();
419   - gridActor.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
  419 + gridActor.SetSizeMode( SIZE_EQUAL_TO_PARENT );
420 420 gridActor.SetParentOrigin( ParentOrigin::CENTER );
421 421 gridActor.SetAnchorPoint( AnchorPoint::CENTER );
422 422  
... ...
examples/item-view/item-view-example.cpp
... ... @@ -164,15 +164,6 @@ const Vector4 DEFAULT_TEXT_STYLE_COLOR(1.0f, 1.0f, 1.0f, 1.0f);
164 164  
165 165 const Vector3 INITIAL_OFFSCREEN_POSITION( 1000.0f, 0, -1000.0f );
166 166  
167   -struct BorderSizeConstraintFunction
168   -{
169   - Vector3 operator()(const Vector3& current,
170   - const PropertyInput& parentSize)
171   - {
172   - return parentSize.GetVector3() + ITEM_BORDER_MARGIN_SIZE;
173   - }
174   -};
175   -
176 167 static Vector3 DepthLayoutItemSizeFunctionPortrait(unsigned int numberOfColumns, float layoutWidth)
177 168 {
178 169 float width = (layoutWidth / static_cast<float>(numberOfColumns + 1)) * DEPTH_LAYOUT_ITEM_SIZE_FACTOR_PORTRAIT;
... ... @@ -897,9 +888,8 @@ public: // From ItemFactory
897 888 borderActor.SetStyle( ImageActor::STYLE_NINE_PATCH );
898 889 borderActor.SetNinePatchBorder( Vector4( ITEM_IMAGE_BORDER_LEFT, ITEM_IMAGE_BORDER_TOP, ITEM_IMAGE_BORDER_RIGHT, ITEM_IMAGE_BORDER_BOTTOM ) );
899 890 borderActor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR ); // darken with parent image-actor
900   -
901   - Constraint constraint = Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), BorderSizeConstraintFunction() );
902   - borderActor.ApplyConstraint(constraint);
  891 + borderActor.SetSizeMode( SIZE_FIXED_OFFSET_FROM_PARENT );
  892 + borderActor.SetSizeModeFactor( ITEM_BORDER_MARGIN_SIZE );
903 893 actor.Add(borderActor);
904 894 actor.SetKeyboardFocusable( true );
905 895  
... ...
examples/scroll-view/scroll-view-example.cpp
... ... @@ -298,7 +298,7 @@ private:
298 298 Actor CreatePage()
299 299 {
300 300 Actor page = Actor::New();
301   - page.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
  301 + page.SetSizeMode( SIZE_EQUAL_TO_PARENT );
302 302 page.SetParentOrigin( ParentOrigin::CENTER );
303 303 page.SetAnchorPoint( AnchorPoint::CENTER );
304 304  
... ... @@ -450,7 +450,7 @@ private:
450 450 void ApplyEffectToPage(Actor page)
451 451 {
452 452 page.RemoveConstraints();
453   - page.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
  453 + page.SetSizeMode( SIZE_EQUAL_TO_PARENT );
454 454  
455 455 switch( mEffectMode )
456 456 {
... ...
examples/shadows/shadow-bone-lighting-example.cpp
... ... @@ -233,7 +233,7 @@ public:
233 233 mShadowView.SetName("Container");
234 234 mShadowView.SetParentOrigin(ParentOrigin::CENTER);
235 235 mShadowView.SetAnchorPoint(AnchorPoint::CENTER);
236   - mShadowView.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
  236 + mShadowView.SetSizeMode( SIZE_EQUAL_TO_PARENT );
237 237 mShadowView.SetPointLightFieldOfView( Math::PI / 2.0f);
238 238 mContents.Add(mShadowView);
239 239  
... ...
examples/shared/view.h
... ... @@ -99,8 +99,8 @@ Dali::Layer CreateToolbar( Dali::Toolkit::ToolBar&amp; toolBar,
99 99 toolBar.SetBackground( toolBarBackground );
100 100 toolBar.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER );
101 101 toolBar.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER );
102   - toolBar.ApplyConstraint( Dali::Constraint::New<Dali::Vector3>( Dali::Actor::SIZE, Dali::ParentSource( Dali::Actor::SIZE ), Dali::EqualToConstraint() ) );
103 102 toolBar.SetSize( 0.0f, style.mToolBarHeight );
  103 + toolBar.SetSizeMode( Dali::SIZE_EQUAL_TO_PARENT );
104 104 toolBarBackground.SetSortModifier(1.0f);
105 105  
106 106 // Add the tool bar to the too bar layer.
... ... @@ -166,7 +166,7 @@ Dali::Layer CreateView( Dali::Application&amp; application,
166 166 Dali::Layer contentLayer = Dali::Layer::New();
167 167 contentLayer.SetAnchorPoint( Dali::AnchorPoint::CENTER );
168 168 contentLayer.SetParentOrigin( Dali::ParentOrigin::CENTER );
169   - contentLayer.ApplyConstraint( Dali::Constraint::New<Dali::Vector3>( Dali::Actor::SIZE, Dali::ParentSource( Dali::Actor::SIZE ), Dali::EqualToConstraint() ) );
  169 + contentLayer.SetSizeMode( Dali::SIZE_EQUAL_TO_PARENT );
170 170 view.AddContentLayer( contentLayer );
171 171 contentLayer.LowerBelow( toolBarLayer );
172 172  
... ...