Merge remote-tracking branch 'origin/tizen' into new_text 36/37536/6
authorPaul Wisbey <p.wisbey@samsung.com>
Mon, 30 Mar 2015 15:03:35 +0000 (16:03 +0100)
committerPaul Wisbey <p.wisbey@samsung.com>
Tue, 31 Mar 2015 13:27:01 +0000 (14:27 +0100)
Conflicts:
automated-tests/src/dali-toolkit/utc-Dali-TextView.cpp
dali-toolkit/internal/controls/buttons/push-button-impl.cpp
dali-toolkit/internal/controls/popup/popup-impl.cpp
dali-toolkit/internal/controls/relayout-controller-impl.cpp
dali-toolkit/internal/controls/relayout-controller.cpp
dali-toolkit/internal/controls/relayout-helper.cpp
dali-toolkit/internal/controls/slider/slider-impl.cpp
dali-toolkit/internal/controls/text-input/text-input-impl.cpp
dali-toolkit/internal/controls/text-input/text-input-impl.h
dali-toolkit/internal/controls/text-input/text-input-popup-impl.cpp
dali-toolkit/internal/controls/text-view/relayout-utilities.cpp
dali-toolkit/internal/controls/text-view/text-view-impl.cpp
dali-toolkit/internal/controls/text-view/text-view-impl.h
dali-toolkit/public-api/controls/control-impl.cpp
dali-toolkit/public-api/controls/control.h
docs/content/main-page.h
plugins/dali-script-v8/src/actors/actor-wrapper.h

Change-Id: Ia0aff01756e6d803616d9c4eae82f405c6cb2c0f

107 files changed:
automated-tests/README.md
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-application.cpp
automated-tests/src/dali-toolkit/utc-Dali-Alignment.cpp
automated-tests/src/dali-toolkit/utc-Dali-Control.cpp
automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp
automated-tests/src/dali-toolkit/utc-Dali-Popup.cpp
automated-tests/src/dali-toolkit/utc-Dali-Slider.cpp
automated-tests/src/dali-toolkit/utc-Dali-TableView.cpp
automated-tests/src/dali-toolkit/utc-Dali-ToolBar.cpp
automated-tests/src/dali-toolkit/utc-Dali-View.cpp
build/tizen/plugins/Makefile.am
dali-toolkit/images/00_popup_bg.9.png [new file with mode: 0644]
dali-toolkit/images/00_popup_bg.png
dali-toolkit/internal/builder/builder-impl.cpp
dali-toolkit/internal/controls/alignment/alignment-impl.cpp
dali-toolkit/internal/controls/alignment/alignment-impl.h
dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp
dali-toolkit/internal/controls/buttons/check-box-button-impl.h
dali-toolkit/internal/controls/buttons/push-button-impl.cpp
dali-toolkit/internal/controls/buttons/push-button-impl.h
dali-toolkit/internal/controls/buttons/radio-button-impl.cpp
dali-toolkit/internal/controls/buttons/radio-button-impl.h
dali-toolkit/internal/controls/magnifier/magnifier-impl.cpp
dali-toolkit/internal/controls/navigation-frame/navigation-control-impl.cpp
dali-toolkit/internal/controls/navigation-frame/navigation-control-impl.h
dali-toolkit/internal/controls/popup/popup-impl.cpp
dali-toolkit/internal/controls/popup/popup-impl.h
dali-toolkit/internal/controls/popup/popup-style-impl.cpp
dali-toolkit/internal/controls/relayout-controller-impl.cpp [deleted file]
dali-toolkit/internal/controls/relayout-controller-impl.h [deleted file]
dali-toolkit/internal/controls/relayout-controller.cpp [deleted file]
dali-toolkit/internal/controls/relayout-controller.h [deleted file]
dali-toolkit/internal/controls/relayout-helper.cpp [deleted file]
dali-toolkit/internal/controls/relayout-helper.h [deleted file]
dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp
dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h
dali-toolkit/internal/controls/shadow-view/shadow-view-impl.cpp
dali-toolkit/internal/controls/slider/slider-impl.cpp
dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp
dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.h
dali-toolkit/internal/controls/table-view/table-view-impl.cpp
dali-toolkit/internal/controls/table-view/table-view-impl.h
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.h
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
dali-toolkit/internal/controls/text-controls/text-label-impl.h
dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp
dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.h
dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp
dali-toolkit/internal/controls/view/view-impl.cpp
dali-toolkit/internal/controls/view/view-impl.h
dali-toolkit/internal/file.list
dali-toolkit/internal/focus-manager/focus-manager-impl.cpp
dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp
dali-toolkit/internal/text/decorator/text-decorator.cpp
dali-toolkit/internal/transition-effects/cube-transition-effect-impl.cpp
dali-toolkit/public-api/controls/control-impl.cpp
dali-toolkit/public-api/controls/control-impl.h
dali-toolkit/public-api/controls/control.cpp
dali-toolkit/public-api/controls/control.h
dali-toolkit/public-api/controls/popup/popup.cpp
dali-toolkit/public-api/controls/popup/popup.h
dali-toolkit/public-api/controls/scrollable/item-view/item-view.cpp
dali-toolkit/public-api/controls/scrollable/item-view/item-view.h
dali-toolkit/public-api/controls/table-view/table-view.cpp
dali-toolkit/public-api/controls/table-view/table-view.h
dali-toolkit/public-api/controls/text-controls/text-label.cpp
dali-toolkit/public-api/controls/text-controls/text-label.h
dali-toolkit/public-api/dali-toolkit-version.cpp
docs/content/images/size-negotiation/Algorithm1.png [deleted file]
docs/content/images/size-negotiation/Algorithm10.png [deleted file]
docs/content/images/size-negotiation/Algorithm2.png [deleted file]
docs/content/images/size-negotiation/Algorithm3.png [deleted file]
docs/content/images/size-negotiation/Algorithm4.png [deleted file]
docs/content/images/size-negotiation/Algorithm8.png [deleted file]
docs/content/images/size-negotiation/Algorithm9.png [deleted file]
docs/content/images/size-negotiation/FixedWidthFlexibleHeight.png [deleted file]
docs/content/images/size-negotiation/FixedWidthFlexibleHeight2.png [deleted file]
docs/content/images/size-negotiation/FixedWidthHeight.png [deleted file]
docs/content/images/size-negotiation/FixedWidthHeight2.png [deleted file]
docs/content/images/size-negotiation/FlexibleWidthFixedHeight.png [deleted file]
docs/content/images/size-negotiation/FlexibleWidthFixedHeight2.png [deleted file]
docs/content/images/size-negotiation/FlexibleWidthHeight.png [deleted file]
docs/content/images/size-negotiation/Popup.png [new file with mode: 0644]
docs/content/images/size-negotiation/PopupExample.png [new file with mode: 0644]
docs/content/images/size-negotiation/ResizePolicies.png [new file with mode: 0644]
docs/content/images/size-negotiation/ResizePoliciesExample.png [new file with mode: 0644]
docs/content/images/size-negotiation/SizeNegotiationExample_After.png [new file with mode: 0644]
docs/content/images/size-negotiation/SizeNegotiationExample_Before.png [new file with mode: 0644]
docs/content/main-page.h
docs/content/programming-guide/size-negotiation-controls.h [new file with mode: 0644]
docs/content/programming-guide/size-negotiation.h
packaging/dali-toolkit.spec
plugins/dali-script-v8/docs/content/shader-effect.js
plugins/dali-script-v8/file.list
plugins/dali-script-v8/src/actors/actor-api.cpp
plugins/dali-script-v8/src/actors/actor-api.h
plugins/dali-script-v8/src/actors/actor-wrapper.cpp
plugins/dali-script-v8/src/actors/actor-wrapper.h
plugins/dali-script-v8/src/animation/path-constraint-wrapper.cpp [new file with mode: 0644]
plugins/dali-script-v8/src/animation/path-constraint-wrapper.h [new file with mode: 0644]
plugins/dali-script-v8/src/constants/constants-wrapper.cpp
plugins/dali-script-v8/src/dali-wrapper.cpp
plugins/dali-script-v8/src/shader-effects/shader-effect-api.cpp
plugins/dali-script-v8/src/shader-effects/shader-effect-wrapper.cpp
plugins/dali-script-v8/src/shared/base-wrapped-object.h
plugins/dali-script-v8/src/utils/v8-utils.h

index 8db6f2c..db21746 100644 (file)
@@ -62,19 +62,19 @@ Run the following commands:
     cd automated-tests
     ./build.sh
 
-This will build dali and dali-internal test sets.
+This will build dali-toolkit and dali-toolkit-internal test sets.
 
 Test sets can be built individually:
 
-    ./build.sh dali
+    ./build.sh dali-toolkit
 
 They can also be built without regenerating test case scripts (Useful for quicker rebuilds)
 
-    ./build.sh -n dali-internal
+    ./build.sh -n dali-toolkit-internal
 
 Or without cleaning down the build area (Useful for fast build/run/debug cycles)
 
-    ./build.sh -n -r dali-internal
+    ./build.sh -n -r dali-toolkit-internal
 
 
 Executing the tests
index 89138eb..df3ae2e 100644 (file)
@@ -72,6 +72,8 @@ void TestApplication::Initialize()
 
   Dali::Integration::Log::LogFunction logFunction(&TestApplication::LogMessage);
   Dali::Integration::Log::InstallLogFunction(logFunction);
+
+  mCore->SceneCreated();
 }
 
 TestApplication::~TestApplication()
index 6d3fa86..4dcef68 100644 (file)
@@ -934,15 +934,15 @@ int UtcDaliAlignmentOnSizeSet(void)
   application.Render();
   application.SendNotification();
 
-  Vector3 size(100.0f, 200.0f, 0.0f);
-  alignment.SetSize(size);
+  Vector2 size( 100.0f, 200.0f );
+  alignment.SetPreferredSize(size);
 
   application.Render();
   application.SendNotification();
   application.Render();
   application.SendNotification();
 
-  DALI_TEST_EQUALS(size, alignment.GetImplementation().GetControlSize(), TEST_LOCATION);
+  DALI_TEST_EQUALS(size, alignment.GetImplementation().GetControlSize().GetVectorXY(), TEST_LOCATION);
 
   Stage::GetCurrent().Remove(alignment);
   END_TEST;
index a424aa7..aa9e46c 100644 (file)
@@ -327,27 +327,11 @@ int UtcDaliControlTestParameters(void)
   ToolkitTestApplication application;
   DummyControl test = DummyControl::New();
 
-  Vector3 maxSize = test.GetNaturalSize();
-  Vector3 minSize = maxSize / 2.0f;
-
-  Toolkit::Control::SizePolicy widthPolicy( Control::Fixed );
-  Toolkit::Control::SizePolicy heightPolicy( Control::Fixed );
-  test.SetSizePolicy( widthPolicy, heightPolicy );
-  test.GetSizePolicy( widthPolicy, heightPolicy );
-
-  DALI_TEST_CHECK( widthPolicy == Control::Fixed && heightPolicy == Control::Fixed );
-
   test.SetSize( 0.7f, 0.7f, 0.7f );
   float width = 640.0f;
   float height = test.GetHeightForWidth( width );
   DALI_TEST_CHECK( test.GetWidthForHeight( height ) == width );
 
-  test.SetMinimumSize( minSize );
-  DALI_TEST_CHECK( test.GetMinimumSize() == minSize );
-
-  test.SetMaximumSize( maxSize );
-  DALI_TEST_CHECK( test.GetMaximumSize() == maxSize );
-
   test.KeyEventSignal();
 
   // Provide coverage for pointer destructor
@@ -381,7 +365,7 @@ int UtcDaliControlBackgroundImage(void)
   DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::TRANSPARENT, TEST_LOCATION );
 
   Image image = ResourceImage::New("TestImage");
-  control.SetBackground( image );
+  control.SetBackgroundImage( image );
   DALI_TEST_CHECK( control.GetBackgroundActor() );
   DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::WHITE, TEST_LOCATION );
 
@@ -393,7 +377,7 @@ int UtcDaliControlBackgroundImage(void)
   DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::TRANSPARENT, TEST_LOCATION );
 
   control.SetBackgroundColor( Color::YELLOW );
-  control.SetBackground( image );
+  control.SetBackgroundImage( image );
   DALI_TEST_CHECK( control.GetBackgroundActor() );
   DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::YELLOW, TEST_LOCATION );
 
@@ -408,7 +392,7 @@ int UtcDaliControlBackgroundProperties(void)
   DALI_TEST_CHECK( !control.GetBackgroundActor() );
   DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::TRANSPARENT, TEST_LOCATION );
   DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), Color::TRANSPARENT, TEST_LOCATION );
-  DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND ).Get< Property::Map >().Empty() );
+  DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND_IMAGE ).Get< Property::Map >().Empty() );
 
   control.SetProperty( Control::Property::BACKGROUND_COLOR, Color::RED );
   DALI_TEST_CHECK( control.GetBackgroundActor() );
@@ -419,72 +403,22 @@ int UtcDaliControlBackgroundProperties(void)
   imageMap[ "filename" ] = "TestImage";
   Property::Map map;
   map[ "image" ] = imageMap;
-  control.SetProperty( Control::Property::BACKGROUND, map );
+  control.SetProperty( Control::Property::BACKGROUND_IMAGE, map );
   DALI_TEST_CHECK( control.GetBackgroundActor() );
   DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::RED, TEST_LOCATION );
   DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), Color::RED, TEST_LOCATION );
 
-  Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
+  Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND_IMAGE );
   DALI_TEST_CHECK( propValue.HasKey( "image" ) );
   DALI_TEST_CHECK( propValue.GetValue( "image" ).HasKey( "filename" ) );
   DALI_TEST_CHECK( propValue.GetValue( "image" ).GetValue( "filename" ).Get< std::string>() == "TestImage" );
 
   Property::Map emptyMap;
-  control.SetProperty( Control::Property::BACKGROUND, emptyMap );
+  control.SetProperty( Control::Property::BACKGROUND_IMAGE, emptyMap );
   DALI_TEST_CHECK( !control.GetBackgroundActor() );
   DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::TRANSPARENT, TEST_LOCATION );
   DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), Color::TRANSPARENT, TEST_LOCATION );
-  DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND ).Get< Property::Map >().Empty() );
-
-  END_TEST;
-}
-
-int UtcDaliControlSizePolicyProperties(void)
-{
-  ToolkitTestApplication application;
-
-  Control control = Control::New();
-
-  Control::SizePolicy widthPolicy( Control::Fixed );
-  Control::SizePolicy heightPolicy( Control::Fixed );
-
-  control.GetSizePolicy( widthPolicy, heightPolicy );
-  DALI_TEST_EQUALS( "FIXED", control.GetProperty( Control::Property::WIDTH_POLICY ).Get< std::string >(), TEST_LOCATION );
-  DALI_TEST_EQUALS( "FIXED", control.GetProperty( Control::Property::HEIGHT_POLICY ).Get< std::string >(), TEST_LOCATION );
-
-  control.SetSizePolicy( Control::Flexible, Control::Range );
-  DALI_TEST_EQUALS( "FLEXIBLE", control.GetProperty( Control::Property::WIDTH_POLICY ).Get< std::string >(), TEST_LOCATION );
-  DALI_TEST_EQUALS( "RANGE", control.GetProperty( Control::Property::HEIGHT_POLICY ).Get< std::string >(), TEST_LOCATION );
-
-  control.SetProperty( Control::Property::WIDTH_POLICY, "MAXIMUM" );
-  control.SetProperty( Control::Property::HEIGHT_POLICY, "MINIMUM" );
-  control.GetSizePolicy( widthPolicy, heightPolicy );
-  DALI_TEST_EQUALS( Control::Maximum, widthPolicy, TEST_LOCATION );
-  DALI_TEST_EQUALS( Control::Minimum, heightPolicy, TEST_LOCATION );
-
-  END_TEST;
-}
-
-int UtcDaliControlSizeProperties(void)
-{
-  ToolkitTestApplication application;
-
-  Control control = Control::New();
-
-  DALI_TEST_EQUALS( control.GetMinimumSize(), control.GetProperty( Control::Property::MINIMUM_SIZE ).Get< Vector3 >(), TEST_LOCATION );
-  DALI_TEST_EQUALS( control.GetMaximumSize(), control.GetProperty( Control::Property::MAXIMUM_SIZE ).Get< Vector3 >(), TEST_LOCATION );
-
-  control.SetMinimumSize( Vector3( 100.0f, 200.0f, 300.0f ) );
-  DALI_TEST_EQUALS( Vector3( 100.0f, 200.0f, 300.0f ), control.GetProperty( Control::Property::MINIMUM_SIZE ).Get< Vector3 >(), TEST_LOCATION );
-
-
-  control.SetMaximumSize( Vector3( 200.0f, 250.0f, 800.0f ) );
-  DALI_TEST_EQUALS( Vector3( 200.0f, 250.0f, 800.0f ), control.GetProperty( Control::Property::MAXIMUM_SIZE ).Get< Vector3 >(), TEST_LOCATION );
-
-  control.SetProperty( Control::Property::MINIMUM_SIZE, Vector3( 1.0f, 2.0f, 3.0f ) );
-  control.SetProperty( Control::Property::MAXIMUM_SIZE, Vector3( 10.0f, 20.0f, 30.0f ) );
-  DALI_TEST_EQUALS( control.GetMinimumSize(), Vector3( 1.0f, 2.0f, 3.0f ), TEST_LOCATION );
-  DALI_TEST_EQUALS( control.GetMaximumSize(), Vector3( 10.0f, 20.0f, 30.0f ), TEST_LOCATION );
+  DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND_IMAGE ).Get< Property::Map >().Empty() );
 
   END_TEST;
 }
index 6965f35..c0cf98c 100644 (file)
@@ -218,7 +218,8 @@ int UtcDaliControlImplOnGestureMethods(void)
   // Check gesture actually happens
   {
     DummyControl dummy = DummyControl::New(true);
-    dummy.SetSize( Vector3(100.0f, 100.0f, 100.0f) );
+    dummy.SetRelayoutEnabled( true );
+    dummy.SetPreferredSize( Vector2(100.0f, 100.0f ) );
 
     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
     Stage::GetCurrent().Add(dummy);
@@ -278,7 +279,8 @@ int UtcDaliControlImplOnGestureMethods(void)
   // Ensure full code coverage
   {
     DummyControl dummy = DummyControl::New();
-    dummy.SetSize( Vector3(100.0f, 100.0f, 100.0f) );
+    dummy.SetRelayoutEnabled( true );
+    dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) );
 
     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
     Stage::GetCurrent().Add(dummy);
@@ -443,22 +445,23 @@ int UtcDaliControlImplSizeSet(void)
 
   {
     DummyControl dummy = DummyControl::New( true );
+    dummy.SetRelayoutEnabled( true );
     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
 
     Stage::GetCurrent().Add(dummy);
     application.Render();
     application.SendNotification();
 
-    DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, false, TEST_LOCATION );
-    Vector3 size(100.0f, 200.0f, 0.0f);
-    dummy.SetSize(size);
+    DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, true, TEST_LOCATION ); // Called from size negotiation
+    Vector2 size(100.0f, 200.0f);
+    dummy.SetPreferredSize(size);
 
     application.Render();
     application.SendNotification();
     application.Render();
     application.SendNotification();
 
-    DALI_TEST_EQUALS(size, dummy.GetCurrentSize(), TEST_LOCATION);
+    DALI_TEST_EQUALS(size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION);
     DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, true, TEST_LOCATION );
 
     Stage::GetCurrent().Remove(dummy);
@@ -467,22 +470,23 @@ int UtcDaliControlImplSizeSet(void)
   // Ensure full code coverage
   {
     DummyControl dummy = DummyControl::New();
+    dummy.SetRelayoutEnabled( true );
     Stage::GetCurrent().Add(dummy);
 
-    Vector3 size(100.0f, 200.0f, 0.0f);
-    DALI_TEST_CHECK( size != dummy.GetCurrentSize() );
+    Vector2 size(100.0f, 200.0f);
+    DALI_TEST_CHECK( size != dummy.GetCurrentSize().GetVectorXY() );
 
     application.Render();
     application.SendNotification();
 
-    dummy.SetSize(size);
+    dummy.SetPreferredSize(size);
 
     application.Render();
     application.SendNotification();
     application.Render();
     application.SendNotification();
 
-    DALI_TEST_EQUALS(size, dummy.GetCurrentSize(), TEST_LOCATION);
+    DALI_TEST_EQUALS(size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION);
 
     Stage::GetCurrent().Remove(dummy);
   }
@@ -542,9 +546,10 @@ int UtcDaliControlImplTouchEvent(void)
 
   {
     DummyControl dummy = DummyControl::New( true );
+    dummy.SetRelayoutEnabled( true );
     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
 
-    dummy.SetSize(100.0f, 100.0f);
+    dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) );
     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
     Stage::GetCurrent().Add(dummy);
 
@@ -566,8 +571,9 @@ int UtcDaliControlImplTouchEvent(void)
   // Ensure full code coverage
   {
     DummyControl dummy = DummyControl::New();
+    dummy.SetRelayoutEnabled( true );
 
-    dummy.SetSize(100.0f, 100.0f);
+    dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) );
     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
     Stage::GetCurrent().Add(dummy);
 
@@ -767,9 +773,10 @@ int UtcDaliControlImplMouseWheelEvent(void)
 
   {
     DummyControl dummy = DummyControl::New( true );
+    dummy.SetRelayoutEnabled( true );
     DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
 
-    dummy.SetSize(100.0f, 100.0f);
+    dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) );
     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
     Stage::GetCurrent().Add(dummy);
 
@@ -794,8 +801,9 @@ int UtcDaliControlImplMouseWheelEvent(void)
   // Ensure full code coverage
   {
     DummyControl dummy = DummyControl::New();
+    dummy.SetRelayoutEnabled( true );
 
-    dummy.SetSize(100.0f, 100.0f);
+    dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) );
     dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
     Stage::GetCurrent().Add(dummy);
 
index 29fca22..580e2c6 100644 (file)
@@ -223,7 +223,6 @@ int UtcDaliPopupSetState(void)
 
   // Create the Popup actor
   Popup popup = Popup::New();
-  Stage::GetCurrent().Add( popup );
 
   ImageActor backgroundImage = CreateSolidColorActor( Color::RED );
   popup.SetBackgroundImage(backgroundImage);
@@ -247,7 +246,6 @@ int UtcDaliPopupSetStateSlow(void)
 
   // Create the Popup actor
   Popup popup = Popup::New();
-  Stage::GetCurrent().Add( popup );
 
   ImageActor backgroundImage = CreateSolidColorActor( Color::RED );
   popup.SetBackgroundImage(backgroundImage);
@@ -281,7 +279,6 @@ int UtcDaliPopupShowHide(void)
 
   // Create the Popup actor
   Popup popup = Popup::New();
-  Stage::GetCurrent().Add( popup );
   popup.HiddenSignal().Connect( &OnPopupHidden );
 
   ImageActor backgroundImage = CreateSolidColorActor( Color::RED );
@@ -289,9 +286,9 @@ int UtcDaliPopupShowHide(void)
 
   PushButton button1 = PushButton::New();
   PushButton button2 = PushButton::New();
-  button1.SetSize(DEFAULT_BUTTON_SIZE);
+  button1.SetPreferredSize(DEFAULT_BUTTON_SIZE.GetVectorXY());
   popup.AddButton(button1);
-  button2.SetSize(DEFAULT_BUTTON_SIZE);
+  button2.SetPreferredSize(DEFAULT_BUTTON_SIZE.GetVectorXY());
   popup.AddButton(button2);
 
   // Showing/Hiding popup, results in all child Actors being
index 8fd2fb6..d5d2ef0 100644 (file)
@@ -125,7 +125,7 @@ int UtcDaliSliderSignals(void)
   Stage::GetCurrent().Add( slider );
   slider.SetParentOrigin(ParentOrigin::TOP_LEFT);
   slider.SetAnchorPoint(ParentOrigin::TOP_LEFT);
-  slider.SetSize( Stage::GetCurrent().GetSize().x, 20.0f );
+  slider.SetPreferredSize( Vector2( Stage::GetCurrent().GetSize().x, 20.0f ) );
   slider.SetPosition( 0.0f, 0.0f );
 
   const float MIN_BOUND = 0.0f;
index 8773187..484453c 100644 (file)
@@ -67,23 +67,28 @@ struct Constraint100
 // Convenience function to quickly set up a 10x10 table with each cell being 10x10 pixels in size by default.
 static void SetupTableViewAndActors(TableView& tableView, Actor& actor1, Actor& actor2, Actor& actor3)
 {
-  tableView = TableView::New(10,10); // 10 by 10 grid.
-  DALI_TEST_CHECK(tableView);
+  tableView = TableView::New( 10, 10 ); // 10 by 10 grid.
+  DALI_TEST_CHECK( tableView );
+
+  tableView.SetRelayoutEnabled( true );
 
   Stage::GetCurrent().Add( tableView );
-  tableView.SetSize( Dali::Vector3( 100.0f, 100.0f, 100.0f ) );
+  tableView.SetPreferredSize( Dali::Vector2( 100.0f, 100.0f ) );
 
   actor1 = Actor::New();
   actor2 = Actor::New();
   actor3 = Actor::New();
 
-  actor1.SetSize(10,10);
-  actor2.SetSize(10,10);
-  actor3.SetSize(10,10);
+  actor1.SetRelayoutEnabled( true );
+  actor1.SetPreferredSize( Dali::Vector2( 10, 10 ) );
+  actor2.SetRelayoutEnabled( true );
+  actor2.SetPreferredSize( Dali::Vector2( 10, 10 ) );
+  actor3.SetRelayoutEnabled( true );
+  actor3.SetPreferredSize( Dali::Vector2( 10, 10 ) );
 
-  tableView.AddChild(actor1, TableView::CellPosition(0,0));
-  tableView.AddChild(actor2, TableView::CellPosition(0,1));
-  tableView.AddChild(actor3, TableView::CellPosition(1,0));
+  tableView.AddChild( actor1, TableView::CellPosition( 0, 0 ) );
+  tableView.AddChild( actor2, TableView::CellPosition( 0, 1 ) );
+  tableView.AddChild( actor3, TableView::CellPosition( 1, 0 ) );
 }
 
 } // namespace
@@ -438,7 +443,7 @@ int UtcDaliTableViewMetricsAssert(void)
   catch( Dali::DaliException& e )
   {
     DALI_TEST_PRINT_ASSERT( e );
-    DALI_TEST_EQUALS(e.condition, "rowIndex < mFixedHeights.size()", TEST_LOCATION);
+    DALI_TEST_EQUALS(e.condition, "rowIndex < mRowData.Size()", TEST_LOCATION);
   }
 
   try
@@ -450,7 +455,7 @@ int UtcDaliTableViewMetricsAssert(void)
   catch( Dali::DaliException& e )
   {
     DALI_TEST_PRINT_ASSERT( e );
-    DALI_TEST_EQUALS(e.condition, "rowIndex < mFixedHeights.size()", TEST_LOCATION);
+    DALI_TEST_EQUALS(e.condition, "rowIndex < mRowData.Size()", TEST_LOCATION);
   }
 
   try
@@ -462,7 +467,7 @@ int UtcDaliTableViewMetricsAssert(void)
   catch( Dali::DaliException& e )
   {
     DALI_TEST_PRINT_ASSERT( e );
-    DALI_TEST_EQUALS(e.condition, "columnIndex < mFixedWidths.size()", TEST_LOCATION);
+    DALI_TEST_EQUALS(e.condition, "columnIndex < mColumnData.Size()", TEST_LOCATION);
   }
 
   try
@@ -474,7 +479,7 @@ int UtcDaliTableViewMetricsAssert(void)
   catch( Dali::DaliException& e )
   {
     DALI_TEST_PRINT_ASSERT( e );
-    DALI_TEST_EQUALS(e.condition, "columnIndex < mFixedWidths.size()", TEST_LOCATION);
+    DALI_TEST_EQUALS(e.condition, "columnIndex < mColumnData.Size()", TEST_LOCATION);
   }
 
   // relatives...
@@ -488,7 +493,7 @@ int UtcDaliTableViewMetricsAssert(void)
   catch( Dali::DaliException& e )
   {
     DALI_TEST_PRINT_ASSERT( e );
-    DALI_TEST_EQUALS(e.condition, "rowIndex < mRelativeHeights.size()", TEST_LOCATION);
+    DALI_TEST_EQUALS(e.condition, "rowIndex < mRowData.Size()", TEST_LOCATION);
   }
 
   try
@@ -500,7 +505,7 @@ int UtcDaliTableViewMetricsAssert(void)
   catch( Dali::DaliException& e )
   {
     DALI_TEST_PRINT_ASSERT( e );
-    DALI_TEST_EQUALS(e.condition, "rowIndex < mRelativeHeights.size()", TEST_LOCATION);
+    DALI_TEST_EQUALS(e.condition, "rowIndex < mRowData.Size()", TEST_LOCATION);
   }
 
   try
@@ -512,7 +517,7 @@ int UtcDaliTableViewMetricsAssert(void)
   catch( Dali::DaliException& e )
   {
     DALI_TEST_PRINT_ASSERT( e );
-    DALI_TEST_EQUALS(e.condition, "columnIndex < mRelativeWidths.size()", TEST_LOCATION);
+    DALI_TEST_EQUALS(e.condition, "columnIndex < mColumnData.Size()", TEST_LOCATION);
   }
 
   try
@@ -524,7 +529,7 @@ int UtcDaliTableViewMetricsAssert(void)
   catch( Dali::DaliException& e )
   {
     DALI_TEST_PRINT_ASSERT( e );
-    DALI_TEST_EQUALS(e.condition, "columnIndex < mRelativeWidths.size()", TEST_LOCATION);
+    DALI_TEST_EQUALS(e.condition, "columnIndex < mColumnData.Size()", TEST_LOCATION);
   }
   END_TEST;
 }
@@ -536,7 +541,7 @@ int UtcDaliTableViewSetGetProperty(void)
 
   // Create a 1x1 table-view
   TableView tableView = TableView::New(1,1);
-  tableView.ApplyConstraint( Constraint::New<Vector3>( Actor::Property::SIZE, Constraint100() ) );
+  tableView.SetPreferredSize( Vector2( 100.0f, 100.0f ) );
   DALI_TEST_CHECK( tableView );
 
   // Test "rows" property
@@ -591,12 +596,14 @@ int UtcDaliTableViewSetGetProperty(void)
   DALI_TEST_EQUALS( tableView.GetRelativeHeight( 3u ), 0.2f, TEST_LOCATION );
 
   Property::Map layoutRowsGet = tableView.GetProperty(TableView::Property::LAYOUT_ROWS).Get<Property::Map>();
-  DALI_TEST_CHECK( layoutRowsGet.GetKey(0).compare(layoutRows.GetKey(0)) == 0 );
-  DALI_TEST_CHECK( layoutRowsGet.GetValue(0).GetValue( "policy" ).Get<std::string>().compare(layoutRows.GetValue(0).GetValue( "policy" ).Get<std::string>()) == 0 );
-  DALI_TEST_EQUALS( layoutRowsGet.GetValue(0).GetValue( "value" ).Get<float>(),layoutRows.GetValue(0).GetValue( "value" ).Get<float>(), TEST_LOCATION );
-  DALI_TEST_CHECK( layoutRowsGet.GetKey(1).compare(layoutRows.GetKey(1)) == 0 );
-  DALI_TEST_CHECK( layoutRowsGet.GetValue(1).GetValue( "policy" ).Get<std::string>().compare(layoutRows.GetValue(1).GetValue( "policy" ).Get<std::string>()) == 0 );
-  DALI_TEST_EQUALS( layoutRowsGet.GetValue(1).GetValue( "value" ).Get<float>(),layoutRows.GetValue(1).GetValue( "value" ).Get<float>(), TEST_LOCATION );
+
+  DALI_TEST_EQUALS( layoutRowsGet.GetKey(1).compare(layoutRows.GetKey(0)), 0, TEST_LOCATION );
+  DALI_TEST_CHECK( layoutRowsGet.GetValue(1).GetValue( "policy" ).Get<std::string>().compare(layoutRows.GetValue(0).GetValue( "policy" ).Get<std::string>()) == 0 );
+  DALI_TEST_EQUALS( layoutRowsGet.GetValue(1).GetValue( "value" ).Get<float>(), layoutRows.GetValue(0).GetValue( "value" ).Get<float>(), TEST_LOCATION );
+
+  DALI_TEST_CHECK( layoutRowsGet.GetKey(3).compare(layoutRows.GetKey(1)) == 0 );
+  DALI_TEST_CHECK( layoutRowsGet.GetValue(3).GetValue( "policy" ).Get<std::string>().compare(layoutRows.GetValue(1).GetValue( "policy" ).Get<std::string>()) == 0 );
+  DALI_TEST_EQUALS( layoutRowsGet.GetValue(3).GetValue( "value" ).Get<float>(), layoutRows.GetValue(1).GetValue( "value" ).Get<float>(), TEST_LOCATION );
 
   // Test "layout-columns" property
   DALI_TEST_CHECK( tableView.GetPropertyIndex( PROPERTY_NAME_LAYOUT_COLUMNS ) == TableView::Property::LAYOUT_COLUMNS );
@@ -617,12 +624,13 @@ int UtcDaliTableViewSetGetProperty(void)
   DALI_TEST_EQUALS( tableView.GetFixedWidth( 3u ), 30.f, TEST_LOCATION );
 
   Property::Map layoutColumnsGet = tableView.GetProperty(TableView::Property::LAYOUT_COLUMNS).Get<Property::Map>();
-  DALI_TEST_CHECK( layoutColumnsGet.GetKey(0).compare(layoutColumns.GetKey(0)) == 0 );
-  DALI_TEST_CHECK( layoutColumnsGet.GetValue(0).GetValue( "policy" ).Get<std::string>().compare(layoutColumns.GetValue(0).GetValue( "policy" ).Get<std::string>()) == 0 );
-  DALI_TEST_EQUALS( layoutColumnsGet.GetValue(0).GetValue( "value" ).Get<float>(),layoutColumns.GetValue(0).GetValue( "value" ).Get<float>(), TEST_LOCATION );
-  DALI_TEST_CHECK( layoutColumnsGet.GetKey(1).compare(layoutColumns.GetKey(1)) == 0 );
-  DALI_TEST_CHECK( layoutColumnsGet.GetValue(1).GetValue( "policy" ).Get<std::string>().compare(layoutColumns.GetValue(1).GetValue( "policy" ).Get<std::string>()) == 0 );
-  DALI_TEST_EQUALS( layoutColumnsGet.GetValue(1).GetValue( "value" ).Get<float>(),layoutColumns.GetValue(1).GetValue( "value" ).Get<float>(), TEST_LOCATION );
+  DALI_TEST_CHECK( layoutColumnsGet.GetKey(2).compare(layoutColumns.GetKey(0)) == 0 );
+  DALI_TEST_CHECK( layoutColumnsGet.GetValue(2).GetValue( "policy" ).Get<std::string>().compare(layoutColumns.GetValue(0).GetValue( "policy" ).Get<std::string>()) == 0 );
+  DALI_TEST_EQUALS( layoutColumnsGet.GetValue(2).GetValue( "value" ).Get<float>(),layoutColumns.GetValue(0).GetValue( "value" ).Get<float>(), TEST_LOCATION );
+
+  DALI_TEST_CHECK( layoutColumnsGet.GetKey(3).compare(layoutColumns.GetKey(1)) == 0 );
+  DALI_TEST_CHECK( layoutColumnsGet.GetValue(3).GetValue( "policy" ).Get<std::string>().compare(layoutColumns.GetValue(1).GetValue( "policy" ).Get<std::string>()) == 0 );
+  DALI_TEST_EQUALS( layoutColumnsGet.GetValue(3).GetValue( "value" ).Get<float>(),layoutColumns.GetValue(1).GetValue( "value" ).Get<float>(), TEST_LOCATION );
 
   END_TEST;
 }
index 4b03c11..e1042b2 100644 (file)
@@ -114,18 +114,23 @@ int UtcDaliToolBarAddControl01(void)
   try
   {
     ImageActor control1 = CreateSolidColorActor( Color::RED );
-    control1.SetSize( 100.f, 100.f );
+    control1.SetPreferredSize( Vector2( 100.f, 100.f ) );
+    control1.SetResizePolicy( FIXED, ALL_DIMENSIONS );
     ImageActor control2 = CreateSolidColorActor( Color::RED );
-    control2.SetSize( 100.f, 100.f );
+    control2.SetPreferredSize( Vector2( 100.f, 100.f ) );
+    control2.SetResizePolicy( FIXED, ALL_DIMENSIONS );
     ImageActor control3 = CreateSolidColorActor( Color::RED );
-    control3.SetSize( 100.f, 100.f );
+    control3.SetPreferredSize( Vector2( 100.f, 100.f ) );
+    control3.SetResizePolicy( FIXED, ALL_DIMENSIONS );
     ImageActor control4 = CreateSolidColorActor( Color::RED );
-    control4.SetSize( 100.f, 100.f );
+    control4.SetPreferredSize( Vector2( 100.f, 100.f ) );
+    control4.SetResizePolicy( FIXED, ALL_DIMENSIONS );
     ImageActor control5 = CreateSolidColorActor( Color::RED );
-    control5.SetSize( 100.f, 100.f );
+    control5.SetPreferredSize( Vector2( 100.f, 100.f ) );
+    control5.SetResizePolicy( FIXED, ALL_DIMENSIONS );
 
     ToolBar toolbar = ToolBar::New();
-    toolbar.SetSize( 600.f, 100.f );
+    toolbar.SetPreferredSize( Vector2( 600.f, 100.f ) );
 
     application.Render();
     application.SendNotification();
@@ -139,11 +144,14 @@ int UtcDaliToolBarAddControl01(void)
     toolbar.AddControl( control5, 0.1f, Alignment::HorizontalRight, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
 
     ImageActor control6 = CreateSolidColorActor( Color::RED );
-    control6.SetSize( 100.f, 100.f );
+    control6.SetPreferredSize( Vector2( 100.f, 100.f ) );
+    control6.SetResizePolicy( FIXED, ALL_DIMENSIONS );
     ImageActor control7 = CreateSolidColorActor( Color::RED );
-    control7.SetSize( 100.f, 100.f );
+    control7.SetPreferredSize( Vector2( 100.f, 100.f ) );
+    control7.SetResizePolicy( FIXED, ALL_DIMENSIONS );
     ImageActor control8 = CreateSolidColorActor( Color::RED );
-    control8.SetSize( 100.f, 100.f );
+    control8.SetPreferredSize( Vector2( 100.f, 100.f ) );
+    control8.SetResizePolicy( FIXED, ALL_DIMENSIONS );
 
     application.Render();
     application.SendNotification();
index 21a57df..2d28fd2 100644 (file)
@@ -305,9 +305,10 @@ int UtcDaliViewOrientationChanged(void)
   try
   {
     View view = View::New();
+    view.SetRelayoutEnabled( true );
     Stage::GetCurrent().Add( view );
 
-    view.SetSize( 480, 800 );
+    view.SetPreferredSize( Vector2( 480, 800 ) );
 
     view.OrientationAnimationStartedSignal().Connect( &StartAnimation );
 
index 1ca51e4..bb89f6c 100644 (file)
@@ -30,8 +30,7 @@ lib_LTLIBRARIES = libdali-script-plugin-v8.la
 # It won't be installed until the rpm is installed, and unfortunately the
 # plugin is part of the same rpm
 script_plugin_v8_includes = -I../../../plugins/dali-script-v8/src \
-                         -I../../../plugins/dali-script-v8/src/utils \
-                         -I../../../
+                            -I../../../plugins/dali-script-v8/src/utils
 
 
 libdali_script_plugin_v8_la_SOURCES = \
@@ -40,14 +39,13 @@ libdali_script_plugin_v8_la_SOURCES = \
 libdali_script_plugin_v8_la_DEPENDENCIES =
 
 libdali_script_plugin_v8_la_CXXFLAGS = -DDALI_COMPILATION \
+                            $(V8_CFLAGS) \
                             $(DALI_TOOLKIT_CFLAGS) \
                             $(DALICORE_CFLAGS) \
                             -DDALI_DATA_READ_ONLY_DIR="\"${dataReadOnlyDir}\"" \
                             $(DALI_CFLAGS) \
                             $(DLOG_CFLAGS) \
-                            -I../../.. \
                             $(script_plugin_v8_includes) \
-                            $(V8_CFLAGS) \
                             -Werror -Wall
 
 libdali_script_plugin_v8_la_LIBADD = \
diff --git a/dali-toolkit/images/00_popup_bg.9.png b/dali-toolkit/images/00_popup_bg.9.png
new file mode 100644 (file)
index 0000000..b8f5b3f
Binary files /dev/null and b/dali-toolkit/images/00_popup_bg.9.png differ
index 18f9533..cc300fa 100644 (file)
Binary files a/dali-toolkit/images/00_popup_bg.png and b/dali-toolkit/images/00_popup_bg.png differ
index b550ac1..8ca0281 100644 (file)
@@ -529,6 +529,9 @@ BaseHandle Builder::DoCreate( const TreeNode& root, const TreeNode& node,
 
       if( actor )
       {
+        // TEMP: Assume all script created actors are not using size negotiation for now
+        actor.SetRelayoutEnabled( false );
+
         // add children of all the styles
         if( OptionalChild actors = IsChild( node, KEYNAME_ACTORS ) )
         {
index 62f5e08..9713587 100644 (file)
@@ -22,6 +22,7 @@
 #include <dali/public-api/object/property-input.h>
 #include <dali/public-api/object/type-registry.h>
 #include <dali/public-api/object/type-registry-helper.h>
+#include <dali/public-api/size-negotiation/relayout-container.h>
 
 namespace Dali
 {
@@ -450,7 +451,7 @@ const Toolkit::Alignment::Padding& Alignment::GetPadding() const
   return mPadding;
 }
 
-void Alignment::OnRelayout( const Vector2& size, ActorSizeContainer& container )
+void Alignment::OnRelayout( const Vector2& size, RelayoutContainer& container )
 {
   // lay out the actors
   Vector3 anchorPointAndParentOrigin  = Vector3::ZERO;
@@ -474,59 +475,59 @@ void Alignment::OnRelayout( const Vector2& size, ActorSizeContainer& container )
     anchorPointAndParentOrigin.y = 1.0f;
   }
 
-  unsigned int childCount = Self().GetChildCount();
-  for( unsigned int i=0; i<childCount; ++i )
+  for( unsigned int i = 0, childCount = Self().GetChildCount(); i < childCount; ++i )
   {
-    Actor actor = Self().GetChildAt(i);
+    Actor child = Self().GetChildAt(i);
 
-    actor.SetAnchorPoint( anchorPointAndParentOrigin );
-    actor.SetParentOrigin( anchorPointAndParentOrigin );
+    child.SetAnchorPoint( anchorPointAndParentOrigin );
+    child.SetParentOrigin( anchorPointAndParentOrigin );
 
-    Vector3 actorSize ( actor.GetSize() );
-    Toolkit::Control control( Toolkit::Control::DownCast( actor ) );
-    if ( actorSize == Vector3::ZERO && control )
+    Vector3 currentChildSize( child.GetTargetSize() );
+    if( currentChildSize == Vector3::ZERO )
     {
-      actorSize = control.GetNaturalSize();
+      currentChildSize = child.GetNaturalSize();
     }
 
-    Vector3 childSize;
+    bool renegotiate = true;
+    Vector3 newChildSize;
 
     switch( mScaling )
     {
       case Toolkit::Alignment::ScaleNone:
       {
         // Nothing to do but needed just to not to jump to the default.
-        childSize = actorSize;
+        newChildSize = currentChildSize;
+        renegotiate = false;
         break;
       }
       case Toolkit::Alignment::ScaleToFill:
       {
         ScaleToFillConstraint constraint( mPadding );
-        childSize = constraint.GetSize( actorSize, Vector3(size) ) ;
+        newChildSize = constraint.GetSize( currentChildSize, Vector3(size) ) ;
         break;
       }
       case Toolkit::Alignment::ScaleToFitKeepAspect:
       {
         ScaleToFitKeepAspectConstraint constraint( mPadding );
-        childSize = constraint.GetSize( actorSize, Vector3(size) ) ;
+        newChildSize = constraint.GetSize( currentChildSize, Vector3(size) ) ;
         break;
       }
       case Toolkit::Alignment::ScaleToFillKeepAspect:
       {
         ScaleToFillKeepAspectConstraint constraint( mPadding );
-        childSize = constraint.GetSize( actorSize, Vector3(size) );
+        newChildSize = constraint.GetSize( currentChildSize, Vector3(size) );
         break;
       }
       case Toolkit::Alignment::ShrinkToFit:
       {
         ShrinkToFitConstraint constraint( mPadding );
-        childSize = constraint.GetSize( actorSize, Vector3(size) );
+        newChildSize = constraint.GetSize( currentChildSize, Vector3(size) );
         break;
       }
       case Toolkit::Alignment::ShrinkToFitKeepAspect:
       {
         ShrinkToFitKeepAspectConstraint constraint( mPadding );
-        childSize = constraint.GetSize( actorSize, Vector3(size) );
+        newChildSize = constraint.GetSize( currentChildSize, Vector3(size) );
         break;
       }
       default:
@@ -537,14 +538,12 @@ void Alignment::OnRelayout( const Vector2& size, ActorSizeContainer& container )
     }
 
     PositionConstraint positionConstraint(mPadding, mHorizontal, mVertical);
-    actor.SetPosition( positionConstraint.GetPosition(childSize, actorSize) );
+    child.SetPosition( positionConstraint.GetPosition(newChildSize, currentChildSize) );
 
-    if( !control )
+    if( renegotiate )
     {
-      actor.SetScale(childSize / actorSize);
+      container.Add( child, Vector2(newChildSize) );
     }
-
-    Relayout( actor, Vector2(childSize), container );
   }
 }
 
index 3788d84..44d058f 100644 (file)
@@ -84,7 +84,7 @@ private: // From Control
   /**
    * @copydoc Control::OnRelayout()
    */
-  virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
+  virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
 
 private:
 
index 656781f..0da7949 100644 (file)
@@ -82,6 +82,12 @@ CheckBoxButton::~CheckBoxButton()
   }
 }
 
+void CheckBoxButton::OnButtonInitialize()
+{
+  // Wrap around all children
+  Self().SetResizePolicy( FIT_TO_CHILDREN, ALL_DIMENSIONS );
+}
+
 void CheckBoxButton::SetSelectedImage( Actor image )
 {
   Actor& selectedImage = GetSelectedImage();
@@ -382,38 +388,6 @@ void CheckBoxButton::OnDisabled( bool disabled )
   }
 }
 
-void CheckBoxButton::OnRelayout( const Vector2& size, ActorSizeContainer& container )
-{
-  Vector3 newSize;
-
-  if( IsDisabled() && GetDisabledBackgroundImage() )
-  {
-    newSize = GetDisabledBackgroundImage().GetNaturalSize();
-  }
-  else if( GetBackgroundImage() )
-  {
-    newSize = GetBackgroundImage().GetNaturalSize();
-  }
-
-  Actor& label = GetLabel();
-
-  if( label )
-  {
-    // Offset the label from the radio button image
-    newSize.width += DISTANCE_BETWEEN_IMAGE_AND_LABEL.width;
-
-    // Find the size of the control using size negotiation
-    Vector3 actorNaturalSize( label.GetNaturalSize() );
-    Control::Relayout( label, Vector2( actorNaturalSize.width, actorNaturalSize.height ), container );
-
-    Vector3 actorSize( label.GetSize() );
-    newSize.width += actorSize.width;
-    newSize.height = std::max( newSize.height, actorSize.height );
-  }
-
-  Self().SetSize( newSize );
-}
-
 void CheckBoxButton::AddChild( Actor& actor )
 {
   if( actor )
index 9d4335a..47b91ae 100644 (file)
@@ -76,6 +76,12 @@ public: // From Button
 
 private: // From Button
 
+
+  /**
+   * @copydoc Toolkit::Internal::Button::OnButtonInitialize()
+   */
+  virtual void OnButtonInitialize();
+
   /**
    * @copydoc Toolkit::Internal::Button::OnLabelSet()
    */
@@ -91,13 +97,6 @@ private: // From Button
    */
   virtual void OnDisabled( bool disabled );
 
-private: // From Control
-
-  /**
-   * @copydoc Dali::Toolkit::Control::OnRelayout()
-   */
-  virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
-
 private:
 
   /**
index bd26b23..08948de 100644 (file)
@@ -23,7 +23,6 @@
 #include <dali/public-api/object/type-registry.h>
 
 // INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/relayout-helper.h>
 
 namespace Dali
 {
@@ -123,7 +122,7 @@ void PushButton::SetButtonImage( Actor image )
 
         buttonImage = image;
 
-        FadeInImage( buttonImage );
+        FadeInImage( buttonImage, 0.0f, 0 );
 
         StartFadeOutAnimation();
         StartFadeInAnimation();
@@ -131,7 +130,7 @@ void PushButton::SetButtonImage( Actor image )
       else
       {
         buttonImage = image;
-        Self().Add( buttonImage );
+        Self().Insert( 0, buttonImage );
       }
       break;
     }
@@ -148,7 +147,7 @@ void PushButton::SetButtonImage( Actor image )
       // Replaces the button image.
       buttonImage = image;
 
-      Self().Add( buttonImage );
+      Self().Insert( 0, buttonImage );
       FadeOutImage( Foreground, buttonImage, opacity );
 
       StartFadeOutAnimation();
@@ -162,7 +161,7 @@ void PushButton::SetButtonImage( Actor image )
 
       buttonImage = image;
 
-      FadeInImage( buttonImage );
+      FadeInImage( buttonImage, 0.0f, 0 );
       StartFadeInAnimation();
       break;
     }
@@ -174,7 +173,8 @@ void PushButton::SetButtonImage( Actor image )
   buttonImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
   buttonImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
   buttonImage.SetPosition( 0.f, 0.f, FOREGROUND_DEPTH );
-  buttonImage.SetSizeMode( SIZE_EQUAL_TO_PARENT );
+  buttonImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+  buttonImage.SetName( "BUTTON_IMAGE" );
 }
 
 void PushButton::SetSelectedImage( Actor image )
@@ -193,7 +193,7 @@ void PushButton::SetSelectedImage( Actor image )
 
         selectedImage = image;
 
-        FadeInImage( selectedImage );
+        FadeInImage( selectedImage, 0.0f, 0 );
 
         StartFadeOutAnimation();
         StartFadeInAnimation();
@@ -201,7 +201,7 @@ void PushButton::SetSelectedImage( Actor image )
       else
       {
         selectedImage = image;
-        Self().Add( selectedImage );
+        Self().Insert( 0, selectedImage );
       }
       break;
     }
@@ -218,7 +218,7 @@ void PushButton::SetSelectedImage( Actor image )
       // Replaces the button image.
       selectedImage = image;
 
-      Self().Add( selectedImage );
+      Self().Insert( 0, selectedImage );
       FadeOutImage( Foreground, selectedImage, opacity );
 
       StartFadeOutAnimation();
@@ -232,7 +232,7 @@ void PushButton::SetSelectedImage( Actor image )
 
       selectedImage = image;
 
-      FadeInImage( selectedImage );
+      FadeInImage( selectedImage, 0.0f, 0 );
       StartFadeInAnimation();
       break;
     }
@@ -244,7 +244,7 @@ void PushButton::SetSelectedImage( Actor image )
   selectedImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
   selectedImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
   selectedImage.SetPosition( 0.f, 0.f, FOREGROUND_DEPTH );
-  selectedImage.SetSizeMode( SIZE_EQUAL_TO_PARENT );
+  selectedImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
 }
 
 void PushButton::SetBackgroundImage( Actor image )
@@ -266,7 +266,7 @@ void PushButton::SetBackgroundImage( Actor image )
 
         backgroundImage = image;
 
-        FadeInImage( backgroundImage );
+        FadeInImage( backgroundImage, 0.0f, 0 );
 
         StartFadeOutAnimation();
         StartFadeInAnimation();
@@ -274,7 +274,7 @@ void PushButton::SetBackgroundImage( Actor image )
       else
       {
         backgroundImage = image;
-        Self().Add( backgroundImage );
+        Self().Insert( 0, backgroundImage );
       }
       break;
     }
@@ -291,7 +291,7 @@ void PushButton::SetBackgroundImage( Actor image )
       // Replaces the button image.
       backgroundImage = image;
 
-      Self().Add( backgroundImage );
+      Self().Insert( 0, backgroundImage );
       FadeOutImage( Background, backgroundImage, opacity );
 
       StartFadeOutAnimation();
@@ -305,7 +305,7 @@ void PushButton::SetBackgroundImage( Actor image )
 
       backgroundImage = image;
 
-      FadeInImage( backgroundImage );
+      FadeInImage( backgroundImage, 0.0f, 0 );
       StartFadeInAnimation();
       break;
     }
@@ -317,7 +317,7 @@ void PushButton::SetBackgroundImage( Actor image )
   backgroundImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
   backgroundImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
   backgroundImage.SetPosition( 0.f, 0.f, BACKGROUND_DEPTH );
-  backgroundImage.SetSizeMode( SIZE_EQUAL_TO_PARENT );
+  backgroundImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
 }
 
 void PushButton::SetDisabledImage( Actor image )
@@ -337,7 +337,7 @@ void PushButton::SetDisabledImage( Actor image )
 
         disabledImage = image;
 
-        FadeInImage( disabledImage );
+        FadeInImage( disabledImage, 0.0f, 0 );
 
         StartFadeOutAnimation();
         StartFadeInAnimation();
@@ -357,7 +357,7 @@ void PushButton::SetDisabledImage( Actor image )
 
       disabledImage = image;
 
-      FadeInImage( disabledImage );
+      FadeInImage( disabledImage, 0.0f, 0 );
       StartFadeInAnimation();
       break;
     }
@@ -388,7 +388,7 @@ void PushButton::SetDisabledImage( Actor image )
   disabledImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
   disabledImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
   disabledImage.SetPosition( 0.f, 0.f, FOREGROUND_DEPTH );
-  disabledImage.SetSizeMode( SIZE_EQUAL_TO_PARENT );
+  disabledImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
 }
 
 void PushButton::SetDisabledBackgroundImage( Actor image )
@@ -408,7 +408,7 @@ void PushButton::SetDisabledBackgroundImage( Actor image )
 
         disabledBackgroundImage = image;
 
-        FadeInImage( disabledBackgroundImage );
+        FadeInImage( disabledBackgroundImage, 0.0f, 0 );
 
         StartFadeOutAnimation();
         StartFadeInAnimation();
@@ -428,7 +428,7 @@ void PushButton::SetDisabledBackgroundImage( Actor image )
 
       disabledBackgroundImage = image;
 
-      FadeInImage( disabledBackgroundImage );
+      FadeInImage( disabledBackgroundImage, 0.0f, 0 );
       StartFadeInAnimation();
       break;
     }
@@ -459,7 +459,7 @@ void PushButton::SetDisabledBackgroundImage( Actor image )
   disabledBackgroundImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
   disabledBackgroundImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
   disabledBackgroundImage.SetPosition( 0.f, 0.f, BACKGROUND_DEPTH );
-  disabledBackgroundImage.SetSizeMode( SIZE_EQUAL_TO_PARENT );
+  disabledBackgroundImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
 }
 
 void PushButton::OnButtonInitialize()
@@ -467,6 +467,9 @@ void PushButton::OnButtonInitialize()
   // Push button requires the Leave event.
   Actor root = Self();
   root.SetLeaveRequired( true );
+
+  // Set resize policy to natural size so that buttons will resize to background images
+  root.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS );
 }
 
 void PushButton::OnLabelSet()
@@ -496,7 +499,7 @@ void PushButton::OnSelected( bool selected )
     {
       StopFadeOutAnimation();
       FadeOutImage( Foreground, buttonImage );
-      FadeInImage( selectedImage );
+      FadeInImage( selectedImage, 0.0f, 0 );
       StartFadeOutAnimation();
       StartFadeInAnimation();
 
@@ -514,7 +517,7 @@ void PushButton::OnSelected( bool selected )
     {
       StopFadeOutAnimation();
       FadeOutImage( Foreground, selectedImage );
-      FadeInImage( buttonImage );
+      FadeInImage( buttonImage, 0.0f, 0 );
       StartFadeOutAnimation();
       StartFadeInAnimation();
 
@@ -539,7 +542,7 @@ void PushButton::OnSelected( bool selected )
       StopFadeInAnimation();
 
       FadeOutImage( Foreground, selectedImage, 1.f - opacity );
-      FadeInImage( buttonImage, opacity );
+      FadeInImage( buttonImage, opacity, 0 );
 
       StartFadeOutAnimation();
       StartFadeInAnimation();
@@ -565,7 +568,7 @@ void PushButton::OnSelected( bool selected )
       StopFadeInAnimation();
 
       FadeOutImage( Foreground, buttonImage, 1.f - opacity );
-      FadeInImage( selectedImage, opacity );
+      FadeInImage( selectedImage, opacity, 0 );
 
       StartFadeOutAnimation();
       StartFadeInAnimation();
@@ -605,8 +608,8 @@ void PushButton::OnDisabled( bool disabled )
       StopFadeOutAnimation();
       FadeOutImage( Background, backgroundImage );
       FadeOutImage( Foreground, buttonImage );
-      FadeInImage( disabledBackgroundImage );
-      FadeInImage( disabledImage );
+      FadeInImage( disabledBackgroundImage, 0.0f, 0 );
+      FadeInImage( disabledImage, 0.0f, 0 );
       StartFadeOutAnimation();
       StartFadeInAnimation();
 
@@ -628,8 +631,8 @@ void PushButton::OnDisabled( bool disabled )
       StopFadeOutAnimation();
       FadeOutImage( Background, backgroundImage );
       FadeOutImage( Foreground, selectedImage );
-      FadeInImage( disabledBackgroundImage );
-      FadeInImage( disabledImage );
+      FadeInImage( disabledBackgroundImage, 0.0f, 0 );
+      FadeInImage( disabledImage, 0.0f, 0 );
       StartFadeOutAnimation();
       StartFadeInAnimation();
 
@@ -651,8 +654,8 @@ void PushButton::OnDisabled( bool disabled )
       StopFadeOutAnimation();
       FadeOutImage( Background, disabledBackgroundImage );
       FadeOutImage( Foreground, disabledImage );
-      FadeInImage( backgroundImage );
-      FadeInImage( buttonImage );
+      FadeInImage( backgroundImage, 0.0f, 0 );
+      FadeInImage( buttonImage, 0.0f, 0 );
       StartFadeOutAnimation();
       StartFadeInAnimation();
 
@@ -674,8 +677,8 @@ void PushButton::OnDisabled( bool disabled )
       StopFadeOutAnimation();
       FadeOutImage( Background, disabledBackgroundImage );
       FadeOutImage( Foreground, disabledImage );
-      FadeInImage( backgroundImage );
-      FadeInImage( selectedImage );
+      FadeInImage( backgroundImage, 0.0f, 0 );
+      FadeInImage( selectedImage, 0.0f, 0 );
       StartFadeOutAnimation();
       StartFadeInAnimation();
 
@@ -705,8 +708,8 @@ void PushButton::OnDisabled( bool disabled )
       FadeOutImage( Foreground, selectedImage, 1.f - opacity );
       FadeOutImage( Background, backgroundImage );
 
-      FadeInImage( disabledImage );
-      FadeInImage( disabledBackgroundImage );
+      FadeInImage( disabledImage, 0.0f, 0 );
+      FadeInImage( disabledBackgroundImage, 0.0f, 0 );
 
       StartFadeOutAnimation();
       StartFadeInAnimation();
@@ -737,8 +740,8 @@ void PushButton::OnDisabled( bool disabled )
       FadeOutImage( Foreground, buttonImage, 1.f - opacity );
       FadeOutImage( Background, backgroundImage );
 
-      FadeInImage( disabledImage );
-      FadeInImage( disabledBackgroundImage );
+      FadeInImage( disabledImage, 0.0f, 0);
+      FadeInImage( disabledBackgroundImage, 0.0f, 0 );
 
       StartFadeOutAnimation();
       StartFadeInAnimation();
@@ -768,8 +771,8 @@ void PushButton::OnDisabled( bool disabled )
 
       FadeOutImage( Foreground, disabledImage, 1.f - opacity );
       FadeOutImage( Background, disabledBackgroundImage, 1.f - opacity );
-      FadeInImage( buttonImage, opacity );
-      FadeInImage( backgroundImage, opacity );
+      FadeInImage( buttonImage, opacity, 0 );
+      FadeInImage( backgroundImage, opacity, 0 );
 
       StartFadeOutAnimation();
       StartFadeInAnimation();
@@ -799,8 +802,8 @@ void PushButton::OnDisabled( bool disabled )
 
       FadeOutImage( Foreground, buttonImage, 1.f - opacity );
       FadeOutImage( Background, backgroundImage, 1.f - opacity );
-      FadeInImage( disabledImage, opacity );
-      FadeInImage( disabledBackgroundImage, opacity );
+      FadeInImage( disabledImage, opacity, 0 );
+      FadeInImage( disabledBackgroundImage, opacity, 0 );
 
       StartFadeOutAnimation();
       StartFadeInAnimation();
@@ -830,8 +833,8 @@ void PushButton::OnDisabled( bool disabled )
 
       FadeOutImage( Foreground, disabledImage, 1.f - opacity );
       FadeOutImage( Background, disabledBackgroundImage, 1.f - opacity );
-      FadeInImage( selectedImage, opacity );
-      FadeInImage( backgroundImage, opacity );
+      FadeInImage( selectedImage, opacity, 0 );
+      FadeInImage( backgroundImage, opacity, 0 );
 
       StartFadeOutAnimation();
       StartFadeInAnimation();
@@ -861,8 +864,8 @@ void PushButton::OnDisabled( bool disabled )
 
       FadeOutImage( Foreground, selectedImage, 1.f - opacity );
       FadeOutImage( Background, backgroundImage, 1.f - opacity );
-      FadeInImage( disabledImage, opacity );
-      FadeInImage( disabledBackgroundImage, opacity );
+      FadeInImage( disabledImage, opacity, 0 );
+      FadeInImage( disabledBackgroundImage, opacity, 0 );
 
       StartFadeOutAnimation();
       StartFadeInAnimation();
@@ -895,7 +898,7 @@ void PushButton::OnPressed()
     {
       StopFadeOutAnimation();
       FadeOutImage( Foreground, buttonImage );
-      FadeInImage( selectedImage );
+      FadeInImage( selectedImage, 0.0f, 0 );
       StartFadeOutAnimation();
       StartFadeInAnimation();
 
@@ -928,7 +931,7 @@ void PushButton::OnPressed()
       StopFadeInAnimation();
 
       FadeOutImage( Foreground, buttonImage, 1.f - opacity );
-      FadeInImage( selectedImage, opacity );
+      FadeInImage( selectedImage, opacity, 0 );
 
       StartFadeOutAnimation();
       StartFadeInAnimation();
@@ -960,7 +963,7 @@ void PushButton::OnReleased()
     {
       StopFadeOutAnimation();
       FadeOutImage( Foreground, selectedImage );
-      FadeInImage( buttonImage );
+      FadeInImage( buttonImage, 0.0f, 0 );
       StartFadeOutAnimation();
       StartFadeInAnimation();
 
@@ -985,7 +988,7 @@ void PushButton::OnReleased()
       StopFadeInAnimation();
 
       FadeOutImage( Foreground, selectedImage, 1.f - opacity );
-      FadeInImage( buttonImage, opacity );
+      FadeInImage( buttonImage, opacity, 0 );
 
       StartFadeOutAnimation();
       StartFadeInAnimation();
@@ -1040,7 +1043,7 @@ Vector3 PushButton::GetNaturalSize()
     ImageActor imageActor = FindImageActor( GetButtonImage() );
     if( imageActor && imageActor.GetStyle() != ImageActor::STYLE_NINE_PATCH )
     {
-      Vector3 imageSize = RelayoutHelper::GetNaturalSize( imageActor );
+      Vector3 imageSize = imageActor.GetNaturalSize();
 
       if( widthIsZero )
       {
@@ -1056,7 +1059,7 @@ Vector3 PushButton::GetNaturalSize()
     ImageActor backgroundImageActor = FindImageActor( GetBackgroundImage() );
     if( backgroundImageActor && backgroundImageActor.GetStyle() != ImageActor::STYLE_NINE_PATCH )
     {
-      Vector3 imageSize = RelayoutHelper::GetNaturalSize( backgroundImageActor );
+      Vector3 imageSize = backgroundImageActor.GetNaturalSize();
 
       if( widthIsZero )
       {
@@ -1158,14 +1161,21 @@ void PushButton::StopFadeOutAnimation( bool remove )
   }
 }
 
-void PushButton::FadeInImage( Actor& image, float opacity )
+void PushButton::FadeInImage( Actor& image, float opacity, int priority )
 {
   if( image )
   {
     image.SetOpacity( opacity );
     if( !image.GetParent() )
     {
-      Self().Add( image );
+      if( priority > -1 )
+      {
+        Self().Insert( priority, image );
+      }
+      else
+      {
+        Self().Add( image );
+      }
     }
 
     AddToFadeInAnimation( image );
index 2784bab..89bce4b 100644 (file)
@@ -201,7 +201,7 @@ private:
    * @param[inout] image The actor.
    * @param[in] opacity The initial opacity.
    */
-  void FadeInImage( Actor& image, float opacity = 0.f );
+  void FadeInImage( Actor& image, float opacity = 0.f, int priority = -1 );
 
   /**
    * It adds the actor fade out animation and stores it to be removed when the animation finishes.
index d1ccebd..05dba27 100644 (file)
@@ -45,7 +45,7 @@ TypeRegistration typeRegistration( typeid( Toolkit::RadioButton ), typeid( Toolk
 const char* const UNSELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "radio-button-unselected.png";
 const char* const SELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "radio-button-selected.png";
 
-const Vector3 DISTANCE_BETWEEN_IMAGE_AND_LABEL(5.0f, 0.0f, 0.0f);
+const float DISTANCE_BETWEEN_IMAGE_AND_LABEL = 5.0f;
 }
 
 Dali::Toolkit::RadioButton RadioButton::New()
@@ -72,72 +72,48 @@ RadioButton::~RadioButton()
 {
 }
 
-void RadioButton::SetButtonImage( Actor image )
+void RadioButton::SetImage( Actor image )
 {
-  Actor& buttonImage = GetButtonImage();
+  mLayoutContainer.RemoveChildAt( Toolkit::TableView::CellPosition( 0, 0 ) );
+  mLayoutContainer.AddChild( image, Toolkit::TableView::CellPosition( 0, 0 ) );
 
-  if( !IsSelected() )
-  {
-    if( buttonImage && buttonImage.GetParent() )
-    {
-      buttonImage.GetParent().Remove( buttonImage );
-      buttonImage.Reset();
-    }
-
-    Self().Add( image );
-
-    Actor& label = GetLabel();
-
-    if( label )
-    {
-      buttonImage.Remove( label );
-      image.Add( label );
-    }
-  }
+  RelayoutRequest();
+}
 
+void RadioButton::SetButtonImage( Actor image )
+{
+  Actor& buttonImage = GetButtonImage();
   buttonImage = image;
-
-  buttonImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-  buttonImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
 }
 
 void RadioButton::SetSelectedImage( Actor image )
 {
   Actor& selectedImage = GetSelectedImage();
-
-  if( IsSelected() )
-  {
-    if( selectedImage && selectedImage.GetParent() )
-    {
-      selectedImage.GetParent().Remove( selectedImage );
-      selectedImage.Reset();
-    }
-
-    Self().Add( image );
-
-    Actor& label = GetLabel();
-
-    if( label )
-    {
-      selectedImage.Remove( label );
-      image.Add( label );
-    }
-  }
-
   selectedImage = image;
-
-  selectedImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-  selectedImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
 }
 
 void RadioButton::OnButtonInitialize()
 {
+  Actor self = Self();
+
+  // Wrap size of radio button around all its children
+  self.SetResizePolicy( FIT_TO_CHILDREN, ALL_DIMENSIONS );
+
+  // Create the layout container empty at first
+  mLayoutContainer = Toolkit::TableView::New( 0, 0 );
+  mLayoutContainer.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  mLayoutContainer.SetParentOrigin( ParentOrigin::TOP_LEFT );
+  mLayoutContainer.SetResizePolicy( FIT_TO_CHILDREN, ALL_DIMENSIONS );
+  self.Add( mLayoutContainer );
+
   Image buttonImage = Dali::ResourceImage::New( UNSELECTED_BUTTON_IMAGE_DIR );
   Image selectedImage = Dali::ResourceImage::New( SELECTED_BUTTON_IMAGE_DIR );
 
   SetButtonImage( ImageActor::New( buttonImage ) );
   SetSelectedImage( ImageActor::New( selectedImage ) );
 
+  SetImage( GetButtonImage() );
+
   RelayoutRequest();
 }
 
@@ -148,7 +124,7 @@ void RadioButton::OnButtonUp()
     // Don't allow selection on an already selected radio button
     if( !IsSelected() )
     {
-      SetSelected(!IsSelected());
+      SetSelected( !IsSelected() );
     }
   }
 }
@@ -159,27 +135,16 @@ void RadioButton::OnLabelSet()
 
   if( label )
   {
-    label.SetParentOrigin( ParentOrigin::CENTER_RIGHT );
-    label.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
-    label.TranslateBy( DISTANCE_BETWEEN_IMAGE_AND_LABEL );
+    // Add padding to the left of the label to create distance from the image
+    label.SetPadding( Padding( DISTANCE_BETWEEN_IMAGE_AND_LABEL, 0.0f, 0.0f, 0.0f ) );
 
-    if( IsSelected() )
-    {
-      GetSelectedImage().Add( label );
-    }
-    else
-    {
-      GetButtonImage().Add( label );
-    }
+    mLayoutContainer.RemoveChildAt( Toolkit::TableView::CellPosition( 0, 1 ) );
+    mLayoutContainer.AddChild( label, Toolkit::TableView::CellPosition( 0, 1 ) );
   }
 }
 
 void RadioButton::OnSelected( bool selected )
 {
-  Actor& buttonImage = GetButtonImage();
-  Actor& selectedImage = GetSelectedImage();
-  Actor& label = GetLabel();
-
   if( selected )
   {
     Actor parent = Self().GetParent();
@@ -187,69 +152,22 @@ void RadioButton::OnSelected( bool selected )
     {
       for( unsigned int i = 0; i < parent.GetChildCount(); ++i )
       {
-        Dali::Toolkit::RadioButton rbChild = Dali::Toolkit::RadioButton::DownCast(parent.GetChildAt(i));
-
-        if( rbChild )
+        Dali::Toolkit::RadioButton radioButtonChild = Dali::Toolkit::RadioButton::DownCast( parent.GetChildAt( i ) );
+        if( radioButtonChild )
         {
-          rbChild.SetSelected(false);
+          radioButtonChild.SetSelected( false );
         }
       }
     }
 
-    buttonImage.GetParent().Remove( buttonImage );
-    Self().Add( selectedImage );
-
-    if( label )
-    {
-      label.GetParent().Remove( label );
-      selectedImage.Add( label );
-    }
+    SetImage( GetSelectedImage() );
   }
   else
   {
-    selectedImage.GetParent().Remove( selectedImage );
-    Self().Add( buttonImage );
-
-    if( label )
-    {
-      label.GetParent().Remove( label );
-      buttonImage.Add( label );
-    }
+    SetImage( GetButtonImage() );
   }
 }
 
-void RadioButton::OnRelayout( const Vector2& /*size*/, ActorSizeContainer& container )
-{
-  Vector3 newSize;
-
-  if( IsSelected() )
-  {
-    newSize = GetSelectedImage().GetNaturalSize();
-  }
-  else
-  {
-    newSize = GetButtonImage().GetNaturalSize();
-  }
-
-  Actor& label = GetLabel();
-
-  if( label )
-  {
-    // Offset the label from the radio button image
-    newSize.width += DISTANCE_BETWEEN_IMAGE_AND_LABEL.width;
-
-    // Find the size of the control using size negotiation
-    Vector3 actorNaturalSize( label.GetNaturalSize() );
-    Control::Relayout( label, Vector2( actorNaturalSize.width, actorNaturalSize.height ), container );
-
-    Vector3 actorSize( label.GetSize() );
-    newSize.width += actorSize.width;
-    newSize.height = std::max( newSize.height, actorSize.height );
-  }
-
-  Self().SetSize( newSize );
-}
-
 } // namespace Internal
 
 } // namespace Toolkit
index 6bda4d6..43a3c62 100644 (file)
@@ -24,6 +24,7 @@
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/buttons/radio-button.h>
+#include <dali-toolkit/public-api/controls/table-view/table-view.h>
 #include "button-impl.h"
 
 namespace Dali
@@ -103,12 +104,14 @@ private: // From Button
    */
   virtual void OnLabelSet();
 
-private: // From Control
+private:
 
   /**
-   * @copydoc Dali::Toolkit::Control::OnRelayout()
+   * @brief Set the image to display
+   *
+   * @param[in] image The image to set
    */
-  virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
+  void SetImage( Actor image );
 
 private:
 
@@ -117,6 +120,11 @@ private:
 
   // Undefined
   RadioButton& operator=( const RadioButton& origin );
+
+private:
+
+  Toolkit::TableView mLayoutContainer;      ///< Container to position button images and labels
+
 };
 
 } // namespace Internal
index 7521051..37e5776 100644 (file)
@@ -283,6 +283,7 @@ void Magnifier::SetFrameVisibility(bool visible)
 
     Image image = ResourceImage::New( DEFAULT_FRAME_IMAGE_PATH );
     mFrame = ImageActor::New( image );
+    mFrame.SetRelayoutEnabled( false );
     mFrame.SetDrawMode(DrawMode::OVERLAY);
     mFrame.SetStyle( ImageActor::STYLE_NINE_PATCH );
     mFrame.SetPositionInheritanceMode(DONT_INHERIT_POSITION);
index ac5244a..91fb19f 100644 (file)
 #include <dali/public-api/events/key-event.h>
 #include <dali/public-api/object/type-registry.h>
 #include <dali/public-api/object/type-registry-helper.h>
+#include <dali/public-api/size-negotiation/relayout-container.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/focus-manager/focus-manager.h>
 #include <dali-toolkit/internal/controls/navigation-frame/navigation-tool-bar.h>
 #include <dali-toolkit/internal/controls/navigation-frame/navigation-title-bar.h>
-#include <dali-toolkit/internal/controls/relayout-controller.h>
+#include <dali-toolkit/public-api/focus-manager/focus-manager.h>
 
 namespace Dali
 {
@@ -284,7 +285,7 @@ Layer NavigationControl::GetBarLayer() const
   return mBarLayer;
 }
 
-void NavigationControl::OnRelayout( const Vector2& size, ActorSizeContainer& container )
+void NavigationControl::OnRelayout( const Vector2& size, RelayoutContainer& container )
 {
   const Vector2 setSize( size );
 
@@ -307,11 +308,11 @@ void NavigationControl::OnRelayout( const Vector2& size, ActorSizeContainer& con
     mCurrentItem.SetPosition( mItemPositionCoefficient * positionOffset);
     Vector2 itemSize( setSize.x, setSize.y-sizeShrink );
 
-    Relayout(mCurrentItem, itemSize, container);
+    container.Add( mCurrentItem, itemSize );
   }
 
-  container.push_back(ActorSizePair( mBarLayer, setSize ));
-  container.push_back(ActorSizePair( mPopupLayer, setSize ));
+  container.Add( mBarLayer, setSize );
+  container.Add( mPopupLayer, setSize );
 }
 
 void NavigationControl::OnControlSizeSet( const Vector3& size )
index 41990a2..1e7f0a2 100644 (file)
@@ -157,7 +157,7 @@ private: // override functions from Control
   /**
    * @copydoc Control::OnRelayout()
    */
-  virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
+  virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
 
   /**
    * @copydoc Control::OnControlSizeSet
index c7bbaf6..b67bdcc 100755 (executable)
@@ -28,6 +28,7 @@
 #include <dali/public-api/images/resource-image.h>
 #include <dali/public-api/object/type-registry.h>
 #include <dali/public-api/object/type-registry-helper.h>
+#include <dali/public-api/size-negotiation/relayout-container.h>
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
@@ -35,7 +36,6 @@
 #include <dali-toolkit/public-api/controls/control-impl.h>
 #include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
 #include <dali-toolkit/public-api/focus-manager/focus-manager.h>
-#include <dali-toolkit/internal/controls/relayout-helper.h>
 #include <dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h>
 
 using namespace Dali;
@@ -69,9 +69,7 @@ DALI_TYPE_REGISTRATION_END()
 const char* const PROPERTY_TITLE = "title";
 const char* const PROPERTY_STATE = "state";
 
-const float CONTENT_DEPTH = 1.0f;                                 ///< 3D Effect of buttons/title etc. appearing off the popup.
-const float POPUP_ANIMATION_DURATION = 0.5f;                      ///< Duration of hide/show animations
-const float BACKING_DEPTH = -1.0f;                                ///< Depth of backing (positioned just behind dialog, so dialog catches hit events first)
+const float POPUP_ANIMATION_DURATION = 0.45f;                      ///< Duration of hide/show animations
 
 const float POPUP_WIDTH = 720.0f;                             ///< Width of Popup
 const float POPUP_OUT_MARGIN_WIDTH = 16.f;                    ///< Space between the screen edge and the popup edge in the horizontal dimension.
@@ -81,40 +79,6 @@ const float POPUP_BUTTON_BG_HEIGHT = 96.f;                    ///< Height of But
 const Vector3 DEFAULT_DIALOG_SIZE = Vector3(POPUP_TITLE_WIDTH/POPUP_WIDTH, 0.5f, 0.0f);
 const Vector3 DEFAULT_BOTTOM_SIZE = Vector3(1.0f, 0.2f, 0.0f);
 
-/**
- * The background size should be at least as big as the Dialog.
- * In some cases a background may have graphics which are visible
- * outside of the Dialog, e.g. A Shadow. For this we need to alter
- * the size of Background.
- *
- * @param[in] outerBorder The border to extend beyond parent's Size.
- * @param[in] parentSize  The parent's size
- */
-Vector3 BackgroundSize(const Vector4& outerBoarder, const Vector3& parentSize)
-{
-  Vector3 size( parentSize );
-  size.width += outerBoarder.x + outerBoarder.y;
-  size.height += outerBoarder.z + outerBoarder.w;
-
-  return size;
-}
-
-  /**
-   * sets button area size to parent's size plus a border.
-   *
-   * @param[in] outerBorder The border to extend beyond parent's Size.
-   * @param[in] parentSize  The parent's size
-   */
-Vector3 ButtonAreaSize( const Vector4& outBoarder, const Vector3& parentSize )
-{
-  Vector3 size( parentSize );
-  size.width += outBoarder.x + outBoarder.y;
-  size.width -= (POPUP_OUT_MARGIN_WIDTH + POPUP_OUT_MARGIN_WIDTH);
-  size.height = POPUP_BUTTON_BG_HEIGHT;
-
-  return size;
-}
-
 } // unnamed namespace
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -152,33 +116,49 @@ Popup::Popup(PopupStyle& style)
 
 void Popup::OnInitialize()
 {
+  Dali::Stage stage = Dali::Stage::GetCurrent();
+
   Actor self = Self();
   self.SetSensitive(false);
+  // Reisize to fit the height of children
+  self.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT );
 
   // Create Layer
   mLayer = Layer::New();
+  mLayer.SetName( "POPUP_LAYER" );
   mLayer.SetParentOrigin(ParentOrigin::CENTER);
   mLayer.SetAnchorPoint(AnchorPoint::CENTER);
-  mLayer.RaiseToTop();
-  self.Add(mLayer);
-
-  mPopupBg = Actor::New();
-  mPopupBg.SetParentOrigin(ParentOrigin::CENTER);
-  mPopupBg.SetAnchorPoint(AnchorPoint::CENTER);
-  mLayer.Add(mPopupBg);
+  mLayer.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+  mLayer.SetDrawMode( DrawMode::OVERLAY );
 
   // Any content after this point which is added to Self() will be reparented to
   // mContent.
   mAlterAddedChild = true;
-
   // Add Backing (Dim effect)
   CreateBacking();
+  mAlterAddedChild = false;
 
   // Add Dialog ( background image, title, content container, button container and tail )
   CreateDialog();
 
+  mLayer.Add( self );
+
+  mPopupLayout = Toolkit::TableView::New( 3, 1 );
+  mPopupLayout.SetName( "POPUP_LAYOUT_TABLE" );
+  mPopupLayout.SetParentOrigin(ParentOrigin::CENTER);
+  mPopupLayout.SetAnchorPoint(AnchorPoint::CENTER);
+  mPopupLayout.SetResizePolicy( FILL_TO_PARENT, WIDTH );
+  mPopupLayout.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
+  mPopupLayout.SetFitHeight( 0 );   // Set row to fit
+  mPopupLayout.SetFitHeight( 1 );   // Set row to fit
+  self.Add( mPopupLayout );
+
+  // Any content after this point which is added to Self() will be reparented to
+  // mContent.
+  mAlterAddedChild = true;
+
   // Default content.
-  ShowTail(ParentOrigin::BOTTOM_CENTER);
+//  ShowTail(ParentOrigin::BOTTOM_CENTER);
 
   // Hide content by default.
   SetState( Toolkit::Popup::POPUP_HIDE, 0.0f );
@@ -191,6 +171,12 @@ void Popup::OnInitialize()
   SetAsKeyboardFocusGroup(true);
 }
 
+void Popup::MarkDirtyForRelayout()
+{
+  // Flag all the popup controls for relayout as it is about to be hidden and miss the main flagging pass
+  mLayer.RelayoutRequestTree();
+}
+
 void Popup::OnPropertySet( Property::Index index, Property::Value propertyValue )
 {
   if( index == mPropertyTitle )
@@ -213,6 +199,7 @@ void Popup::OnPropertySet( Property::Index index, Property::Value propertyValue
 
 Popup::~Popup()
 {
+  mLayer.Unparent();
 }
 
 size_t Popup::GetButtonCount() const
@@ -223,26 +210,39 @@ size_t Popup::GetButtonCount() const
 void Popup::SetBackgroundImage( Actor image )
 {
   // Removes any previous background.
-  if( mBackgroundImage && mPopupBg )
+  if( mBackgroundImage && mPopupLayout )
   {
-    mPopupBg.Remove( mBackgroundImage );
+    mPopupLayout.Remove( mBackgroundImage );
   }
 
   // Adds new background to the dialog.
   mBackgroundImage = image;
 
+  mBackgroundImage.SetName( "POPUP_BACKGROUND_IMAGE" );
+
   // OnDialogTouched only consume the event. It prevents the touch event to be caught by the backing.
   mBackgroundImage.TouchedSignal().Connect( this, &Popup::OnDialogTouched );
 
-  mPopupBg.Add( mBackgroundImage );
+  mBackgroundImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+  mBackgroundImage.SetAnchorPoint( AnchorPoint::CENTER );
+  mBackgroundImage.SetParentOrigin( ParentOrigin::CENTER );
+
+  mBackgroundImage.SetSizeMode( SIZE_FIXED_OFFSET_FROM_PARENT );
+  Vector3 border( mPopupStyle->backgroundOuterBorder.x, mPopupStyle->backgroundOuterBorder.z, 0.0f );
+  mBackgroundImage.SetSizeModeFactor( border );
+
+  const bool prevAlter = mAlterAddedChild;
+  mAlterAddedChild = false;
+  Self().Add( mBackgroundImage );
+  mAlterAddedChild = prevAlter;
 }
 
 void Popup::SetButtonAreaImage( Actor image )
 {
   // Removes any previous area image.
-  if( mButtonAreaImage && mPopupBg )
+  if( mButtonAreaImage && mPopupLayout )
   {
-    mPopupBg.Remove( mButtonAreaImage );
+    mPopupLayout.Remove( mButtonAreaImage );
   }
 
   // Adds new area image to the dialog.
@@ -251,11 +251,19 @@ void Popup::SetButtonAreaImage( Actor image )
   // OnDialogTouched only consume the event. It prevents the touch event to be caught by the backing.
   mButtonAreaImage.TouchedSignal().Connect( this, &Popup::OnDialogTouched );
 
-  mPopupBg.Add( mButtonAreaImage );
+  mButtonAreaImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+  mButtonAreaImage.SetAnchorPoint( AnchorPoint::CENTER );
+  mButtonAreaImage.SetParentOrigin( ParentOrigin::CENTER );
+
+  if( GetButtonCount() > 0 )
+  {
+    mBottomBg.Add( mButtonAreaImage );
+  }
 }
 
 void Popup::SetTitle( const std::string& text )
 {
+// TODO
 }
 
 const std::string& Popup::GetTitle() const
@@ -264,9 +272,37 @@ const std::string& Popup::GetTitle() const
   return temp;
 }
 
+void Popup::CreateFooter()
+{
+  if( !mBottomBg )
+  {
+    // Adds bottom background
+    mBottomBg = Actor::New();
+    mBottomBg.SetName( "POPUP_BOTTOM_BG" );
+    mBottomBg.SetRelayoutEnabled( true );
+    mBottomBg.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+
+    mPopupLayout.SetFixedHeight( 2, mPopupStyle->bottomSize.height );   // Buttons
+    mPopupLayout.AddChild( mBottomBg, Toolkit::TableView::CellPosition( 2, 0 ) );
+  }
+}
+
 void Popup::AddButton( Toolkit::Button button )
 {
   mButtons.push_back( button );
+  button.SetResizePolicy( USE_ASSIGNED_SIZE, ALL_DIMENSIONS );    // Size will be assigned to it
+
+  // If this is the first button added
+  if( mButtons.size() == 1 )
+  {
+    CreateFooter();
+
+    if( mButtonAreaImage )
+    {
+      mBottomBg.Add( mButtonAreaImage );
+    }
+  }
+
   mBottomBg.Add( button );
 
   RelayoutRequest();
@@ -326,6 +362,8 @@ void Popup::ShowTail(const Vector3& position)
     mTailImage.SetParentOrigin(position);
     mTailImage.SetAnchorPoint(anchorPoint);
 
+    CreateFooter();
+
     mBottomBg.Add(mTailImage);
   }
 }
@@ -348,30 +386,25 @@ PopupStylePtr Popup::GetStyle() const
 
 void Popup::SetDefaultBackgroundImage()
 {
-  Image bg = ResourceImage::New( mPopupStyle->backgroundImage );
-  ImageActor bgImage = ImageActor::New( bg );
-  bgImage.SetStyle( ImageActor::STYLE_NINE_PATCH );
-  bgImage.SetNinePatchBorder( mPopupStyle->backgroundScale9Border );
-
   Image buttonBg = ResourceImage::New( mPopupStyle->buttonAreaImage );
   ImageActor buttonBgImage = ImageActor::New( buttonBg );
   buttonBgImage.SetStyle( ImageActor::STYLE_NINE_PATCH );
   buttonBgImage.SetNinePatchBorder( mPopupStyle->buttonArea9PatchBorder );
 
-  SetBackgroundImage( bgImage );
+  SetBackgroundImage( ImageActor::New( ResourceImage::New( mPopupStyle->backgroundImage ) ) );
   SetButtonAreaImage( buttonBgImage );
 }
 
 void Popup::CreateBacking()
 {
   mBacking = Dali::Toolkit::CreateSolidColorActor( mPopupStyle->backingColor );
+  mBacking.SetName( "POPUP_BACKING" );
 
-  mBacking.SetPositionInheritanceMode(DONT_INHERIT_POSITION);
+  mBacking.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
   mBacking.SetSensitive(true);
 
-  mLayer.Add(mBacking);
+  mLayer.Add( mBacking );
   mBacking.SetOpacity(0.0f);
-  mBacking.SetPosition(0.0f, 0.0f, BACKING_DEPTH);
   mBacking.TouchedSignal().Connect( this, &Popup::OnBackingTouched );
   mBacking.MouseWheelEventSignal().Connect(this, &Popup::OnBackingMouseWheelEvent);
 }
@@ -380,19 +413,12 @@ void Popup::CreateDialog()
 {
   // Adds default background image.
   SetDefaultBackgroundImage();
-
-  // Adds bottom background
-  mBottomBg = Actor::New();
-  mPopupBg.Add( mBottomBg );
 }
 
 void Popup::HandleStateChange( Toolkit::Popup::PopupState state, float duration )
 {
-  const Vector2& stageSize( Stage::GetCurrent().GetSize() );
-
   Vector3 targetSize;
   float targetBackingAlpha;
-  Vector3 targetBackingSize;
 
   if(mState == state)
   {
@@ -405,7 +431,6 @@ void Popup::HandleStateChange( Toolkit::Popup::PopupState state, float duration
     {
       targetSize = Vector3(0.0f, 0.0f, 1.0f);
       targetBackingAlpha = 0.0f;
-      targetBackingSize = Vector3(0.0f, 0.0f, 1.0f);
       mShowing = false;
       ClearKeyInputFocus();
 
@@ -427,17 +452,16 @@ void Popup::HandleStateChange( Toolkit::Popup::PopupState state, float duration
     {
       targetSize = Vector3(1.0f, 1.0f, 1.0f);
       targetBackingAlpha = 1.0f;
-      float length = (stageSize.width > stageSize.height) ? stageSize.width : stageSize.height;
-      targetBackingSize = Vector3( length, length, 1.0f );
       mShowing = true;
 
       // Add contents to stage for showing.
       if( !mLayer.GetParent() )
       {
-        mAlterAddedChild = false;
-        Self().Add(mLayer);
-        mAlterAddedChild = true;
+        Dali::Stage stage = Dali::Stage::GetCurrent();
+        stage.Add( mLayer );
+        mLayer.RaiseToTop();
       }
+
       Self().SetSensitive(true);
       SetKeyInputFocus();
 
@@ -466,8 +490,7 @@ void Popup::HandleStateChange( Toolkit::Popup::PopupState state, float duration
     }
   }
 
-  mBacking.SetSize( targetBackingSize );
-
+  Actor self = Self();
   if(duration > Math::MACHINE_EPSILON_1)
   {
     if ( mAnimation )
@@ -481,12 +504,12 @@ void Popup::HandleStateChange( Toolkit::Popup::PopupState state, float duration
     if(mShowing)
     {
       mAnimation.AnimateTo( Property(mBacking, Actor::Property::COLOR_ALPHA), targetBackingAlpha, AlphaFunctions::EaseInOut, TimePeriod(0.0f, duration * 0.5f) );
-      mAnimation.AnimateTo( Property(mPopupBg, Actor::Property::SCALE), targetSize, AlphaFunctions::EaseInOut, TimePeriod(duration * 0.5f, duration * 0.5f) );
+      mAnimation.AnimateTo( Property(self, Actor::Property::SCALE), targetSize, AlphaFunctions::EaseInOut, TimePeriod(duration * 0.5f, duration * 0.5f) );
     }
     else
     {
       mAnimation.AnimateTo( Property(mBacking, Actor::Property::COLOR_ALPHA), targetBackingAlpha, AlphaFunctions::EaseInOut, TimePeriod(0.0f, duration * 0.5f) );
-      mAnimation.AnimateTo( Property(mPopupBg, Actor::Property::SCALE), targetSize, AlphaFunctions::EaseInOut, TimePeriod(0.0f, duration * 0.5f) );
+      mAnimation.AnimateTo( Property(self, Actor::Property::SCALE), targetSize, AlphaFunctions::EaseInOut, TimePeriod(0.0f, duration * 0.5f) );
     }
     mAnimation.Play();
     mAnimation.FinishedSignal().Connect(this, &Popup::OnStateAnimationFinished);
@@ -494,7 +517,7 @@ void Popup::HandleStateChange( Toolkit::Popup::PopupState state, float duration
   else
   {
     mBacking.SetOpacity( targetBackingAlpha );
-    mPopupBg.SetScale( targetSize );
+    self.SetScale( targetSize );
 
     HandleStateChangeComplete();
   }
@@ -503,9 +526,9 @@ void Popup::HandleStateChange( Toolkit::Popup::PopupState state, float duration
 void Popup::HandleStateChangeComplete()
 {
   // Remove contents from stage if completely hidden.
-  if( (mState == Toolkit::Popup::POPUP_HIDE) && (mLayer.GetParent()) )
+  if( ( mState == Toolkit::Popup::POPUP_HIDE ) && mLayer.GetParent() )
   {
-    Self().Remove(mLayer);
+    mLayer.Unparent();
     Self().SetSensitive( false );
 
     // Guard against destruction during signal emission
@@ -591,152 +614,78 @@ void Popup::OnControlChildAdd( Actor& child )
     // Removes previously added content.
     if( mContent )
     {
-      mPopupBg.Remove( mContent );
+      mPopupLayout.RemoveChildAt( Toolkit::TableView::CellPosition( 1, 0 ) );
     }
 
-    // Reparent new content.
-    Self().Remove( child );
-
     // keep a handle to the new content.
     mContent = child;
 
-    mPopupBg.Add( mContent );
+    mPopupLayout.AddChild( mContent, Toolkit::TableView::CellPosition( 1, 0 ) );
   }
 }
 
-void Popup::OnControlSizeSet( const Vector3& targetSize )
+void Popup::OnRelayout( const Vector2& size, RelayoutContainer& container )
 {
-  mLayer.SetSize( targetSize );
-  mPopupBg.SetSize( targetSize );
-
-  const Vector4 outerBorder = mPopupStyle->backgroundOuterBorder;
-  if( mBackgroundImage )
-  {
-    mBackgroundImage.SetSize( BackgroundSize( outerBorder,targetSize ) );
-  }
-  if( mButtonAreaImage )
-  {
-    mButtonAreaImage.SetSize( ButtonAreaSize( outerBorder, targetSize ) );
-  }
-
-}
-
-void Popup::OnRelayout( const Vector2& size, ActorSizeContainer& container )
-{
-  // Set the popup size
-  Vector2 popupSize;
-  popupSize.width  = size.width - 2.f * ( POPUP_OUT_MARGIN_WIDTH + mPopupStyle->margin );
-  popupSize.height = size.height - 2.f * ( POPUP_OUT_MARGIN_WIDTH + mPopupStyle->margin );
-
-  // Update sizes of all popup's components.
-
-  // Relayout background image.
-  // Adjust background position and size relative to parent to cater to outer Border.
-  // Some backgrounds are intended to over-spill. That is some content
-  // should appear outside the Dialog on all sides i.e. Shadows, glow effects.
-  const Vector4 outerBorder = mPopupStyle->backgroundOuterBorder;
-
-  if( mBackgroundImage )
-  {
-    mBackgroundImage.SetSize(BackgroundSize(outerBorder, Vector3(size)));
-    mBackgroundImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-    mBackgroundImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
-    mBackgroundImage.SetPosition( -outerBorder.x, -outerBorder.y, 0.0f );
-  }
-
-  if( mPopupBg && mButtonAreaImage )
-  {
-    // If there are no buttons, button background is also removed.
-    if ( mButtons.size() == 0 )
-    {
-      mPopupBg.Remove( mButtonAreaImage );
-    }
-    else
-    {
-      mButtonAreaImage.SetSize( ButtonAreaSize(outerBorder, Vector3(size)) );
-      mButtonAreaImage.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
-      mButtonAreaImage.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
-      mButtonAreaImage.SetY( -outerBorder.z - POPUP_OUT_MARGIN_HEIGHT );
-
-      mPopupBg.Add( mButtonAreaImage );
-    }
-  }
-
-  // Relayout title
-  Vector3 positionOffset( 0.0f, mPopupStyle->margin + POPUP_OUT_MARGIN_WIDTH, CONTENT_DEPTH );
-  // TODO
-
-  // Relayout content
-  if( mContent )
-  {
-    // If the content width is greater than popup width then scale it down/wrap text as needed
-    Vector2 contentSize( RelayoutHelper::GetNaturalSize( mContent ) );
-    if( contentSize.width > popupSize.width )
-    {
-      contentSize.width = popupSize.width;
-      contentSize.height = RelayoutHelper::GetHeightForWidth( mContent, contentSize.width );
-    }
-
-    mContent.SetSize( contentSize );
-    Relayout( mContent, contentSize, container );
-
-    mContent.SetParentOrigin(ParentOrigin::TOP_CENTER);
-    mContent.SetAnchorPoint(AnchorPoint::TOP_CENTER);
-
-    mContent.SetPosition( positionOffset );
-
-    positionOffset.y += contentSize.height + mPopupStyle->margin;
-  }
-
-  // Relayout Button Area
-  if( mBottomBg )
-  {
-    mBottomBg.SetSize( popupSize.width, mPopupStyle->bottomSize.height );
-
-    mBottomBg.SetParentOrigin(ParentOrigin::TOP_CENTER);
-    mBottomBg.SetAnchorPoint(AnchorPoint::TOP_CENTER);
-
-    mBottomBg.SetPosition( positionOffset );
-  }
+  // Hide the background image
+  mBackgroundImage.SetVisible( !( mButtons.empty() && mPopupLayout.GetChildCount() == 0 ) );
 
   // Relayout All buttons
   if ( !mButtons.empty() )
   {
     // All buttons should be the same size and fill the button area. The button spacing needs to be accounted for as well.
-    Vector2 buttonSize( ( ( popupSize.width - mPopupStyle->buttonSpacing * ( mButtons.size() - 1 ) ) / mButtons.size() ),
+    Vector2 buttonSize( ( ( size.width - mPopupStyle->buttonSpacing * ( mButtons.size() + 1 ) ) / mButtons.size() ),
                         mPopupStyle->bottomSize.height - mPopupStyle->margin );
 
-    Vector3 buttonPosition;
+    Vector3 buttonPosition( mPopupStyle->buttonSpacing, 0.0f, 0.0f );
 
     for ( ActorIter iter = mButtons.begin(), endIter = mButtons.end();
           iter != endIter;
           ++iter, buttonPosition.x += mPopupStyle->buttonSpacing + buttonSize.width )
     {
-      iter->SetPosition( buttonPosition );
+      Actor button = *iter;
 
       // If there is only one button, it needs to be laid out on center.
       if ( mButtons.size() == 1 )
       {
-        iter->SetAnchorPoint( AnchorPoint::CENTER );
-        iter->SetParentOrigin( ParentOrigin::CENTER );
+        buttonPosition.x = 0.0f;
+        button.SetAnchorPoint( AnchorPoint::CENTER );
+        button.SetParentOrigin( ParentOrigin::CENTER );
       }
       else
       {
-        iter->SetAnchorPoint( AnchorPoint::CENTER_LEFT );
-        iter->SetParentOrigin( ParentOrigin::CENTER_LEFT );
+        button.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
+        button.SetParentOrigin( ParentOrigin::CENTER_LEFT );
       }
 
-      Relayout( *iter, buttonSize, container );
+      button.SetPosition( buttonPosition );
+
+      button.PropagateRelayoutFlags();    // Reset relayout flags for relayout
+      container.Add( button, buttonSize );
     }
   }
+}
 
-  if( mShowing && mBacking )
+void Popup::OnSetResizePolicy( ResizePolicy policy, Dimension dimension )
+{
+  if( mPopupLayout )
   {
-    Vector2 stageSize = Stage::GetCurrent().GetSize();
-    float length = (stageSize.width > stageSize.height) ? stageSize.width : stageSize.height;
-    Vector3 targetBackingSize = Vector3( length, length, 1.0f );
-
-    mBacking.SetSize( targetBackingSize );
+    if( policy == FIT_TO_CHILDREN )
+    {
+      mPopupLayout.SetResizePolicy( USE_NATURAL_SIZE, dimension );
+      if( dimension & HEIGHT )
+      {
+        mPopupLayout.SetFitHeight( 1 );
+      }
+    }
+    else
+    {
+      mPopupLayout.SetResizePolicy( FILL_TO_PARENT, dimension );
+      // Make the content cell fill the whole of the available space
+      if( dimension & HEIGHT )
+      {
+        mPopupLayout.SetRelativeHeight( 1, 1.0f );
+      }
+    }
   }
 }
 
@@ -765,13 +714,13 @@ Vector3 Popup::GetNaturalSize()
 
   if( mContent )
   {
-    Vector3 contentSize = RelayoutHelper::GetNaturalSize( mContent );
+    Vector3 contentSize = mContent.GetNaturalSize();
     // Choose the biggest width
     naturalSize.width = std::max( naturalSize.width, contentSize.width );
     if( naturalSize.width > maxWidth )
     {
       naturalSize.width = maxWidth;
-      contentSize.height = RelayoutHelper::GetHeightForWidth( mContent, maxWidth );
+      contentSize.height = mContent.GetHeightForWidth( maxWidth );
     }
     naturalSize.height += contentSize.height + mPopupStyle->margin;
   }
@@ -795,7 +744,7 @@ float Popup::GetHeightForWidth( float width )
 
   if( mContent )
   {
-    height += RelayoutHelper::GetHeightForWidth( mContent, popupWidth ) + mPopupStyle->margin;
+    height += mContent.GetHeightForWidth( popupWidth ) + mPopupStyle->margin;
   }
 
   if( !mButtons.empty() )
index 6a6fc0e..3fe2aba 100755 (executable)
@@ -27,6 +27,7 @@
 #include <dali-toolkit/public-api/controls/control-impl.h>
 #include <dali-toolkit/public-api/controls/popup/popup.h>
 #include <dali-toolkit/internal/controls/popup/popup-style-impl.h>
+#include <dali-toolkit/public-api/controls/table-view/table-view.h>
 
 namespace Dali
 {
@@ -117,7 +118,6 @@ public:
    */
   void HideTail();
 
-
   /**
    * Sets the style of the popup
    * @param[in] style The style of the popup
@@ -130,6 +130,11 @@ public:
    */
   PopupStylePtr GetStyle() const;
 
+  /**
+   * @copydoc Toolkit::Popup::MarkDirtyForRelayout
+   */
+  void MarkDirtyForRelayout();
+
 protected:
 
   /**
@@ -246,14 +251,14 @@ private:
   virtual void OnControlChildAdd( Actor& child );
 
   /**
-   * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& size )
+   * @copydoc Control::OnRelayOut()
    */
-  virtual void OnControlSizeSet( const Vector3& size );
+  virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
 
   /**
-   * @copydoc Control::OnRelayOut()
+   * @copydoc Control::OnSetResizePolicy()
    */
-  virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
+  virtual void OnSetResizePolicy( ResizePolicy policy, Dimension dimension );
 
   /**
    * @copydoc Control::OnKeyEvent()
@@ -280,6 +285,11 @@ private:
    */
   Actor GetNextKeyboardFocusableActor(Actor currentFocusedActor, Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled);
 
+  /**
+   * Create the root actor for the footer
+   */
+  void CreateFooter();
+
 private:
 
   // Undefined
@@ -303,7 +313,7 @@ private:
   bool mShowing;                          ///< Popup is showing or not
 
   Layer mLayer;                           ///< Popup Layer (i.e. Dim backing and PopupBg reside in this)
-  Actor mPopupBg;                         ///< Popup Background (i.e. dialog reside in this)
+  Toolkit::TableView mPopupLayout;        ///< Popup layout (i.e. dialog reside in this)
   ImageActor mBacking;                    ///< Backing actor (dim effect)
 
   Actor mPreviousFocusedActor;            ///< Store the previous focused actor to restore the focus when popup hide
index 2a94eff..4dba00b 100644 (file)
@@ -26,9 +26,9 @@ namespace // unnamed namespace
 // Popup style default
 const Vector4 DEFAULT_BACKING_COLOR = Vector4(0.0f, 0.0f, 0.0f, 0.5f);
 const float DEFAULT_MARGIN = 20.0f;          //From Tizen GUI UX
-const float DEFAULT_BUTTON_SPACING = 20.0f;  //From Tizen GUI UX
+const float DEFAULT_BUTTON_SPACING = 10.0f;  //From Tizen GUI UX
 const Vector3 DEFAULT_BUTTON_SIZE(275.0f, 74.0f, 0.0f);
-const char* DEFAULT_BACKGROUND_IMAGE_PATH = DALI_IMAGE_DIR "00_popup_bg.png";
+const char* DEFAULT_BACKGROUND_IMAGE_PATH = DALI_IMAGE_DIR "00_popup_bg.9.png";
 const char* DEFAULT_BUTTON_AREA_IMAGE_PATH = DALI_IMAGE_DIR "00_popup_button_bg.png";
 const char* DEFAULT_TAIL_UP_IMAGE_PATH = DALI_IMAGE_DIR "popup_tail_up.png";
 const char* DEFAULT_TAIL_DOWN_IMAGE_PATH = DALI_IMAGE_DIR "popup_tail_down.png";
@@ -37,7 +37,7 @@ const char* DEFAULT_TAIL_RIGHT_IMAGE_PATH = DALI_IMAGE_DIR "popup_tail_right.png
 const Vector3 DEFAULT_BOTTOM_SIZE(620.0f,96.0f,0.0f);
 const Vector2 DEFAULT_BACKGROUND_SIZE(620.0f, 236.0f);
 const Vector4 DEFAULT_BACKGROUND_STYLE_9_BORDER( 25.0f, 25.0f, 26.0f, 50.0f );
-const Vector4 DEFAULT_BACKGROUND_OUTER_BORDER( 0.0f, 0.0f, 0.0f, 0.0f );
+const Vector4 DEFAULT_BACKGROUND_OUTER_BORDER( 40.0f, 0.0f, 30.0f, 0.0f );
 const Vector4 DEFAULT_BUTTON_AREA_9_PATCH_BORDER( 13.0f, 8.0f, 13.0f, 8.0f );
 }
 
diff --git a/dali-toolkit/internal/controls/relayout-controller-impl.cpp b/dali-toolkit/internal/controls/relayout-controller-impl.cpp
deleted file mode 100644 (file)
index 8c8f00a..0000000
+++ /dev/null
@@ -1,230 +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 "relayout-controller-impl.h"
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/actors/layer.h>
-#include <dali/public-api/common/stage.h>
-#include <dali/integration-api/debug.h>
-
-#if defined(DEBUG_ENABLED)
-#include <sstream>
-#endif // defined(DEBUG_ENABLED)
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-namespace
-{
-#if defined(DEBUG_ENABLED)
-
-Integration::Log::Filter* gLogFilter( Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_RELAYOUT_CONTROLLER") );
-
-/**
- * Prints out all the children of the given actor when debug is enabled.
- *
- * @param[in]  actor  The actor whose children to print.
- * @param[in]  level  The number of " | " to put in front of the children.
- */
-void PrintChildren( Actor actor, int level )
-{
-  std::ostringstream output;
-
-  for ( int t = 0; t < level; ++t )
-  {
-    output << " | ";
-  }
-
-  output << actor.GetTypeName();
-
-  output << " - Pos: " << actor.GetCurrentPosition() << " Size: " << actor.GetCurrentSize() << ",";
-
-  output << " (" << actor.GetObjectPtr() << ")" << std::endl;
-
-  DALI_LOG_INFO( gLogFilter, Debug::Verbose, output.str().c_str() );
-
-  ++level;
-  unsigned int numChildren = actor.GetChildCount();
-  for( unsigned int i=0; i<numChildren; ++i )
-  {
-    PrintChildren( actor.GetChildAt(i), level );
-  }
-  --level;
-}
-
-/**
- * Prints the entire hierarchy of the scene.
- */
-void PrintHierarchy()
-{
-  if ( gLogFilter->IsEnabledFor( Debug::Verbose ) )
-  {
-    PrintChildren( Stage().GetCurrent().GetRootLayer(), 0 );
-  }
-}
-
-#define PRINT_HIERARCHY PrintHierarchy()
-
-#else // defined(DEBUG_ENABLED)
-
-#define PRINT_HIERARCHY
-
-#endif // defined(DEBUG_ENABLED)
-
-/**
- * Sets the target to source if the individual elements of source are NOT zero.
- *
- * @param[out]  target  The Vector2 elements to set if the source Vector2 elements are not 0.
- * @param[in]   source  The Vector2 elements that are to be set to the target Vector2.
- */
-void SetIfNotZero( Vector2& target, const Vector2& source )
-{
-  // Only set the width if it is non zero.
-  if ( !EqualsZero( source.width ) )
-  {
-    target.width  = source.width;
-  }
-
-  // Only set the height if it is non zero.
-  if ( !EqualsZero( source.height ) )
-  {
-    target.height = source.height;
-  }
-}
-
-/**
- * Finds controls in the hierarchy of actor. It descends the tree if the actor has more Actors.
- * If it is a control, it no longer descends the tree.
- *
- * @param[in]  actor  The actor in which controls should be found.
- * @param[in]  size   The size that this actor and its children should be.
- */
-void FindControls( Actor actor, ControlStack& controls, Vector2 size )
-{
-  Toolkit::Control control( Toolkit::Control::DownCast( actor ) );
-  if( control )
-  {
-    // If the control size has been set by the application / control, then we should try and honour that.
-    Vector2 controlSetSize( control.GetImplementation().GetSizeSet() );
-
-    // Only set the width and height if they are non zero.
-    SetIfNotZero( size, controlSetSize );
-
-    controls.push_back( ControlSizePair( control, size ) );
-  }
-  else
-  {
-    unsigned int numChildren = actor.GetChildCount();
-    for( unsigned int i=numChildren; i>0; --i )
-    {
-      FindControls( actor.GetChildAt(i-1), controls, size );
-    }
-  }
-}
-
-/**
- * Pushes the controls in the container, to the stack.
- *
- * @param[in,out]  controlStack  The stack to push controls to.
- * @param[in]      container     The container to push controls from.
- */
-void PushToStack( ControlStack& controlStack, const ActorSizeContainer& container )
-{
-  for ( ActorSizeContainer::const_reverse_iterator iter = container.rbegin(), endIter = container.rend(); iter != endIter; ++iter )
-  {
-    FindControls( iter->first, controlStack, iter->second );
-  }
-}
-
-} // unnamed namespace
-
-RelayoutControllerImpl::RelayoutControllerImpl( bool& relayoutFlag )
-: mRelayoutFlag( relayoutFlag ),
-  mRelayoutConnection( false )
-{
-  // make space for 32 controls to avoid having to copy construct a lot in the beginning
-  mControlStack.reserve( 32 );
-  mSizecontainer.reserve( 32 );
-}
-
-RelayoutControllerImpl::~RelayoutControllerImpl()
-{
-}
-
-void RelayoutControllerImpl::Request()
-{
-  //TODO use Relayout Request to set up logic to optimize relayout of the actors/controls in the scene
-
-  if( !mRelayoutConnection )
-  {
-    Stage stage = Stage::GetCurrent();
-    stage.EventProcessingFinishedSignal().Connect( this, &RelayoutControllerImpl::Relayout );
-    mRelayoutConnection = true;
-  }
-}
-
-void RelayoutControllerImpl::Relayout()
-{
-  // only do something when requested
-  if( mRelayoutFlag )
-  {
-    // clear the flag as we're now doing the relayout
-    mRelayoutFlag = false;
-    PRINT_HIERARCHY;
-
-    mControlStack.clear(); // we do not release memory, just empty the container
-
-    // 1. Finds all top-level controls from the root actor and allocate them the size of the stage
-    //    These controls are paired with the stage size and added to the stack.
-    FindControls( Stage().GetCurrent().GetRootLayer(), mControlStack, Stage::GetCurrent().GetSize() );
-
-    // 2. Iterate through the stack until it's empty.
-    while ( !mControlStack.empty() )
-    {
-      ControlSizePair pair ( mControlStack.back() );
-      Toolkit::Control control ( pair.first );
-      Vector2 size ( pair.second );
-      mControlStack.pop_back();
-
-      DALI_LOG_INFO( gLogFilter, Debug::General, "Allocating %p (%.2f, %.2f)\n", control.GetObjectPtr(), size.width, size.height );
-
-      mSizecontainer.clear();
-      // 3. Negotiate the size with the current control. Pass it an empty container which the control
-      //    has to fill with all the actors it has not done any size negotiation for.
-      control.GetImplementation().NegotiateSize( size, mSizecontainer );
-
-      // 4. Push the controls from the actors in the container to the stack.
-      PushToStack( mControlStack, mSizecontainer );
-    }
-  }
-  // should not disconnect the signal as that causes some control size negotiations to not work correctly
-  // this algorithm needs more optimization as well
-}
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
diff --git a/dali-toolkit/internal/controls/relayout-controller-impl.h b/dali-toolkit/internal/controls/relayout-controller-impl.h
deleted file mode 100644 (file)
index f60d5e5..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-#ifndef __DALI_TOOLKIT_INTERNAL_RELAYOUT_CONTROLLER_IMPL_H__
-#define __DALI_TOOLKIT_INTERNAL_RELAYOUT_CONTROLLER_IMPL_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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
-#include <dali/public-api/object/base-object.h>
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/control.h>
-#include <dali-toolkit/public-api/controls/control-impl.h>
-#include "relayout-controller.h"
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-class RelayoutController;
-
-typedef std::pair< Dali::Toolkit::Control, Vector2 > ControlSizePair;
-typedef std::vector< ControlSizePair > ControlStack;
-
-/**
- * @copydoc Toolkit::Internal::RelayoutController
- */
-class RelayoutControllerImpl : public Dali::BaseObject, public ConnectionTracker
-{
-public:
-
-  /**
-   * Constructor.
-   * We should only create a unique instance.
-   * @param relayoutFlag to avoid unnecessary calls inside a single frame
-   */
-  RelayoutControllerImpl( bool& relayoutFlag );
-
-
-  /**
-   * Destructor
-   */
-  virtual ~RelayoutControllerImpl();
-
-  /**
-   * Request for relayout.
-   */
-  void Request();
-
-private:
-
-  /**
-   * Relayouts controls inside actor tree from bottom to top.
-   */
-  void Relayout();
-
-  /**
-   * Resets the relayout controller.
-   */
-  void Reset();
-
-  /**
-   * Disconnect the Relayout() method from the Stage::EventProcessingFinishedSignal().
-   */
-  void Disconnect();
-
-  // Undefined
-  RelayoutControllerImpl(const RelayoutControllerImpl&);
-  RelayoutControllerImpl& operator=(const RelayoutControllerImpl&);
-
-private:
-
-  bool& mRelayoutFlag;               ///< reference to relayout flag to avoid unnecessary calls
-  ControlStack mControlStack;        ///< stack for relayouting
-  ActorSizeContainer mSizecontainer; ///< size container
-  bool mRelayoutConnection:1;        ///< Whether EventProcessingFinishedSignal signal is connected.
-
-};
-
-} // namespace Internal
-
-
-inline Internal::RelayoutControllerImpl& GetImpl(Dali::Toolkit::Internal::RelayoutController& obj)
-{
-  DALI_ASSERT_ALWAYS(obj);
-
-  Dali::BaseObject& handle = obj.GetBaseObject();
-
-  return static_cast<Internal::RelayoutControllerImpl&>(handle);
-}
-
-inline const Internal::RelayoutControllerImpl& GetImpl(const Dali::Toolkit::Internal::RelayoutController& obj)
-{
-  DALI_ASSERT_ALWAYS(obj);
-
-  const Dali::BaseObject& handle = obj.GetBaseObject();
-
-  return static_cast<const Internal::RelayoutControllerImpl&>(handle);
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_INTERNAL_RELAYOUT_CONTROLLER_IMPL_H__
diff --git a/dali-toolkit/internal/controls/relayout-controller.cpp b/dali-toolkit/internal/controls/relayout-controller.cpp
deleted file mode 100644 (file)
index cc0ed66..0000000
+++ /dev/null
@@ -1,102 +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 "relayout-controller.h"
-
-// EXTERNAL INCLUDES
-#include <stack>
-#include <sstream>
-#include <dali/public-api/adaptor-framework/singleton-service.h>
-#include <dali/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-
-#include "relayout-controller-impl.h"
-#include "dali-toolkit/public-api/controls/control.h"
-#include "dali-toolkit/public-api/controls/control-impl.h"
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-namespace
-{
-// Flag to avoid doing more than one request per frame
-// getting the singleton handle can be expensive as it requires calling to adaptor, dynamic cast etc
-// and it can get called 100 times per frame easily in startup and new view initialization
-  bool gRelayoutRequestPending = false;
-}
-
-RelayoutController::RelayoutController()
-{
-
-}
-
-RelayoutController::~RelayoutController()
-{
-
-}
-
-void RelayoutController::Request()
-{
-  // are we already going to do it this frame
-  if( !gRelayoutRequestPending )
-  {
-    RelayoutController controller;
-
-    // Check whether the RelayoutController is already created
-    SingletonService singletonService( SingletonService::Get() );
-    if ( singletonService )
-    {
-      Dali::BaseHandle handle = singletonService.GetSingleton(typeid(RelayoutController));
-
-      if(handle)
-      {
-        // If so, downcast the handle of singleton to RelayoutController
-        controller = RelayoutController(dynamic_cast<Internal::RelayoutControllerImpl*>(handle.GetObjectPtr()));
-      }
-
-      if(!controller)
-      {
-        // If not, create the RelayoutController and register it as a singleton
-        controller = RelayoutController( new Internal::RelayoutControllerImpl(gRelayoutRequestPending) );
-        singletonService.Register( typeid(controller), controller );
-      }
-
-      GetImpl(controller).Request();
-      gRelayoutRequestPending = true;
-    }
-  }
-}
-
-RelayoutController::RelayoutController(Internal::RelayoutControllerImpl *impl)
-  : BaseHandle(impl)
-{
-}
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
-
diff --git a/dali-toolkit/internal/controls/relayout-controller.h b/dali-toolkit/internal/controls/relayout-controller.h
deleted file mode 100644 (file)
index 40438b9..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-#ifndef __DALI_TOOLKIT_INTERNAL_RELAYOUT_CONTROLLER_H__
-#define __DALI_TOOLKIT_INTERNAL_RELAYOUT_CONTROLLER_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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/object/base-handle.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-class RelayoutControllerImpl;
-
-/**
- * RelayoutController
- * This singleton class provides functionality to trigger relayouting of toolkit controls in the dali scene graph.
- */
-class RelayoutController : public Dali::BaseHandle
-{
-public:
-
-  /**
-   * Constructor.
-   * We should only create a unique instance.
-   */
-  RelayoutController();
-
-  /**
-   * @brief Destructor
-   *
-   * This is non-virtual since derived Handle types must not contain data or virtual methods.
-   */
-  ~RelayoutController();
-
-  /**
-   * Request to relayout.
-   */
-  static void Request();
-
-private:
-
-  RelayoutController(Internal::RelayoutControllerImpl* impl);
-
-};
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_INTERNAL_RELAYOUT_CONTROLLER_H__
diff --git a/dali-toolkit/internal/controls/relayout-helper.cpp b/dali-toolkit/internal/controls/relayout-helper.cpp
deleted file mode 100644 (file)
index d7aab5b..0000000
+++ /dev/null
@@ -1,117 +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 "relayout-helper.h"
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/actors/image-actor.h>
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/control.h>
-
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-namespace RelayoutHelper
-{
-
-Vector3 GetNaturalSize( Actor actor )
-{
-  Vector3 size( 0.0f, 0.0f, 0.0f );
-
-  Toolkit::Control control = Toolkit::Control::DownCast( actor );
-  if( control )
-  {
-    size = control.GetNaturalSize();
-  }
-  else
-  {
-    size = actor.GetCurrentSize();
-    const float depth = size.depth;
-
-    // Get natural size for ImageActor.
-    // TODO: currently it doesn't work as expected.
-    ImageActor imageActor = ImageActor::DownCast( actor );
-    if( ( imageActor ) && ( imageActor.GetImage() ) )
-    {
-      Image image = imageActor.GetImage();
-      size = Vector3( static_cast<float>( image.GetWidth() ), static_cast<float>( image.GetHeight() ), depth );
-    }
-  }
-
-  return size;
-}
-
-float GetHeightForWidth( Actor actor, float width )
-{
-  float height = 0.0f;
-
-  Toolkit::Control control = Toolkit::Control::DownCast( actor );
-  if( control )
-  {
-    height = control.GetHeightForWidth( width );
-  }
-  else
-  {
-    bool constrainSize = false;
-    Vector3 size( 0.0f, 0.0f, 0.0f );
-
-    ImageActor imageActor = ImageActor::DownCast( actor );
-    if( ( imageActor ) && ( imageActor.GetImage() ) )
-    {
-      Image image = imageActor.GetImage();
-      size = Vector3( static_cast<float>( image.GetWidth() ), static_cast<float>( image.GetHeight() ), 0.0f );
-
-      constrainSize = true;
-    }
-    else
-    {
-      size = actor.GetCurrentSize();
-    }
-
-    // Scale the actor
-    float scaleRatio = width / size.width;
-    if( constrainSize )
-    {
-      // Allow the scale to decrease if greater than input width but not increase if less than input width
-      if( scaleRatio > 1.0f )
-      {
-        scaleRatio = 1.0f;
-      }
-    }
-
-    height = size.height * scaleRatio;
-  }
-
-  return height;
-}
-
-} // namespace RelayoutHelper
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
diff --git a/dali-toolkit/internal/controls/relayout-helper.h b/dali-toolkit/internal/controls/relayout-helper.h
deleted file mode 100644 (file)
index c7f2372..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-#ifndef __DALI_TOOLKIT_INTERNAL_RELAYOUT_HELPER_H__
-#define __DALI_TOOLKIT_INTERNAL_RELAYOUT_HELPER_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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/actors/actor.h>
-#include <dali/public-api/math/vector3.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-namespace RelayoutHelper
-{
-
-/**
- * Gets the natural size of the given actor.
- *
- * If the actor is a Control, it returns the natural size of the Control. @see Control::GetNaturalSize()
- * If the actor is an ImageActor, it returns the size of the image.
- * If the actor is a TextActor, it returns the size of the text. @see Font::MeasureText()
- * Otherwise it returns the actor's current size. @see Actor::GetCurrentSize()
- *
- * @param[in] actor The actor.
- *
- * @return The natural size.
- */
-Vector3 GetNaturalSize( Actor actor );
-
-/**
- * Gets the actor's height for the given width.
- *
- * If the actor is a Control it returns the height for width. @see Control::GetHeightForWidth()
- * If the actor is an ImageActor or a TextActor it scales the natural size to fit the given width. @see GetNaturalSize()
- * Otherwise it returns the actor's current size. @see Actor::GetCurrentSize()
- *
- * @param[in] actor The actor.
- * @param[in] width The width.
- *
- * @return The actor's height for given width.
- */
-float GetHeightForWidth( Actor actor, float width );
-
-} // namespace RelayoutHelper
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_INTERNAL_RELAYOUT_HELPER_H__
index 405e819..f9b3281 100644 (file)
@@ -362,12 +362,13 @@ ItemView::ItemView(ItemFactory& factory)
 
 void ItemView::OnInitialize()
 {
-  SetSizePolicy( Toolkit::Control::Fixed, Toolkit::Control::Fixed );
-
   RegisterCommonProperties();
 
   Actor self = Self();
 
+  // Disable size negotiation for item views
+  self.SetRelayoutEnabled( false );
+
   mScrollConnector = Dali::Toolkit::ScrollConnector::New();
   mScrollPositionObject = mScrollConnector.GetScrollPositionObject();
   mScrollConnector.ScrollPositionChangedSignal().Connect( this, &ItemView::OnScrollPositionChanged );
@@ -460,7 +461,6 @@ void ItemView::ActivateLayout(unsigned int layoutIndex, const Vector3& targetSiz
 
   // Move the items to the new layout positions...
 
-  bool resizeAnimationNeeded(false);
   for (ConstItemPoolIter iter = mItemPool.begin(); iter != mItemPool.end(); ++iter)
   {
     unsigned int itemId = iter->first;
@@ -472,34 +472,14 @@ void ItemView::ActivateLayout(unsigned int layoutIndex, const Vector3& targetSiz
     Vector3 size;
     if(mActiveLayout->GetItemSize(itemId, targetSize, size))
     {
-      if( durationSeconds > 0.0f )
-      {
-        // Use a size animation
-        if (!resizeAnimationNeeded)
-        {
-          resizeAnimationNeeded = true;
-          RemoveAnimation(mResizeAnimation);
-          mResizeAnimation = Animation::New(durationSeconds);
-        }
-
-        // The layout provides its own resize animation
-        mActiveLayout->GetResizeAnimation(mResizeAnimation, actor, size, durationSeconds);
-      }
-      else
-      {
-        // resize immediately
-        actor.SetSize(size);
-      }
+      // resize immediately
+      actor.SetResizePolicy( FIXED, ALL_DIMENSIONS );
+      actor.SetPreferredSize( size.GetVectorXY() );
     }
 
     mActiveLayout->ApplyConstraints(actor, itemId, durationSeconds, mScrollPositionObject, Self() );
   }
 
-  if (resizeAnimationNeeded)
-  {
-    mResizeAnimation.Play();
-  }
-
   // Refresh the new layout
   ItemRange range = GetItemRange(*mActiveLayout, targetSize, GetCurrentLayoutPosition(0), false/* don't reserve extra*/);
   AddActorsWithinRange( range, durationSeconds );
@@ -570,6 +550,17 @@ void ItemView::OnRefreshNotification(PropertyNotification& source)
   }
 }
 
+void ItemView::Refresh()
+{
+  for (ItemPoolIter iter = mItemPool.begin(); iter != mItemPool.end(); ++iter )
+  {
+    ReleaseActor( iter->first, iter->second );
+  }
+  mItemPool.clear();
+
+  DoRefresh(GetCurrentLayoutPosition(0), true);
+}
+
 void ItemView::DoRefresh(float currentLayoutPosition, bool cacheExtra)
 {
   if (mActiveLayout)
@@ -1005,7 +996,8 @@ void ItemView::SetupActor( Item item, float durationSeconds )
     Vector3 size;
     if( mActiveLayout->GetItemSize( item.first, mActiveLayoutTargetSize, size ) )
     {
-      item.second.SetSize( size );
+      item.second.SetResizePolicy( FIXED, ALL_DIMENSIONS );
+      item.second.SetPreferredSize( size.GetVectorXY() );
     }
 
     mActiveLayout->ApplyConstraints( item.second, item.first, durationSeconds, mScrollPositionObject, Self() );
index 991f538..7c41d1f 100644 (file)
@@ -171,6 +171,11 @@ public:
   float GetRefreshInterval() const;
 
   /**
+   * @copydoc Toolkit::ItemView::Refresh
+   */
+  void Refresh();
+
+  /**
    * @copydoc Toolkit::ItemView::GetItem
    */
   Actor GetItem(unsigned int itemId) const;
index 23f1f0f..5ce5e22 100644 (file)
@@ -182,9 +182,9 @@ void ShadowView::SetShadowPlane(Actor shadowPlane)
 
   ConstrainCamera();
 
-  mShadowPlane.SetSizeMode( SIZE_EQUAL_TO_PARENT );
+  mShadowPlane.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
 
-  mBlurRootActor.SetSizeMode( SIZE_EQUAL_TO_PARENT );
+  mBlurRootActor.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
 }
 
 void ShadowView::SetPointLight(Actor pointLight)
@@ -239,7 +239,8 @@ void ShadowView::OnInitialize()
 {
   // root actor to parent all user added actors. Used as source actor for shadow render task.
   mChildrenRoot.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
-  mChildrenRoot.SetSizeMode( SIZE_EQUAL_TO_PARENT );
+  mChildrenRoot.SetRelayoutEnabled( true );
+  mChildrenRoot.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
 
   Vector2 stageSize = Stage::GetCurrent().GetSize();
   mCameraActor = CameraActor::New(stageSize);
@@ -275,6 +276,7 @@ void ShadowView::OnInitialize()
 
   mBlurRootActor = Actor::New();
 
+  mBlurRootActor.SetRelayoutEnabled( true );
   // Turn off inheritance to ensure filter renders properly
   mBlurRootActor.SetPositionInheritanceMode(USE_PARENT_POSITION);
   mBlurRootActor.SetInheritOrientation(false);
index af62846..d5d1596 100755 (executable)
@@ -347,6 +347,8 @@ void Slider::DisplayValue( float value, bool raiseSignals )
       mMarkSignal.Emit( self, markIndex );
     }
   }
+
+  // TODO
 }
 
 void Slider::SetMarks( const MarkList& marks )
@@ -389,6 +391,7 @@ Actor Slider::CreateHitRegion()
 ImageActor Slider::CreateBacking()
 {
   ImageActor backing = ImageActor::New();
+  backing.SetRelayoutEnabled( false );
   backing.SetParentOrigin( ParentOrigin::CENTER );
   backing.SetAnchorPoint( AnchorPoint::CENTER );
   backing.SetZ( BACKING_Z );
@@ -418,6 +421,7 @@ std::string Slider::GetBackingImageName()
 ImageActor Slider::CreateProgress()
 {
   ImageActor progress = ImageActor::New();
+  progress.SetRelayoutEnabled( false );
   progress.SetParentOrigin( ParentOrigin::CENTER_LEFT );
   progress.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
   progress.SetZ( PROGRESS_Z );
@@ -493,6 +497,7 @@ void Slider::ResizeProgressRegion( const Vector2& region )
 ImageActor Slider::CreateHandle()
 {
   ImageActor handle = ImageActor::New();
+  handle.SetRelayoutEnabled( false );
   handle.SetParentOrigin( ParentOrigin::CENTER_LEFT );
   handle.SetAnchorPoint( AnchorPoint::CENTER );
   handle.SetZ( HANDLE_Z );
@@ -503,6 +508,7 @@ ImageActor Slider::CreateHandle()
 ImageActor Slider::CreatePopupArrow()
 {
   ImageActor arrow = ImageActor::New();
+  arrow.SetRelayoutEnabled( false );
   arrow.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
   arrow.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
   arrow.SetZ( HANDLE_Z );
@@ -517,6 +523,7 @@ ImageActor Slider::CreatePopupArrow()
 ImageActor Slider::CreatePopup()
 {
   ImageActor popup = ImageActor::New();
+  popup.SetRelayoutEnabled( false );
   popup.SetParentOrigin( ParentOrigin::TOP_CENTER );
   popup.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
 
index 1b15f2b..5544761 100644 (file)
@@ -250,7 +250,7 @@ void SuperBlurView::ClearBlurResource()
   }
 }
 
-void SuperBlurView::OnRelayout( const Vector2& size, ActorSizeContainer& container )
+void SuperBlurView::OnRelayout( const Vector2& size, RelayoutContainer& container )
 {
   unsigned int numChildren = Self().GetChildCount();
 
index ebbe453..041e717 100644 (file)
@@ -122,7 +122,7 @@ private: // from Control
   /**
    * @copydoc Control::OnRelayout()
    */
-  virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
+  virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
 
 private:
 
index e18fd6d..4f17023 100644 (file)
 #include <dali/public-api/object/type-registry.h>
 #include <dali/public-api/object/type-registry-helper.h>
 #include <dali/public-api/scripting/scripting.h>
+#include <dali/public-api/size-negotiation/relayout-container.h>
 #include <dali/integration-api/debug.h>
 
 using namespace Dali;
 
 namespace
 {
-const float DEFAULT_CONSTRAINT_DURATION = 0.0f;
 
 /**
- * sets a child property relative to parents size and applies a unit based padding before the relative calculation.
- * @param[in] scale of parent minus padding between 0 and 1
- * @param[in] padding in world coordinate units
- * @param[in] fixed part in world coordinate units
- * @param[in] size of the parent
- * @return The relative size with padding.
+ * @brief Should the tableview fit around the given actor
+ *
+ * @param[in] actor The child actor to test against
+ * @param[dimension] The dimnesion to test against
  */
-Vector2 RelativeToSize( const Vector2& scale, const Vector2& padding, const Vector2& fixed, const Vector2& parentSize)
+bool FitToChild( Actor actor, Dimension dimension )
 {
-  return fixed + ( parentSize - padding ) * scale;
+  return actor.GetResizePolicy( dimension ) != FILL_TO_PARENT && actor.GetRelayoutSize( dimension ) > 0.0f;
 }
 
 #if defined(DEBUG_ENABLED)
@@ -136,9 +134,9 @@ DALI_TYPE_REGISTRATION_END()
 
 const Scripting::StringEnum< Toolkit::TableView::LayoutPolicy > LAYOUT_POLICY_STRING_TABLE[] =
 {
- { "fixed",    Toolkit::TableView::Fixed    },
- { "relative", Toolkit::TableView::Relative },
- { "fill",     Toolkit::TableView::Fill     }
+ { "fixed",    Toolkit::TableView::FIXED    },
+ { "relative", Toolkit::TableView::RELATIVE },
+ { "fill",     Toolkit::TableView::FILL     }
 };
 
 const unsigned int LAYOUT_POLICY_STRING_TABLE_COUNT = sizeof(LAYOUT_POLICY_STRING_TABLE) / sizeof( LAYOUT_POLICY_STRING_TABLE[0] );
@@ -160,7 +158,7 @@ Toolkit::TableView TableView::New( unsigned int initialRows, unsigned int initia
   return handle;
 }
 
-bool TableView::AddChild( Actor child, Toolkit::TableView::CellPosition position )
+bool TableView::AddChild( Actor& child, const Toolkit::TableView::CellPosition& position )
 {
   // check that the child is valid
   DALI_ASSERT_ALWAYS( child );
@@ -170,31 +168,35 @@ bool TableView::AddChild( Actor child, Toolkit::TableView::CellPosition position
   {
     child.GetParent().Remove( child );
   }
+
   // check if we need to expand our data array
   if( position.rowIndex >= mCellData.GetRows() )
   {
     // only adding new rows
     ResizeContainers( position.rowIndex + 1, mCellData.GetColumns() );
   }
+
   if( position.columnIndex >= mCellData.GetColumns() )
   {
     // only adding new columns
     ResizeContainers( mCellData.GetRows(), position.columnIndex + 1 );
   }
+
   // check if there already is something in this cell
   if( mCellData[ position.rowIndex ][ position.columnIndex ].actor )
   {
     return false; // cannot share a cell, it would complicate all logic and not bring much benefit
   }
+
   RelayoutingLock lock( *this );
   // adopt the child
   Self().Add( child );
 
   // put the actor to the main cell
-  CellData data;
+  CellData& data = mCellData[ position.rowIndex ][ position.columnIndex ];
   data.actor = child;
   data.position = position;
-  mCellData[ position.rowIndex ][ position.columnIndex ] = data;
+
   // if child spans multiple rows of columns
   bool spanned = false;
   if( position.rowSpan > 1 )
@@ -205,8 +207,10 @@ bool TableView::AddChild( Actor child, Toolkit::TableView::CellPosition position
       // increase table size for the full span, only increasing rows
       ResizeContainers( position.rowIndex + position.rowSpan, mCellData.GetColumns() );
     }
+
     spanned = true;
   }
+
   if( position.columnSpan > 1 )
   {
     // span might go outside table
@@ -215,8 +219,10 @@ bool TableView::AddChild( Actor child, Toolkit::TableView::CellPosition position
       // increase table size for the full span, only increasing columns
       ResizeContainers( mCellData.GetRows(), position.columnIndex + position.columnSpan );
     }
+
     spanned = true;
   }
+
   // if it spanned multiple rows, put the cellinfo in all of those
   if( spanned )
   {
@@ -232,25 +238,25 @@ bool TableView::AddChild( Actor child, Toolkit::TableView::CellPosition position
       }
     }
   }
-  // relayout the whole table
+
+  // Relayout the whole table
   RelayoutRequest();
-  return true; // addition successful
+
+  return true;    // Addition successful
 }
 
-Actor TableView::GetChildAt( Toolkit::TableView::CellPosition position )
+Actor TableView::GetChildAt( const Toolkit::TableView::CellPosition& position )
 {
-  // check if we have this row and column in the table
-  if( ( position.columnIndex >= mCellData.GetColumns() )||
-      ( position.rowIndex >= mCellData.GetRows() ) )
+  if( ( position.rowIndex < mCellData.GetRows() ) && ( position.columnIndex < mCellData.GetColumns() ) )
   {
-    // return an empty handle
-    return Actor();
+    return mCellData[ position.rowIndex ][ position.columnIndex ].actor;
   }
-  // return the child handle
-  return mCellData[ position.rowIndex ][ position.columnIndex ].actor;
+
+  // Return an empty handle
+  return Actor();
 }
 
-Actor TableView::RemoveChildAt( Toolkit::TableView::CellPosition position )
+Actor TableView::RemoveChildAt( const Toolkit::TableView::CellPosition& position )
 {
   // get the child handle
   Actor child = GetChildAt( position );
@@ -271,62 +277,70 @@ Actor TableView::RemoveChildAt( Toolkit::TableView::CellPosition position )
   return child;
 }
 
-bool TableView::FindChildPosition( Actor child, Toolkit::TableView::CellPosition& position )
+bool TableView::FindChildPosition( const Actor& child, Toolkit::TableView::CellPosition& positionOut )
 {
-  // only find valid child actors
+  // Only find valid child actors
   if( child )
   {
-    // walk through the layout data
+    // Walk through the layout data
     const unsigned int rowCount = mCellData.GetRows();
     const unsigned int columnCount = mCellData.GetColumns();
+
     for( unsigned int row = 0; row < rowCount; ++row )
     {
       for( unsigned int column = 0; column < columnCount; ++column )
       {
         if( mCellData[ row ][ column ].actor == child )
         {
-          position = mCellData[ row ][ column ].position;
+          positionOut = mCellData[ row ][ column ].position;
           return true;
         }
       }
     }
   }
+
   return false;
 }
 
 void TableView::InsertRow( unsigned int rowIndex )
 {
   RelayoutingLock lock( *this );
+
   mCellData.InsertRow( rowIndex );
-  // need to update the cellinfos for the items that moved
+
+  // Need to update the cell infos for the items that moved
   const unsigned int rowCount = mCellData.GetRows();
   const unsigned int columnCount = mCellData.GetColumns();
+
   for( unsigned int row = 0; row < rowCount; ++row )
   {
     for( unsigned int column = 0; column < columnCount; ++column )
     {
       Toolkit::TableView::CellPosition& position = mCellData[ row ][ column ].position;
-      // if cell is spanning and above and spans to inserted row
-      if( ( position.rowSpan > 1 )&&( position.rowIndex <= rowIndex )&&
+
+      // If cell is spanning and above and spans to inserted row
+      if( ( position.rowSpan > 1 ) && ( position.rowIndex <= rowIndex ) &&
           ( position.rowIndex + position.rowSpan > rowIndex ) )
       {
-        // increase span by one
+        // Increment span
         position.rowSpan++;
-        // copy cell to occupy the new column
+
+        // Copy cell to occupy the new column
         mCellData[ rowIndex ][ column ] = mCellData[ row ][ column ];
       }
-      // if below of inserted row, increase row index
-      else if( row > rowIndex )
+      else if( row > rowIndex )   // If below of inserted row, increase row index
       {
-        // increase index by one
+        // Increment index
         position.rowIndex++;
       }
     }
   }
-  mRelativeSizes.InsertRow( rowIndex );
-  // inserting a row requires adjusting the height vectors
-  mFixedHeights.insert( mFixedHeights.begin() + rowIndex, 0 );
-  mRelativeHeights.insert( mRelativeHeights.begin() + rowIndex, 0 );
+
+  // Expand row data array
+  mRowData.Insert( mRowData.Begin() + rowIndex, RowColumnData() );
+
+  // Sizes may have changed, so relayout
+  mRowColumnDirty = true;
   RelayoutRequest();
 }
 
@@ -339,30 +353,34 @@ void TableView::DeleteRow( unsigned int rowIndex )
 void TableView::DeleteRow( unsigned int rowIndex, std::vector<Actor>& removed )
 {
   RelayoutingLock lock( *this );
+
+  // Delete the row
   std::vector< CellData > lost;
   mCellData.DeleteRow( rowIndex, lost );
-  // need to update the cellinfos for the items that moved
+
+  // Need to update the cell infos for the items that moved
   const unsigned int rowCount = mCellData.GetRows();
   const unsigned int columnCount = mCellData.GetColumns();
+
   for( unsigned int row = 0; row < rowCount; ++row )
   {
     for( unsigned int column = 0; column < columnCount; ++column )
     {
       Toolkit::TableView::CellPosition& position = mCellData[ row ][ column ].position;
-      // if cell is spanning and above and spans to deleted row
-      if( ( position.rowSpan > 1 )&&( position.rowIndex <= rowIndex )&&
+
+      // If cell is spanning and above and spans to deleted row
+      if( ( position.rowSpan > 1 ) && ( position.rowIndex <= rowIndex ) &&
           ( position.rowIndex + position.rowSpan > rowIndex ) )
       {
-        // decrease span by one
+        // Decrement span
         if( position.rowSpan > 1 )
         {
           position.rowSpan--;
         }
       }
-      // if below of or at the inserted row, decrease row index
-      else if( row >= rowIndex )
+      else if( row >= rowIndex )    // If below of or at the inserted row, decrease row index
       {
-        // decrease index by one
+        // Decrement index
         if( position.rowIndex > 1 )
         {
           position.rowIndex--;
@@ -370,50 +388,58 @@ void TableView::DeleteRow( unsigned int rowIndex, std::vector<Actor>& removed )
       }
     }
   }
+
   // 1 row removed, 0 columns
   RemoveAndGetLostActors( lost, removed, 1u, 0u );
-  // resize the data structures
-  mRelativeSizes.DeleteRow( rowIndex );
-  // deleting a row requires adjusting the height vectors
-  mFixedHeights.erase( mFixedHeights.begin() + rowIndex );
-  mRelativeHeights.erase( mRelativeHeights.begin() + rowIndex );
+
+  // Contract row data array
+  mRowData.Erase( mRowData.Begin() + rowIndex );
+
+  // Sizes may have changed, so relayout
+  mRowColumnDirty = true;
   RelayoutRequest();
 }
 
 void TableView::InsertColumn( unsigned int columnIndex )
 {
   RelayoutingLock lock( *this );
+
+  // Insert the new column
   mCellData.InsertColumn( columnIndex );
-  // need to update the cellinfos for the items that moved
+
+  // Need to update the cell infos for the items that moved
   const unsigned int rowCount = mCellData.GetRows();
   const unsigned int columnCount = mCellData.GetColumns();
+
   for( unsigned int row = 0; row < rowCount; ++row )
   {
     for( unsigned int column = 0; column < columnCount; ++column )
     {
       Toolkit::TableView::CellPosition& position = mCellData[ row ][ column ].position;
-      // if cell is spanning and left side and spans to inserted column
-      if( ( position.columnSpan > 1 )&&( position.columnIndex <= columnIndex )&&
+
+      // If cell is spanning and left side and spans to inserted column
+      if( ( position.columnSpan > 1 ) && ( position.columnIndex <= columnIndex ) &&
           ( position.columnIndex + position.columnSpan > columnIndex ) )
       {
-        // increase span by one
+        // Increment span
         position.columnSpan++;
-        // copy cell to occupy the new column
+
+        // Copy cell to occupy the new column
         mCellData[ row ][ columnIndex ] = mCellData[ row ][ column ];
       }
-      // if on the right side of inserted column, increase column index
-      else if( column > columnIndex )
+      else if( column > columnIndex )   // If on the right side of inserted column, increase column index
       {
-        // increase index by one
+        // Increment index
         position.columnIndex++;
       }
     }
   }
-  // relative sizes gets recalculated on Relayout
-  mRelativeSizes.InsertColumn( columnIndex );
-  // inserting a column requires adjusting the width vectors
-  mFixedWidths.insert( mFixedWidths.begin() + columnIndex, 0 );
-  mRelativeWidths.insert( mRelativeWidths.begin() + columnIndex, 0 );
+
+  // Expand column data array
+  mColumnData.Insert( mColumnData.Begin() + columnIndex, RowColumnData() );
+
+  // Sizes may have changed so relayout
+  mRowColumnDirty = true;
   RelayoutRequest();
 }
 
@@ -426,30 +452,34 @@ void TableView::DeleteColumn( unsigned int columnIndex )
 void TableView::DeleteColumn( unsigned int columnIndex, std::vector<Actor>& removed )
 {
   RelayoutingLock lock( *this );
+
+  // Remove the column
   std::vector< CellData > lost;
   mCellData.DeleteColumn( columnIndex, lost );
-  // need to update the cellinfos for the items that moved
+
+  // Need to update the cell infos for the items that moved
   const unsigned int rowCount = mCellData.GetRows();
   const unsigned int columnCount = mCellData.GetColumns();
+
   for( unsigned int row = 0; row < rowCount; ++row )
   {
     for( unsigned int column = 0; column < columnCount; ++column )
     {
       Toolkit::TableView::CellPosition& position = mCellData[ row ][ column ].position;
-      // if cell is spanning and left side and spans to inserted column
-      if( ( position.columnSpan > 1 )&&( position.columnIndex <= columnIndex )&&
+
+      // If cell is spanning and left side and spans to inserted column
+      if( ( position.columnSpan > 1 ) && ( position.columnIndex <= columnIndex ) &&
           ( position.columnIndex + position.columnSpan > columnIndex ) )
       {
-        // decrease span by one
+        // Decrement span
         if( position.columnSpan > 1 )
         {
           position.columnSpan--;
         }
       }
-      // if on the right side of or at the inserted column, decrease column index
-      else if( column >= columnIndex )
+      else if( column >= columnIndex )    // If on the right side of or at the inserted column, decrease column index
       {
-        // decrease index by one
+        // Decrement index
         if( position.columnIndex > 0 )
         {
           position.columnIndex--;
@@ -457,14 +487,15 @@ void TableView::DeleteColumn( unsigned int columnIndex, std::vector<Actor>& remo
       }
     }
   }
+
   // 0 rows, 1 column removed
   RemoveAndGetLostActors( lost, removed, 0u, 1u );
-  // resize the data structures
-  mRelativeSizes.DeleteColumn( columnIndex );
-  // deleting a column requires adjusting the width vectors
-  mFixedWidths.erase( mFixedWidths.begin() + columnIndex );
-  mRelativeWidths.erase( mRelativeWidths.begin() + columnIndex );
-  // relayout
+
+  // Contract column data array
+  mColumnData.Erase( mColumnData.Begin() + columnIndex );
+
+  // Size may have changed so relayout
+  mRowColumnDirty = true;
   RelayoutRequest();
 }
 
@@ -477,36 +508,45 @@ void TableView::Resize( unsigned int rows, unsigned int columns )
 void TableView::Resize( unsigned int rows, unsigned int columns, std::vector<Actor>& removed )
 {
   RelayoutingLock lock( *this );
+
   unsigned int oldRows = GetRows();
   unsigned int oldColumns = GetColumns();
-  // resize data array
+
+  // Resize data array
   std::vector< CellData > lost;
   ResizeContainers( rows, columns, lost );
-  // calculate if we lost rows or columns
+
+  // Calculate if we lost rows
   unsigned int rowsRemoved = 0;
   unsigned int newRows = GetRows();
+
   if( oldRows < newRows )
   {
     rowsRemoved = newRows - oldRows;
   }
+
+  // Calculate if we lost columns
   unsigned int columnsRemoved = 0;
   unsigned int newColumns = GetColumns();
   if( oldColumns < newColumns )
   {
     rowsRemoved = newColumns - oldColumns;
   }
+
   RemoveAndGetLostActors( lost, removed, rowsRemoved, columnsRemoved );
-  // finally relayout once all actors are removed
+
+  // Sizes may have changed so request a relayout
+  mRowColumnDirty = true;
   RelayoutRequest();
 }
 
 void TableView::SetCellPadding( Size padding )
 {
-  // if padding really changed
+  // If padding really changed
   if( padding != mPadding )
   {
     mPadding = padding;
-    // do a relayout
+
     RelayoutRequest();
   }
 }
@@ -516,184 +556,224 @@ Size TableView::GetCellPadding()
   return mPadding;
 }
 
+void TableView::SetRowPolicy( unsigned int rowIndex, CellSizePolicy policy )
+{
+  DALI_ASSERT_ALWAYS( rowIndex < mRowData.Size() );
+
+  if( mRowData[ rowIndex ].sizePolicy != policy )
+  {
+    mRowData[ rowIndex ].sizePolicy = policy;
+
+    mRowColumnDirty = true;
+    RelayoutRequest();
+  }
+}
+
+TableView::CellSizePolicy TableView::GetRowPolicy( unsigned int rowIndex ) const
+{
+  DALI_ASSERT_ALWAYS( rowIndex < mRowData.Size() );
+
+  return mRowData[ rowIndex ].sizePolicy;
+}
+
+void TableView::SetColumnPolicy( unsigned int columnIndex, CellSizePolicy policy )
+{
+  DALI_ASSERT_ALWAYS( columnIndex < mColumnData.Size() );
+
+  if( mColumnData[ columnIndex ].sizePolicy != policy )
+  {
+    mColumnData[ columnIndex ].sizePolicy = policy;
+
+    mRowColumnDirty = true;
+    RelayoutRequest();
+  }
+}
+
+TableView::CellSizePolicy TableView::GetColumnPolicy( unsigned int columnIndex ) const
+{
+  DALI_ASSERT_ALWAYS( columnIndex < mColumnData.Size() );
+
+  return mColumnData[ columnIndex ].sizePolicy;
+}
+
 void TableView::SetFixedHeight( unsigned int rowIndex, float height )
 {
-  DALI_ASSERT_ALWAYS( rowIndex < mFixedHeights.size() );
-  // add the fixed height to the array of fixed heights
-  mFixedHeights[ rowIndex ] = height;
-  // remove the relative height of the same row
-  mRelativeHeights[ rowIndex ] = 0.f;
-  // relayout all cells, no lock needed as nothing added or removed
+  DALI_ASSERT_ALWAYS( rowIndex < mRowData.Size() );
+
+  RowColumnData& data = mRowData[ rowIndex ];
+  data.size = height;
+  data.sizePolicy = FIXED;
+
+  mRowColumnDirty = true;
   RelayoutRequest();
 }
 
 float TableView::GetFixedHeight( unsigned int rowIndex ) const
 {
-  DALI_ASSERT_ALWAYS( rowIndex < mFixedHeights.size() );
+  DALI_ASSERT_ALWAYS( rowIndex < mRowData.Size() );
 
-  return mFixedHeights[ rowIndex ];
+  return mRowData[ rowIndex ].size;
 }
 
-void TableView::SetRelativeHeight( unsigned int rowIndex, float heightPercentage )
+void TableView::SetFixedWidth( unsigned int columnIndex, float width )
 {
-  DALI_ASSERT_ALWAYS( rowIndex < mRelativeHeights.size() );
-  // add the relative height to the array of relative heights
-  mRelativeHeights[ rowIndex ] = heightPercentage;
-  // remove the fixed height of the same row
-  mFixedHeights[ rowIndex ] = 0.f;
-  // relayout all cells, no lock needed as nothing added or removed
+  DALI_ASSERT_ALWAYS( columnIndex < mColumnData.Size() );
+
+  RowColumnData& data = mColumnData[ columnIndex ];
+  data.size = width;
+  data.sizePolicy = FIXED;
+
+  mRowColumnDirty = true;
   RelayoutRequest();
 }
 
-float TableView::GetRelativeHeight( unsigned int rowIndex ) const
+float TableView::GetFixedWidth( unsigned int columnIndex ) const
 {
-  DALI_ASSERT_ALWAYS( rowIndex < mRelativeHeights.size() );
+  DALI_ASSERT_ALWAYS( columnIndex < mColumnData.Size() );
 
-  return mRelativeHeights[ rowIndex ];
+  return mColumnData[ columnIndex ].size;
 }
 
-void TableView::SetFixedWidth( unsigned int columnIndex, float width )
+void TableView::SetRelativeHeight( unsigned int rowIndex, float heightPercentage )
 {
-  DALI_ASSERT_ALWAYS( columnIndex < mFixedWidths.size() );
-  // add the fixed width to the array of fixed column widths
-  mFixedWidths[ columnIndex ] = width;
-  // remove the relative width of the same column
-  mRelativeWidths[ columnIndex ] = 0.f;
-  // relayout all cells, no lock needed as nothing added or removed
+  DALI_ASSERT_ALWAYS( rowIndex < mRowData.Size() );
+
+  RowColumnData& data = mRowData[ rowIndex ];
+  data.fillRatio = heightPercentage;
+  data.userFillRatio = true;
+  data.sizePolicy = FILL;
+
+  mRowColumnDirty = true;
   RelayoutRequest();
 }
 
-float TableView::GetFixedWidth( unsigned int columnIndex ) const
+float TableView::GetRelativeHeight( unsigned int rowIndex ) const
 {
-  DALI_ASSERT_ALWAYS( columnIndex < mFixedWidths.size() );
+  DALI_ASSERT_ALWAYS( rowIndex < mRowData.Size() );
 
-  return mFixedWidths[ columnIndex ];
+  return mRowData[ rowIndex ].fillRatio;
 }
 
 void TableView::SetRelativeWidth( unsigned int columnIndex, float widthPercentage )
 {
-  DALI_ASSERT_ALWAYS( columnIndex < mRelativeWidths.size() );
-  // add the relative widths to the array of relative widths
-  mRelativeWidths[ columnIndex ] = widthPercentage;
-  // remove the fixed width of the same column
-  mFixedWidths[ columnIndex ] = 0.f;
-  // relayout all cells, no lock needed as nothing added or removed
+  DALI_ASSERT_ALWAYS( columnIndex < mColumnData.Size() );
+
+  RowColumnData& data = mColumnData[ columnIndex ];
+  data.fillRatio = widthPercentage;
+  data.userFillRatio = true;
+  data.sizePolicy = FILL;
+
+  mRowColumnDirty = true;
   RelayoutRequest();
 }
 
 float TableView::GetRelativeWidth( unsigned int columnIndex ) const
 {
-  DALI_ASSERT_ALWAYS( columnIndex < mRelativeWidths.size() );
+  DALI_ASSERT_ALWAYS( columnIndex < mColumnData.Size() );
+
+  return mColumnData[ columnIndex ].fillRatio;
+}
+
+void TableView::CalculateRowColumnData()
+{
+  // Calculate the relative sizes
+  if( mRowColumnDirty )
+  {
+    ComputeRelativeSizes( mRowData );
+    ComputeRelativeSizes( mColumnData );
 
-  return mRelativeWidths[ columnIndex ];
+    mRowColumnDirty = false;
+  }
 }
 
-void TableView::OnRelayout( const Vector2& size, ActorSizeContainer& container )
+void TableView::OnCalculateRelayoutSize( Dimension dimension )
 {
-  float fixedHeightsTotal = 0.0f;
-  float fixedWidthsTotal = 0.0f;
+  CalculateRowColumnData();
 
-  // 1. update the relative sizes and calculate total fixed height and width
-  UpdateRelativeSizes( fixedHeightsTotal, fixedWidthsTotal );
+  if( dimension & WIDTH )
+  {
+    CalculateFixedSizes( mColumnData, WIDTH );
+    mFixedTotals.width = CalculateTotalFixedSize( mColumnData );
+  }
 
-  // 2. go through the layout data and create constraints
-  float cumulatedFixedHeight = 0.0f;
-  float cumulatedRelativeHeight = 0.0f;
+  if( dimension & HEIGHT )
+  {
+    CalculateFixedSizes( mRowData, HEIGHT );
+    mFixedTotals.height = CalculateTotalFixedSize( mRowData );
+  }
+}
+
+void TableView::OnLayoutNegotiated( float size, Dimension dimension )
+{
+  CalculateRowColumnData();
+
+  // Calculate the value of all relative sized rows and columns
+  if( dimension & WIDTH )
+  {
+    float remainingSize = size - mFixedTotals.width;
+    if( remainingSize < 0.0f )
+    {
+      remainingSize = 0.0f;
+    }
+
+    CalculateRelativeSizes( mColumnData, remainingSize );
+  }
+
+  if( dimension & HEIGHT )
+  {
+    float remainingSize = size - mFixedTotals.height;
+    if( remainingSize < 0.0f )
+    {
+      remainingSize = 0.0f;
+    }
+
+    CalculateRelativeSizes( mRowData, remainingSize );
+  }
+}
+
+void TableView::OnRelayout( const Vector2& size, RelayoutContainer& container )
+{
+  CalculateRowColumnData();
+
+  // Go through the layout data
+  float cumulatedHeight = 0.0f;
 
-  // iterate the table
   const unsigned int rowCount = mCellData.GetRows();
   const unsigned int columnCount = mCellData.GetColumns();
-  // float versions of the count + 1 to keep precision
-  const float maxRowPlusOne( rowCount + 1 );
-  const float maxColumnPlusOne( columnCount + 1 );
+
   for( unsigned int row = 0; row < rowCount; ++row )
   {
-    // reset widths at the start of each row
-    float cumulatedFixedWidth = 0.0f;
-    float cumulatedRelativeWidth = 0.0f;
+    float cumulatedWidth = 0.0f;
+
     for( unsigned int column = 0; column < columnCount; ++column )
     {
-      // check if this cell has an actor
-      Actor actor = mCellData[ row ][ column ].actor;
+      Actor& actor = mCellData[ row ][ column ].actor;
       const Toolkit::TableView::CellPosition position = mCellData[ row ][ column ].position;
-      // if there is an actor and this is the main cell of the actor
-      // an actor can be in multiple cells if its row or columnspan is more than 1
-      // we however must only lay out each actor only once
-      if( ( actor )&&( position.rowIndex == row )&&( position.columnIndex == column ) )
+
+      // If there is an actor and this is the main cell of the actor.
+      // An actor can be in multiple cells if its row or columnspan is more than 1.
+      // We however must lay out each actor only once.
+      if( actor && ( position.rowIndex == row ) && ( position.columnIndex == column ) )
       {
-        // anchor actor correctly
+        // Anchor actor to top left of table view
         actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
         actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
-        // remove old constraints
-        actor.RemoveConstraints();
-
-        // 1. set position
-        // get the row and column indices
-        float rowPos( position.rowIndex );
-        float colPos( position.columnIndex );
-        // constrain the actor position to be relative to the width and height of table
-        // minus the padding of course (padding is all around cells)
-        Vector2 relativePosition( cumulatedRelativeWidth, cumulatedRelativeHeight );
-        // fixed height rows and fixed width cells are considered as padding so
-        // they are removed from the total size for relative
-        // for position only consider cumulated fixed rows and columns from top and left
-        Vector2 positionPadding( maxColumnPlusOne * mPadding.width + fixedWidthsTotal,
-                                 maxRowPlusOne * mPadding.height + fixedHeightsTotal );
-        Vector2 fixedPosition( ( colPos + 1.0f ) * mPadding.width + cumulatedFixedWidth,
-                                 ( rowPos + 1.0f ) * mPadding.height + cumulatedFixedHeight );
-
-        Vector3 actorPosition( RelativeToSize( relativePosition, positionPadding, fixedPosition, size ) );
-        actor.SetPosition( actorPosition );
 
-        // 2. set size
-        // constrain the actor size to be relative to the size of table
-        // get the relative size for this cell
-        Vector2 relativeSize( mRelativeSizes[ row ][ column ] );
-        Vector2 fixedSize( mFixedWidths[ column ], mFixedHeights[ row ] );
-        // if we span multiple cells, need to sum them all up, both fixed and relative parts
-        if( position.rowSpan > 1 )
-        {
-          for( unsigned int i = 1; i < position.rowSpan; ++i )
-          {
-            // accumulate the height only
-            relativeSize.height += mRelativeSizes[ row + i ][ column ].height;
-            fixedSize.height += mFixedHeights[ row + i ];
-          }
-        }
-        if( position.columnSpan > 1 )
-        {
-          for( unsigned int i = 1; i < position.columnSpan; ++i )
-          {
-            // accumulate the width only
-            relativeSize.width += mRelativeSizes[ row ][ column + i ].width;
-            fixedSize.width += mFixedWidths[ column + i ];
-          }
-        }
-        // minus the padding from size (padding is all around cells)
-        // if item spans multiple columns or rows then less padding is added (default span is 1)
-        // fixed height rows and fixed width cells are considered as padding so they are removed
-        // from the total available size for relative cells
-        Vector2 sizePadding( maxColumnPlusOne * mPadding.width + fixedWidthsTotal,
-                             maxRowPlusOne * mPadding.height + fixedHeightsTotal );
-        // and added to the fixed size multiplied by the span of rows and columns
-        fixedSize.width += ( position.columnSpan - 1.0f ) * mPadding.width;
-        fixedSize.height += ( position.rowSpan - 1.0f ) * mPadding.height;
-
-        Vector2 actorSize( RelativeToSize( relativeSize, sizePadding, fixedSize, size ) );
-        actor.SetSize(actorSize.x, actorSize.y);
-
-        // Relayout Children
-        Relayout ( actor, actorSize, container );
+        Padding padding;
+        actor.GetPadding( padding );
+
+        Vector3 actorPosition( cumulatedWidth + mPadding.width + padding.left,       // Left padding
+                               cumulatedHeight + mPadding.height + padding.top,      // Top padding
+                               0.0f );
+        actor.SetPosition( actorPosition );
       }
-      // for position we need to keep track of current fixed width and relative width
-      // increase for next column
-      cumulatedFixedWidth += mFixedWidths[ column ];
-      cumulatedRelativeWidth += mRelativeSizes[ row ][ column ].width;
+
+      DALI_ASSERT_DEBUG( column < mColumnData.Size() );
+      cumulatedWidth += mColumnData[ column ].size;
     }
-    // for position we need to keep track of current fixed height and relative height
-    // increase for next row
-    cumulatedFixedHeight += mFixedHeights[ row ];
-    cumulatedRelativeHeight += mRelativeSizes[ row ][ 0 ].height; // all columns share same height
+
+    DALI_ASSERT_DEBUG( row < mRowData.Size() );
+    cumulatedHeight += mRowData[ row ].size;
   }
 }
 
@@ -801,15 +881,20 @@ void TableView::OnControlChildAdd( Actor& child )
     return;
   }
 
+  RelayoutRequest();
+
+  // Test properties on actor
   Toolkit::TableView::CellPosition cellPosition;
   if( child.GetPropertyIndex(Toolkit::TableView::ROW_SPAN_PROPERTY_NAME) != Property::INVALID_INDEX )
   {
     cellPosition.rowSpan = static_cast<unsigned int>( child.GetProperty( child.GetPropertyIndex(Toolkit::TableView::ROW_SPAN_PROPERTY_NAME) ).Get<float>() );
   }
+
   if( child.GetPropertyIndex(Toolkit::TableView::COLUMN_SPAN_PROPERTY_NAME) != Property::INVALID_INDEX )
   {
     cellPosition.columnSpan = static_cast<unsigned int>( child.GetProperty( child.GetPropertyIndex(Toolkit::TableView::COLUMN_SPAN_PROPERTY_NAME) ).Get<float>() );
   }
+
   if( child.GetPropertyIndex(Toolkit::TableView::CELL_INDICES_PROPERTY_NAME) != Property::INVALID_INDEX )
   {
     Vector2 indices = child.GetProperty( child.GetPropertyIndex(Toolkit::TableView::CELL_INDICES_PROPERTY_NAME) ).Get<Vector2 >();
@@ -817,44 +902,43 @@ void TableView::OnControlChildAdd( Actor& child )
     cellPosition.columnIndex = static_cast<unsigned int>( indices.y );
 
     AddChild( child, cellPosition );
-    // donot continue
+
+    // Do not continue
     return;
   }
 
-  // check if we're already laying out this child somewhere on the table
-  // walk through the layout data
+  // Find the first available cell to store the actor in
   const unsigned int rowCount = mCellData.GetRows();
   const unsigned int columnCount = mCellData.GetColumns();
-  // child not yet laid out, find the first free slot
   for( unsigned int row = 0; row < rowCount; ++row )
   {
     for( unsigned int column = 0; column < columnCount; ++column )
     {
-      // no actor means free cell
       if( !(mCellData[ row ][ column ].actor) )
       {
-        // put the actor in the cell
+        // Put the actor in the cell
         CellData data;
         data.actor = child;
         data.position.columnIndex = column;
         data.position.rowIndex = row;
         mCellData[ row ][ column ] = data;
-        RelayoutRequest();
-        // don' continue
+
+        // Don't continue
         return;
       }
     }
   }
-  // still here, no room for the poor child so increase the array. Need a new row
-  ResizeContainers( rowCount + 1, columnCount );
-  // put the actor to the first cell of the new row
+
+  // No empty cells, so increase size of the table
+  unsigned int newColumnCount = ( columnCount > 0 ) ? columnCount : 1;
+  ResizeContainers( rowCount + 1, newColumnCount );
+
+  // Put the actor in the first cell of the new row
   CellData data;
   data.actor = child;
   data.position.rowIndex = rowCount;
   data.position.columnIndex = 0;
   mCellData[ rowCount ][ 0 ] = data;
-  // finally relayout the table
-  RelayoutRequest();
 }
 
 void TableView::OnControlChildRemove( Actor& child )
@@ -873,7 +957,8 @@ void TableView::OnControlChildRemove( Actor& child )
 TableView::TableView( unsigned int initialRows, unsigned int initialColumns )
 : Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
   mCellData( initialRows, initialColumns ),
-  mLayoutingChild( false )
+  mLayoutingChild( false ),
+  mRowColumnDirty( true )     // Force recalculation first time
 {
   SetKeyboardNavigationSupport( true );
   ResizeContainers( initialRows, initialColumns );
@@ -895,13 +980,12 @@ void TableView::ResizeContainers( unsigned int rows, unsigned int columns )
 
 void TableView::ResizeContainers( unsigned int rows, unsigned int columns, std::vector<CellData>& removed )
 {
+  // Resize cell data
   mCellData.Resize( rows, columns, removed );
-  // we dont care if these go smaller, data will be regenerated or is not needed anymore
-  mRelativeSizes.Resize( rows, columns );
-  mFixedHeights.resize( rows );
-  mRelativeHeights.resize( rows );
-  mFixedWidths.resize( columns );
-  mRelativeWidths.resize( columns );
+
+  // We don't care if these go smaller, data will be regenerated or is not needed anymore
+  mRowData.Resize( rows );
+  mColumnData.Resize( columns );
 }
 
 void TableView::RemoveAndGetLostActors( const std::vector<CellData>& lost, std::vector<Actor>& removed,
@@ -952,7 +1036,7 @@ void TableView::RemoveAndGetLostActors( const std::vector<CellData>& lost, std::
   }
 }
 
-bool TableView::RemoveAllInstances( Actor child )
+bool TableView::RemoveAllInstances( const Actor& child )
 {
   bool found = false;
   // walk through the layout data
@@ -973,104 +1057,6 @@ bool TableView::RemoveAllInstances( Actor child )
   return found;
 }
 
-void TableView::UpdateRelativeSizes( float& fixedHeightsTotal, float& fixedWidthsTotal )
-{
-  // 1. check all the fixed heights and widths to know how much size they take in total
-  // as well as the relative heights and widths to know how much is left for the 'fill' cells
-  unsigned int fixedRowCount = 0;
-  unsigned int relativeRowCount = 0;
-  float relativeHeightsTotal = 0.0f;
-  const unsigned int rowCount = mCellData.GetRows();
-  for( unsigned int row = 0; row < rowCount; ++row )
-  {
-    if( mFixedHeights[ row ] > 0.0f )
-    {
-      ++fixedRowCount;
-      fixedHeightsTotal += mFixedHeights[ row ];
-    }
-    if( mRelativeHeights[ row ] > 0.0f )
-    {
-      ++relativeRowCount;
-      relativeHeightsTotal += mRelativeHeights[ row ];
-    }
-  }
-  unsigned int fixedColumnCount = 0;
-  unsigned int relativeColumnCount = 0;
-  const unsigned int columnCount = mCellData.GetColumns();
-  float relativeWidthsTotal = 0.0f;
-  for( unsigned int column = 0; column < columnCount; ++column )
-  {
-    if( mFixedWidths[ column ] > 0.0f )
-    {
-      ++fixedColumnCount;
-      fixedWidthsTotal += mFixedWidths[ column ];
-    }
-    if( mRelativeWidths[ column ] > 0.0f )
-    {
-      ++relativeColumnCount;
-      relativeWidthsTotal += mRelativeWidths[ column ];
-    }
-  }
-
-  // 2. cap the relative width and height totals to 100%
-  if( relativeHeightsTotal > 1.0f )
-  {
-    relativeHeightsTotal = 1.0f;
-  }
-  if( relativeWidthsTotal > 1.0f )
-  {
-    relativeWidthsTotal = 1.0f;
-  }
-
-  // 3. create a table of relative sizes so we can lookup for cells that span multiple rows & colums
-  const float fillRowCount( rowCount - relativeRowCount - fixedRowCount );
-  const float fillColumnCount( columnCount - relativeColumnCount - fixedColumnCount );
-
-  // walk through the data containers
-  for( unsigned int row = 0; row < rowCount; ++row )
-  {
-    float relativeHeight = 0.0f;
-    // if we have a fixed height, relative height is 0
-    if( mFixedHeights[ row ] > 0.0f )
-    {
-      relativeHeight = 0.0f;
-    }
-    // else if we're given a specific row height %, use that
-    else if( mRelativeHeights[ row ] > 0.0f )
-    {
-      relativeHeight = mRelativeHeights[ row ];
-    }
-    // else if there are fill rows
-    else if( fillRowCount > 0 )
-    {
-      // this is a 'fill' row. it gets the remainder of the 100% divided evenly between 'fill' rows
-      relativeHeight = (1.0f - relativeHeightsTotal ) / fillRowCount;
-    }
-    for( unsigned int column = 0; column < columnCount; ++column )
-    {
-      float relativeWidth = 0.0f;
-      // if we have a fixed width, relative width is 0
-      if( mFixedWidths[ column ] > 0.0f )
-      {
-        relativeWidth = 0.0f;
-      }
-      // else if we're given a specific column width %, use that
-      else if( mRelativeWidths[ column ] > 0.0f )
-      {
-        relativeWidth = mRelativeWidths[ column ];
-      }
-      // else if there are fill columns
-      else if( fillColumnCount > 0 )
-      {
-        // this is a 'fill' column. it gets the remainder of the 100% divided evenly between 'fill' columns
-        relativeWidth = (1.0f - relativeWidthsTotal ) / fillColumnCount;
-      }
-      // store the value
-      mRelativeSizes[ row ][ column ] = Size( relativeWidth, relativeHeight );
-    }
-  }
-}
-
 void TableView::SetHeightOrWidthProperty(TableView& tableViewImpl,
                                          void(TableView::*funcFixed)(unsigned int, float),
                                          void(TableView::*funcRelative)(unsigned int, float),
@@ -1090,11 +1076,11 @@ void TableView::SetHeightOrWidthProperty(TableView& tableViewImpl,
         if( item.HasKey( "policy" ) && item.HasKey( "value" ) )
         {
           Toolkit::TableView::LayoutPolicy policy = Scripting::GetEnumeration< Toolkit::TableView::LayoutPolicy >( item.GetValue("policy").Get<std::string>().c_str(), LAYOUT_POLICY_STRING_TABLE, LAYOUT_POLICY_STRING_TABLE_COUNT );
-          if( policy == Toolkit::TableView::Fixed )
+          if( policy == Toolkit::TableView::FIXED )
           {
             (tableViewImpl.*funcFixed)( rowIndex, item.GetValue("value").Get<float>() );
           }
-          else if( policy == Toolkit::TableView::Relative )
+          else if( policy == Toolkit::TableView::RELATIVE )
           {
             (tableViewImpl.*funcRelative)( rowIndex, item.GetValue("value").Get<float>() );
           }
@@ -1107,40 +1093,61 @@ void TableView::SetHeightOrWidthProperty(TableView& tableViewImpl,
 Property::Value TableView::GetRowHeightsPropertyValue()
 {
   Property::Map map;
-  GetMapPropertyValue( mFixedHeights, mRelativeHeights, map);
+  GetMapPropertyValue( mRowData, map);
   return Property::Value(map);
 }
 
 Property::Value TableView::GetColumnWidthsPropertyValue()
 {
   Property::Map map;
-  GetMapPropertyValue( mFixedWidths, mRelativeWidths, map);
+  GetMapPropertyValue( mColumnData, map);
   return Property::Value(map);
 }
 
-void TableView::GetMapPropertyValue( const std::vector<float>& fixedSize, const std::vector<float>& relativeSize, Property::Map& map )
+void TableView::GetMapPropertyValue( const RowColumnArray& data, Property::Map& map )
 {
-  std::string fixedPolicy( Scripting::GetEnumerationName< Toolkit::TableView::LayoutPolicy >( Toolkit::TableView::Fixed, LAYOUT_POLICY_STRING_TABLE, LAYOUT_POLICY_STRING_TABLE_COUNT ) );
-  std::string relativePolicy( Scripting::GetEnumerationName< Toolkit::TableView::LayoutPolicy >( Toolkit::TableView::Relative, LAYOUT_POLICY_STRING_TABLE, LAYOUT_POLICY_STRING_TABLE_COUNT ) );
+  std::string fixedPolicy( Scripting::GetEnumerationName< Toolkit::TableView::LayoutPolicy >( Toolkit::TableView::FIXED, LAYOUT_POLICY_STRING_TABLE, LAYOUT_POLICY_STRING_TABLE_COUNT ) );
+  std::string relativePolicy( Scripting::GetEnumerationName< Toolkit::TableView::LayoutPolicy >( Toolkit::TableView::RELATIVE, LAYOUT_POLICY_STRING_TABLE, LAYOUT_POLICY_STRING_TABLE_COUNT ) );
 
-  size_t count = fixedSize.size();
-  for( size_t index = 0; index < count; index++ )
+  const RowColumnArray::SizeType count = data.Size();
+  for( RowColumnArray::SizeType i = 0; i < count; i++ )
   {
-    if( ! EqualsZero( fixedSize[index] ) )
-    {
-      Property::Map item;
-      item[ "policy" ] = fixedPolicy;
-      item[ "value" ] = fixedSize[index];
+    const RowColumnData& dataInstance = data[ i ];
 
-      map[ static_cast<std::ostringstream*>( &(std::ostringstream() << index ) )->str() ] = item;
-    }
-    else if( ! EqualsZero( relativeSize[index] ) )
+    switch( dataInstance.sizePolicy )
     {
-      Property::Map item;
-      item[ "policy" ] = relativePolicy;
-      item[ "value" ] = relativeSize[index];
+      case FIXED:
+      {
+        Property::Map item;
+        item[ "policy" ] = fixedPolicy;
+        item[ "value" ] = dataInstance.size;
+
+        std::ostringstream ss;
+        ss << i;
+
+        map[ ss.str() ] = item;
+
+        break;
+      }
+
+      case FILL:
+      {
+        Property::Map item;
+        item[ "policy" ] = relativePolicy;
+        item[ "value" ] = dataInstance.fillRatio;
+
+        std::ostringstream ss;
+        ss << i;
 
-      map[ static_cast<std::ostringstream*>( &(std::ostringstream() << index ) )->str() ] = item;
+        map[ ss.str() ] = item;
+
+        break;
+      }
+
+      default:
+      {
+        break;
+      }
     }
   }
 }
@@ -1236,6 +1243,257 @@ Actor TableView::GetNextKeyboardFocusableActor(Actor currentFocusedActor, Toolki
   return nextFocusableActor;
 }
 
+Vector3 TableView::GetNaturalSize()
+{
+  // Natural size is the size of all fixed cell widths or heights. This ignores cells with relative heights.
+  return Vector3( mFixedTotals.width, mFixedTotals.height, 1.0f );
+}
+
+float TableView::CalculateChildSize( const Actor& child, Dimension dimension )
+{
+  CalculateRowColumnData();
+
+  const unsigned int rowCount = mCellData.GetRows();
+  const unsigned int columnCount = mCellData.GetColumns();
+
+  for( unsigned int row = 0; row < rowCount; ++row )
+  {
+    for( unsigned int column = 0; column < columnCount; ++column )
+    {
+      // check if this cell has an actor
+      Actor& actor = mCellData[ row ][ column ].actor;
+
+      if( actor && ( actor == child ) )
+      {
+        const Toolkit::TableView::CellPosition position = mCellData[ row ][ column ].position;
+
+        // If there is an actor and this is the main cell of the actor.
+        // An actor can be in multiple cells if its row or columnspan is more than 1.
+        if ( ( position.rowIndex == row ) && ( position.columnIndex == column ) )
+        {
+          switch( dimension )
+          {
+            case WIDTH:
+            {
+              float cellSize = 0.0f;
+
+              // Accumulate the width
+              for( unsigned int i = 0; i < position.columnSpan; ++i )
+              {
+                cellSize += mColumnData[ column + i ].size;
+              }
+
+              // Apply padding
+              cellSize -= mPadding.width * 2.0f;
+              if( cellSize < 0.0f )
+              {
+                cellSize = 0.0f;
+              }
+
+              return cellSize;
+            }
+
+            case HEIGHT:
+            {
+              float cellSize = 0.0f;
+
+              // Accumulate the height
+              for( unsigned int i = 0; i < position.rowSpan; ++i )
+              {
+                cellSize += mRowData[ row + i ].size;
+              }
+
+              // Apply padding
+              cellSize -= mPadding.width * 2.0f;
+              if( cellSize < 0.0f )
+              {
+                cellSize = 0.0f;
+              }
+
+              return cellSize;
+            }
+
+            default:
+            {
+              return 0.0f;
+            }
+          }
+        }
+      }
+    }
+  }
+
+  return 0.0f;    // Child not found
+}
+
+bool TableView::RelayoutDependentOnChildren( Dimension dimension )
+{
+  if ( Control::RelayoutDependentOnChildren( dimension ) )
+  {
+    return true;
+  }
+
+  return FindFit( mRowData ) || FindFit( mColumnData );
+}
+
+void TableView::SetCellAlignment( Toolkit::TableView::CellPosition position, HorizontalAlignment::Type horizontal, VerticalAlignment::Type vertical )
+{
+  // Check if we need to expand our data array
+  if( position.rowIndex >= mCellData.GetRows() )
+  {
+    // Only adding new rows
+    ResizeContainers( position.rowIndex + 1, mCellData.GetColumns() );
+  }
+
+  if( position.columnIndex >= mCellData.GetColumns() )
+  {
+    // Only adding new columns
+    ResizeContainers( mCellData.GetRows(), position.columnIndex + 1 );
+  }
+
+  // Set the alignment of the cell
+  CellData& data = mCellData[ position.rowIndex ][ position.columnIndex ];
+  data.horizontalAlignment = horizontal;
+  data.verticalAlignment = vertical;
+}
+
+void TableView::ComputeRelativeSizes( RowColumnArray& data )
+{
+  // First pass: Count number of fill entries and calculate used relative space
+  Dali::Vector< RowColumnData* > fillData;
+  float relativeTotal = 0.0f;
+
+  const unsigned int dataCount = data.Size();
+
+  for( unsigned int i = 0; i < dataCount; ++i )
+  {
+    RowColumnData& dataInstance = data[ i ];
+
+    if( dataInstance.sizePolicy == FILL )
+    {
+      if( dataInstance.userFillRatio )
+      {
+        relativeTotal += dataInstance.fillRatio;
+      }
+      else
+      {
+        fillData.PushBack( &dataInstance );
+      }
+    }
+  }
+
+  // Second pass: Distribute remaining relative space
+  const unsigned int fillCount = fillData.Size();
+  if( fillCount > 0 )
+  {
+    if( relativeTotal > 1.0f )
+    {
+      relativeTotal = 1.0f;
+    }
+
+    const float evenFillRatio = (1.0f - relativeTotal ) / fillCount;
+
+    for( unsigned int i = 0; i < fillCount; ++i )
+    {
+      fillData[ i ]->fillRatio = evenFillRatio;
+    }
+  }
+}
+
+float TableView::CalculateTotalFixedSize( const RowColumnArray& data )
+{
+  float totalSize = 0.0f;
+
+  const unsigned int dataCount = data.Size();
+
+  for( unsigned int i = 0; i < dataCount; ++i )
+  {
+    const RowColumnData& dataInstance = data[ i ];
+
+    switch( dataInstance.sizePolicy )
+    {
+      case FIXED:
+      case FIT:
+      {
+        totalSize += dataInstance.size;
+        break;
+      }
+
+      default:
+      {
+        break;
+      }
+    }
+  }
+
+  return totalSize;
+}
+
+void TableView::CalculateFixedSizes( RowColumnArray& data, Dimension dimension )
+{
+  const unsigned int dataCount = data.Size();
+
+  for( unsigned int i = 0; i < dataCount; ++i )
+  {
+    RowColumnData& dataInstance = data[ i ];
+
+    if( dataInstance.sizePolicy == FIT )
+    {
+      // Find the size of the biggest actor in the row or column
+      float maxActorHeight = 0.0f;
+
+      unsigned int fitCount = ( dimension == WIDTH ) ? mCellData.GetRows() : mCellData.GetColumns();
+
+      for( unsigned int j = 0; j < fitCount; ++j )
+      {
+        unsigned int row = ( dimension == WIDTH ) ? j : i;
+        unsigned int column = ( dimension == WIDTH ) ? i : j;
+        DALI_ASSERT_DEBUG( row < mCellData.GetRows() );
+        DALI_ASSERT_DEBUG( column < mCellData.GetColumns() );
+
+        Actor& actor = mCellData[ row ][ column ].actor;
+        if( actor )
+        {
+          if( FitToChild( actor, dimension ) )
+          {
+            maxActorHeight = std::max( maxActorHeight, actor.GetRelayoutSize( dimension ) );
+          }
+        }
+      }
+
+      dataInstance.size = maxActorHeight;
+    }
+  }
+}
+
+void TableView::CalculateRelativeSizes( RowColumnArray& data, float size )
+{
+  const unsigned int dataCount = data.Size();
+
+  for( unsigned int i = 0; i < dataCount; ++i )
+  {
+    RowColumnData& dataInstance = data[ i ];
+
+    if( dataInstance.sizePolicy == FILL )
+    {
+      dataInstance.size = dataInstance.fillRatio * size;
+    }
+  }
+}
+
+bool TableView::FindFit( const RowColumnArray& data )
+{
+  for( unsigned int i = 0, count = data.Size(); i < count; ++i )
+  {
+    if( data[ i ].sizePolicy == FIT )
+    {
+      return true;
+    }
+  }
+
+  return false;
+}
+
 } // namespace Internal
 
 } // namespace Toolkit
index 154c341..55a7d7b 100644 (file)
@@ -41,13 +41,13 @@ class TableView : public Control
 public:
 
   /**
-   * Structure for the layout data
+   * Enum for the size policies of rows and columns
    */
-  struct CellData
+  enum CellSizePolicy
   {
-    // data members
-    Actor actor;
-    Toolkit::TableView::CellPosition position;
+    FILL,       ///< Fill up available space, may have a ratio associated with it
+    FIXED,      ///< A specific fixed width or height
+    FIT         ///< Fit around actors in the row or column
   };
 
   /**
@@ -59,22 +59,22 @@ public:
   /**
    * @copydoc Toolkit::TableView::AddChild
    */
-  bool AddChild( Actor child, Toolkit::TableView::CellPosition position );
+  bool AddChild( Actor& child, const Toolkit::TableView::CellPosition& position );
 
   /**
    * @copydoc Toolkit::TableView::GetChildAt
    */
-  Actor GetChildAt( Toolkit::TableView::CellPosition position );
+  Actor GetChildAt( const Toolkit::TableView::CellPosition& position );
 
   /**
    * @copydoc Toolkit::TableView::RemoveChildAt
    */
-  Actor RemoveChildAt( Toolkit::TableView::CellPosition position );
+  Actor RemoveChildAt( const Toolkit::TableView::CellPosition& position );
 
   /**
    * @copydoc Toolkit::TableView::FindChildPosition
    */
-  bool FindChildPosition( Actor child, Toolkit::TableView::CellPosition& position );
+  bool FindChildPosition( const Actor& child, Toolkit::TableView::CellPosition& positionOut );
 
   /**
    * @copydoc Toolkit::TableView::InsertRow
@@ -127,24 +127,36 @@ public:
   Size GetCellPadding();
 
   /**
-   * @copydoc Toolkit::TableView::SetFixedHeight
+   * @brief Set a row policy
+   *
+   * @param[in] rowIndex The row to set the policy for
+   * @param[in] policy The policy to set
    */
-  void SetFixedHeight( unsigned int rowIndex, float height );
+  void SetRowPolicy( unsigned int rowIndex, CellSizePolicy policy );
 
   /**
-   * @copydoc Toolkit::TableView::GetFixedHeight
+   * @brief Querry a row policy
+   *
+   * @param[in] rowIndex The row to querry
+   * @return Return the policy
    */
-  float GetFixedHeight( unsigned int rowIndex ) const;
+  CellSizePolicy GetRowPolicy( unsigned int rowIndex ) const;
 
   /**
-   * @copydoc Toolkit::TableView::SetRelativeHeight
+   * @brief Set a column policy
+   *
+   * @param[in] columnIndex The column to set the policy for
+   * @param[in] policy The policy to set
    */
-  void SetRelativeHeight( unsigned int rowIndex, float heightPercentage );
+  void SetColumnPolicy( unsigned int columnIndex, CellSizePolicy policy );
 
   /**
-   * @copydoc Toolkit::TableView::GetRelativeHeight
+   * @brief Querry a column policy
+   *
+   * @param[in] columnIndex The column to querry
+   * @return Return the policy
    */
-  float GetRelativeHeight( unsigned int rowIndex ) const;
+  CellSizePolicy GetColumnPolicy( unsigned int columnIndex ) const;
 
   /**
    * @copydoc Toolkit::TableView::SetFixedWidth
@@ -157,6 +169,26 @@ public:
   float GetFixedWidth( unsigned int columnIndex ) const;
 
   /**
+   * @copydoc Toolkit::TableView::SetFixedHeight
+   */
+  void SetFixedHeight( unsigned int rowIndex, float height );
+
+  /**
+   * @copydoc Toolkit::TableView::GetFixedHeight
+   */
+  float GetFixedHeight( unsigned int rowIndex ) const;
+
+  /**
+   * @copydoc Toolkit::TableView::SetRelativeHeight
+   */
+  void SetRelativeHeight( unsigned int rowIndex, float heightPercentage );
+
+  /**
+   * @copydoc Toolkit::TableView::GetRelativeHeight
+   */
+  float GetRelativeHeight( unsigned int rowIndex ) const;
+
+  /**
    * @copydoc Toolkit::TableView::SetRelativeWidth
    */
   void SetRelativeWidth( unsigned int columnIndex, float widthPercentage );
@@ -176,6 +208,11 @@ public:
    */
   unsigned int GetColumns();
 
+  /**
+   * @copydoc Toolkit::TableView::SetCellAlignment
+   */
+  void SetCellAlignment( Toolkit::TableView::CellPosition position, HorizontalAlignment::Type horizontal, VerticalAlignment::Type vertical );
+
   // Properties
 
   /**
@@ -199,17 +236,22 @@ private: // From Control
   /**
    * @copydoc Control::OnControlChildAdd(Actor& child)
    */
-  virtual void OnControlChildAdd(Actor& child);
+  virtual void OnControlChildAdd( Actor& child );
 
   /**
    * @copydoc Control::OnControlChildRemove(Actor& child)
    */
-  virtual void OnControlChildRemove(Actor& child);
+  virtual void OnControlChildRemove( Actor& child );
 
   /**
    * @copydoc Control::OnRelayout
    */
-  virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
+  virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
+
+  /**
+   * @copydoc Control::CalculateChildSize
+   */
+  virtual float CalculateChildSize( const Actor& child, Dimension dimension );
 
   /**
    * @copydoc Control::OnInitialize()
@@ -219,11 +261,94 @@ private: // From Control
   /**
    * @copydoc Control::GetNextKeyboardFocusableActor
    */
-  virtual Actor GetNextKeyboardFocusableActor(Actor currentFocusedActor, Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled);
+  virtual Actor GetNextKeyboardFocusableActor( Actor currentFocusedActor, Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled );
+
+  /**
+   * @copydoc Control::GetNaturalSize()
+   */
+  virtual Vector3 GetNaturalSize();
+
+  /**
+   * @copydoc Control::RelayoutDependentOnChildren()
+   */
+  virtual bool RelayoutDependentOnChildren( Dimension dimension = ALL_DIMENSIONS );
+
+  /**
+   * @copydoc Control::OnCalculateRelayoutSize
+   */
+  virtual void OnCalculateRelayoutSize( Dimension dimension );
+
+  /**
+   * @copydoc Control::OnLayoutNegotiated
+   */
+  virtual void OnLayoutNegotiated( float size, Dimension dimension );
 
 private: // Implementation
 
   /**
+   * Struct to hold data for rows and columns
+   *
+   * If sizePolicy is FIXED then size is the absolute size to use.
+   * If sizePolicy is FIT or FILL then size is the calculated value of size.
+   */
+  struct RowColumnData
+  {
+    /**
+     * Default constructor
+     */
+    RowColumnData()
+    : size( 0.0f ),
+      fillRatio( 0.0f ),
+      sizePolicy( FILL ),
+      userFillRatio( false )
+    {
+    }
+
+    /**
+     * Constructor
+     *
+     * @param[in] newSize The size to set for this data
+     * @param[in] newSizePolicy The policy used to interpret the size value
+     */
+    RowColumnData( float newSize, float newFillRatio, CellSizePolicy newSizePolicy, bool newUserFillRatio )
+    : size( newSize ),
+      fillRatio( newFillRatio ),
+      sizePolicy( newSizePolicy ),
+      userFillRatio( newUserFillRatio )
+    {
+    }
+
+    float size;                       ///< Set or calculated size
+    float fillRatio;                  ///< Ratio to fill remaining space
+    CellSizePolicy sizePolicy;        ///< The size policy used to interpret the size value
+    bool userFillRatio : 1;           ///< FillRatio was set by user
+  };
+
+  typedef Dali::Vector<RowColumnData> RowColumnArray;
+
+public:
+
+  /**
+   * Structure for the layout data
+   */
+  struct CellData
+  {
+    CellData()
+    : horizontalAlignment( HorizontalAlignment::LEFT ),
+      verticalAlignment( VerticalAlignment::TOP )
+    {
+    }
+
+    // data members
+    Dali::Actor actor;
+    Toolkit::TableView::CellPosition position;
+    HorizontalAlignment::Type horizontalAlignment;
+    VerticalAlignment::Type verticalAlignment;
+  };
+
+private:
+
+  /**
    * Construct a new TableView.
    */
   TableView( unsigned int initialRows, unsigned int initialColumns );
@@ -259,14 +384,50 @@ private: // Implementation
    * @param child actor to remove
    * @return true if the actor was found
    */
-  bool RemoveAllInstances( Actor child );
+  bool RemoveAllInstances( const Actor& child );
+
+  /**
+   * @brief Compute relative sizes for an array
+   *
+   * @param[in] data The RowColumn data to compute the relative sizes for
+   */
+  void ComputeRelativeSizes( RowColumnArray& data );
+
+  /**
+   * @brief Calculate the total fixed sizes for a row or column
+   *
+   * @param[in] data The row or column data to process
+   */
+  float CalculateTotalFixedSize( const RowColumnArray& data );
+
+  /**
+   * @brief Calculate the fixed sizes for a row or column
+   *
+   * @param[in] data The row or column data to process
+   * @param[in] dimension The dimension being calculated: row == HEIGHT, column == WIDTH
+   */
+  void CalculateFixedSizes( RowColumnArray& data, Dimension dimension );
+
+  /**
+   * @brief Calculate the value of the relative sizes
+   *
+   * @param[in] data The row or column data to process
+   * @param[in] size The size of the table view in that dimension
+   */
+  void CalculateRelativeSizes( RowColumnArray& data, float size );
+
+  /**
+   * @brief Search for a FIT cell in the array
+   *
+   * @param[in] data The row or column data to process
+   * @return Return if a FIT cell was found or not
+   */
+  bool FindFit( const RowColumnArray& data );
 
   /**
-   * Helper to update relative sizes
-   * @param fixedHeightsTotal sum of the fixed height rows
-   * @param fixedWidthsTotal sum of the fixed width columns
+   * @brief Calculate row and column data when it is dirty
    */
-  void UpdateRelativeSizes( float& fixedHeightsTotal, float& fixedWidthsTotal );
+  void CalculateRowColumnData();
 
   /**
    * A reference counted object may only be deleted by calling Unreference()
@@ -301,11 +462,10 @@ private: // scripting support
 
   /**
    * Generate the map type property value from the size vectors.
-   * @param[in] fixedSize The vector of fixed heights or widths.
-   * @param[in] relativeSize The vector of relative heights or widths.
+   * @param[in] data The array of row or column data
    * @param[out] map The property value.
    */
-  void GetMapPropertyValue( const std::vector<float>& fixedSize, const std::vector<float>& relativeSize, Property::Map& map );
+  void GetMapPropertyValue( const RowColumnArray& data, Property::Map& map );
 
 
   /**
@@ -350,15 +510,15 @@ private:
 
 private: // Data
 
-  Array2d<CellData> mCellData;
-  Array2d<Size> mRelativeSizes;
-  std::vector<float> mFixedHeights;
-  std::vector<float> mRelativeHeights;
-  std::vector<float> mFixedWidths;
-  std::vector<float> mRelativeWidths;
-  Size mPadding;
-  bool mLayoutingChild;
+  Array2d<CellData> mCellData;                ///< Data for each cell: Actor, alignment settings etc
+
+  RowColumnArray mRowData;       ///< Data for each row
+  RowColumnArray mColumnData;    ///< Data for each column
+  Size mFixedTotals;             ///< Accumulated totals for fixed width and height
 
+  Size mPadding;                 ///< Padding to apply to each cell
+  bool mLayoutingChild;          ///< Can't be a bitfield due to Relayouting lock
+  bool mRowColumnDirty : 1;       ///< Flag to indicate the row column data is dirty
 };
 
 } // namespace Internal
index 390cb89..38d2732 100644 (file)
@@ -439,7 +439,7 @@ float TextField::GetHeightForWidth( float width )
   return mController->GetHeightForWidth( width );
 }
 
-void TextField::OnRelayout( const Vector2& size, ActorSizeContainer& container )
+void TextField::OnRelayout( const Vector2& size, RelayoutContainer& container )
 {
   if( mController->Relayout( size ) ||
       !mRenderer )
index a4f4831..5428275 100644 (file)
@@ -96,7 +96,7 @@ private: // From Control
   /**
    * @copydoc Control::OnInitialize()
    */
-  virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
+  virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
 
   /**
    * @copydoc Control::OnKeyInputFocusGained()
index 69bb5dc..4ff2035 100644 (file)
@@ -328,7 +328,13 @@ Property::Value TextLabel::GetProperty( BaseObject* object, Property::Index inde
 
 void TextLabel::OnInitialize()
 {
+  Actor self = Self();
+
   mController = Text::Controller::New( *this );
+
+  // Use height-for-width negotiation by default
+  self.SetResizePolicy( FILL_TO_PARENT, WIDTH );
+  self.SetDimensionDependency( HEIGHT, WIDTH );
 }
 
 void TextLabel::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change )
@@ -346,7 +352,7 @@ float TextLabel::GetHeightForWidth( float width )
   return mController->GetHeightForWidth( width );
 }
 
-void TextLabel::OnRelayout( const Vector2& size, ActorSizeContainer& container )
+void TextLabel::OnRelayout( const Vector2& size, RelayoutContainer& container )
 {
   if( mController->Relayout( size ) ||
       !mRenderer )
index 6356651..c69bd7c 100644 (file)
@@ -80,7 +80,7 @@ private: // From Control
   /**
    * @copydoc Control::OnRelayout()
    */
-  virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
+  virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
 
   /**
    * @copydoc Control::GetNaturalSize()
index e117e22..133fa09 100644 (file)
@@ -260,7 +260,7 @@ void TextSelectionPopup::OnInitialize()
   CreatePopup();
 }
 
-void TextSelectionPopup::OnRelayout( const Vector2& size, ActorSizeContainer& container )
+void TextSelectionPopup::OnRelayout( const Vector2& size, RelayoutContainer& container )
 {
 
 }
@@ -429,8 +429,8 @@ Dali::Image TextSelectionPopup::GetPopupImage( PopupParts part )
      mNinePatchMargins.w = ninePatchImageSize.height - ( childRect.y + childRect.height ) - 1u;
    }
 
-   SetBackground ( mBackgroundImage );
-   SetBackgroundColor ( mBackgroundColor );
+   SetBackgroundImage( mBackgroundImage );
+   SetBackgroundColor( mBackgroundColor );
  }
 
  void TextSelectionPopup::AddOption( Actor& parent, const std::string& name, const std::string& caption, const Image iconImage, bool finalOption, bool showIcons )
@@ -515,7 +515,7 @@ Dali::Image TextSelectionPopup::GetPopupImage( PopupParts part )
 
    // 5. Create a option.
    Toolkit::PushButton option = Toolkit::PushButton::New();
-   option.SetSizePolicy( Toolkit::Control::Fixed, Toolkit::Control::Fixed );
+   //option.SetSizePolicy( Toolkit::Control::Fixed, Toolkit::Control::Fixed ); FIXME
    option.SetSize( optionSize );
    option.SetAnchorPoint( AnchorPoint::TOP_LEFT );
    option.SetX( mContentSize.width );
index 2650c57..ffca9dd 100644 (file)
@@ -159,7 +159,7 @@ private: // From Control
   /**
    * @copydoc Control::OnInitialize()
    */
-  virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
+  virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
 //
 //  /**
 //   * Received for single & double taps
index e0dbd86..73654a4 100644 (file)
@@ -74,7 +74,7 @@ void ToolBar::SetBackground( Actor background )
   // ToolBar image
   background.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER );
   background.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER );
-  background.SetSize( mToolBarSize );
+  background.SetPreferredSize( Vector2( mToolBarSize.width, mToolBarSize.height ) );
 
   RenderableActor renderableActor = RenderableActor::DownCast( background );
   if ( renderableActor )
@@ -125,8 +125,9 @@ void ToolBar::AddControl( Actor control, float relativeSize, Toolkit::Alignment:
 
   // Create an alignment container where to place the control.
   Toolkit::Alignment alignmentContainer = Toolkit::Alignment::New( alignment );
-  alignmentContainer.SetScaling( Toolkit::Alignment::ScaleToFill );
+  alignmentContainer.SetSizeScalePolicy( FIT_WITH_ASPECT_RATIO );
   alignmentContainer.SetPadding( padding );
+  alignmentContainer.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
   alignmentContainer.Add( control );
 
   // Insert the control in the table view.
@@ -320,6 +321,8 @@ void ToolBar::OnInitialize()
 
   // Layout
   mLayout = Toolkit::TableView::New( 1, 1 );
+  mLayout.SetName( "TOOLBAR_LAYOUT" );
+  mLayout.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
   mLayout.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
 
   Self().Add( mLayout );
@@ -356,7 +359,7 @@ void ToolBar::OnControlChildAdd(Actor& child)
 void ToolBar::OnControlSizeSet( const Vector3& targetSize )
 {
   mToolBarSize = targetSize;
-  mBackground.SetSize( mToolBarSize );
+  mBackground.SetPreferredSize( Vector2( mToolBarSize.width, mToolBarSize.height ) );
 }
 
 } // namespace Internal
index 9a486ed..a1d0c09 100644 (file)
@@ -132,7 +132,7 @@ void View::SetBackground( ImageActor backgroundImage )
     mBackgroundLayer = Layer::New();
 
     mBackgroundLayer.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
-    mBackgroundLayer.SetSize( mViewSize );
+    mBackgroundLayer.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
 
     // Add background layer to custom actor.
     Self().Add( mBackgroundLayer );
@@ -152,8 +152,10 @@ void View::SetBackground( ImageActor backgroundImage )
   }
 
   backgroundImage.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
-  backgroundImage.SetScale( FillXYKeepAspectRatio( mViewSize, backgroundImage.GetSize() ) );
+  backgroundImage.SetRelayoutEnabled( false );    // We will scale its size manually
   mBackgroundLayer.Add( backgroundImage );
+
+  RelayoutRequest();
 }
 
 void View::SetOrientationFunction( Degree portrait, Degree landscale, Degree portraitInverse, Degree landscapeInverse )
@@ -290,16 +292,14 @@ void View::OnInitialize()
   }
 }
 
-void View::OnControlSizeSet( const Vector3& targetSize )
+void View::OnRelayout( const Vector2& size, RelayoutContainer& container )
 {
-  mViewSize = targetSize;
   if( mBackgroundLayer )
   {
-    mBackgroundLayer.SetSize( mViewSize );
-    if( mBackgroundLayer.GetChildCount() > 0 )
+    if( mBackgroundLayer && mBackgroundLayer.GetChildCount() > 0 )
     {
       Actor background = mBackgroundLayer.GetChildAt(0);
-      background.SetScale( FillXYKeepAspectRatio( mViewSize, background.GetSize() ) );
+      background.SetScale( FillXYKeepAspectRatio( Vector3( size.width, size.height, 1.0f ), background.GetTargetSize() ) );
     }
   }
 }
index 5352afe..9aacc9e 100644 (file)
@@ -138,10 +138,9 @@ private: // From Control
   virtual void OnInitialize();
 
   /**
-   *
-   * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& targetSize )
+   * @copydoc Toolkit::Control::OnRelayout()
    */
-  virtual void OnControlSizeSet( const Vector3& targetSize );
+  virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
 
 private:
 
@@ -180,7 +179,6 @@ private:
   Animation      mRotateAnimation;        ///< The animation which rotates the view (and all layers added to it)
   float          mOrientationFunction[4]; ///< The orientation function used to transform from degrees to the internal orientation.
   bool           mAutoRotateEnabled;      ///< Whether the view rotates if the OrientationChanged method is called.
-  Vector3        mViewSize;               ///< The Control Size
 
   Toolkit::View::OrientationAnimationStartedSignalType mOrientationAnimationStartedSignal;
 };
index d8b57e0..838592c 100644 (file)
@@ -35,9 +35,6 @@ toolkit_src_files = \
    $(toolkit_src_dir)/controls/page-turn-view/page-turn-portrait-view-impl.cpp \
    $(toolkit_src_dir)/controls/page-turn-view/page-turn-landscape-view-impl.cpp \
    $(toolkit_src_dir)/controls/page-turn-view/page-turn-view-impl.cpp \
-   $(toolkit_src_dir)/controls/relayout-controller-impl.cpp \
-   $(toolkit_src_dir)/controls/relayout-controller.cpp \
-   $(toolkit_src_dir)/controls/relayout-helper.cpp \
    $(toolkit_src_dir)/controls/scroll-bar/scroll-bar-impl.cpp \
    $(toolkit_src_dir)/controls/scroll-component/scroll-bar-internal-impl.cpp \
    $(toolkit_src_dir)/controls/scroll-component/scroll-bar-internal.cpp \
index 0b48ecb..5a3a611 100644 (file)
@@ -674,7 +674,7 @@ void FocusManager::CreateDefaultFocusIndicatorActor()
   focusIndicator.SetPosition(Vector3(0.0f, 0.0f, 1.0f));
 
   // Apply size constraint to the focus indicator
-  focusIndicator.SetSizeMode( SIZE_EQUAL_TO_PARENT );
+  focusIndicator.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
 
   SetFocusIndicatorActor(focusIndicator);
 }
index 014e215..038f99c 100644 (file)
@@ -477,7 +477,7 @@ void KeyboardFocusManager::CreateDefaultFocusIndicatorActor()
   focusIndicator.SetPosition(Vector3(0.0f, 0.0f, 1.0f));
 
   // Apply size constraint to the focus indicator
-  focusIndicator.SetSizeMode( SIZE_EQUAL_TO_PARENT );
+  focusIndicator.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
 
   SetFocusIndicatorActor(focusIndicator);
 }
index 92b475c..88f22e5 100644 (file)
@@ -339,7 +339,7 @@ struct Decorator::Impl : public ConnectionTracker
 
       mActiveLayer.SetAnchorPoint( AnchorPoint::CENTER);
       mActiveLayer.SetParentOrigin( ParentOrigin::CENTER);
-      mActiveLayer.SetSizeMode( SIZE_EQUAL_TO_PARENT );
+      //mActiveLayer.SetSizeMode( SIZE_EQUAL_TO_PARENT ); FIXME
       mActiveLayer.SetPositionInheritanceMode( USE_PARENT_POSITION );
 
       parent.Add( mActiveLayer );
index 14645f6..2872ffa 100644 (file)
@@ -119,6 +119,7 @@ void CubeTransitionEffect::Initialize()
   mEmptyImage.SetSize(Stage::GetCurrent().GetSize());
   mEmptyImage.SetParentOrigin( ParentOrigin::CENTER );
   mEmptyImage.SetAnchorPoint( AnchorPoint::CENTER );
+  mEmptyImage.SetRelayoutEnabled( false );
   mFullImageCreator = FullAreaImageCreator::New();
   mEmptyImage.SetShaderEffect( mFullImageCreator );
   Stage::GetCurrent().Add(mEmptyImage);
@@ -141,6 +142,7 @@ ImageActor CubeTransitionEffect::CreateTile( Image image, const Vector4& color )
   ImageActor tile = ImageActor::New( image );
   tile.SetParentOrigin( ParentOrigin::CENTER );
   tile.SetAnchorPoint( AnchorPoint::CENTER );
+  tile.SetRelayoutEnabled( false );
   tile.SetSize( mTileSize );
   tile.SetColorMode( Dali::USE_OWN_COLOR );
   tile.SetColor( color );
index d88afec..b495d1f 100644 (file)
 #include <dali/public-api/object/type-registry.h>
 #include <dali/public-api/object/type-registry-helper.h>
 #include <dali/public-api/scripting/scripting.h>
+#include <dali/public-api/size-negotiation/relayout-container.h>
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
-#include <dali-toolkit/internal/controls/relayout-controller.h>
-#include <dali-toolkit/internal/controls/relayout-helper.h>
 #include <dali-toolkit/public-api/focus-manager/keyinput-focus-manager.h>
 #include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
 #include <dali-toolkit/public-api/controls/control.h>
@@ -49,16 +48,6 @@ namespace Toolkit
 namespace
 {
 
-const Scripting::StringEnum< Control::SizePolicy > SIZE_POLICY_STRING_TABLE[] =
-{
-  { "FIXED",      Control::Fixed      },
-  { "MINIMUM",    Control::Minimum    },
-  { "MAXIMUM",    Control::Maximum    },
-  { "RANGE",      Control::Range      },
-  { "FLEXIBLE",   Control::Flexible   },
-};
-const unsigned int SIZE_POLICY_STRING_TABLE_COUNT = sizeof( SIZE_POLICY_STRING_TABLE ) / sizeof( SIZE_POLICY_STRING_TABLE[0] );
-
 #if defined(DEBUG_ENABLED)
 Integration::Log::Filter* gLogFilter  = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_CONTROL");
 #endif
@@ -106,70 +95,6 @@ struct Background
 };
 
 /**
- * Helper function to calculate a dimension given the policy of that dimension; the minimum &
- * maximum values that dimension can be; and the allocated value for that dimension.
- *
- * @param[in]  policy     The size policy for that dimension.
- * @param[in]  minimum    The minimum value that dimension can be.
- * @param[in]  maximum    The maximum value that dimension can be.
- * @param[in]  allocated  The value allocated for that dimension.
- *
- * @return The value that the dimension should be.
- *
- * @note This does not handle Control::Fixed policy.
- */
-float Calculate( Control::SizePolicy policy, float minimum, float maximum, float allocated )
-{
-  float size( allocated );
-
-  switch( policy )
-  {
-    case Control::Fixed:
-    {
-      // Use allocated value
-      break;
-    }
-
-    case Control::Minimum:
-    {
-      // Size is always at least the minimum.
-      size = std::max( allocated, minimum );
-      break;
-    }
-
-    case Control::Maximum:
-    {
-      // Size can grow but up to a maximum value.
-      size = std::min( allocated, maximum );
-      break;
-    }
-
-    case Control::Range:
-    {
-      // Size is at least the minimum and can grow up to the maximum
-      size = std::max( size, minimum );
-      size = std::min( size, maximum );
-     break;
-    }
-
-    case Control::Flexible:
-    {
-      // Size grows or shrinks with no limits.
-      size = allocated;
-      break;
-    }
-
-    default:
-    {
-      DALI_ASSERT_DEBUG( false && "This function was not intended to be used by any other policy." );
-      break;
-    }
-  }
-
-  return size;
-}
-
-/**
  * Creates a white coloured Mesh.
  */
 Mesh CreateMesh()
@@ -213,11 +138,8 @@ void SetupBackgroundActor( Actor actor, Property::Index constrainingIndex, const
   actor.SetPositionInheritanceMode( USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
   actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
   actor.SetZ( BACKGROUND_ACTOR_Z_POSITION );
-
-  Constraint constraint = Constraint::New<Vector3>( constrainingIndex,
-                                                    ParentSource( Actor::Property::SIZE ),
-                                                    EqualToConstraint() );
-  actor.ApplyConstraint( constraint );
+  actor.SetRelayoutEnabled( true );
+  actor.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
 }
 
 } // unnamed namespace
@@ -252,10 +174,7 @@ public:
     mLongPressGestureDetector(),
     mCurrentSize(),
     mNaturalSize(),
-    mWidthPolicy( Toolkit::Control::Fixed ),
-    mHeightPolicy( Toolkit::Control::Fixed ),
     mFlags( Control::CONTROL_BEHAVIOUR_NONE ),
-    mInsideRelayout( false ),
     mIsKeyboardNavigationSupported( false ),
     mIsKeyboardFocusGroup( false ),
     mInitialized( false )
@@ -336,7 +255,7 @@ public:
           break;
         }
 
-        case Toolkit::Control::Property::BACKGROUND:
+        case Toolkit::Control::Property::BACKGROUND_IMAGE:
         {
           if ( value.HasKey( "image" ) )
           {
@@ -345,7 +264,7 @@ public:
 
             if ( image )
             {
-              controlImpl.SetBackground( image );
+              controlImpl.SetBackgroundImage( image );
             }
           }
           else if ( value.Get< Property::Map >().Empty() )
@@ -356,30 +275,6 @@ public:
           break;
         }
 
-        case Toolkit::Control::Property::WIDTH_POLICY:
-        {
-          controlImpl.mImpl->mWidthPolicy = Scripting::GetEnumeration< Toolkit::Control::SizePolicy >( value.Get< std::string >().c_str(), SIZE_POLICY_STRING_TABLE, SIZE_POLICY_STRING_TABLE_COUNT );
-          break;
-        }
-
-        case Toolkit::Control::Property::HEIGHT_POLICY:
-        {
-          controlImpl.mImpl->mHeightPolicy = Scripting::GetEnumeration< Toolkit::Control::SizePolicy >( value.Get< std::string >().c_str(), SIZE_POLICY_STRING_TABLE, SIZE_POLICY_STRING_TABLE_COUNT );
-          break;
-        }
-
-        case Toolkit::Control::Property::MINIMUM_SIZE:
-        {
-          controlImpl.SetMinimumSize( value.Get< Vector3 >() );
-          break;
-        }
-
-        case Toolkit::Control::Property::MAXIMUM_SIZE:
-        {
-          controlImpl.SetMaximumSize( value.Get< Vector3 >() );
-          break;
-        }
-
         case Toolkit::Control::Property::KEY_INPUT_FOCUS:
         {
           if ( value.Get< bool >() )
@@ -426,7 +321,7 @@ public:
           break;
         }
 
-        case Toolkit::Control::Property::BACKGROUND:
+        case Toolkit::Control::Property::BACKGROUND_IMAGE:
         {
           Property::Map map;
 
@@ -447,30 +342,6 @@ public:
           break;
         }
 
-        case Toolkit::Control::Property::WIDTH_POLICY:
-        {
-          value = std::string( Scripting::GetEnumerationName< Toolkit::Control::SizePolicy >( controlImpl.mImpl->mWidthPolicy, SIZE_POLICY_STRING_TABLE, SIZE_POLICY_STRING_TABLE_COUNT ) );
-          break;
-        }
-
-        case Toolkit::Control::Property::HEIGHT_POLICY:
-        {
-          value = std::string( Scripting::GetEnumerationName< Toolkit::Control::SizePolicy >( controlImpl.mImpl->mHeightPolicy, SIZE_POLICY_STRING_TABLE, SIZE_POLICY_STRING_TABLE_COUNT ) );
-          break;
-        }
-
-        case Toolkit::Control::Property::MINIMUM_SIZE:
-        {
-          value = controlImpl.mImpl->GetMinimumSize();
-          break;
-        }
-
-        case Toolkit::Control::Property::MAXIMUM_SIZE:
-        {
-          value = controlImpl.mImpl->GetMaximumSize();
-          break;
-        }
-
         case Toolkit::Control::Property::KEY_INPUT_FOCUS:
         {
           value = controlImpl.HasKeyInputFocus();
@@ -482,79 +353,6 @@ public:
     return value;
   }
 
-  /**
-   * Helper to get minimum size
-   * @return minimum size
-   */
-  inline const Vector3& GetMinimumSize()
-  {
-    if( mMinMaxSize.Count() > MIN_SIZE_INDEX )
-    {
-      return mMinMaxSize[ MIN_SIZE_INDEX ];
-    }
-    else
-    {
-      // its not been allocated so its ZERO
-      return Vector3::ZERO;
-    }
-  }
-  /**
-   * Helper to Set minimum size
-   * @param size to set
-   */
-  inline void SetMinimumSize( const Vector3& size )
-  {
-    if( mMinMaxSize.Count() > MIN_SIZE_INDEX )
-    {
-      mMinMaxSize[ MIN_SIZE_INDEX ] = size;
-    }
-    else
-    {
-      // its not been allocated so push the new value there
-      mMinMaxSize.PushBack( size );
-    }
-  }
-
-  /**
-   * Helper to get maximum size
-   * @return maximum size
-   */
-  inline const Vector3& GetMaximumSize()
-  {
-    if( mMinMaxSize.Count() > MAX_SIZE_INDEX )
-    {
-      return mMinMaxSize[ MAX_SIZE_INDEX ];
-    }
-    else
-    {
-      // its not been allocated so its MAX_SIZE
-      return MAX_SIZE;
-    }
-  }
-
-  /**
-   * Helper to Set minimum size
-   * @param size to set
-   */
-  inline void SetMaximumSize( const Vector3& size )
-  {
-    if( mMinMaxSize.Count() > MAX_SIZE_INDEX )
-    {
-      mMinMaxSize[ MAX_SIZE_INDEX ] = size;
-    }
-    else if( mMinMaxSize.Count() > MIN_SIZE_INDEX )
-    {
-      // max has not been allocated, but min has
-      mMinMaxSize.PushBack( size );
-    }
-    else
-    {
-      // min and max both unallocated so allocate both
-      mMinMaxSize.Resize( 2u ); // this will reserve and default construct two Vector3s
-      mMinMaxSize[ MAX_SIZE_INDEX ] = size;
-    }
-  }
-
   // Data
 
   Control& mControlImpl;
@@ -571,36 +369,24 @@ public:
   // @todo change all these to Vector2 when we have a chance to sanitize the public API as well
   Vector3 mCurrentSize; ///< Stores the current control's size, this is the negotiated size
   Vector3 mNaturalSize; ///< Stores the size set through the Actor's API. This is size the actor wants to be. Useful when reset to the initial size is needed.
-  Dali::Vector< Vector3 > mMinMaxSize; ///< Stores the minimum and maximum size if they are set
 
-  Toolkit::Control::SizePolicy mWidthPolicy :3;  ///< Stores the width policy. 3 bits covers 8 values
-  Toolkit::Control::SizePolicy mHeightPolicy :3; ///< Stores the height policy. 3 bits covers 8 values
-  ControlBehaviour mFlags :6;             ///< Flags passed in from constructor. Need to increase this size when new enums are added
-  bool mInsideRelayout:1;                 ///< Detect when were in Relayout
-  bool mIsKeyboardNavigationSupported:1;  ///< Stores whether keyboard navigation is supported by the control.
-  bool mIsKeyboardFocusGroup:1;           ///< Stores whether the control is a focus group.
-  bool mInitialized:1;
+  ControlBehaviour mFlags :6;              ///< Flags passed in from constructor. Need to increase this size when new enums are added
+  bool mIsKeyboardNavigationSupported :1;  ///< Stores whether keyboard navigation is supported by the control.
+  bool mIsKeyboardFocusGroup :1;           ///< Stores whether the control is a focus group.
+  bool mInitialized :1;
 
   // Properties - these need to be members of Internal::Control::Impl as they need to function within this class.
   static PropertyRegistration PROPERTY_1;
   static PropertyRegistration PROPERTY_2;
   static PropertyRegistration PROPERTY_3;
   static PropertyRegistration PROPERTY_4;
-  static PropertyRegistration PROPERTY_5;
-  static PropertyRegistration PROPERTY_6;
-  static PropertyRegistration PROPERTY_7;
-  static PropertyRegistration PROPERTY_8;
 };
 
 // Properties registered without macro to use specific member variables.
 PropertyRegistration Control::Impl::PROPERTY_1( typeRegistration, "style-name",       Toolkit::Control::Property::STYLE_NAME,       Property::STRING,  &Control::Impl::SetProperty, &Control::Impl::GetProperty );
 PropertyRegistration Control::Impl::PROPERTY_2( typeRegistration, "background-color", Toolkit::Control::Property::BACKGROUND_COLOR, Property::VECTOR4, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
-PropertyRegistration Control::Impl::PROPERTY_3( typeRegistration, "background",       Toolkit::Control::Property::BACKGROUND,       Property::MAP,     &Control::Impl::SetProperty, &Control::Impl::GetProperty );
-PropertyRegistration Control::Impl::PROPERTY_4( typeRegistration, "width-policy",     Toolkit::Control::Property::WIDTH_POLICY,     Property::STRING,  &Control::Impl::SetProperty, &Control::Impl::GetProperty );
-PropertyRegistration Control::Impl::PROPERTY_5( typeRegistration, "height-policy",    Toolkit::Control::Property::HEIGHT_POLICY,    Property::STRING,  &Control::Impl::SetProperty, &Control::Impl::GetProperty );
-PropertyRegistration Control::Impl::PROPERTY_6( typeRegistration, "minimum-size",     Toolkit::Control::Property::MINIMUM_SIZE,     Property::VECTOR3, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
-PropertyRegistration Control::Impl::PROPERTY_7( typeRegistration, "maximum-size",     Toolkit::Control::Property::MAXIMUM_SIZE,     Property::VECTOR3, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
-PropertyRegistration Control::Impl::PROPERTY_8( typeRegistration, "key-input-focus",  Toolkit::Control::Property::KEY_INPUT_FOCUS,  Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
+PropertyRegistration Control::Impl::PROPERTY_3( typeRegistration, "background-image", Toolkit::Control::Property::BACKGROUND_IMAGE, Property::MAP,     &Control::Impl::SetProperty, &Control::Impl::GetProperty );
+PropertyRegistration Control::Impl::PROPERTY_4( typeRegistration, "key-input-focus",  Toolkit::Control::Property::KEY_INPUT_FOCUS,  Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
 
 Toolkit::Control Control::New()
 {
@@ -622,79 +408,21 @@ Control::~Control()
   delete mImpl;
 }
 
-void Control::SetSizePolicy( Toolkit::Control::SizePolicy widthPolicy, Toolkit::Control::SizePolicy heightPolicy )
-{
-  bool relayoutRequest( false );
-
-  if ( ( mImpl->mWidthPolicy != widthPolicy ) || ( mImpl->mHeightPolicy != heightPolicy ) )
-  {
-    relayoutRequest = true;
-  }
-
-  mImpl->mWidthPolicy = widthPolicy;
-  mImpl->mHeightPolicy = heightPolicy;
-
-  // Ensure RelayoutRequest is called AFTER new policies have been set.
-  if ( relayoutRequest )
-  {
-    RelayoutRequest();
-  }
-}
-
-void Control::GetSizePolicy( Toolkit::Control::SizePolicy& widthPolicy, Toolkit::Control::SizePolicy& heightPolicy ) const
-{
-  widthPolicy = mImpl->mWidthPolicy;
-  heightPolicy = mImpl->mHeightPolicy;
-}
-
-void Control::SetMinimumSize( const Vector3& size )
-{
-  const Vector3& minSize = mImpl->GetMinimumSize();
-  if ( fabsf( minSize.width - size.width ) > Math::MACHINE_EPSILON_1000 ||
-       fabsf( minSize.height - size.height ) > Math::MACHINE_EPSILON_1000 )
-  {
-    mImpl->SetMinimumSize( size );
-
-    // Only relayout if our control is using the minimum or range policy.
-    if ( ( mImpl->mHeightPolicy == Toolkit::Control::Minimum ) || ( mImpl->mWidthPolicy  == Toolkit::Control::Minimum ) ||
-         ( mImpl->mHeightPolicy == Toolkit::Control::Range   ) || ( mImpl->mWidthPolicy  == Toolkit::Control::Range   ) )
-    {
-      RelayoutRequest();
-    }
-  }
-}
-
-const Vector3& Control::GetMinimumSize() const
+Vector3 Control::GetNaturalSize()
 {
-  return mImpl->GetMinimumSize();
+  // could be overridden in derived classes.
+  return mImpl->mNaturalSize;
 }
 
-void Control::SetMaximumSize( const Vector3& size )
+float Control::CalculateChildSize( const Dali::Actor& child, Dimension dimension )
 {
-  const Vector3& maxSize = mImpl->GetMaximumSize();
-  if ( fabsf( maxSize.width - size.width ) > Math::MACHINE_EPSILON_1000 ||
-       fabsf( maxSize.height - size.height ) > Math::MACHINE_EPSILON_1000 )
-  {
-    mImpl->SetMaximumSize( size );
-
-    // Only relayout if our control is using the maximum or range policy.
-    if ( ( mImpl->mHeightPolicy == Toolkit::Control::Maximum ) || ( mImpl->mWidthPolicy  == Toolkit::Control::Maximum ) ||
-         ( mImpl->mHeightPolicy == Toolkit::Control::Range   ) || ( mImpl->mWidthPolicy  == Toolkit::Control::Range   ) )
-    {
-      RelayoutRequest();
-    }
-  }
+  // Could be overridden in derived classes.
+  return CalculateChildSizeBase( child, dimension );
 }
 
-const Vector3& Control::GetMaximumSize() const
+bool Control::RelayoutDependentOnChildren( Dimension dimension )
 {
-  return mImpl->GetMaximumSize();
-}
-
-Vector3 Control::GetNaturalSize()
-{
-  // could be overridden in derived classes.
-  return mImpl->mNaturalSize;
+  return RelayoutDependentOnChildrenBase( dimension );
 }
 
 float Control::GetHeightForWidth( float width )
@@ -825,7 +553,7 @@ Vector4 Control::GetBackgroundColor() const
   return Color::TRANSPARENT;
 }
 
-void Control::SetBackground( Image image )
+void Control::SetBackgroundImage( Image image )
 {
   Background& background( mImpl->GetBackground() );
 
@@ -897,116 +625,6 @@ bool Control::OnAccessibilityValueChange(bool isIncrease)
   return false; // Accessibility value change action is not handled by default
 }
 
-void Control::NegotiateSize( const Vector2& allocatedSize, ActorSizeContainer& container )
-{
-  Vector2 size;
-
-  if ( mImpl->mWidthPolicy == Toolkit::Control::Fixed )
-  {
-    if ( mImpl->mHeightPolicy == Toolkit::Control::Fixed )
-    {
-      // If a control says it has a fixed size, then use the size set by the application / control.
-      Vector2 setSize( mImpl->mNaturalSize );
-      if ( setSize != Vector2::ZERO )
-      {
-        size = setSize;
-
-        // Policy is set to Fixed, so if the application / control has not set one of the dimensions,
-        // then we should use the natural size of the control rather than the full allocation.
-        if ( EqualsZero( size.width ) )
-        {
-          size.width = GetWidthForHeight( size.height );
-        }
-        else if ( EqualsZero( size.height ) )
-        {
-          size.height = GetHeightForWidth( size.width );
-        }
-      }
-      else
-      {
-        // If that is not set then set the size to the control's natural size
-        size = Vector2( GetNaturalSize() );
-      }
-    }
-    else
-    {
-      // Width is fixed so if the application / control has set it, then use that.
-      if ( !EqualsZero( mImpl->mNaturalSize.width ) )
-      {
-        size.width = mImpl->mNaturalSize.width;
-      }
-      else
-      {
-        // Otherwise, set the width to what has been allocated.
-        size.width = allocatedSize.width;
-      }
-
-      // Height is flexible so ask control what the height should be for our width.
-      size.height = GetHeightForWidth( size.width );
-
-      // Ensure height is within our policy rules
-      size.height = Calculate( mImpl->mHeightPolicy, GetMinimumSize().height, GetMaximumSize().height, size.height );
-    }
-  }
-  else
-  {
-    if ( mImpl->mHeightPolicy == Toolkit::Control::Fixed )
-    {
-      // Height is fixed so if the application / control has set it, then use that.
-      if ( !EqualsZero( mImpl->mNaturalSize.height ) )
-      {
-        size.height = mImpl->mNaturalSize.height;
-      }
-      else
-      {
-        // Otherwise, set the height to what has been allocated.
-        size.height = allocatedSize.height;
-      }
-
-      // Width is flexible so ask control what the width should be for our height.
-      size.width = GetWidthForHeight( size.height );
-
-      // Ensure width is within our policy rules
-      size.width = Calculate( mImpl->mWidthPolicy, mImpl->GetMinimumSize().width, mImpl->GetMaximumSize().width, size.width );
-    }
-    else
-    {
-      // Width and height are BOTH flexible.
-      // Calculate the width and height using the policy rules.
-      size.width = Calculate( mImpl->mWidthPolicy, mImpl->GetMinimumSize().width, mImpl->GetMaximumSize().width, allocatedSize.width );
-      size.height = Calculate( mImpl->mHeightPolicy, mImpl->GetMinimumSize().height, mImpl->GetMaximumSize().height, allocatedSize.height );
-    }
-  }
-
-  // If the width has not been set, then set to the allocated width.
-  // Also if the width set is greater than the allocated, then set to allocated (no exceed support).
-  if ( EqualsZero( size.width ) || ( size.width > allocatedSize.width ) )
-  {
-    size.width = allocatedSize.width;
-  }
-
-  // If the height has not been set, then set to the allocated height.
-  // Also if the height set is greater than the allocated, then set to allocated (no exceed support).
-  if ( EqualsZero( size.height ) || ( size.height > allocatedSize.height ) )
-  {
-    size.height = allocatedSize.height;
-  }
-
-  DALI_LOG_INFO( gLogFilter, Debug::Verbose,
-                 "%p: Natural: [%.2f, %.2f] Allocated: [%.2f, %.2f] Set: [%.2f, %.2f]\n",
-                 Self().GetObjectPtr(),
-                 GetNaturalSize().x, GetNaturalSize().y,
-                 allocatedSize.x, allocatedSize.y,
-                 size.x, size.y );
-
-  // Avoids relayout again when OnSizeSet callback arrives as a function of us or deriving class calling SetSize()
-  mImpl->mInsideRelayout = true;
-  Self().SetSize( size );
-  // Only relayout controls which requested to be relaid out.
-  OnRelayout( size, container );
-  mImpl->mInsideRelayout = false;
-}
-
 void Control::SetAsKeyboardFocusGroup(bool isFocusGroup)
 {
   mImpl->mIsKeyboardFocusGroup = isFocusGroup;
@@ -1129,6 +747,13 @@ void Control::Initialize()
   // Calling deriving classes
   OnInitialize();
 
+  // Test if the no size negotiation flag is not set
+  if( ( mImpl->mFlags & NO_SIZE_NEGOTIATION ) == 0 )
+  {
+    // Size negotiate disabled by default, so turn it on for this actor
+    Self().SetRelayoutEnabled( true );
+  }
+
   if( mImpl->mFlags & REQUIRES_STYLE_CHANGE_SIGNALS )
   {
     Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
@@ -1204,32 +829,6 @@ void Control::DisableGestureDetection(Gesture::Type type)
   }
 }
 
-void Control::RelayoutRequest()
-{
-  // unfortunate double negative but thats to guarantee new controls get size negotiation
-  // by default and have to "opt-out" if they dont want it
-  if( !(mImpl->mFlags & NO_SIZE_NEGOTIATION) )
-  {
-    Internal::RelayoutController::Request();
-  }
-}
-
-void Control::Relayout( Actor actor, const Vector2& size, ActorSizeContainer& container )
-{
-  if ( actor )
-  {
-    Toolkit::Control control( Toolkit::Control::DownCast( actor ) );
-    if( control )
-    {
-      control.GetImplementation().NegotiateSize( size, container );
-    }
-    else
-    {
-      container.push_back( ActorSizePair( actor, size ) );
-    }
-  }
-}
-
 void Control::OnInitialize()
 {
 }
@@ -1295,16 +894,26 @@ void Control::OnControlSizeSet( const Vector3& size )
 {
 }
 
-void Control::OnRelayout( const Vector2& size, ActorSizeContainer& container )
+void Control::OnCalculateRelayoutSize( Dimension dimension )
 {
-  unsigned int numChildren = Self().GetChildCount();
+}
 
-  for( unsigned int i=0; i<numChildren; ++i )
+void Control::OnLayoutNegotiated( float size, Dimension dimension )
+{
+}
+
+void Control::OnRelayout( const Vector2& size, RelayoutContainer& container )
+{
+  for( unsigned int i = 0, numChildren = Self().GetChildCount(); i < numChildren; ++i )
   {
-    container.push_back( ActorSizePair( Self().GetChildAt(i), size ) );
+    container.Add( Self().GetChildAt( i ), size );
   }
 }
 
+void Control::OnSetResizePolicy( ResizePolicy policy, Dimension dimension )
+{
+}
+
 void Control::OnKeyInputFocusGained()
 {
   // Do Nothing
@@ -1342,8 +951,6 @@ bool Control::OnMouseWheelEvent(const MouseWheelEvent& event)
 
 void Control::OnStageConnection()
 {
-  RelayoutRequest();
-
   // Notify derived classes.
   OnControlStageConnection();
 }
@@ -1362,9 +969,6 @@ void Control::OnChildAdd(Actor& child)
     return;
   }
 
-  // Request for relayout as we may need to position the new child and old ones
-  RelayoutRequest();
-
   // Notify derived classes.
   OnControlChildAdd( child );
 }
@@ -1377,16 +981,13 @@ void Control::OnChildRemove(Actor& child)
     return;
   }
 
-  // Request for relayout as we may need to re-position the old child
-  RelayoutRequest();
-
   // Notify derived classes.
   OnControlChildRemove( child );
 }
 
 void Control::OnSizeSet(const Vector3& targetSize)
 {
-  if( ( !mImpl->mInsideRelayout ) && ( targetSize != mImpl->mNaturalSize ) )
+  if( targetSize != mImpl->mNaturalSize )
   {
     // Only updates size if set through Actor's API
     mImpl->mNaturalSize = targetSize;
index 928fda1..a816989 100644 (file)
@@ -41,13 +41,9 @@ class StyleManager;
 
 namespace Internal DALI_INTERNAL
 {
-class RelayoutControllerImpl;
 class KeyInputFocusManager;
 }
 
-typedef std::pair< Actor, Vector2 > ActorSizePair;       ///< Pair of actor and size
-typedef std::vector< ActorSizePair > ActorSizeContainer; ///< Container of actors and their sizes
-
 namespace Internal
 {
 
@@ -80,34 +76,14 @@ public:
   // Size negotiation
 
   /**
-   * @copydoc Toolkit::Control::SetSizePolicy()
-   */
-  void SetSizePolicy( Toolkit::Control::SizePolicy widthPolicy, Toolkit::Control::SizePolicy heightPolicy );
-
-  /**
-   * @copydoc Toolkit::Control::GetSizePolicy()
-   */
-  void GetSizePolicy( Toolkit::Control::SizePolicy& widthPolicy, Toolkit::Control::SizePolicy& heightPolicy ) const;
-
-  /**
-   * @copydoc Toolkit::Control::SetMinimumSize()
-   */
-  void SetMinimumSize( const Vector3& size );
-
-  /**
-   * @copydoc Toolkit::Control::GetMinimumSize()
-   */
-  const Vector3& GetMinimumSize() const;
-
-  /**
-   * @copydoc Toolkit::Control::SetMaximumSize()
+   * @copydoc Dali::CustomActorImpl::GetHeightForWidth()
    */
-  void SetMaximumSize( const Vector3& size );
+  virtual float GetHeightForWidth( float width );
 
   /**
-   * @copydoc Toolkit::Control::GetMaximumSize()
+   * @copydoc Dali::CustomActorImpl::GetWidthForHeight()
    */
-  const Vector3& GetMaximumSize() const;
+  virtual float GetWidthForHeight( float height );
 
   /**
    * @copydoc Toolkit::Control::GetNaturalSize()
@@ -115,26 +91,6 @@ public:
   virtual Vector3 GetNaturalSize();
 
   /**
-   * @brief This method is called during size negotiation when a height is required for a given width.
-   *
-   * Derived classes should override this if they wish to customize the height returned.
-   *
-   * @param width to use.
-   * @return the height based on the width.
-   */
-  virtual float GetHeightForWidth( float width );
-
-  /**
-   * @brief This method is called during size negotiation when a width is required for a given height.
-   *
-   * Derived classes should override this if they wish to customize the width returned.
-   *
-   * @param height to use.
-   * @return the width based on the width.
-   */
-  virtual float GetWidthForHeight( float height );
-
-  /**
    * @brief Retrieves the current Control's size.
    *
    * @return The control's size.
@@ -234,9 +190,9 @@ public:
   Vector4 GetBackgroundColor() const;
 
   /**
-   * @copydoc Dali::Toolkit::Control::SetBackground
+   * @copydoc Dali::Toolkit::Control::SetBackgroundImage
    */
-  void SetBackground( Image image );
+  void SetBackgroundImage( Image image );
 
   /**
    * @copydoc Dali::Toolkit::Control::ClearBackground
@@ -301,22 +257,6 @@ public:
    */
   virtual bool OnAccessibilityValueChange(bool isIncrease);
 
-  // Called by the RelayoutController
-
-  /**
-   * @brief Called by the RelayoutController to negotiate the size of a control.
-   *
-   * The size allocated by the the algorithm is passed in which the
-   * control must adhere to.  A container is passed in as well which
-   * the control should populate with actors it has not / or does not
-   * need to handle in its size negotiation.
-   *
-   * @param[in]      size       The allocated size.
-   * @param[in,out]  container  The container that holds actors that are fed back into the
-   *                            RelayoutController algorithm.
-   */
-  DALI_INTERNAL void NegotiateSize( const Vector2& size, ActorSizeContainer& container );
-
   // Keyboard Focus
 
   /**
@@ -441,32 +381,10 @@ protected:
    */
   void DisableGestureDetection(Gesture::Type type);
 
-  // Size Negotiation
-
-  /**
-   * @brief Request a relayout, which means performing a size negotiation on this control, its parent and children (and potentially whole scene)
-   *
-   * This method is automatically called from OnStageConnection(), OnChildAdd(),
-   * OnChildRemove(), SetSizePolicy(), SetMinimumSize() and SetMaximumSize().
-   *
-   * This method can also be called from a derived class every time it needs a different size.
-   * At the end of event processing, the relayout process starts and
-   * all controls which requested Relayout will have their sizes (re)negotiated.
-   *
-   * @note RelayoutRequest() can be called multiple times; the size negotiation is still
-   * only performed once, i.e. there is no need to keep track of this in the calling side.
-   */
-  void RelayoutRequest();
-
   /**
-   * @brief Helper method for controls to Relayout their children if
-   * they do not know whether that child is a control or not.
-   *
-   * @param[in]      actor      The actor to relayout.
-   * @param[in]      size       The size to allocate to the actor.
-   * @param[in,out]  container  The container that holds actors that have not been allocated a size yet.
+   * @copydoc Dali::CustomActorImpl::RelayoutDependentOnChildren()
    */
-  static void Relayout( Actor actor, const Vector2& size, ActorSizeContainer& container );
+  virtual bool RelayoutDependentOnChildren( Dimension dimension = ALL_DIMENSIONS );
 
 private:
 
@@ -589,24 +507,6 @@ private:
   virtual void OnControlSizeSet( const Vector3& size );
 
   /**
-   * @brief Called after the size negotiation has been finished for this control.
-   *
-   * The control is expected to assign this given size to itself/its children.
-   *
-   * Should be overridden by derived classes if they need to layout
-   * actors differently after certain operations like add or remove
-   * actors, resize or after changing specific properties.
-   *
-   * Note! As this function is called from inside the size negotiation algorithm, you cannot
-   * call RequestRelayout (the call would just be ignored)
-   *
-   * @param[in]      size       The allocated size.
-   * @param[in,out]  container  The control should add actors to this container that it is not able
-   *                            to allocate a size for.
-   */
-  virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
-
-  /**
    * @brief Called when the control gains key input focus.
    *
    * Should be overridden by derived classes if they need to customize what happens when focus is gained.
@@ -647,6 +547,31 @@ private:
    */
   virtual bool OnMouseWheelEvent(const MouseWheelEvent& event);
 
+  /**
+   * @copydoc Dali::CustomActorImpl::OnCalculateRelayoutSize()
+   */
+  virtual void OnCalculateRelayoutSize( Dimension dimension );
+
+  /**
+   * @copydoc Dali::CustomActorImpl::OnLayoutNegotiated()
+   */
+  virtual void OnLayoutNegotiated( float size, Dimension dimension );
+
+  /**
+   * @copydoc Dali::CustomActorImpl::OnRelayout()
+   */
+  virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
+
+  /**
+   * @copydoc Dali::CustomActorImpl::OnSetResizePolicy()
+   */
+  virtual void OnSetResizePolicy( ResizePolicy policy, Dimension dimension );
+
+  /**
+   * @copydoc Dali::CustomActorImpl::CalculateChildSize()
+   */
+  virtual float CalculateChildSize( const Dali::Actor& child, Dimension dimension );
+
   // From CustomActorImpl, derived classes should NOT override these.
 
   /**
index 0721ff9..4ceae4f 100644 (file)
@@ -69,51 +69,6 @@ const Internal::Control& Control::GetImplementation() const
   return static_cast<const Internal::Control&>(CustomActor::GetImplementation());
 }
 
-void Control::SetSizePolicy( SizePolicy widthPolicy, SizePolicy heightPolicy )
-{
-  GetImplementation().SetSizePolicy( widthPolicy, heightPolicy );
-}
-
-void Control::GetSizePolicy( SizePolicy& widthPolicy, SizePolicy& heightPolicy ) const
-{
-  GetImplementation().GetSizePolicy( widthPolicy, heightPolicy );
-}
-
-void Control::SetMinimumSize( const Vector3& size )
-{
-  GetImplementation().SetMinimumSize( size );
-}
-
-const Vector3& Control::GetMinimumSize() const
-{
-  return GetImplementation().GetMinimumSize();
-}
-
-void Control::SetMaximumSize( const Vector3& size )
-{
-  GetImplementation().SetMaximumSize( size );
-}
-
-const Vector3& Control::GetMaximumSize() const
-{
-  return GetImplementation().GetMaximumSize();
-}
-
-Vector3 Control::GetNaturalSize()
-{
-  return GetImplementation().GetNaturalSize();
-}
-
-float Control::GetHeightForWidth( float width )
-{
-  return GetImplementation().GetHeightForWidth( width );
-}
-
-float Control::GetWidthForHeight( float height )
-{
-  return GetImplementation().GetWidthForHeight( height );
-}
-
 void Control::SetKeyInputFocus()
 {
   GetImplementation().SetKeyInputFocus();
@@ -169,9 +124,9 @@ Vector4 Control::GetBackgroundColor() const
   return GetImplementation().GetBackgroundColor();
 }
 
-void Control::SetBackground( Image image )
+void Control::SetBackgroundImage( Image image )
 {
-  GetImplementation().SetBackground( image );
+  GetImplementation().SetBackgroundImage( image );
 }
 
 void Control::ClearBackground()
index 6e88177..b4373c7 100644 (file)
@@ -84,38 +84,12 @@ public:
     {
       STYLE_NAME = PROPERTY_START_INDEX,       ///< name "style-name",       @see SetStyleName,       type std::string
       BACKGROUND_COLOR,                        ///< name "background-color", @see SetBackgroundColor, type Vector4
-      BACKGROUND,                              ///< name "background",       @see SetBackground,      type Map
-      WIDTH_POLICY,                            ///< name "width-policy",     @see SetSizePolicy,      type std::string
-      HEIGHT_POLICY,                           ///< name "height-policy",    @see SetSizePolicy,      type std::string
-      MINIMUM_SIZE,                            ///< name "minimum-size",     @see SetMinimumSize,     type Vector3
-      MAXIMUM_SIZE,                            ///< name "maximum-size",     @see SetMaximumSize,     type Vector3
+      BACKGROUND_IMAGE,                        ///< name "background-image", @see SetBackgroundImage, type Map
       KEY_INPUT_FOCUS,                         ///< name "key-input-focus",  @see SetKeyInputFocus,   type bool
     };
   };
 
   /**
-   * @brief Describes how a control could be resized.
-   */
-  enum SizePolicy
-  {
-    Fixed,    ///< Size can't grow or shrink.
-    Minimum,  ///< Size can grow but shrink up to a minimum level.
-    Maximum,  ///< Size can shrink but grow up to a maximum value.
-    Range,    ///< Size can grow or shrink between a minimum and a maximum values.
-    Flexible, ///< Size can grow or shrink with no limits.
-  };
-
-  /**
-   * @brief Describes what a control should do when a contained actor/control exceeds the boundary of the control.
-   */
-  enum ExceedPolicy
-  {
-    Crop,   ///< Control's contents will be cropped.
-    Shrink, ///< Control's contents will be shrunk.
-    Scroll  ///< Control's contents will be added to a scroll.
-  };
-
-  /**
    * @brief Describes the direction to move the keyboard focus towards.
    */
   enum KeyboardFocusNavigationDirection
@@ -201,79 +175,6 @@ public:
    */
   const Internal::Control& GetImplementation() const;
 
-  // Size Negotiation
-
-  /**
-   * @brief Sets the size policies for the width and height dimensions.
-   *
-   * @param[in] widthPolicy Size policy for the width dimension.
-   * @param[in] heightPolicy Size policy for the height dimension.
-   */
-  void SetSizePolicy( SizePolicy widthPolicy, SizePolicy heightPolicy );
-
-  /**
-   * @brief Retrieves the size policies for the width and height dimensions.
-   *
-   * @param[out] widthPolicy Width's size policy.
-   * @param[out] heightPolicy Height's size policy.
-   */
-  void GetSizePolicy( SizePolicy& widthPolicy, SizePolicy& heightPolicy ) const;
-
-  /**
-   * @brief Sets the minimum size for the control.
-   *
-   * @param[in] size The minimum size.
-   */
-  void SetMinimumSize( const Vector3& size );
-
-  /**
-   * @brief Retrieves the minimum size.
-   *
-   * @return The minimum size.
-   */
-  const Vector3& GetMinimumSize() const;
-
-  /**
-   * @brief Sets the maximum size.
-   *
-   * @param[in] size The maximum size.
-   */
-  void SetMaximumSize( const Vector3& size );
-
-  /**
-   * @brief Retrieves the maximum size.
-   *
-   * @return The maximum size.
-   */
-  const Vector3& GetMaximumSize() const;
-
-  /**
-   * @brief Works out the natural size.
-   *
-   * Natural size is the control's size with any restriction.
-   *
-   * @return The natural size.
-   */
-  Vector3 GetNaturalSize();
-
-  /**
-   * @brief Works out the control's height for a given width.
-   *
-   * @param[in] width The control's width.
-   *
-   * @return The control's height for the given width.
-   */
-  float GetHeightForWidth( float width );
-
-  /**
-   * @brief Works out the control's width for a given height.
-   *
-   * @param[in] height The control's height.
-   *
-   * @return The control's width for the given height.
-   */
-  float GetWidthForHeight( float height );
-
   // Key Input
 
   /**
@@ -383,7 +284,7 @@ public:
    *
    * @param[in] image The image to set as the background.
    */
-  void SetBackground( Image image );
+  void SetBackgroundImage( Image image );
 
   /**
    * @brief Clears the background.
index 8441dd6..1bb3fab 100644 (file)
@@ -132,6 +132,11 @@ void Popup::HideTail()
   GetImpl(*this).HideTail();
 }
 
+void Popup::MarkDirtyForRelayout()
+{
+  GetImpl(*this).MarkDirtyForRelayout();
+}
+
 Popup::TouchedOutsideSignalType& Popup::OutsideTouchedSignal()
 {
   return GetImpl(*this).OutsideTouchedSignal();
index 3c38259..108dd9e 100644 (file)
@@ -244,6 +244,11 @@ public:
    */
   void HideTail();
 
+  /**
+   * @brief Flag the popup as dirty for relayout
+   */
+  void MarkDirtyForRelayout();
+
 public: // Not intended for application developers
 
   /**
index 0bb8842..26a232f 100644 (file)
@@ -178,6 +178,11 @@ float ItemView::GetRefreshInterval() const
   return GetImpl(*this).GetRefreshInterval();
 }
 
+void ItemView::Refresh()
+{
+  return GetImpl(*this).Refresh();
+}
+
 Actor ItemView::GetItem(unsigned int itemId) const
 {
   return GetImpl(*this).GetItem(itemId);
index 1dd4fe3..aefa4f1 100644 (file)
@@ -277,6 +277,11 @@ public:
   float GetRefreshInterval() const;
 
   /**
+   * @brief Do a refresh of the item view.
+   */
+  void Refresh();
+
+  /**
    * @brief Given the Item ID, this returns the accompanying actor.
    *
    * @param[in] itemId The Item ID of the actor required.
index 7c77387..82e6e10 100644 (file)
@@ -135,6 +135,26 @@ Size TableView::GetCellPadding()
   return GetImpl(*this).GetCellPadding();
 }
 
+void TableView::SetFitHeight( unsigned int rowIndex )
+{
+  GetImpl(*this).SetRowPolicy( rowIndex, Internal::TableView::FIT );
+}
+
+bool TableView::IsFitHeight( unsigned int rowIndex ) const
+{
+  return ( GetImpl(*this).GetRowPolicy( rowIndex ) == Internal::TableView::FIT );
+}
+
+void TableView::SetFitWidth( unsigned int columnIndex )
+{
+  GetImpl(*this).SetColumnPolicy( columnIndex, Internal::TableView::FIT );
+}
+
+bool TableView::IsFitWidth( unsigned int columnIndex ) const
+{
+  return ( GetImpl(*this).GetColumnPolicy( columnIndex ) == Internal::TableView::FIT );
+}
+
 void TableView::SetFixedHeight( unsigned int rowIndex, float height )
 {
   GetImpl(*this).SetFixedHeight( rowIndex, height );
@@ -185,6 +205,11 @@ unsigned int TableView::GetColumns()
   return GetImpl(*this).GetColumns();
 }
 
+void TableView::SetCellAlignment( CellPosition position, HorizontalAlignment::Type horizontal, VerticalAlignment::Type vertical )
+{
+  GetImpl(*this).SetCellAlignment( position, horizontal, vertical );
+}
+
 TableView::TableView(Internal::TableView& implementation)
 : Control(implementation)
 {
index 104a050..4340d45 100644 (file)
@@ -20,6 +20,7 @@
 
 // EXTERNAL INCLUDES
 #include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/actors/actor-enumerations.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/control.h>
@@ -99,9 +100,9 @@ public:
    */
   enum LayoutPolicy
   {
-    Fixed,      ///< Fixed with the given value.
-    Relative,   ///< Calculated as percentage of the remainder after subtracting Padding and Fixed height/width
-    Fill        ///< Get the remainder of the 100% (after subtracting Padding, Fixed and Relative height/ width) divided evenly between 'fill' rows/columns
+    FIXED,      ///< Fixed with the given value.
+    RELATIVE,   ///< Calculated as percentage of the remainder after subtracting Padding and Fixed height/width
+    FILL        ///< Get the remainder of the 100% (after subtracting Padding, Fixed and Relative height/ width) divided evenly between 'fill' rows/columns
   };
 
   /**
@@ -271,6 +272,36 @@ public:
   Size GetCellPadding();
 
   /**
+   * @brief Specify this row as fitting its height to its children
+   *
+   * @param[in] rowIndex The row to set
+   */
+  void SetFitHeight( unsigned int rowIndex );
+
+  /**
+   * @brief Is the row a fit row
+   *
+   * @param[in] rowIndex The row to check
+   * @return Return true if the row is fit
+   */
+  bool IsFitHeight( unsigned int rowIndex ) const;
+
+  /**
+   * @brief Specify this column as fitting its width to its children
+   *
+   * @param[in] columnIndex The column to set
+   */
+  void SetFitWidth( unsigned int columnIndex );
+
+  /**
+   * @brief Is the column a fit column
+   *
+   * @param[in] columnIndex The column to check
+   * @return Return true if the column is fit
+   */
+  bool IsFitWidth( unsigned int columnIndex ) const;
+
+  /**
    * Sets a row to have fixed height
    * Setting a fixed height of 0 has no effect
    * @pre The row rowIndex must exist.
@@ -350,6 +381,15 @@ public:
    */
   unsigned int GetColumns();
 
+  /**
+   * @brief Set the alignment on a cell
+   *
+   * @param[in] position The cell to set alignment on
+   * @param[in] horizontal The horizontal alignment
+   * @param[in] vertical The vertical alignment
+   */
+  void SetCellAlignment( CellPosition position, HorizontalAlignment::Type horizontal, VerticalAlignment::Type vertical );
+
 public: // Not intended for application developers
 
   /**
index 97e8485..7a61615 100644 (file)
@@ -32,6 +32,14 @@ TextLabel TextLabel::New()
   return Internal::TextLabel::New();
 }
 
+TextLabel TextLabel::New( const std::string& text )
+{
+  TextLabel label = Internal::TextLabel::New();
+  label.SetProperty( TextLabel::Property::TEXT, text );
+
+  return label;
+}
+
 TextLabel::TextLabel()
 {
 }
index ba755da..ac64fe6 100644 (file)
@@ -71,12 +71,21 @@ public:
   };
 
   /**
-   * Create the TextLabel control.
+   * @brief Create the TextLabel control.
+   *
    * @return A handle to the TextLabel control.
    */
   static TextLabel New();
 
   /**
+   * @brief Create the TextLabel control.
+   *
+   * @param[in] text The text to display.
+   * @return A handle to the TextLabel control.
+   */
+  static TextLabel New( const std::string& text );
+
+  /**
    * @brief Creates an empty handle.
    */
   TextLabel();
index 89d0637..5487676 100644 (file)
@@ -31,7 +31,7 @@ namespace Toolkit
 
 const unsigned int TOOLKIT_MAJOR_VERSION = 1;
 const unsigned int TOOLKIT_MINOR_VERSION = 0;
-const unsigned int TOOLKIT_MICRO_VERSION = 34;
+const unsigned int TOOLKIT_MICRO_VERSION = 35;
 const char * const TOOLKIT_BUILD_DATE    = __DATE__ " " __TIME__;
 
 #ifdef DEBUG_ENABLED
diff --git a/docs/content/images/size-negotiation/Algorithm1.png b/docs/content/images/size-negotiation/Algorithm1.png
deleted file mode 100644 (file)
index dc0b603..0000000
Binary files a/docs/content/images/size-negotiation/Algorithm1.png and /dev/null differ
diff --git a/docs/content/images/size-negotiation/Algorithm10.png b/docs/content/images/size-negotiation/Algorithm10.png
deleted file mode 100644 (file)
index 154777e..0000000
Binary files a/docs/content/images/size-negotiation/Algorithm10.png and /dev/null differ
diff --git a/docs/content/images/size-negotiation/Algorithm2.png b/docs/content/images/size-negotiation/Algorithm2.png
deleted file mode 100644 (file)
index 3de7aeb..0000000
Binary files a/docs/content/images/size-negotiation/Algorithm2.png and /dev/null differ
diff --git a/docs/content/images/size-negotiation/Algorithm3.png b/docs/content/images/size-negotiation/Algorithm3.png
deleted file mode 100644 (file)
index 76d088e..0000000
Binary files a/docs/content/images/size-negotiation/Algorithm3.png and /dev/null differ
diff --git a/docs/content/images/size-negotiation/Algorithm4.png b/docs/content/images/size-negotiation/Algorithm4.png
deleted file mode 100644 (file)
index eafd019..0000000
Binary files a/docs/content/images/size-negotiation/Algorithm4.png and /dev/null differ
diff --git a/docs/content/images/size-negotiation/Algorithm8.png b/docs/content/images/size-negotiation/Algorithm8.png
deleted file mode 100644 (file)
index df20bf3..0000000
Binary files a/docs/content/images/size-negotiation/Algorithm8.png and /dev/null differ
diff --git a/docs/content/images/size-negotiation/Algorithm9.png b/docs/content/images/size-negotiation/Algorithm9.png
deleted file mode 100644 (file)
index 7a22cdb..0000000
Binary files a/docs/content/images/size-negotiation/Algorithm9.png and /dev/null differ
diff --git a/docs/content/images/size-negotiation/FixedWidthFlexibleHeight.png b/docs/content/images/size-negotiation/FixedWidthFlexibleHeight.png
deleted file mode 100644 (file)
index 0dd09b8..0000000
Binary files a/docs/content/images/size-negotiation/FixedWidthFlexibleHeight.png and /dev/null differ
diff --git a/docs/content/images/size-negotiation/FixedWidthFlexibleHeight2.png b/docs/content/images/size-negotiation/FixedWidthFlexibleHeight2.png
deleted file mode 100644 (file)
index 54cb64e..0000000
Binary files a/docs/content/images/size-negotiation/FixedWidthFlexibleHeight2.png and /dev/null differ
diff --git a/docs/content/images/size-negotiation/FixedWidthHeight.png b/docs/content/images/size-negotiation/FixedWidthHeight.png
deleted file mode 100644 (file)
index af6dee0..0000000
Binary files a/docs/content/images/size-negotiation/FixedWidthHeight.png and /dev/null differ
diff --git a/docs/content/images/size-negotiation/FixedWidthHeight2.png b/docs/content/images/size-negotiation/FixedWidthHeight2.png
deleted file mode 100644 (file)
index c792b73..0000000
Binary files a/docs/content/images/size-negotiation/FixedWidthHeight2.png and /dev/null differ
diff --git a/docs/content/images/size-negotiation/FlexibleWidthFixedHeight.png b/docs/content/images/size-negotiation/FlexibleWidthFixedHeight.png
deleted file mode 100644 (file)
index 0edf63f..0000000
Binary files a/docs/content/images/size-negotiation/FlexibleWidthFixedHeight.png and /dev/null differ
diff --git a/docs/content/images/size-negotiation/FlexibleWidthFixedHeight2.png b/docs/content/images/size-negotiation/FlexibleWidthFixedHeight2.png
deleted file mode 100644 (file)
index 9ee0bb4..0000000
Binary files a/docs/content/images/size-negotiation/FlexibleWidthFixedHeight2.png and /dev/null differ
diff --git a/docs/content/images/size-negotiation/FlexibleWidthHeight.png b/docs/content/images/size-negotiation/FlexibleWidthHeight.png
deleted file mode 100644 (file)
index 1025009..0000000
Binary files a/docs/content/images/size-negotiation/FlexibleWidthHeight.png and /dev/null differ
diff --git a/docs/content/images/size-negotiation/Popup.png b/docs/content/images/size-negotiation/Popup.png
new file mode 100644 (file)
index 0000000..f5d9b7f
Binary files /dev/null and b/docs/content/images/size-negotiation/Popup.png differ
diff --git a/docs/content/images/size-negotiation/PopupExample.png b/docs/content/images/size-negotiation/PopupExample.png
new file mode 100644 (file)
index 0000000..531622d
Binary files /dev/null and b/docs/content/images/size-negotiation/PopupExample.png differ
diff --git a/docs/content/images/size-negotiation/ResizePolicies.png b/docs/content/images/size-negotiation/ResizePolicies.png
new file mode 100644 (file)
index 0000000..7b8350e
Binary files /dev/null and b/docs/content/images/size-negotiation/ResizePolicies.png differ
diff --git a/docs/content/images/size-negotiation/ResizePoliciesExample.png b/docs/content/images/size-negotiation/ResizePoliciesExample.png
new file mode 100644 (file)
index 0000000..19b806f
Binary files /dev/null and b/docs/content/images/size-negotiation/ResizePoliciesExample.png differ
diff --git a/docs/content/images/size-negotiation/SizeNegotiationExample_After.png b/docs/content/images/size-negotiation/SizeNegotiationExample_After.png
new file mode 100644 (file)
index 0000000..3a64d36
Binary files /dev/null and b/docs/content/images/size-negotiation/SizeNegotiationExample_After.png differ
diff --git a/docs/content/images/size-negotiation/SizeNegotiationExample_Before.png b/docs/content/images/size-negotiation/SizeNegotiationExample_Before.png
new file mode 100644 (file)
index 0000000..30251d2
Binary files /dev/null and b/docs/content/images/size-negotiation/SizeNegotiationExample_Before.png differ
index 1073c3f..3802d3d 100644 (file)
  * \section Constraints
  * - \link constraints-intro Introduction to Constraints \endlink
  *
+ * \section SizeNegotiation Size Negotiation
+ * - \link size-negotiation Size Negotiation \endlink
+ *
  * \section UIControls UI Controls
  * - \link text-label Text Label \endlink
  * - \link item-view Item View \endlink
  * - \link scroll-view Scroll View \endlink
- * - \link size-negotiation Size Negotiation \endlink
+ * - \link size-negotiation-controls Size Negotiation for Controls \endlink
  * - \link type-registration Type Registration \endlink
  * - \link properties Properties \endlink
  * - \link background Background \endlink
diff --git a/docs/content/programming-guide/size-negotiation-controls.h b/docs/content/programming-guide/size-negotiation-controls.h
new file mode 100644 (file)
index 0000000..641da16
--- /dev/null
@@ -0,0 +1,256 @@
+/*! \page size-negotiation-controls Size Negotiation for Controls
+ *
+<h2 class="pg">Overview</h2>
+
+This document details how to create controls using the size negotiation API and is intended for UI control writters. For an introduction to
+size negotiation please see the <i>Size Negotiation Programming Guide</i>.
+
+The topics covered are:
+- The Relayout Controller
+- Resize Policies
+- Creating a Control: Popups
+- Size Negotiation API
+- Creating a Control: TableView
+
+<h2 class="pg">The Relayout Controller</h2>
+
+<h3>Overview</h3>
+The RelayoutController is an object that is private in DALi Core. It's main job is to take relayout requests from actors.
+It can be enabled or disabled internally. If disabled, then all relayout requests are ignored. By default the relayout controller is disabled until just after the
+initial application initialize. This allows the scene for an application to be created without generating many relayout requests. After the application
+has initialized the scene, then the relayout controller is automatically enabled and a relayout request is called on the root of the scene. This request spreads down the scene
+hierarchy and requests relayout on all actors that have size negotiation enabled.
+
+Relayout requests are put in automatically when a property is changed on an actor or a change to the stage hierarchy is made and manual requests are usually not necessary.
+
+<h2 class="pg">Resize Policies</h2>
+
+In addition to the resize policies detailed in the Size Negotiation Programming Guide there is one additional policy available to control writers:
+
+- USE_ASSIGNED_SIZE: Tells the actor to use the size that was passed into the size negotiation algorithm for it. This is used in the OnRelayout
+method derived from Actor when passing back controls to be negotiated using the container argument to the method.
+
+<h2 class="pg">Creating a Control: Popups</h2>
+
+<h3>Initialization</h3>
+Size negotiation is enabled on controls by default. If a control is desired to not have size negotiation enabled then simply pass in the
+NO_SIZE_NEGOTIATION flag into the Control constructor. This will then call SetRelayoutEnabled( false ) on the base class.
+
+The other step to perform is to set default resize policies for width and height.
+
+<h3>A Simple Example: Popup</h3>
+
+This example shows how to set up a popup for use with size negotiation. The popup contains a layer to raise it above all other controls,
+a semi-transparent full-screen backing image to dim the screen, a background image with a shadow border, and buttons that are positioned
+and resized by the popup. The following screen shot shows an example popup.
+
+\image html size-negotiation/PopupExample.png
+
+The first step is to set the default resize policies. This is done in the OnInitialize method. In the following snippet the popup
+is set to have a height resize policy of FIT_TO_CHILDREN. This assumes that the width of the popup will be specified by the user of
+the popup and that the desired behaviour is to fit the height of the popup to the size of its content.
+@code
+void Popup::OnInitialize()
+...
+Actor self = Self();
+self.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT );
+@endcode
+The popup will use a layer to place its content in. The layer is created and specified to fill the whole screen by using the following command.
+@code
+mLayer.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+@endcode
+A half transparent backing image is added to the layer and told to fill the layer with the following.
+@code
+mBacking.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+@endcode
+The popup control is added to the layer and a background image is specified to fill the size of the popup and add a border by the following.
+@code
+mBackgroundImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+mBackgroundImage.SetSizeMode( SIZE_FIXED_OFFSET_FROM_PARENT );
+Vector3 border( mPopupStyle->backgroundOuterBorder.x, mPopupStyle->backgroundOuterBorder.z, 0.0f );
+mBackgroundImage.SetSizeModeFactor( border );
+@endcode
+A table view is added to the popup to specify layout. It will fill to the width of the popup and expand/contract around its children cell heights.
+@code
+mPopupLayout.SetResizePolicy( FILL_TO_PARENT, WIDTH );
+mPopupLayout.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
+@endcode
+Override the OnRelayout method to position and resize the buttons. The trick to this is that the buttons do not know they are part of a popup and are
+about to be resized so could already have had their sizes negotiated. The call to PropagateRelayoutFlags on the button will ensure that it and all
+its child dependents are ready for a new size negotiation pass. The container.Add call will add the button to the relayout queue to be processed this frame.
+The buttonSize parameter is the desired size for the button. The desired size will only be set if the size policy of the button has already been changed to
+USE_ASSIGNED_SIZE, which is what happens when a button is added to the popup.
+@code
+void Popup::AddButton( Toolkit::Button button )
+...
+button.SetResizePolicy( USE_ASSIGNED_SIZE, ALL_DIMENSIONS );
+...
+
+void Popup::OnRelayout( const Vector2& size, RelayoutContainer& container )
+...
+button.SetPosition( buttonPosition );
+
+button.PropagateRelayoutFlags();    // Reset relayout flags for relayout
+container.Add( button, buttonSize );
+...
+@endcode
+Another aspect to the popup is that depending which resize policies are active on it then the inner table view requires different resize policies itself.
+OnSetResizePolicy can be overridden to receive notice that the resize policy has changed on the control and action can be taken.
+@code
+void Popup::OnSetResizePolicy( ResizePolicy policy, Dimension dimension )
+...
+if( policy == FIT_TO_CHILDREN )
+{
+  // Make content fit to children
+  mPopupLayout.SetResizePolicy( USE_NATURAL_SIZE, dimension );
+  if( dimension & HEIGHT )
+  {
+    mPopupLayout.SetFitHeight( 1 );
+  }
+}
+else
+{
+  mPopupLayout.SetResizePolicy( FILL_TO_PARENT, dimension );
+  // Make the content cell fill the whole of the available space
+  if( dimension & HEIGHT )
+  {
+    mPopupLayout.SetRelativeHeight( 1, 1.0f );
+  }
+}
+@endcode
+Popup also implements the following methods for use with the relevant resize policies:
+- GetNaturalSize
+- GetHeightForWidth
+- GetWidthForHeight
+
+<h2 class="pg">Size Negotiation API</h2>
+
+<h3>Base Class Methods</h3>
+
+The base class methods are used to call functionality held in Actor and are defined in CustomActorImpl.
+
+There is a RelayoutRequest method defined. This method is available for deriving controls to call when they would like themselves to be relaid out.
+@code void RelayoutRequest() @endcode
+
+<h3>Overridable Methods</h3>
+These overridable methods in control provide customization points for the size negotiation algorithm.
+
+<h4>Responding to the Change of Size on a Control</h4>
+
+OnRelayout is called during the relayout process at the end of the frame immediately after the new size has been set on the actor. If the actor has calculated
+the size of child actors then add them to container with their desired size and set the USE_ASSIGNED_SIZE resize policy on them.
+At this point the size of the actor has been calculated so it is a good place to calculate positions of child actors etc.
+@code virtual void OnRelayout( const Vector2& size, RelayoutContainer& container ) @endcode
+
+The OnRelayoutSignal signal is raised after SetSize and OnRelayout have been called during the relayout processing at the end of the frame. If the control is deriving
+from Control then the OnRelayout virtual is preferred over this signal. The signal is provided for instance when custom code needs to be run on the
+children of an actor that is not a control.
+@code OnRelayoutSignalType& OnRelayoutSignal() @endcode
+
+The OnCalculateRelayoutSize is called right before the size is calculated for an actor's dimension during the size negotiation phase. At this point all other actors this actor is
+dependent on have been negotiated so calculations depending on these actors can be performed before the size for this actor is calculated. Useful for container size calculations.
+@code virtual void OnCalculateRelayoutSize( Dimension dimension ) @endcode
+
+OnLayoutNegotiated is called right after the size in a given dimension has been negotiated for an actor. This allows calculations to be performed in response to the change
+in a given dimension but before OnRelayout is called.
+@code virtual void OnLayoutNegotiated( float size, Dimension dimension ) @endcode
+
+<h4>Calculating Sizes</h4>
+
+Calculate the natural size for this control. This will be called when a control's resize policy is set to USE_NATURAL_SIZE.
+For example, TableView will calculated the size of the table given its various cell properties.
+@code virtual Vector3 GetNaturalSize() @endcode
+
+Given an input width return the correct height for this control. This will be called when the resize policy is set to DIMENSION_DEPENDENCY and
+height has a dependency on width.
+@code virtual float GetHeightForWidth( float width ) @endcode
+
+Given the input height return the correct width for this control. This will be called when the resize policy is set to DIMENSION_DEPENDENCY and
+width has a dependency on height.
+@code virtual float GetWidthForHeight( float height ) @endcode
+
+<h4>Relayout Dependencies</h4>
+
+Return true from this method if this control is dependent on any of its children to calculate its own size. All relayout containers that can be dependent on their
+children for their own size need to return true from this.
+@code virtual bool RelayoutDependentOnChildren( Dimension dimension = ALL_DIMENSIONS ) @endcode
+
+This will be called by children when they are using the FILL_TO_PARENT resize policy. It is the parent's responsibility to calculate the child's correct size.
+@code virtual float CalculateChildSize( const Dali::Actor& child, Dimension dimension ) @endcode
+
+<h4>Events</h4>
+
+OnSetResizePolicy is called when the resize policy is set on an actor. Allows deriving actors to respond to changes in resize policy.
+@code virtual void OnSetResizePolicy( ResizePolicy policy, Dimension dimension ) @endcode
+
+<h2 class="pg">Creating a Control: TableView</h2>
+
+This section demonstrates how size negotiation may be used when creating a table view.
+
+First we define some policies for how table row and columns may resize. These are:
+- Fixed: Use a fixed size
+- Relative: Use a ratio size of empty remaining space
+- Fill: Fill up to all remaining space, distributing evenly between all "fill" row or columns
+
+A data structure is defined to hold information for each row and column regarding their cell size policy and their assigned and calculated sizes.
+
+We need to be able to calculate the fixed sizes of all actors placed into table cells. The place to do this is in OnCalculateRelayoutSize. When
+this is called every actor the table view is dependent on has already had their sizes calculated. Calculations can be made that the main calculation
+for the actor can then use.
+@code
+void TableView::OnCalculateRelayoutSize( Dimension dimension )
+...
+CalculateRowColumnData();
+
+if( dimension & WIDTH )
+{
+  CalculateFixedSizes( mColumnData, WIDTH );
+  mFixedTotals.width = CalculateTotalFixedSize( mColumnData );
+}
+
+if( dimension & HEIGHT )
+{
+  CalculateFixedSizes( mRowData, HEIGHT );
+  mFixedTotals.height = CalculateTotalFixedSize( mRowData );
+}
+...
+@endcode
+
+An important override is GetNaturalSize. This will simply return the total sum of the fixed cells for each row and column.
+@code
+Vector3 TableView::GetNaturalSize()
+...
+return Vector3( mFixedTotals.width, mFixedTotals.height, 1.0f );
+...
+@endcode
+
+When the time comes to calculate the size of each child in the table cells the following method will be called.
+@code
+float TableView::CalculateChildSize( const Actor& child, Dimension dimension )
+...
+// Use cell data to calculate child size
+@endcode
+
+The table view is dependent on its children if its size policy is set to USE_NATURAL_SIZE or a row or column is set to "fit" an actor.
+The following code shows calling the base class RelayoutDependentOnChildren to check the resize policy and then searches for fit row or columns.
+@code
+bool TableView::RelayoutDependentOnChildren( Dimension dimension )
+{
+  if ( Control::RelayoutDependentOnChildren( dimension ) )
+  {
+    return true;
+  }
+
+  return FindFit( mRowData ) || FindFit( mColumnData );
+}
+@endcode
+
+With the cell sizes already calculated, the job of OnRelayout is to position all the actors in the table view in their respective positions.
+@code
+void TableView::OnRelayout( const Vector2& size, RelayoutContainer& container )
+...
+// Find each actor and position it, taking padding into account
+@endcode
+
+*
+*/
index d53bc39..536a8f8 100644 (file)
  *
 <h2 class="pg">Overview</h2>
 
-Size negotiation provides the ability for controls to be resized without the application having to set a size.
-A parent control can resize itself according to its children. Each control can provide hints to using policies for the width and height.
-Controls will be relaid just once and only when requested to, rather than relaid out several times when different properties are set.
-Using size negotiation avoids the need for using size constraints to resize children, which would need to be calculated in the update
-thread every time even minor changes occur.
-
-This topic covers size policies, deriving from ControlImpl, size policy examples and the size negotiation algorithm.
-
-<h2 class="pg">Size Policies</h2>
-
-Each control has a policy for both width and height:
-- <b>Fixed:</b> The size is fixed to the size set by the application. If no size is set, then the size is fixed to the <i>natural</i> size of the control.
-- <b>Mininum:</b> The size can grow and shrink but cannot be smaller than the <i>minimum</i> size specified.
-- <b>Maximum:</b> The size can grow and shrink but cannot be larger than the <i>maximum</i> size specified.
-- <b>Range:</b> The size can grow or shrink but within the <i>minimum</i> and <i>maximum</i> sizes specified.
-- <b>Flexible:</b> The size of the control can grow or shrink as required without any limits.
-
-Currently, by default, controls use a fixed size policy for width and height. If one dimension is set, and the other dimension is set to zero, then the latter
-dimension is assumed to have a non fixed policy.
-
-<h2 class="pg">Deriving from ControlImpl</h2>
-
-The size negotiation utilises several methods to work out the best size of a control. The default behaviour is in the ControlImpl class.
-The following methods can be overridden.
-@code Vector3 GetNaturalSize() @endcode
-This method should return the natural size of the control. This can be dependent on the control's children or the control may decide to have a fixed size.
-
-@code float GetHeightForWidth( float width ) @endcode
-This method should return the height it needs to be when given a certain width.
-
-@code float GetWidthForHeight( float height ) @endcode
-This method should return the width it needs to be when given a certain height.
-
-All these methods can be overridden by deriving classes. This allows each control to dictate what size it would like to be. If you want the default behaviour,
-then you do not have to override these methods. A parent control can call the child's methods to determine its size if it needs to.
-
-<h2 class="pg">Size Policies and Virtual Methods</h2>
-
-The table below shows the methods that are called when certain width and height policies are in place.
-
-<table>
-  <tr>
-    <td></td>
-    <td><b>Fixed Height</b></td>
-    <td><b>Height Not Fixed (All other policies)</b></td>
-  </tr>
-  <tr>
-    <td><b>Fixed Width</b></td>
-    <td>
-    - Use size set by application
-    - If only height set by application
-      - Use height set by application
-      - Use <b>GetWidthForHeight()</b> for width
-    - If only width set by application
-      - Use width set by application
-      - Use <b>GetHeightForWidth()</b> for height
-    - If not set, then get size by calling <b>GetNaturalSize()</b>
-    </td>
-    <td>
-    - Use width set by application
-    - Use allocated width if not set
-      - Ensure it satisfies our width policy
-      - Adjust if required
-    - Use <b>GetHeightForWidth()</b> for height
-    - Ensure height satisfies our height policy
-      - Adjust if required
-    </td>
-  </tr>
-  <tr>
-    <td><b>Width Not Fixed (All other policies)</b></td>
-    <td>
-    - Use height set by application
-    - Use allocated height if not set
-      - Ensure it satisfies our height policy
-      - Adjust if required
-    - Use <b>GetWidthForHeight()</b> for width
-    - Ensure width satisfies our width policy
-      - Adjust if required
-    </td>
-    <td>
-    - Constrain the allocated width and height according to the two policies
-    </td>
-  </tr>
-</table>
-
-<h2 class="pg">Size Policy Examples</h2>
-
-<h3 class="pg">Policy: Fixed Width and Height (1)</h3>
-
-<table border=0 cellpadding=10><tr>
-<td>
-\image html FixedWidthHeight.png
-</td>
-<td>
-The application/control has set the following settings:
-- <b>SetSize:</b> 200 x 300
-- <b>Natural Size:</b> 400 x 400
-- <b>Width To Height Ratio:</b> 1 to 1
-- <b>Width Policy:</b> Fixed
-- <b>Height Policy:</b> Fixed
-- <b>ParentOrigin:</b> TopLeft
-- <b>AnchorPoint:</b> TopLeft
-
-Control methods called:
-- None
-
-Result
-- <b>Allocated size:</b> 200 x 300
-</td>
-</tr></table>
-
-<h3 class="pg">Policy: Fixed Width and Height (2)</h3>
-
-<table border=0 cellpadding=10><tr>
-<td>
-\image html FixedWidthHeight2.png
-</td>
-<td>
-The application/control has set the following settings:
-- <b>SetSize:</b> 0 x 0 (No size set)
-- <b>Natural Size:</b> 400 x 400
-- <b>Width To Height Ratio:</b> 1 to 1
-- <b>Width Policy:</b> Fixed
-- <b>Height Policy:</b> Fixed
-- <b>ParentOrigin:</b> TopLeft
-- <b>AnchorPoint:</b> TopLeft
-
-Control methods called:
-- GetNaturalSize() = 400 x 400
-
-Result
-- <b>Allocated size:</b> 400 x 400
-</td>
-</tr></table>
-
-<h3 class="pg">Policy: Flexible Width and Height</h3>
-
-<table border=0 cellpadding=10><tr>
-<td>
-\image html FlexibleWidthHeight.png
-</td>
-<td>
-The application/control has set the following settings:
-- <b>SetSize:</b> 200 x 300
-- <b>Natural Size:</b> 400 x 400
-- <b>Width To Height Ratio:</b> 1 to 1
-- <b>Width Policy:</b> Flexible
-- <b>Height Policy:</b> Flexible
-- <b>ParentOrigin:</b> TopLeft
-- <b>AnchorPoint:</b> TopLeft
-
-Control methods called:
-- None
-
-Result
-- <b>Allocated size:</b> 480 x 800  (Assume stage size 480 x 800)
-</td>
-</tr></table>
-
-<h3 class="pg">Policy: Fixed Width and Flexible Height (1)</h3>
-
-<table border=0 cellpadding=10><tr>
-<td>
-\image html FixedWidthFlexibleHeight.png
-</td>
-<td>
-The application/control has set the following settings:
-- <b>SetSize:</b> 200 x 300
-- <b>Natural Size:</b> 400 x 400
-- <b>Width To Height Ratio:</b> 1 to 1
-- <b>Width Policy:</b> Fixed
-- <b>Height Policy:</b> Flexible
-- <b>ParentOrigin:</b> TopLeft
-- <b>AnchorPoint:</b> TopLeft
-
-Control methods called:
-- GetHeightForWidth( 200 ) = 200
-
-Result
-- <b>Allocated size:</b> 200 x 200
-</td>
-</tr></table>
-
-<h3 class="pg">Policy: Fixed Width and Flexible Height (2)</h3>
-
-<table border=0 cellpadding=10><tr>
-<td>
-\image html FixedWidthFlexibleHeight.png
-</td>
-<td>
-The application/control has set the following settings:
-- <b>SetSize:</b> 200 x 0 (No height set)
-- <b>Natural Size:</b> 400 x 400
-- <b>Width To Height Ratio:</b> 1 to 1
-- <b>Width Policy:</b> Fixed
-- <b>Height Policy:</b> Flexible
-- <b>ParentOrigin:</b> TopLeft
-- <b>AnchorPoint:</b> TopLeft
-
-Control methods called:
-- GetHeightForWidth( 200 ) = 200
-
-Result
-- <b>Allocated size:</b> 200 x 200
-</td>
-</tr></table>
-
-<h3 class="pg">Policy: Fixed Width and Flexible Height (3)</h3>
-
-If the control did not have the GetHeightForWidth() method, then the <i>size set</i> is used to calculate the ratio.
-
-<table border=0 cellpadding=10><tr>
-<td>
-\image html FixedWidthFlexibleHeight2.png
-</td>
-<td>
-The application/control has set the following settings:
-- <b>SetSize:</b> 200 x 0 (No height set)
-- <b>Natural Size:</b> 400 x 400
-- <b>Width To Height Ratio:</b> Not set
-- <b>Width Policy:</b> Fixed
-- <b>Height Policy:</b> Flexible
-- <b>ParentOrigin:</b> TopLeft
-- <b>AnchorPoint:</b> TopLeft
-
-Control methods called:
-- GetHeightForWidth( 200 ) = 200  <i>(Unable to calculate ratio using size set)</i>
-
-Result
-- <b>Allocated size:</b> 200 x 800  <i>(Allocate entire height)</i>
-</td>
-</tr></table>
-
-<h3 class="pg">Policy: Fixed Width and Flexible Height (4)</h3>
-
-<table border=0 cellpadding=10><tr>
-<td>
-\image html FlexibleWidthHeight.png
-</td>
-<td>
-The application/control has set the following settings:
-- <b>SetSize:</b> 0 x 0 (No size set)
-- <b>Natural Size:</b> 400 x 400
-- <b>Width To Height Ratio:</b> 1 to 1
-- <b>Width Policy:</b> Fixed
-- <b>Height Policy:</b> Flexible
-- <b>ParentOrigin:</b> TopLeft
-- <b>AnchorPoint:</b> TopLeft
-
-Control methods called:
-- GetHeightForWidth( 0 ) = 0
-
-Result
-- <b>Allocated size:</b> 480 x 800  <i>(Allocate entire size)</i>
-</td>
-</tr></table>
-
-<h3 class="pg">Policy: Flexible Width and Fixed Height (1)</h3>
-
-<table border=0 cellpadding=10><tr>
-<td>
-\image html FlexibleWidthFixedHeight.png
-</td>
-<td>
-The application/control has set the following settings:
-- <b>SetSize:</b> 0 x 300 (No width set)
-- <b>Natural Size:</b> 400 x 400
-- <b>Width To Height Ratio:</b> 1 to 1
-- <b>Width Policy:</b> Flexible
-- <b>Height Policy:</b> Fixed
-- <b>ParentOrigin:</b> TopLeft
-- <b>AnchorPoint:</b> TopLeft
-
-Control methods called:
-- GetWidthForHeight( 300 ) = 300
-
-Result
-- <b>Allocated size:</b> 300 x 300
-</td>
-</tr></table>
-
-<h3 class="pg">Policy: Flexible Width and Fixed Height (2)</h3>
-
-If the control did not have the GetWidthForHeight() method, then the <i>size set</i> is used to calculate the ratio.
-
-<table border=0 cellpadding=10><tr>
-<td>
-\image html FlexibleWidthFixedHeight2.png
-</td>
-<td>
-The application/control has set the following settings:
-- <b>SetSize:</b> 0 x 300 (No width set)
-- <b>Natural Size:</b> 400 x 400
-- <b>Width To Height Ratio:</b> Not set
-- <b>Width Policy:</b> Flexible
-- <b>Height Policy:</b> Fixed
-- <b>ParentOrigin:</b> TopLeft
-- <b>AnchorPoint:</b> TopLeft
-
-Control methods called:
-- GetWidthForHeight( 300 ) = 0  <i>(Unable to calculate ratio using size set)</i>
-
-Result
-- <b>Allocated size:</b> 480 x 300  <i>(Allocate entire width)</i>
-</td>
-</tr></table>
-
-<h2 class="pg">The Size Negotiation Algorithm</h2>
-
-<h3 class="pg">The Algorithm</h3>
-
--# The algorithm starts at the stage
-  - All top level controls are found and offered the size of the stage
-  - The control negotiates the size offered by using the policy rules to determine the size that it should be allocated
-  - The control is then set to that allocated size
--# The control is responsible for setting the sizes of all its children
-  - Can set a size on an Actor
-  - Or can call relayout on a Control directly
--# Children that a control does not handle, the control can add to a container so that the top-level algorithm delas with it instead
-  - The control should call Relayout with the child and size of itself as parameters
-
-<table border=0 cellpadding=10><tr>
-<td>
-\image html Algorithm1.png
-</td>
-<td>
-\image html Algorithm2.png
-</td>
-</tr></table>
-
-<h3 class="pg">A closer look at Control A</h3>
-
-Taking a closer look at Control A we see in this example that children should share the width equally and that the height of Control A
-is the maximum height of the children.
-
-<table border=0 cellpadding=10><tr>
-<td>
-\image html Algorithm3.png
-</td>
-<td>
-<table border=0 cellpadding=10><tr>
-<td>
-\image html Algorithm4.png
-</td>
-</tr></table>
-</td>
-</tr></table>
+Size negotiation, also known as layout management, is responsible for allocating sizes to all actors on the stage based on rules of dependency between
+the actors. Requests for relayout on actors are collected during the frame with the actual relayout performed at the end of the frame.
+
+This document details how to use the size negotiation API and is intended for application writters.
+
+The topics covered are:
+- Dimensions
+- Resize policies
+- Actor
+- Debugging
+
+<h2 class="pg">Dimensions</h2>
+
+The notion of width and height is generalised into the concept of a Dimension. Several methods take a Dimension parameter.
+
+The Dimension enum specifies the available dimensions as bitfields:
+- WIDTH
+- HEIGHT
+
+If a method can process width and height at the same time then the ALL_DIMENSIONS mask can be specified.
+
+<h2 class="pg">Resize Policies</h2>
+
+<h3>Policies</h3>
+The ResizePolicy enum specifies a range of options for controlling the way actors resize. These are powerful rules that enable much automatic
+resizing behaviour. They are as following:
+
+- FIXED: This is the option to use when you want the specific definite size as set by SetPreferredSize
+- USE_NATURAL_SIZE: Use this option for objects such as images or text to get their natural size e.g. The dimensions of the image, or the size of the text without wrapping. Also use this on TableViews when the size of the table is dependent on its children.
+- FILL_TO_PARENT: Size will fill up to the size of its parent's size, taking a size factor into account to allow proportionate filling
+- FIT_TO_CHILDREN: Size will scale around the size of the actor's children. E.g. A popup's height may resize itself around it's contents.
+- DIMENSION_DEPENDENCY: This covers rules such as width-for-height and height-for-width. You specify that one dimension depends on another.
+
+\image html size-negotiation/ResizePolicies.png
+
+<h2 class="pg">Actor</h2>
+
+This section details how an actor may be used with size negotiation.
+
+<h3>Enabling Size Negotiation</h3>
+
+The first thing to do is to specify whether you want an actor to be included or excluded from the relayout process. The following method is used to enable or disable the relayout
+for an individual actor.
+@code void SetRelayoutEnabled( bool enabled ) @endcode
+Text and image actors have relayout enabled by default, while a plain Actor is disabled. Be aware that if desiring to use an Actor in relayout
+then relayout needs to be explicitly enabled first.
+
+<h3>Specifying Size Policies</h3>
+
+The next step is to specify how an actor will be size negotiated. The resize policies for an actor may be specified by the following method:
+@code void SetResizePolicy( ResizePolicy policy, Dimension dimension ) @endcode
+It is common to specifiy different policies for the different dimensions of width and height to achive different layouts. Different actors have
+different resize policies specified by default. For example ImageActors are set to use USE_NATURAL_SIZE.
+
+The following example code snippet shows rootActor having its width policy set to FILL_TO_PARENT and its height policy set to FIT_TO_CHILDREN.
+It has an ImageActor added to it with an explicit call to USE_NATURAL_SIZE in both dimensions called on it. This will make an actor that will
+fill up the space of its parent in the width dimension and fit to its child in the height dimension. As the image actor child is using natural size
+the height of the root actor will fit to the height of the child image.
 
 @code
-class ControlA : public Control
-{
-  ...
-private:
-  // Data
-  Actor mActorC; // Container to store children
-  TextView mControlD; // Some text we want to display
-  ImageActor mActorD; // An image
-};
+Actor rootActor = Actor::New();
+rootActor.SetRelayoutEnabled( true );
+rootActor.SetResizePolicy( FILL_TO_PARENT, WIDTH );
+rootActor.SetResizePolicy( FIT_TO_CHILDREN, HEIGHT );
+ImageActor image = ImageActor::New( Image::New( MY_IMAGE_PATH ) );
+image.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS );
+rootActor.Add( image );
 @endcode
 
+The following images show the before and after layouts for this code example.
+
+Before:
+\image html size-negotiation/SizeNegotiationExample_Before.png
+After:
+\image html size-negotiation/SizeNegotiationExample_After.png
+
+This example shows an actor rootActor set to expand to its parent's width and contract/expand around its child's height. The child image actor
+is set to natural size which means it will display at the acutal size of the image.
+
+To specify that a dimension has a dependency on another dimension use the following method. Calling this method will automatically set the resize policy to be DIMENSION_DEPENDENCY
+for the given dimension.
+@code void SetDimensionDependency( Dimension dimension, Dimension dependency ) @endcode
+For example if dimension is HEIGHT and dependency is WIDTH then there is a height-for-width dependency in effect. The classic use case for this
+is a text view that wraps its text. The following example snippet shows a text view that expands its width to the size of its parent, wraps its
+contents and then determines its height based on the width.
 @code
-Vector3 ControlA::GetNaturalSize()
-{
-  // Width is total of ControlD and ActorD
-  // Height is max of ControlD and ActorD
-  // Don't care about the Depth
-  Vector3 naturalSize;  // Initialised to (0.0f, 0.0f, 0.0f)
-
-  if ( mControlD )
-  {
-    // We know ControlD is a control, so just ask its natural size
-    naturalSize = mControlD.GetNaturalSize();
-  }
-
-  if ( mActorD )
-  {
-    // We know ActorD is an ImageActor, we can get the image's natural size
-    Image image = mActorD.GetImage();
-    naturalSize.width += image.GetWidth;
-    naturalSize.height = std::max( naturalSize.height, image.GetHeight() );
-  }
-
-  return naturalSize;
-}
+TextView text = TextView::New( "Example" );
+text.SetMultilinePolicy( SplitByWord );
+text.SetResizePolicy( FILL_TO_PARENT, WIDTH );
+text.SetDimensionDependency( HEIGHT, WIDTH );
 @endcode
 
-GetHeightForWidth() and GetWidthForHeight() can be created in a similar manner.
+<h3>Specifying Sizes and Size Limits</h3>
+
+When wanting a specific fixed size for an actor then specify the resize policy to be FIXED and set the desired, or preferred size using the following method.
+This method is to be used instead of SetSize when wishing to specify a size for an actor being size negotiated.
+@code void SetPreferredSize( const Vector2& size ) @endcode
+If only one dimension is FIXED then the other value in the size parameter will be ignored, so it is safe to set it to zero.
 
+To constrain the final negotiated size of an actor, set the following for minimum and maximum sizes respectively.
 @code
-void ControlA::OnRelayout( const Vector2& size, ActorSizeContainer& container )
-{
-  // Width to be shared between ControlD and ActorD
-  Vector2 childSize( size.width * 0.5f, size.height );
-
-  if ( mActorC )
-  {
-    // ActorC is the same size as ControlA
-    mActorC.SetSize( size );
-  }
-
-  if ( mControlD )
-  {
-    Relayout( mControlD, childSize );
-    // Can add more complex calculations to preserve aspect ratio etc.
-  }
-
-  if ( mActorD )
-  {
-    mActorD.SetSize( childSize );
-    // Can add more complex calculations to preserve aspect ratio etc.
-  }
-}
+void SetMinimumSize( const Vector2& size )
+void SetMaximumSize( const Vector2& size )
 @endcode
 
-The allocated layout is as follows.
-<table border=0 cellpadding=10><tr>
-<td>
-\image html Algorithm8.png
-</td>
-</tr></table>
-
-<h3 class="pg">A closer look at Control B</h3>
-
-In this example we have the following requirements:
-- Control B creates a small border around its children
-- Control B just allocates whatever its given to its children (minus the border)
-- Actor E is a simple container actor and contains one control (Control E)
-- Control B is not aware of the actors it contains
-
-<table border=0 cellpadding=10><tr>
-<td>
-\image html Algorithm9.png
-</td>
-<td>
-\image html Algorithm10.png
-</td>
-</tr></table>
+<h3>Altering Negotiated Size</h3>
+
+The following method specifies a size mode to use. Use one of: USE_OWN_SIZE, SIZE_RELATIVE_TO_PARENT or SIZE_FIXED_OFFSET_FROM_PARENT. SIZE_RELATIVE_TO_PARENT will
+scale the image relative to it's parent size when the resize policy of FILL_TO_PARENT is in effect. While SIZE_FIXED_OFFSET_FROM_PARENT will
+add an offset to this parent size, for example when wanting an image to act as a border around its parent.
+@code void SetSizeMode( const SizeMode mode ) @endcode
+
+Use the following with SetSizeMode to specify either the size relative to parent or the fixed offset to apply.
+@code void SetSizeModeFactor( const Vector3& factor ) @endcode
+
+When an actor is required to maintain the aspect ratio of its natural size the following method can be used. This is useful for size negotiating images
+to ensure they maintain their aspect ratio while still fitting within the bounds they have been allocated. This can be one of USE_SIZE_SET, FIT_WITH_ASPECT_RATIO
+or FILL_WITH_ASPECT_RATIO. The first is the default. The second will fit the actor within the bounds it has been allocated while maintaining aspect ratio. The
+third will fill all available space, potentially overflowing its bounds, while maintaining apsect ratio.
+@code void SetSizeScalePolicy( SizeScalePolicy policy ) @endcode
+
+<h3>Using Actors in Containers</h3>
 
+When laying out actors in containers such as TableView it is useful to be able to specify padding that surrounds the actor. E.g. You may
+want some white space around an image actor placed in a table cell. The padding specifies the left, right, bottom and top padding values.
+@code void SetPadding( const Padding& padding ) @endcode
+
+<h2 class="pg">An Example</h2>
+
+This section shows a more complex example of how to configure size negotiation. It creates a popup and adds a table view to it with a text view,
+an image and a sub-table. The sub-table contains a checkbox and another text view.
+@code
+mPopup = CreatePopup();
+mPopup.SetTitle( "Warning" );
+
+// Content
+Toolkit::TableView content = Toolkit::TableView::New( 2, 2 );
+content.SetResizePolicy( FILL_TO_PARENT, WIDTH );
+content.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
+content.SetFitHeight( 0 );
+content.SetFitHeight( 1 );
+content.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 0.0f ) );
+
+// Text
+Toolkit::TextView text = Toolkit::TextView::New();
+text.SetText( "Do you really want to quit?" );
+text.SetMultilinePolicy( Toolkit::TextView::SplitByWord );
+text.SetWidthExceedPolicy( Toolkit::TextView::Split );
+text.SetLineJustification( Toolkit::TextView::Left );
+text.SetResizePolicy( FILL_TO_PARENT, WIDTH );
+text.SetDimensionDependency( HEIGHT, WIDTH );
+
+content.AddChild( text, Toolkit::TableView::CellPosition( 0, 0 ) );
+
+// Image
+ImageActor image = ImageActor::New( ResourceImage::New( IMAGE1 ) );
+image.SetResizePolicy( FILL_TO_PARENT, WIDTH );
+image.SetDimensionDependency( HEIGHT, WIDTH );
+image.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 0.0f ) );
+content.AddChild( image, Toolkit::TableView::CellPosition( 0, 1 ) );
+
+// Checkbox and text
+Toolkit::TableView root = Toolkit::TableView::New( 1, 2 );
+root.SetResizePolicy( FILL_TO_PARENT, WIDTH );
+root.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
+root.SetFitHeight( 0 );
+root.SetFitWidth( 0 );
+root.SetPadding( Padding( 0.0f, 0.0f, 0.0f, 20.0f ) );
+
+Dali::Image unchecked = Dali::ResourceImage::New( CHECKBOX_UNCHECKED_IMAGE );
+Dali::Image checked = Dali::ResourceImage::New( CHECKBOX_CHECKED_IMAGE );
+Toolkit::CheckBoxButton checkBox = Toolkit::CheckBoxButton::New();
+checkBox.SetBackgroundImage( unchecked );
+checkBox.SetSelectedImage( checked );
+checkBox.SetPreferredSize( Vector2( 48, 48 ) );
+checkBox.SetResizePolicy( FIXED, ALL_DIMENSIONS );
+
+root.AddChild( checkBox, Toolkit::TableView::CellPosition( 0, 0 ) );
+
+Toolkit::TextView text2 = Toolkit::TextView::New();
+text2.SetText( "Don't show again" );
+text2.SetLineJustification( Toolkit::TextView::Left );
+text2.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 10.0f ) );
+
+root.AddChild( text2, Toolkit::TableView::CellPosition( 0, 1 ) );
+
+content.AddChild( root, Toolkit::TableView::CellPosition( 1, 0, 0, 2 ) );  // Column span 2
+
+mPopup.Add( content );
+@endcode
+
+The resulting popup with additional buttons added is shown below.
+\image html size-negotiation/Popup.png
+
+The key things to pick out from this example are the use of the size negotiation API.
+The content table view is set to FILL_TO_PARENT for its width and USE_NATURAL_SIZE for its height. This will result
+in the table view expanding its width to fit the available space in the popup while also expanding/contracting its
+height based on the size of the contents in its cells.
+@code
+content.SetResizePolicy( FILL_TO_PARENT, WIDTH );
+content.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
+@endcode
+To add a little space around the left, right and bottom of the table view, some padding is added.
+@code
+content.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 0.0f ) );
+@endcode
+The first text view has its width set to FILL_TO_PARENT and its height has a dimension dependency on its width. This
+will result in a text view that fills up its width to available space in the table cell and then then calculates its
+height based on its new width. The table view will then fit its height taking the height of the text view into account.
+@code
+text.SetResizePolicy( FILL_TO_PARENT, WIDTH );
+text.SetDimensionDependency( HEIGHT, WIDTH );
+@endcode
+The image view performs a similar relayout. It fits its width to the size of the cell and calculates its height based on the new
+width. Some padding is added to the left of it as well to center it more.
 @code
-void ControlA::OnRelayout( const Vector2& size, ActorSizeContainer& container )
-{
-  // Width of children is our size minus border
-  Vector3 childSize( size.width - mBorder.width * 2.0f,
-                     size.height - mBorder.height * 2.0f );
-
-  // Our children should be set to the childSize
-  ActorContainer children( Self().GetChildren() );
-  for ( ActorIter iter = children.begin(), endIter = children.end();
-        iter != endIter;
-        ++iter )
-  {
-    Relayout( *iter, childSize, container );
-  }
-}
+image.SetResizePolicy( FILL_TO_PARENT, WIDTH );
+image.SetDimensionDependency( HEIGHT, WIDTH );
+image.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 0.0f ) );
 @endcode
+The sub table view is similar as well in that it expands its width to the size of its cell. When it is added to the table view it
+will span two columns. Its height is set to natural size so that it will grow or shrink based on its children cells. Note that for
+a container like table view, USE_NATURAL_SIZE acts in a similar manner to FIT_TO_CHILDREN in that the size of the container could
+grow or shrink based on the sizes of the child actors.
+@code
+root.SetResizePolicy( FILL_TO_PARENT, WIDTH );
+root.SetResizePolicy( USE_NATURAL_SIZE, HEIGHT );
+@endcode
+The checkbox is set to have a fixed size.
+@code
+checkBox.SetResizePolicy( FIXED, ALL_DIMENSIONS );
+@endcode
+The second text view has not specified a resize policy so will use its default of USE_NATURAL_SIZE.
+
+<h2 class="pg">Debugging</h2>
+
+When constructing large scenes using interacting resize policies it is useful to be able to debug the relayout process. The following sections
+describe a pitfall to avoid when creating scenes and a way to print debug output about the actors.
+
+<h3>Infinite Dependency Loops</h3>
+Despite the power of the resize rules there is one pitfall to be aware of: infinite dependency loops. The most simplest form of this is
+shown by a parent actor with resize policy set to FIT_TO_CHILDREN with a child that has a resize policy of FILL_TO_PARENT. Who should
+determine the size in this case? A more complex loop occurs when DIMENSION_DEPENDENCY comes into play. Say a parent has a width policy
+of DIMENSION_DEPENDENCY with height and a height policy of FIT_TO_CHILDREN. The parent has a single child with a height policy DIMENSION_DEPENDENCY
+with width. If the child's width policy is FILL_TO_PARENT then a loop will occur. These are two simple examples but the loops could occur
+over larger spreads of parent child relationships. These loops are detected by the relayout algorithm with the result being that actors will
+receive zero sizes. These loops are not common but are still something to watch out for.
+
+<h3 class="pg">Inspecting Actor Relayout Properties</h3>
+To get a print out of the stage hierarchy before and after negotiation, with a list of actors that were negotiated set the LOG_RELAYOUT_CONTROLLER environment variable to 3,true.
+
+E.g. On desktop run:
+
+$  LOG_RELAYOUT_CONTROLLER=3,true dali-demo
+
+Example output from the logging is as follows:
+
+PushButton, OKAY_BUTTON - Pos: [185, 0, 0.1] Size: [165, 76, 76], Dirty: (FALSE,FALSE), Negotiated: (TRUE,TRUE), Enabled: TRUE, (0x1649850)
 
-The Relayout method will add ControlB's children to the size negotiation algorithm container where the child's size will be negotiated. Control E's
-size will be negotiated with the childSize as the allocation.
+The format is as follows:
 
+[Actor type], [Actor name] â€“ Pos:[X, Y, Z] Size[WIDTH, HEIGHT, DEPTH], Dirty:(WIDTH, HEIGHT), Negotiated: (WIDTH, HEIGHT), Enabled: BOOLEAN, (Object address)
+- <i>Actor type</i>: The type name of the actor E.g. PushButton
+- <i>Actor name</i>: The name set on the actor with SetName(). Useful for debugging.
+- <i>Pos</i>: The position of the actor
+- <i>Size</i>: The current size of the actor. Check this to see if the actor has been negotiated correctly.
+- <i>Dirty</i>: Booleans to say if the width or height has been marked as dirty by the relayout dirty flag propagation algorithm
+- <i>Negotiated</i>: Booleans to say if the width or height has been negotiated by the size negotiation algorithm
+- <i>Enabled</i>: Boolean to say if the actor is enabled for size negotitation
+- <i>Object address</i>: The address of the actor object in memory
 *
 */
index 22bac10..8b2c7c7 100644 (file)
@@ -1,6 +1,6 @@
 Name:       dali-toolkit
 Summary:    The OpenGLES Canvas Core Library Toolkit
-Version:    1.0.34
+Version:    1.0.35
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0
index a83df51..98e9c17 100644 (file)
@@ -5,7 +5,13 @@
 
 Shader effects provide a visual effect for actors.
 
-For a Custom shader you can provide the vertex and fragment shader code as strings.
+You can create a type-registered shader effect by its type name.
+```
+// create a new shader effect
+var shader = new dali.ShaderEffect("BlindEffect");
+```
+
+Alternatively you can create a Custom shader by providing the vertex and fragment shader code as strings.
 Each shader is provided with default uniforms and attributes.
 For a vertex shader this part contains the following code:
 ```
index ef35cf9..91b3661 100644 (file)
@@ -20,6 +20,7 @@ script_v8_plugin_src_files = \
    $(v8_plugin_dir)/animation/animation-api.cpp \
    $(v8_plugin_dir)/animation/animation-wrapper.cpp \
    $(v8_plugin_dir)/animation/path-api.cpp \
+   $(v8_plugin_dir)/animation/path-constraint-wrapper.cpp \
    $(v8_plugin_dir)/animation/path-wrapper.cpp \
    $(v8_plugin_dir)/stage/stage-wrapper.cpp \
    $(v8_plugin_dir)/events/event-object-generator.cpp \
index c169b2a..926c5cd 100644 (file)
@@ -24,6 +24,7 @@
 // INTERNAL INCLUDES
 #include <v8-utils.h>
 #include <actors/actor-wrapper.h>
+#include <animation/path-constraint-wrapper.h>
 
 namespace Dali
 {
@@ -609,6 +610,111 @@ void ActorApi::ScaleBy( const v8::FunctionCallbackInfo<v8::Value>& args )
   actor.ScaleBy( vector );
 }
 
+void ActorApi::ApplyPathConstraint( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+  v8::Isolate* isolate = args.GetIsolate();
+  v8::HandleScope handleScope( isolate );
+
+  //Get target actor
+  Actor targetActor = GetActor( isolate, args );
+
+  //Get PathConstraint
+  bool found(false);
+  Handle pathConstraintHandle =  V8Utils::GetHandleParameter(PARAMETER_0, found, isolate, args );
+  if( !found )
+  {
+    DALI_SCRIPT_EXCEPTION( isolate, "bad parameter 0 (PathConstraint)" );
+    return;
+  }
+  PathConstraint pathConstraint = PathConstraint::DownCast(pathConstraintHandle);
+
+  //Get target property
+  std::string propertyName = V8Utils::GetStringParameter( PARAMETER_1, found, isolate, args );
+  if(!found)
+  {
+    DALI_SCRIPT_EXCEPTION( isolate, "bad parameter 1 (Property name)" );
+    return;
+  }
+
+  // try both properties with dashes and without
+  Property::Index targetPropertyIndex = targetActor.GetPropertyIndex( propertyName );
+  if( targetPropertyIndex == Property::INVALID_INDEX )
+  {
+    std::string convertedName = V8Utils::JavaScriptNameToPropertyName( propertyName );
+    targetPropertyIndex = targetActor.GetPropertyIndex( convertedName );
+
+    if( targetPropertyIndex == Property::INVALID_INDEX )
+    {
+      DALI_SCRIPT_EXCEPTION( isolate, "Property not found" );
+    }
+  }
+
+  //Get source actor
+  Actor sourceActor = V8Utils::GetActorParameter( PARAMETER_2, found, isolate, args );
+  if( !found )
+  {
+    DALI_SCRIPT_EXCEPTION( isolate, "bad parameter 2 (Actor)" );
+  }
+
+  // try both properties with dashes and without
+  propertyName = V8Utils::GetStringParameter( PARAMETER_3, found, isolate, args );
+  if(!found)
+  {
+    DALI_SCRIPT_EXCEPTION( isolate, "bad parameter 3 (Property name)" );
+    return;
+  }
+
+  Property::Index sourcePropertyIndex = sourceActor.GetPropertyIndex( propertyName );
+  if( sourcePropertyIndex == Property::INVALID_INDEX )
+  {
+    std::string convertedName = V8Utils::JavaScriptNameToPropertyName( propertyName );
+    sourcePropertyIndex = sourceActor.GetPropertyIndex( convertedName );
+
+    if( sourcePropertyIndex == Property::INVALID_INDEX )
+    {
+      DALI_SCRIPT_EXCEPTION( isolate, "Property not found" );
+      return;
+    }
+  }
+
+  //Check if forward vector is specified
+  Vector3 forward( 0.0f,0.0f,0.0f);
+  if( args.Length() > 4 )
+  {
+    forward =  V8Utils::GetVector3Parameter( PARAMETER_4, found, isolate, args );
+    if( !found )
+    {
+      DALI_SCRIPT_EXCEPTION( isolate, "bad parameter 4 (Vector3)" );
+      return;
+    }
+  }
+
+  pathConstraint.Apply( Dali::Property(sourceActor,sourcePropertyIndex),
+                        Dali::Property(targetActor,targetPropertyIndex),
+                        forward );
+
+}
+
+void ActorApi::RemovePathConstraint( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+  v8::Isolate* isolate = args.GetIsolate();
+  v8::HandleScope handleScope( isolate );
+
+  //Get target actor
+  Actor actor = GetActor( isolate, args );
+
+  //Get PathConstraint
+  bool found(false);
+  Handle pathConstraintHandle =  V8Utils::GetHandleParameter(PARAMETER_0, found, isolate, args );
+  if( !found )
+  {
+    DALI_SCRIPT_EXCEPTION( isolate, "bad parameter 0 (PathConstraint)" );
+    return;
+  }
+  PathConstraint pathConstraint = PathConstraint::DownCast(pathConstraintHandle);
+  pathConstraint.Remove(actor);
+}
+
 } // namespace V8Plugin
 
 } // namespace Dali
index 8543f11..509c976 100644 (file)
@@ -68,6 +68,12 @@ namespace ActorApi
   void RotateBy( const v8::FunctionCallbackInfo< v8::Value >& args );
   void ScaleBy( const v8::FunctionCallbackInfo< v8::Value >& args );
 
+  // new function just for JavaScript API, to apply a PathConstraint to an actor
+  void ApplyPathConstraint( const v8::FunctionCallbackInfo< v8::Value >& args );
+
+  // new function just for JavaScript API, to remove a PathConstraint from an actor
+  void RemovePathConstraint( const v8::FunctionCallbackInfo< v8::Value >& args );
+
   // new function just for JavaScript API, to help developers know what type of actor
   // they're dealing with, returns actor name as a string
   void GetActorType( const v8::FunctionCallbackInfo< v8::Value >& args );
index 5916dd2..112dfeb 100644 (file)
@@ -197,6 +197,8 @@ const ActorFunctions ActorFunctionTable[]=
     { "FindChildById",     ActorApi::FindChildById,    ACTOR_API },
     { "GetParent" ,        ActorApi::GetParent,        ACTOR_API },
     { "GetActorType" ,     ActorApi::GetActorType,     ACTOR_API }, // custom for javascript
+    { "ApplyPathConstraint",  ActorApi::ApplyPathConstraint,  ACTOR_API }, // custom for javascript
+    { "RemovePathConstraint", ActorApi::RemovePathConstraint, ACTOR_API }, // custom for javascript
 
     // ignore. SetParentOrigin() use Actor.parentOrigin
     // ignore. GetCurrentParentOrigin()  use Actor.parentOrigin
index ab6999b..06b2e06 100644 (file)
@@ -51,8 +51,7 @@ public:
     MESH_ACTOR   =2,
     LAYER_ACTOR  =3,
     CAMERA_ACTOR =4,
-    LIGHT_ACTOR  =5,
-    TEXT_LABEL   =6
+    TEXT_LABEL   =5
   };
 
   /**
diff --git a/plugins/dali-script-v8/src/animation/path-constraint-wrapper.cpp b/plugins/dali-script-v8/src/animation/path-constraint-wrapper.cpp
new file mode 100644 (file)
index 0000000..72434d9
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2015 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 "path-constraint-wrapper.h"
+
+// INTERNAL INCLUDES
+#include <v8-utils.h>
+#include <dali-wrapper.h>
+#include <shared/object-template-helper.h>
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+PathConstraintWrapper::PathConstraintWrapper( PathConstraint pathConstraint, GarbageCollectorInterface& gc )
+:HandleWrapper( BaseWrappedObject::PATH_CONSTRAINT, pathConstraint, gc ),
+ mPathConstraint( pathConstraint )
+{
+}
+
+v8::Handle<v8::ObjectTemplate> PathConstraintWrapper::MakePathConstraintTemplate( v8::Isolate* isolate )
+{
+  v8::EscapableHandleScope handleScope( isolate );
+
+  v8::Local<v8::ObjectTemplate> objTemplate = v8::ObjectTemplate::New();
+  objTemplate->SetInternalFieldCount( BaseWrappedObject::FIELD_COUNT );
+
+  // property handle intercepts property getters and setters and signals
+  HandleWrapper::AddInterceptsToTemplate( isolate, objTemplate );
+
+  return handleScope.Escape( objTemplate );
+}
+
+v8::Handle<v8::Object> PathConstraintWrapper::WrapPathConstraint( v8::Isolate* isolate, PathConstraint pathConstraint )
+{
+  v8::EscapableHandleScope handleScope( isolate );
+  v8::Local<v8::ObjectTemplate> objectTemplate;
+
+  objectTemplate = MakePathConstraintTemplate( isolate );
+
+  // create an instance of the template
+  v8::Local<v8::Object> localObject = objectTemplate->NewInstance();
+
+  // create the pathconstraint object
+  PathConstraintWrapper* pointer = new PathConstraintWrapper( pathConstraint, Dali::V8Plugin::DaliWrapper::Get().GetDaliGarbageCollector() );
+
+  // assign the JavaScript object to the wrapper.
+  // This also stores Dali object, in an internal field inside the JavaScript object.
+  pointer->SetJavascriptObject( isolate, localObject );
+
+  return handleScope.Escape( localObject );
+}
+
+PathConstraint PathConstraintWrapper::GetPathConstraint()
+{
+  return mPathConstraint;
+}
+
+/**
+ * Create an initialized PathConstraint handle.
+ * @constructor
+ * @for Path
+ * @method Path
+ */
+void PathConstraintWrapper::NewPathConstraint( const v8::FunctionCallbackInfo< v8::Value >& args)
+{
+  v8::Isolate* isolate = args.GetIsolate();
+  v8::HandleScope handleScope( isolate );
+
+  if( !args.IsConstructCall() )
+  {
+    DALI_SCRIPT_EXCEPTION( isolate, "constructor called without 'new" );
+    return;
+  }
+
+  //Extract Path Handle
+  bool parameterFound;
+  Handle pathHandle = V8Utils::GetHandleParameter( PARAMETER_0, parameterFound, isolate, args );
+  if( !parameterFound )
+  {
+    DALI_SCRIPT_EXCEPTION( isolate, "bad parameter 0 (Path)" );
+    return;
+  }
+  Dali::Path path = Path::DownCast(pathHandle);
+
+  //Extract range
+  Vector2 range = V8Utils::GetVector2Parameter( PARAMETER_1, parameterFound, isolate, args );
+  if( !parameterFound )
+  {
+    DALI_SCRIPT_EXCEPTION( isolate, "bad parameter 1 (Range)" );
+    return;
+  }
+
+  PathConstraint pathConstraint = PathConstraint::New(path, range );
+  v8::Local<v8::Object> localObject = WrapPathConstraint( isolate, pathConstraint );
+  args.GetReturnValue().Set( localObject );
+}
+
+
+} // namespace V8Plugin
+
+} // namespace Dali
diff --git a/plugins/dali-script-v8/src/animation/path-constraint-wrapper.h b/plugins/dali-script-v8/src/animation/path-constraint-wrapper.h
new file mode 100644 (file)
index 0000000..bbc4c92
--- /dev/null
@@ -0,0 +1,83 @@
+#ifndef __DALI_V8PLUGIN_PATH_CONSTRAINT_WRAPPER_H__
+#define __DALI_V8PLUGIN_PATH_CONSTRAINT_WRAPPER_H__
+
+/*
+ * Copyright (c) 2015 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 <v8.h>
+#include <dali/public-api/animation/path-constraint.h>
+
+// INTERNAL INCLUDES
+#include <object/handle-wrapper.h>
+
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+/**
+ * Wraps a Path.
+ */
+class PathConstraintWrapper : public HandleWrapper
+{
+
+public:
+
+  /**
+   * Constructor
+   */
+  PathConstraintWrapper( PathConstraint pathConstraint, GarbageCollectorInterface& gc );
+
+  /**
+   * Virtual destructor
+   */
+  virtual ~PathConstraintWrapper(){};
+
+  /**
+   * Creates a new PathConstraint wrapped inside a Javascript Object.
+   * @param[in] args v8 function call arguments interpreted
+   */
+  static void NewPathConstraint( const v8::FunctionCallbackInfo< v8::Value >& args);
+
+  /**
+   * Wraps a PathConstraint inside a Javascript object
+   */
+  static v8::Handle<v8::Object> WrapPathConstraint(v8::Isolate* isolate, PathConstraint pathConstraint );
+
+  /*
+   * Get the wrapped PathConstraint
+   */
+  PathConstraint GetPathConstraint();
+
+private:
+
+  /**
+   * Create a v8 object template for the PathConstraint
+   */
+  static v8::Handle<v8::ObjectTemplate> MakePathConstraintTemplate( v8::Isolate* isolate );
+
+  PathConstraint mPathConstraint;
+};
+
+} // namespace V8Plugin
+
+} // namespace Dali
+
+#endif // header
index e7c4c16..938e485 100644 (file)
@@ -202,7 +202,6 @@ const IntegerPair EnumTable[] =
     { "CULL_FRONT_AND_BACK_FACE",                           CullFrontAndBack },
 
     { "USE_OWN_SIZE",                                       USE_OWN_SIZE },
-    { "SIZE_EQUAL_TO_PARENT",                               SIZE_EQUAL_TO_PARENT },
     { "SIZE_RELATIVE_TO_PARENT",                            SIZE_RELATIVE_TO_PARENT },
     { "SIZE_FIXED_OFFSET_FROM_PARENT",                      SIZE_FIXED_OFFSET_FROM_PARENT },
 
index 20fa9f6..f674551 100644 (file)
@@ -27,6 +27,7 @@
 #include <image/image-attributes-wrapper.h>
 #include <image/image-wrapper.h>
 #include <animation/path-wrapper.h>
+#include <animation/path-constraint-wrapper.h>
 #include <animation/animation-wrapper.h>
 #include <events/pan-gesture-detector-wrapper.h>
 #include <shader-effects/shader-effect-wrapper.h>
@@ -59,6 +60,7 @@ const ApiFunction ConstructorFunctionTable[]=
     { "Rotation",           PropertyValueWrapper::NewRotation},
     { "Matrix",             PropertyValueWrapper::NewMatrix},
     { "Path",               PathWrapper::NewPath },
+    { "PathConstraint",     PathConstraintWrapper::NewPathConstraint },
     { "Actor",              ActorWrapper::NewActor },
     { "TextActor",          ActorWrapper::NewActor },
     { "ImageActor",         ActorWrapper::NewActor },
index a793c07..4d65e64 100644 (file)
@@ -19,6 +19,9 @@
 // CLASS HEADER
 #include "shader-effect-api.h"
 
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/type-registry.h>
+
 // INTERNAL INCLUDES
 #include <v8-utils.h>
 #include <shader-effects/shader-effect-wrapper.h>
@@ -186,14 +189,12 @@ ShaderEffect GetShaderEffect( v8::Isolate* isolate, const v8::FunctionCallbackIn
  */
 ShaderEffect ShaderEffectApi::New(  v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
 {
-
-
   v8::HandleScope handleScope( isolate );
 
-  ShaderParameters shaderParams;
-
   if( args[0]->IsObject() )
   {
+    ShaderParameters shaderParams;
+
     v8::Local<v8::Object > obj = args[0]->ToObject();
 
     v8::Local<v8::Value> geometryTypeValue = obj->Get(v8::String::NewFromUtf8( isolate, "geometryType"));
@@ -244,9 +245,39 @@ ShaderEffect ShaderEffectApi::New(  v8::Isolate* isolate, const v8::FunctionCall
       }
       shaderParams.ProcessHintsArray( hintsArray );
     }
+
+    return shaderParams.NewShader();
   }
-  return shaderParams.NewShader();
+  else
+  {
+    ShaderEffect effect;
+
+    bool found( false );
+    std::string typeName = V8Utils::GetStringParameter( PARAMETER_0, found, isolate, args );
+    if( !found )
+    {
+      DALI_SCRIPT_EXCEPTION( isolate, "string parameter missing" );
+    }
+    else
+    {
+      // create a new shader effect based on type, using the type registry.
+      Dali::TypeInfo typeInfo = Dali::TypeRegistry::Get().GetTypeInfo( typeName );
+      if( typeInfo ) // handle, check if it has a value
+      {
+        Dali::BaseHandle handle = typeInfo.CreateInstance();
+        if( handle )
+        {
+          effect = ShaderEffect::DownCast( handle );
+        }
+      }
+      else
+      {
+        DALI_SCRIPT_EXCEPTION(isolate,"Unknown shader effect type");
+      }
+    }
 
+    return effect;
+  }
 }
 
 ShaderEffect ShaderEffectApi::GetShaderEffectFromParams( int paramIndex,
index 04ae5fa..89f4ebe 100644 (file)
@@ -126,8 +126,11 @@ void ShaderEffectWrapper::NewShaderEffect( const v8::FunctionCallbackInfo< v8::V
   }
   Dali::ShaderEffect shaderEffect = ShaderEffectApi::New( isolate, args );
 
-  v8::Local<v8::Object> localObject = WrapShaderEffect( isolate, shaderEffect );
-  args.GetReturnValue().Set( localObject );
+  if(shaderEffect)
+  {
+    v8::Local<v8::Object> localObject = WrapShaderEffect( isolate, shaderEffect );
+    args.GetReturnValue().Set( localObject );
+  }
 }
 
 
index 7e473cd..fee9d8c 100644 (file)
@@ -71,6 +71,7 @@ public:
       CONNECTION,
       ANIMATION,
       PATH,
+      PATH_CONSTRAINT,
       BUILDER,
       STAGE,
       FONT,
index e8933be..534c547 100644 (file)
@@ -46,6 +46,7 @@ enum
   PARAMETER_1 = 1,   ///< second parameter of a function call
   PARAMETER_2 = 2,   ///< third parameter of a function call
   PARAMETER_3 = 3,   ///< forth parameter of a function call
+  PARAMETER_4 = 4,   ///< fifth parameter of a function call
 };
 
 #define DALI_SCRIPT_EXCEPTION( isolate, message ) V8Utils::ScriptError( __FUNCTION__ , isolate, message );