Merge "Changed ImageView to use a unit square mesh and instead to size the mesh in...
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Wed, 22 Jul 2015 14:15:15 +0000 (07:15 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Wed, 22 Jul 2015 14:15:16 +0000 (07:15 -0700)
39 files changed:
automated-tests/src/dali-toolkit-internal/utc-Dali-Text-MultiLanguage.cpp
automated-tests/src/dali-toolkit/CMakeLists.txt
automated-tests/src/dali-toolkit/utc-Dali-Button.cpp
automated-tests/src/dali-toolkit/utc-Dali-GaussianBlurView.cpp
automated-tests/src/dali-toolkit/utc-Dali-ItemLayout.cpp
automated-tests/src/dali-toolkit/utc-Dali-PushButton.cpp
automated-tests/src/dali-toolkit/utc-Dali-RadioButton.cpp
automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp
automated-tests/src/dali-toolkit/utc-Dali-Toolkit.cpp [new file with mode: 0644]
dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h
dali-toolkit/internal/controls/buttons/button-impl.cpp
dali-toolkit/internal/controls/buttons/button-impl.h
dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp
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/scrollable/item-view/item-view-impl.cpp
dali-toolkit/internal/controls/scrollable/item-view/item-view-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/text/bidirectional-support.cpp
dali-toolkit/internal/text/bidirectional-support.h
dali-toolkit/internal/text/layouts/layout-engine.cpp
dali-toolkit/internal/text/layouts/layout-parameters.h
dali-toolkit/internal/text/multi-language-support-impl.cpp
dali-toolkit/internal/text/multi-language-support-impl.h
dali-toolkit/internal/text/multi-language-support.cpp
dali-toolkit/internal/text/multi-language-support.h
dali-toolkit/internal/text/shaper.cpp
dali-toolkit/internal/text/shaper.h
dali-toolkit/internal/text/text-controller-impl.cpp
dali-toolkit/internal/text/text-controller.cpp
dali-toolkit/public-api/controls/buttons/button.cpp
dali-toolkit/public-api/controls/buttons/button.h
dali-toolkit/public-api/controls/buttons/push-button.cpp
dali-toolkit/public-api/controls/buttons/push-button.h
dali-toolkit/public-api/controls/buttons/radio-button.cpp
dali-toolkit/public-api/controls/buttons/radio-button.h
dali-toolkit/public-api/controls/image-view/image-view.h

index 4b89f25..410c34f 100644 (file)
@@ -68,23 +68,17 @@ bool ScriptsTest( const ScriptsData& data )
                                                    &utf32[0u] );
   utf32.Resize( numberOfCharacters );
 
-  // 2) Set the line break info.
-  Vector<LineBreakInfo> lineBreakInfo;
-  lineBreakInfo.Resize( numberOfCharacters );
-
-  SetLineBreakInfo( utf32, lineBreakInfo );
-
-  // 3) Set the script info.
+  // 2) Set the script info.
   Vector<ScriptRun> scripts;
   multilanguageSupport.SetScripts( utf32,
-                                   lineBreakInfo,
                                    scripts );
 
-  // 4) Compare the results.
+  // 3) Compare the results.
 
+  tet_printf( "Testing %s\n", data.description.c_str() );
   if( scripts.Count() != data.scriptRuns.Count() )
   {
-    tet_infoline("ScriptsTest: different number of scripts.");
+    tet_printf("ScriptsTest FAIL: different number of scripts. %d, should be %d\n", scripts.Count(), data.scriptRuns.Count() );
     return false;
   }
 
@@ -95,19 +89,19 @@ bool ScriptsTest( const ScriptsData& data )
 
     if( scriptRun1.characterRun.characterIndex != scriptRun2.characterRun.characterIndex )
     {
-      tet_infoline("ScriptsTest: different character index.");
+      tet_printf("ScriptsTest FAIL: different character index. %d, should be %d\n", scriptRun1.characterRun.characterIndex, scriptRun2.characterRun.characterIndex );
       return false;
     }
 
     if( scriptRun1.characterRun.numberOfCharacters != scriptRun2.characterRun.numberOfCharacters )
     {
-      tet_infoline("ScriptsTest: different number of characters.");
+      tet_printf("ScriptsTest FAIL: different number of characters. %d, should be %d\n", scriptRun1.characterRun.numberOfCharacters, scriptRun2.characterRun.numberOfCharacters );
       return false;
     }
 
     if( scriptRun1.script != scriptRun2.script )
     {
-      tet_infoline("ScriptsTest: different script.");
+      tet_printf("ScriptsTest FAIL: different script. %s, should be %s\n", TextAbstraction::ScriptName[scriptRun1.script], TextAbstraction::ScriptName[scriptRun2.script] );
       return false;
     }
   }
@@ -128,20 +122,13 @@ bool ValidateFontTest( const ValidateFontsData& data )
                                                    &utf32[0u] );
   utf32.Resize( numberOfCharacters );
 
-  // 2) Set the line break info.
-  Vector<LineBreakInfo> lineBreakInfo;
-  lineBreakInfo.Resize( numberOfCharacters );
-
-  SetLineBreakInfo( utf32, lineBreakInfo );
-
-  // 3) Set the script info.
+  // 2) Set the script info.
   Vector<ScriptRun> scripts;
   multilanguageSupport.SetScripts( utf32,
-                                   lineBreakInfo,
                                    scripts );
 
   Vector<FontRun> fonts;
-  // 4) Validate the fonts
+  // 3) Validate the fonts
   multilanguageSupport.ValidateFonts( utf32,
                                       scripts,
                                       fonts );
@@ -190,6 +177,249 @@ int UtcDaliTextMultiLanguageSetScripts(void)
   };
   scriptRuns01.PushBack( scriptRun0100 );
 
+  // Mix of LTR '\n'and RTL
+  Vector<ScriptRun> scriptRuns02;
+  ScriptRun scriptRun0200 =
+  {
+    0u,
+    12u,
+    TextAbstraction::LATIN
+  };
+  ScriptRun scriptRun0201 =
+  {
+    12u,
+    13u,
+    TextAbstraction::ARABIC
+  };
+  scriptRuns02.PushBack( scriptRun0200 );
+  scriptRuns02.PushBack( scriptRun0201 );
+
+  // Mix of RTL '\n'and LTR
+  Vector<ScriptRun> scriptRuns03;
+  ScriptRun scriptRun0300 =
+  {
+    0u,
+    14u,
+    TextAbstraction::ARABIC
+  };
+  ScriptRun scriptRun0301 =
+  {
+    14u,
+    11u,
+    TextAbstraction::LATIN
+  };
+  scriptRuns03.PushBack( scriptRun0300 );
+  scriptRuns03.PushBack( scriptRun0301 );
+
+  // White spaces. At the beginning of the text.
+  Vector<ScriptRun> scriptRuns04;
+  ScriptRun scriptRun0400 =
+  {
+    0u,
+    16u,
+    TextAbstraction::LATIN
+  };
+  scriptRuns04.PushBack( scriptRun0400 );
+
+  // White spaces. At the end of the text.
+  Vector<ScriptRun> scriptRuns05;
+  ScriptRun scriptRun0500 =
+  {
+    0u,
+    16u,
+    TextAbstraction::LATIN
+  };
+  scriptRuns05.PushBack( scriptRun0500 );
+
+  // White spaces. At the middle of the text.
+  Vector<ScriptRun> scriptRuns06;
+  ScriptRun scriptRun0600 =
+  {
+    0u,
+    16u,
+    TextAbstraction::LATIN
+  };
+  scriptRuns06.PushBack( scriptRun0600 );
+
+  // White spaces between different scripts.
+  Vector<ScriptRun> scriptRuns07;
+  ScriptRun scriptRun0700 =
+  {
+    0u,
+    8u,
+    TextAbstraction::LATIN
+  };
+  ScriptRun scriptRun0701 =
+  {
+    8u,
+    5u,
+    TextAbstraction::HANGUL
+  };
+  scriptRuns07.PushBack( scriptRun0700 );
+  scriptRuns07.PushBack( scriptRun0701 );
+
+  // White spaces between different scripts and differetn directions. Starting LTR.
+  Vector<ScriptRun> scriptRuns08;
+  ScriptRun scriptRun0800 =
+  {
+    0u,
+    18u,
+    TextAbstraction::LATIN
+  };
+  ScriptRun scriptRun0801 =
+  {
+    18u,
+    14u,
+    TextAbstraction::ARABIC
+  };
+  ScriptRun scriptRun0802 =
+  {
+    32u,
+    18u,
+    TextAbstraction::HANGUL
+  };
+  scriptRuns08.PushBack( scriptRun0800 );
+  scriptRuns08.PushBack( scriptRun0801 );
+  scriptRuns08.PushBack( scriptRun0802 );
+
+  // White spaces between different scripts and differetn directions. Starting RTL.
+  Vector<ScriptRun> scriptRuns09;
+  ScriptRun scriptRun0900 =
+  {
+    0u,
+    21u,
+    TextAbstraction::ARABIC
+  };
+  ScriptRun scriptRun0901 =
+  {
+    21u,
+    16u,
+    TextAbstraction::LATIN
+  };
+  ScriptRun scriptRun0902 =
+  {
+    37u,
+    10u,
+    TextAbstraction::HANGUL
+  };
+  ScriptRun scriptRun0903 =
+  {
+    47u,
+    20u,
+    TextAbstraction::ARABIC
+  };
+  scriptRuns09.PushBack( scriptRun0900 );
+  scriptRuns09.PushBack( scriptRun0901 );
+  scriptRuns09.PushBack( scriptRun0902 );
+  scriptRuns09.PushBack( scriptRun0903 );
+
+  // Paragraphs with different directions.
+  Vector<ScriptRun> scriptRuns10;
+  ScriptRun scriptRun1000 =
+  {
+    0u,
+    20u,
+    TextAbstraction::ARABIC
+  };
+  ScriptRun scriptRun1001 =
+  {
+    20u,
+    12u,
+    TextAbstraction::HEBREW
+  };
+  ScriptRun scriptRun1002 =
+  {
+    32u,
+    17u,
+    TextAbstraction::ARABIC
+  };
+  ScriptRun scriptRun1003 =
+  {
+    49u,
+    18u,
+    TextAbstraction::LATIN
+  };
+  ScriptRun scriptRun1004 =
+  {
+    67u,
+    14u,
+    TextAbstraction::HANGUL
+  };
+  ScriptRun scriptRun1005 =
+  {
+    81u,
+    19u,
+    TextAbstraction::ARABIC
+  };
+  ScriptRun scriptRun1006 =
+  {
+    100u,
+    13u,
+    TextAbstraction::LATIN
+  };
+  ScriptRun scriptRun1007 =
+  {
+    113u,
+    16u,
+    TextAbstraction::HEBREW
+  };
+  ScriptRun scriptRun1008 =
+  {
+    129u,
+    20u,
+    TextAbstraction::LATIN
+  };
+  ScriptRun scriptRun1009 =
+  {
+    149u,
+    14u,
+    TextAbstraction::ARABIC
+  };
+  ScriptRun scriptRun1010 =
+  {
+    163u,
+    35u,
+    TextAbstraction::HANGUL
+  };
+  scriptRuns10.PushBack( scriptRun1000 );
+  scriptRuns10.PushBack( scriptRun1001 );
+  scriptRuns10.PushBack( scriptRun1002 );
+  scriptRuns10.PushBack( scriptRun1003 );
+  scriptRuns10.PushBack( scriptRun1004 );
+  scriptRuns10.PushBack( scriptRun1005 );
+  scriptRuns10.PushBack( scriptRun1006 );
+  scriptRuns10.PushBack( scriptRun1007 );
+  scriptRuns10.PushBack( scriptRun1008 );
+  scriptRuns10.PushBack( scriptRun1009 );
+  scriptRuns10.PushBack( scriptRun1010 );
+
+  // Paragraphs with no scripts mixed with paragraphs with scripts.
+  Vector<ScriptRun> scriptRuns11;
+  ScriptRun scriptRun1100 =
+  {
+    0u,
+    31u,
+    TextAbstraction::LATIN
+  };
+  ScriptRun scriptRun1101 =
+  {
+    31u,
+    21u,
+    TextAbstraction::HEBREW
+  };
+  scriptRuns11.PushBack( scriptRun1100 );
+  scriptRuns11.PushBack( scriptRun1101 );
+
+  // Paragraphs with no scripts.
+  Vector<ScriptRun> scriptRuns12;
+  ScriptRun scriptRun1200 =
+  {
+    0u,
+    11u,
+    TextAbstraction::LATIN
+  };
+  scriptRuns12.PushBack( scriptRun1200 );
+
   const ScriptsData data[] =
   {
     {
@@ -202,8 +432,67 @@ int UtcDaliTextMultiLanguageSetScripts(void)
       "Hello world",
       scriptRuns01,
     },
+    {
+      "Mix of LTR '\\n'and RTL",
+      "Hello world\nمرحبا بالعالم",
+      scriptRuns02,
+    },
+    {
+      "Mix of RTL '\\n'and LTR",
+      "مرحبا بالعالم\nHello world",
+      scriptRuns03,
+    },
+    {
+      "White spaces. At the beginning of the text.",
+      "    Hello world.",
+      scriptRuns04,
+    },
+    {
+      "White spaces. At the end of the text.",
+      "Hello world.    ",
+      scriptRuns05,
+    },
+    {
+      "White spaces. At the middle of the text.",
+      "Hello     world.",
+      scriptRuns06,
+    },
+    {
+      "White spaces between different scripts.",
+      "  Hel   세계   ",
+      scriptRuns07,
+    },
+    {
+      "White spaces between different scripts and differetn directions. Starting LTR.",
+      "  Hello   world   مرحبا  بالعالم     안녕하세요   세계   ",
+      scriptRuns08,
+    },
+    {
+      "White spaces between different scripts and differetn directions. Starting RTL.",
+      "   مرحبا  بالعالم    Hello   world   안녕하세요   세계   مرحبا  بالعالم   ",
+      scriptRuns09
+    },
+    {
+      "Paragraphs with different directions.",
+      "   مرحبا  بالعالم   שלום עולם   مرحبا  بالعالم  \n "
+      " Hello   world   안녕하세요   세계   \n "
+      "  مرحبا  بالعالم  Hello   world    שלום עולם  \n  "
+      " Hello   world    مرحبا  بالعالم    안녕하세요   세계   \n "
+      "   안녕하세요   세계   ",
+      scriptRuns10
+    },
+    {
+      "Paragraphs with no scripts mixed with paragraphs with scripts.",
+      "  \n  \n   Hello   world  \n  \n  \n   שלום עולם  \n \n \n  ",
+      scriptRuns11
+    },
+    {
+      "Paragraphs with no scripts.",
+      "  \n  \n  \n  ",
+      scriptRuns12
+    }
   };
-  const unsigned int numberOfTests = 2u;
+  const unsigned int numberOfTests = 13u;
 
   for( unsigned int index = 0u; index < numberOfTests; ++index )
   {
index c75e082..2b1858e 100644 (file)
@@ -46,6 +46,7 @@ SET(TC_SOURCES
    utc-Dali-ScrollViewEffect.cpp
    utc-Dali-StyleManager.cpp
    utc-Dali-SuperBlurView.cpp
+   utc-Dali-Toolkit.cpp
 )
 
 # Append list of test harness files (Won't get parsed for test cases)
index 3e7f4cf..990be9c 100644 (file)
@@ -310,9 +310,9 @@ int UtcDaliButtonSetLabelStringP(void)
 
   Button button = PushButton::New();
 
-  button.SetLabel( "Button Label" );
+  button.SetLabelText( "Button Label" );
 
-  DALI_TEST_CHECK( button.GetLabel() );
+  DALI_TEST_EQUALS( button.GetLabelText(), "Button Label", TEST_LOCATION );
   END_TEST;
 }
 
@@ -322,19 +322,16 @@ int UtcDaliButtonSetLabelActorP(void)
 
   Button button = PushButton::New();
 
-  TextLabel textLabel = TextLabel::New( "Button Label" );
-  button.SetLabel( textLabel );
+  button.SetLabelText( "Button Label" );
 
-  DALI_TEST_CHECK( button.GetLabel() );
+  DALI_TEST_EQUALS( button.GetLabelText(), "Button Label", TEST_LOCATION );
   END_TEST;
 }
 
-int UtcDaliButtonSetButtonImage(void)
+int UtcDaliButtonSetUnselectedImageP(void)
 {
   ToolkitTestApplication application;
-  tet_infoline(" UtcDaliButtonSetButtonImage");
-
-  Image image = CreateSolidColorImage( Color::RED, 10, 10 );
+  tet_infoline(" UtcDaliButtonSetUnselectedImageP");
 
   PushButton pushButton = PushButton::New();
   Stage::GetCurrent().Add( pushButton );
@@ -343,12 +340,13 @@ int UtcDaliButtonSetButtonImage(void)
   application.Render();
 
   pushButton.SetSize( Vector2( 20.0f, 20.0f ) );
-  pushButton.SetButtonImage( image );
+  pushButton.SetUnselectedImage( "Image.jpg" );
 
   application.SendNotification();
   application.Render();
 
   Vector3 size = pushButton.GetCurrentSize();
+  tet_printf( "todor: size: %f,%f", size.width, size.height );
 
   DALI_TEST_EQUALS( size.width, 20.f, TEST_LOCATION );
   DALI_TEST_EQUALS( size.height, 20.f, TEST_LOCATION );
@@ -361,8 +359,6 @@ int UtcDaliButtonSetSelectedImageP(void)
   ToolkitTestApplication application;
   tet_infoline(" UtcDaliButtonSetButtonImage");
 
-  Image image = CreateSolidColorImage( Color::RED, 10, 10 );
-
   PushButton pushButton = PushButton::New();
   Stage::GetCurrent().Add( pushButton );
 
@@ -370,7 +366,7 @@ int UtcDaliButtonSetSelectedImageP(void)
   application.Render();
 
   pushButton.SetSize( Vector2( 20.0f, 20.0f ) );
-  pushButton.SetSelectedImage( image );
+  pushButton.SetSelectedImage( "Image.jpg" );
 
   application.SendNotification();
   application.Render();
@@ -599,8 +595,10 @@ int UtcDaliButtonSetProperty(void)
 
   pushButton.SetProperty(pushButton.GetPropertyIndex("disabled"), false);
   DALI_TEST_CHECK( false == pushButton.IsDisabled() );
+
   pushButton.SetProperty(pushButton.GetPropertyIndex("disabled"), true);
   DALI_TEST_CHECK( true == pushButton.IsDisabled() );
+
   END_TEST;
 }
 
@@ -609,26 +607,17 @@ int UtcDaliButtonSize(void)
   ToolkitTestApplication application;
   tet_infoline(" UtcDaliButtonSize");
 
-  ImageActor image01 = ImageActor::New(CreateBufferImage());
-  image01.SetSize( 100, 50 );
-
-  PushButton pushButton;
-
-  Vector3 size;
-
-  // Test1 Size is set through Actor API
-
   // First an image is set, then SetSize is called.
-  pushButton = PushButton::New();
+  PushButton pushButton = PushButton::New();
   Stage::GetCurrent().Add( pushButton );
 
-  pushButton.SetBackgroundImage( image01 );
+  pushButton.SetBackgroundImage( "Image.jpg" );
   pushButton.SetSize( 10.f, 10.f );
 
   application.SendNotification();
   application.Render();
 
-  size = pushButton.GetCurrentSize();
+  Vector3 size = pushButton.GetCurrentSize();
 
   DALI_TEST_EQUALS( size.width, 10.f, TEST_LOCATION );
   DALI_TEST_EQUALS( size.height, 10.f, TEST_LOCATION );
index 2028c6c..f3f6f77 100644 (file)
@@ -38,7 +38,28 @@ void utc_gaussian_blur_view_cleanup(void)
   test_return_value = TET_PASS;
 }
 
+class TestCallback : public ConnectionTracker
+{
+public:
+  TestCallback( Dali::Toolkit::GaussianBlurView& blurView )
+  : mBlurView( blurView )
+  {
+    mFinished = false;
+  }
 
+  void Connect()
+  {
+    mBlurView.FinishedSignal().Connect( this, &TestCallback::OnFinished );
+  }
+
+  void OnFinished( Dali::Toolkit::GaussianBlurView source )
+  {
+    mFinished = true;
+  }
+
+  bool mFinished;
+  Dali::Toolkit::GaussianBlurView& mBlurView;
+};
 
 // Negative test case for a method
 int UtcDaliGaussianBlurViewUninitialized(void)
@@ -199,3 +220,55 @@ int UtcDaliGaussianBlurViewSetGetRenderTarget(void)
   DALI_TEST_CHECK( view.GetBlurredRenderTarget() == renderTarget );
   END_TEST;
 }
+
+int UtcDaliGaussianBlurViewActivateOnce(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliGaussianBlurActivateOnce");
+
+  Toolkit::GaussianBlurView view = Toolkit::GaussianBlurView::New(5, 1.5f, Pixel::RGB888, 0.5f, 0.5f, true);
+  DALI_TEST_CHECK( view );
+
+  RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
+  DALI_TEST_CHECK( 1u == taskList.GetTaskCount() );
+
+  view.SetParentOrigin(ParentOrigin::CENTER);
+  view.SetSize(Stage::GetCurrent().GetSize());
+  view.Add(Actor::New());
+  Stage::GetCurrent().Add(view);
+  view.ActivateOnce();
+
+  RenderTaskList taskList2 = Stage::GetCurrent().GetRenderTaskList();
+  DALI_TEST_CHECK( 1u != taskList2.GetTaskCount() );
+  application.Render();
+
+  END_TEST;
+}
+
+int UtcDaliGaussianBlurViewFinishedSignalN(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliGaussianBlurViewSetGetRenderTarget");
+
+  Toolkit::GaussianBlurView view = Toolkit::GaussianBlurView::New(5, 1.5f, Pixel::RGB888, 0.5f, 0.5f, true);
+  DALI_TEST_CHECK( view );
+
+  view.SetParentOrigin(ParentOrigin::CENTER);
+  view.SetSize(Stage::GetCurrent().GetSize());
+  view.Add(Actor::New());
+  Stage::GetCurrent().Add(view);
+  view.Activate();
+
+  TestCallback callback( view );
+  DALI_TEST_CHECK( callback.mFinished == false );
+
+  callback.Connect();
+
+  view.Deactivate();
+  application.SendNotification();
+
+  // FinishedSignal is only for ActivateOnce()
+  DALI_TEST_CHECK( callback.mFinished == false );
+
+  END_TEST;
+}
index 68938b9..c85bffd 100644 (file)
@@ -346,3 +346,24 @@ int UtcDaliItemLayoutGetNextFocusItemID(void)
   END_TEST;
 }
 
+int UtcDaliItemRangeIntersection(void)
+{
+  ToolkitTestApplication application;
+
+  unsigned int uBeginItemFirst = 100u, uEndItemFirst = 300u;
+  unsigned int uBeginItemSecond = 290u, uEndItemSecond = 400;
+  unsigned int uInterBeginCheck=290u , uInterEndCheck=301u;
+  bool bIsInThisRange = false, bOutOfThisRange = false;
+
+  Toolkit::ItemRange objItemRangeFirst(uBeginItemFirst, uEndItemFirst);
+  Toolkit::ItemRange objItemRangeSecond(uBeginItemSecond, uEndItemSecond);
+  ItemRange itmInterSect = objItemRangeFirst.Intersection(objItemRangeSecond);
+
+  bIsInThisRange = itmInterSect.Within(uInterBeginCheck);
+  DALI_TEST_EQUALS(bIsInThisRange, true, TEST_LOCATION );
+
+  bOutOfThisRange = itmInterSect.Within(uInterEndCheck);
+  DALI_TEST_EQUALS(bOutOfThisRange, false, TEST_LOCATION );
+
+  END_TEST;
+}
index 326928b..17ebc5f 100644 (file)
@@ -357,10 +357,9 @@ int UtcDaliPushButtonSetLabelText(void)
   application.SendNotification();
   application.Render();
 
-  pushButton.SetLabel( STR );
+  pushButton.SetLabelText( STR );
 
-  TextLabel label = TextLabel::DownCast( pushButton.GetLabel() );
-  DALI_TEST_CHECK( STR == label.GetProperty<std::string>( TextLabel::Property::TEXT ) );
+  DALI_TEST_EQUALS( pushButton.GetLabelText(), STR, TEST_LOCATION );
 
   END_TEST;
 }
@@ -588,3 +587,221 @@ int UtcDaliPushButtonSelected(void)
   DALI_TEST_CHECK( !gPushButtonSelectedState );
   END_TEST;
 }
+
+int UtcDaliPushButtonPropertySetIconAlignment(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliPushButtonPropertySetIconAlignment");
+
+  PushButton pushButton = PushButton::New();
+  pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "TOP" );
+  DALI_TEST_EQUALS( pushButton.GetProperty<std::string>( Toolkit::PushButton::Property::ICON_ALIGNMENT ), "TOP", TEST_LOCATION );
+
+  pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "RIGHT" );
+  DALI_TEST_EQUALS( pushButton.GetProperty<std::string>( Toolkit::PushButton::Property::ICON_ALIGNMENT ), "RIGHT", TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliPushButtonPropertySetLabelPadding(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliPushButtonPropertySetLabelPadding");
+
+  PushButton pushButton = PushButton::New();
+  pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
+  DALI_TEST_EQUALS( pushButton.GetProperty<Vector4>( Toolkit::PushButton::Property::LABEL_PADDING ), Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+  pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 10.0f, 10.0f, 10.0f, 10.0f ) );
+  DALI_TEST_EQUALS( pushButton.GetProperty<Vector4>( Toolkit::PushButton::Property::LABEL_PADDING ), Vector4( 10.0f, 10.0f, 10.0f, 10.0f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliPushButtonPropertySetIconPadding(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliPushButtonPropertySetIconPadding");
+
+  PushButton pushButton = PushButton::New();
+  pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) );
+  DALI_TEST_EQUALS( pushButton.GetProperty<Vector4>( Toolkit::PushButton::Property::ICON_PADDING ), Vector4( 1.0f, 1.0f, 1.0f, 1.0f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+  pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, Vector4( 10.0f, 10.0f, 10.0f, 10.0f ) );
+  DALI_TEST_EQUALS( pushButton.GetProperty<Vector4>( Toolkit::PushButton::Property::ICON_PADDING ), Vector4( 10.0f, 10.0f, 10.0f, 10.0f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliPushButtonPaddingLayout(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliPushButtonPaddingLayout");
+
+  // This test creates padding for an icon and a label.
+  // The icon and label are each enabled and disabled to confirm the correct padding is used.
+  PushButton pushButton = PushButton::New();
+
+  pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 10.0f, 10.0f, 10.0f, 10.0f ) );
+  pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, Vector4( 20.0f, 20.0f, 20.0f, 20.0f ) );
+
+  pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
+  pushButton.SetPosition( 0.0f, 0.0f );
+  pushButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
+
+  Stage::GetCurrent().Add( pushButton );
+
+  application.SendNotification();
+  application.Render();
+
+  // First test the size is zero.
+  // No padding should be added as there is no label or icon.
+  Vector2 size( Vector2::ZERO );
+  size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
+  size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+
+  DALI_TEST_EQUALS( size, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+  // Check label only padding.
+  pushButton.SetLabelText( "Label" );
+
+  application.SendNotification();
+  application.Render();
+
+  size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
+  size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+
+  // We should not test against the exact label size, we just make sure it is larger than our label padding so we know the padding has been applied.
+  DALI_TEST_GREATER( size.width, 20.0f, TEST_LOCATION );
+  DALI_TEST_GREATER( size.height, 20.0f, TEST_LOCATION );
+
+  // Re-initialise the button so we can setup icon-only padding.
+  pushButton.Unparent();
+  pushButton = PushButton::New();
+
+  pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 10.0f, 10.0f, 10.0f, 10.0f ) );
+  pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, Vector4( 20.0f, 20.0f, 20.0f, 20.0f ) );
+
+  pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
+  pushButton.SetPosition( 0.0f, 0.0f );
+  pushButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
+
+  Stage::GetCurrent().Add( pushButton );
+
+  const char* INVALID_IMAGE_FILE_NAME = "invalid-image.jpg";
+  pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "RIGHT" );
+  pushButton.SetProperty( Toolkit::PushButton::Property::UNSELECTED_ICON, INVALID_IMAGE_FILE_NAME );
+  pushButton.SetProperty( Toolkit::PushButton::Property::SELECTED_ICON, INVALID_IMAGE_FILE_NAME );
+
+  application.SendNotification();
+  application.Render();
+
+  size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
+  size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+
+  DALI_TEST_EQUALS( size, Vector2( 40.0f, 40.0f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+  // Now test padding for both label and icon simultaneously.
+  pushButton.SetLabelText( "Label" );
+
+  application.SendNotification();
+  application.Render();
+
+  size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
+  size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+
+  // We should not test against the exact label size, we just make sure it is larger than our label padding so we know the padding has been applied.
+  // Note we only test the width as we are horizontally aligned and the label my be less high than the icon.
+  // Full directional alignment tests are done in UtcDaliPushButtonAlignmentLayout.
+  DALI_TEST_GREATER( size.width, 60.0f, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliPushButtonAlignmentLayout(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliPushButtonAlignmentLayout");
+
+  // This test checks different alignments for the icon against the label.
+  // The icon is then moved around the label in each of it's alignments.
+  // The final relayed out size is checked to confirm the layout has been done correctly.
+  PushButton pushButton = PushButton::New();
+
+  pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 30.0f, 30.0f, 30.0f, 30.0f ) );
+  pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, Vector4( 75.0f, 75.0f, 75.0f, 75.0f ) );
+
+  pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
+  pushButton.SetPosition( 0.0f, 0.0f );
+  pushButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
+
+  Stage::GetCurrent().Add( pushButton );
+
+  const char* INVALID_IMAGE_FILE_NAME = "invalid-image.jpg";
+  pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "RIGHT" );
+  pushButton.SetProperty( Toolkit::PushButton::Property::UNSELECTED_ICON, INVALID_IMAGE_FILE_NAME );
+  pushButton.SetProperty( Toolkit::PushButton::Property::SELECTED_ICON, INVALID_IMAGE_FILE_NAME );
+
+  application.SendNotification();
+  application.Render();
+
+  // First get the base size (without label).
+  Vector2 baseSize( Vector2::ZERO );
+  baseSize.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
+  baseSize.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+
+  DALI_TEST_EQUALS( baseSize, Vector2( 150.0f, 150.0f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+  // Add a label to cause size to be modified in the direction of alignment.
+  pushButton.SetLabelText( "Label" );
+
+  application.SendNotification();
+  application.Render();
+
+  Vector2 size( Vector2::ZERO );
+  size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
+  size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+
+  DALI_TEST_GREATER( size.width, 150.0f + 60.0f, TEST_LOCATION );
+  DALI_TEST_EQUALS( size.height, 150.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+  // Now test left alignment matches right for size.
+  pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "LEFT" );
+
+  application.SendNotification();
+  application.Render();
+
+  Vector2 compareSize( Vector2::ZERO );
+  compareSize.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
+  compareSize.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+
+  DALI_TEST_EQUALS( size, compareSize, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+  // Test top alignment.
+  pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "TOP" );
+
+  application.SendNotification();
+  application.Render();
+
+  compareSize.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
+  compareSize.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+
+  DALI_TEST_EQUALS( compareSize.width, 150.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+  DALI_TEST_GREATER( compareSize.height, 150.0f + 60.0f, TEST_LOCATION );
+
+  // Test bottom alignment.
+  pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "BOTTOM" );
+
+  application.SendNotification();
+  application.Render();
+
+  size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
+  size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+
+  DALI_TEST_EQUALS( size, compareSize, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+  END_TEST;
+}
index 521d6ca..a56ad13 100644 (file)
@@ -140,14 +140,14 @@ int UtcDaliRadioButtonLabelActor(void)
 {
   ToolkitTestApplication application;
 
-  TextLabel actor1 = TextLabel::New( "test actor 1" );
+  std::string labelText = "test actor 1";
 
-  RadioButton radioButton = RadioButton::New( actor1 );
-  DALI_TEST_CHECK( actor1 == radioButton.GetLabel() );
+  RadioButton radioButton = RadioButton::New( labelText );
+  DALI_TEST_EQUALS( radioButton.GetLabelText(), labelText, TEST_LOCATION );
 
-  TextLabel actor2 = TextLabel::New( "test actor 2" );
-  radioButton.SetLabel( actor2 );
-  DALI_TEST_CHECK( actor2 == radioButton.GetLabel() );
+  std::string labelText2 = "test actor 2";
+  radioButton.SetLabelText( labelText2 );
+  DALI_TEST_EQUALS( radioButton.GetLabelText(), labelText2, TEST_LOCATION );
 
   END_TEST;
 }
index f2f0461..d5baabb 100644 (file)
@@ -2186,6 +2186,97 @@ int UtcDaliToolkitScrollViewFixedRulerSnapP(void)
   END_TEST;
 }
 
+int UtcDaliToolkitScrollViewConstraintsMove(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitScrollViewConstraintsMove");
+
+  // Set up a scrollView...
+  ScrollView scrollView = ScrollView::New();
+  Stage::GetCurrent().Add( scrollView );
+  Vector2 stageSize = Stage::GetCurrent().GetSize();
+  scrollView.SetSize(stageSize);
+  scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
+  scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+
+  // Position rulers.
+  RulerPtr rulerX = new DefaultRuler();
+  RulerPtr rulerY = new DefaultRuler();
+  rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
+  rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
+  scrollView.SetRulerX(rulerX);
+  scrollView.SetRulerY(rulerY);
+
+  // Add an Actor to ScrollView,
+  Actor a = Actor::New();
+  scrollView.Add(a);
+  a.SetPosition( TEST_ACTOR_POSITION );
+  Wait(application);
 
+  const Vector2 target = Vector2(100.0f, 100.0f);
+  const Vector2 target2 = Vector2(200.0f, 200.0f);
 
+  Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, MoveActorConstraint );
+  constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
+  constraint.SetRemoveAction(Constraint::Discard);
+  scrollView.ApplyConstraintToChildren(constraint);
 
+  scrollView.ScrollTo( target, 0.0f );
+  Wait(application);
+  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
+  scrollView.ScrollTo( target2 );
+  Wait(application, RENDER_DELAY_SCROLL);
+  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliToolkitScrollViewConstraintsWrap(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitScrollViewConstraintsWrap");
+
+  // Set up a scrollView...
+  ScrollView scrollView = ScrollView::New();
+  Stage::GetCurrent().Add( scrollView );
+  Vector2 stageSize = Stage::GetCurrent().GetSize();
+  scrollView.SetSize(stageSize);
+  scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT);
+  scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+
+  // Position rulers.
+  RulerPtr rulerX = new DefaultRuler();
+  RulerPtr rulerY = new DefaultRuler();
+  rulerX->SetDomain( RulerDomain(0.0f, stageSize.width + CLAMP_EXCESS_WIDTH, true) );
+  rulerY->SetDomain( RulerDomain(0.0f, stageSize.height + CLAMP_EXCESS_HEIGHT, true) );
+  scrollView.SetRulerX(rulerX);
+  scrollView.SetRulerY(rulerY);
+
+  // Add an Actor to ScrollView,
+  Actor a = Actor::New();
+  scrollView.Add(a);
+  a.SetPosition( TEST_ACTOR_POSITION );
+  Wait(application);
+
+  const Vector2 target = Vector2(100.0f, 100.0f);
+  const Vector2 target2 = Vector2(200.0f, 200.0f);
+
+  Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, WrapActorConstraint );
+  constraint.AddSource( LocalSource( Actor::Property::SCALE ) );
+  constraint.AddSource( LocalSource( Actor::Property::ANCHOR_POINT ) );
+  constraint.AddSource( LocalSource( Actor::Property::SIZE ) );
+  constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
+  constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
+  constraint.AddSource( Source( scrollView, Toolkit::ScrollView::Property::WRAP ) );
+  constraint.SetRemoveAction(Constraint::Discard);
+  scrollView.ApplyConstraintToChildren(constraint);
+
+  scrollView.ScrollTo( target, 0.0f );
+  Wait(application);
+  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target, TEST_LOCATION );
+  scrollView.ScrollTo( target2 );
+  Wait(application, RENDER_DELAY_SCROLL);
+  DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION );
+
+  END_TEST;
+}
diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Toolkit.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Toolkit.cpp
new file mode 100644 (file)
index 0000000..bf75f39
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ *
+ */
+
+#include <iostream>
+#include <stdlib.h>
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+
+using namespace Dali;
+using namespace Toolkit;
+
+void dali_toolkit_startup(void)
+{
+  test_return_value = TET_UNDEF;
+}
+
+void dali_toolkit_cleanup(void)
+{
+  test_return_value = TET_PASS;
+}
+
+int UtcToolkitIsVertical(void)
+{
+  ToolkitTestApplication application;
+
+  bool bRet = false;
+
+  tet_infoline(" UtcToolkitIsVertical");
+  bRet = IsVertical(ControlOrientation::Up);
+  DALI_TEST_EQUALS( bRet, true, TEST_LOCATION );
+
+  bRet = IsVertical(ControlOrientation::Down);
+  DALI_TEST_EQUALS( bRet, true, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcToolkitIsHorizontal(void)
+{
+  ToolkitTestApplication application;
+
+  bool bRet = false;
+
+  tet_infoline(" UtcToolkitIsHorizontal");
+  bRet = IsHorizontal(ControlOrientation::Left);
+  DALI_TEST_EQUALS( bRet, true, TEST_LOCATION );
+
+  bRet = IsHorizontal(ControlOrientation::Right);
+  DALI_TEST_EQUALS( bRet, true, TEST_LOCATION );
+
+  END_TEST;
+}
+
index 67a7966..fd473ad 100644 (file)
@@ -86,9 +86,10 @@ public:
       POPUP_PASTE_BUTTON_ICON_IMAGE,            ///< name "popup-paste-button-image",      The image to use as the popup paste icon,       type STRING
       POPUP_SELECT_BUTTON_ICON_IMAGE,           ///< name "popup-select-button-image",     The image to use as the popup select icon,      type STRING
       POPUP_SELECT_ALL_BUTTON_ICON_IMAGE,       ///< name "popup-select-all-button-image", The image to use as the popup select all icon,  type STRING
-      DIVIDER_COLOR,                            ///< name "popup-divider-color", VECTOR4,  The color of the divider between options,       type VECTOR4
-      ICON_COLOR,                               ///< name "popup-icon-color", VECTOR4,     The color of the icons (if supplied),           type VECTOR4
-      PRESSED_COLOR                             ///< name "popup-pressed-color", VECTOR4,  The color of the option when pressed,           type VECTOR4
+      POPUP_DIVIDER_COLOR,                      ///< name "popup-divider-color",           The color of the divider between options,       type VECTOR4
+      POPUP_ICON_COLOR,                         ///< name "popup-icon-color",              The color of the icons (if supplied),           type VECTOR4
+      POPUP_PRESSED_COLOR,                      ///< name "popup-pressed-color",           The color of the option when pressed,           type VECTOR4
+      POPUP_PRESSED_IMAGE                       ///< name "popup-pressed-image",           The image to use for the option when pressed,   type STRING
     };
   };
 
index 2883c9a..28b9d4a 100644 (file)
 // EXTERNAL INCLUDES
 #include <cstring> // for strcmp
 #include <dali/public-api/events/touch-event.h>
+#include <dali/public-api/images/resource-image.h>
 #include <dali/public-api/object/type-registry.h>
 #include <dali/devel-api/object/type-registry-helper.h>
 #include <dali/public-api/actors/image-actor.h>
 #include <dali/devel-api/scripting/scripting.h>
 
 // INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
 #include <dali-toolkit/public-api/controls/text-controls/text-label.h>
 
 /**
@@ -80,10 +82,12 @@ DALI_PROPERTY_REGISTRATION( Toolkit, Button, "initial-auto-repeating-delay", FLO
 DALI_PROPERTY_REGISTRATION( Toolkit, Button, "next-auto-repeating-delay",    FLOAT,   NEXT_AUTO_REPEATING_DELAY    )
 DALI_PROPERTY_REGISTRATION( Toolkit, Button, "togglable",                    BOOLEAN, TOGGLABLE                    )
 DALI_PROPERTY_REGISTRATION( Toolkit, Button, "selected",                     BOOLEAN, SELECTED                     )
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "normal-state-actor",           MAP,     NORMAL_STATE_ACTOR           )
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "selected-state-actor",         MAP,     SELECTED_STATE_ACTOR         )
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "disabled-state-actor",         MAP,     DISABLED_STATE_ACTOR         )
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "label-actor",                  MAP,     LABEL_ACTOR                  )
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "unselected-state-image",       STRING,  UNSELECTED_STATE_IMAGE       )
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "selected-state-image",         STRING,  SELECTED_STATE_IMAGE         )
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "disabled-state-image",         STRING,  DISABLED_STATE_IMAGE         )
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "unselected-color",             VECTOR4, UNSELECTED_COLOR             )
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "selected-color",               VECTOR4, SELECTED_COLOR               )
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "label-text",                   STRING,  LABEL_TEXT                   )
 
 DALI_SIGNAL_REGISTRATION(   Toolkit, Button, "pressed",                               SIGNAL_PRESSED               )
 DALI_SIGNAL_REGISTRATION(   Toolkit, Button, "released",                              SIGNAL_RELEASED              )
@@ -97,11 +101,15 @@ DALI_TYPE_REGISTRATION_END()
 const unsigned int INITIAL_AUTOREPEATING_DELAY( 0.15f );
 const unsigned int NEXT_AUTOREPEATING_DELAY( 0.05f );
 
+const char* const STYLE_BUTTON_LABEL = "button.label";
+
 } // unnamed namespace
 
 Button::Button()
 : Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
   mAutoRepeatingTimer(),
+  mUnselectedColor( Color::WHITE ), // The natural colors of the specified images will be used by default.
+  mSelectedColor( Color::WHITE ),
   mDisabled( false ),
   mAutoRepeating( false ),
   mTogglableButton( false ),
@@ -147,8 +155,11 @@ void Button::SetDisabled( bool disabled )
       TransitionButtonImage( mDisabledBackgroundContent );
       AddButtonImage( mUnselectedContent );
       TransitionButtonImage( mDisabledContent );
+
+      AddButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
       ReAddLabel();
 
+      TransitionOut( mDecoration[ SELECTED_DECORATION ] );
       TransitionOut( mUnselectedContent );
       TransitionOut( mSelectedContent );
       TransitionOut( mBackgroundContent );
@@ -172,8 +183,11 @@ void Button::SetDisabled( bool disabled )
       TransitionButtonImage( mDisabledBackgroundContent );
       AddButtonImage( mSelectedContent );
       TransitionButtonImage( mDisabledSelectedContent );
+
+      AddButtonImage( mDecoration[ SELECTED_DECORATION ] );
       ReAddLabel();
 
+      TransitionOut( mDecoration[ UNSELECTED_DECORATION ] );
       TransitionOut( mUnselectedContent );
       TransitionOut( mSelectedContent );
       TransitionOut( mBackgroundContent );
@@ -195,8 +209,11 @@ void Button::SetDisabled( bool disabled )
       TransitionButtonImage( mBackgroundContent );
       AddButtonImage( mDisabledContent );
       TransitionButtonImage( mUnselectedContent );
+
+      AddButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
       ReAddLabel();
 
+      TransitionOut( mDecoration[ SELECTED_DECORATION ] );
       TransitionOut( mSelectedContent );
       TransitionOut( mSelectedBackgroundContent );
       TransitionOut( mDisabledContent );
@@ -220,8 +237,11 @@ void Button::SetDisabled( bool disabled )
       TransitionButtonImage( mSelectedBackgroundContent );
       AddButtonImage( mDisabledSelectedContent );
       TransitionButtonImage( mSelectedContent );
+
+      AddButtonImage( mDecoration[ SELECTED_DECORATION ] );
       ReAddLabel();
 
+      TransitionOut( mDecoration[ UNSELECTED_DECORATION ] );
       TransitionOut( mUnselectedContent );
       TransitionOut( mDisabledContent );
       TransitionOut( mDisabledSelectedContent );
@@ -331,8 +351,12 @@ void Button::SetSelected( bool selected, bool emitSignal )
       TransitionButtonImage( mSelectedBackgroundContent );
       AddButtonImage( mUnselectedContent );
       TransitionButtonImage( mSelectedContent );
+
+      AddButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
+      TransitionButtonImage( mDecoration[ SELECTED_DECORATION ] );
       ReAddLabel();
 
+      TransitionOut( mDecoration[ UNSELECTED_DECORATION ] );
       TransitionOut( mUnselectedContent );
       TransitionOut( mDisabledContent );
       TransitionOut( mDisabledSelectedContent );
@@ -351,8 +375,12 @@ void Button::SetSelected( bool selected, bool emitSignal )
       AddButtonImage( mBackgroundContent );
       AddButtonImage( mSelectedContent );
       TransitionButtonImage( mUnselectedContent );
+
+      AddButtonImage( mDecoration[ SELECTED_DECORATION ] );
+      TransitionButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
       ReAddLabel();
 
+      TransitionOut( mDecoration[ SELECTED_DECORATION ] );
       TransitionOut( mSelectedContent );
       TransitionOut( mSelectedBackgroundContent );
       TransitionOut( mDisabledContent );
@@ -398,26 +426,24 @@ float Button::GetAnimationTime() const
   return mAnimationTime;
 }
 
-void Button::SetLabel( const std::string& label )
-{
-  Toolkit::TextLabel textLabel = Toolkit::TextLabel::New( label );
-  SetLabel( textLabel );
-}
-
-void Button::SetLabel( Actor label )
+void Button::SetLabelText( const std::string& label )
 {
-  if( mLabel != label )
+  if( !mLabel || ( label != GetLabelText() ) )
   {
-    if( mLabel && mLabel.GetParent() )
+    // If we have a label, unparent and update it.
+    if( mLabel )
     {
-      mLabel.GetParent().Remove( mLabel );
+      mLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, label );
+    }
+    else
+    {
+      // If we don't have a label, create one and set it up.
+      mLabel = Toolkit::TextLabel::New( label );
+      mLabel.SetProperty( Toolkit::Control::Property::STYLE_NAME, STYLE_BUTTON_LABEL );
+      mLabel.SetPosition( 0.f, 0.f );
+      // label should be the top of the button
+      Self().Add( mLabel );
     }
-
-    mLabel = label;
-    mLabel.SetPosition( 0.f, 0.f );
-
-    // label should be the top of the button
-    Self().Add( mLabel );
 
     OnLabelSet();
 
@@ -425,168 +451,216 @@ void Button::SetLabel( Actor label )
   }
 }
 
-Actor Button::GetLabel() const
+std::string Button::GetLabelText() const
 {
-  return mLabel;
+  Toolkit::TextLabel label = Dali::Toolkit::TextLabel::DownCast( mLabel );
+  if( label )
+  {
+    return label.GetProperty<std::string>( Dali::Toolkit::TextLabel::Property::TEXT );
+  }
+  return std::string();
 }
 
-Actor& Button::GetLabel()
+Actor& Button::GetLabelActor()
 {
   return mLabel;
 }
 
-void Button::SetButtonImage( Actor image )
+void Button::SetDecoration( DecorationState state, Actor actor )
 {
-  StopTransitionAnimation();
-
-  if( mUnselectedContent && mUnselectedContent.GetParent() )
+  if( mDecoration[ state ] && mDecoration[ state ].GetParent() )
   {
-    Self().Remove( mUnselectedContent );
+    mDecoration[ state ].Unparent();
   }
 
-  mUnselectedContent = image;
-  if( mUnselectedContent )
-  {
-    mUnselectedContent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-    mUnselectedContent.SetParentOrigin( ParentOrigin::TOP_LEFT );
-    mUnselectedContent.SetPosition( 0.f, 0.f );
-  }
-  ResetImageLayers();
-  OnButtonImageSet();
+  mDecoration[ state ] = actor;
+  mDecoration[ state ].SetColorMode( USE_OWN_COLOR );
 
+  ResetImageLayers();
   RelayoutRequest();
 }
 
-Actor Button::GetButtonImage() const
+Actor& Button::GetDecoration( DecorationState state )
 {
-  return mUnselectedContent;
+  return mDecoration[ state ];
 }
 
-Actor& Button::GetButtonImage()
+void Button::SetupContent( Actor& actorToModify, Actor newActor )
 {
-  return mUnselectedContent;
+  if( newActor )
+  {
+    StopTransitionAnimation();
+
+    if( actorToModify && actorToModify.GetParent() )
+    {
+      actorToModify.Unparent();
+    }
+
+    actorToModify = newActor;
+
+    if( actorToModify )
+    {
+      actorToModify.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+      actorToModify.SetParentOrigin( ParentOrigin::TOP_LEFT );
+      actorToModify.SetPosition( 0.f, 0.f );
+    }
+
+    ResetImageLayers();
+  }
 }
 
-void Button::SetSelectedImage( Actor image )
+void Button::SetUnselectedColor( const Vector4& color )
 {
-  StopTransitionAnimation();
+  mUnselectedColor = color;
 
-  if( mSelectedContent && mSelectedContent.GetParent() )
+  if( mUnselectedContent && !GetUnselectedImageFilename().empty() )
   {
-    Self().Remove( mSelectedContent );
+    // If there is existing unselected content, change the color on it directly.
+    mUnselectedContent.SetColor( mUnselectedColor );
   }
-
-  mSelectedContent = image;
-  if( mSelectedContent )
+  else
   {
-    mSelectedContent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-    mSelectedContent.SetParentOrigin( ParentOrigin::TOP_LEFT );
-    mSelectedContent.SetPosition( 0.f, 0.f );
+    // If there is no existing content, create a new actor to use for flat color.
+    SetupContent( mUnselectedContent, CreateSolidColorActor( mUnselectedColor ) );
+    mUnselectedContent.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
   }
-  ResetImageLayers();
-  OnSelectedImageSet();
-
-  RelayoutRequest();
 }
 
-Actor Button::GetSelectedImage() const
+const Vector4 Button::GetUnselectedColor() const
 {
-  return mSelectedContent;
+  return mUnselectedColor;
 }
 
-Actor& Button::GetSelectedImage()
+void Button::SetSelectedColor( const Vector4& color )
 {
-  return mSelectedContent;
+  mSelectedColor = color;
+
+  if( mSelectedContent && !GetSelectedImageFilename().empty() )
+  {
+    // If there is existing unselected content, change the color on it directly.
+    mSelectedContent.SetColor( mSelectedColor );
+  }
+  else
+  {
+    // If there is no existing content, create a new actor to use for flat color.
+    SetupContent( mSelectedContent, CreateSolidColorActor( mSelectedColor ) );
+    mSelectedContent.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+  }
 }
 
-void Button::SetBackgroundImage( Actor image )
+const Vector4 Button::GetSelectedColor() const
 {
-  StopTransitionAnimation();
+  return mSelectedColor;
+}
 
-  if( mBackgroundContent && mBackgroundContent.GetParent() )
+void Button::SetUnselectedImage( const std::string& filename )
+{
+  ImageActor newContent;
+  if( !filename.empty() )
   {
-    Self().Remove( mBackgroundContent );
+    Image resourceimage = Dali::ResourceImage::New( filename );
+    if( resourceimage )
+    {
+      newContent = ImageActor::New( resourceimage );
+    }
   }
-
-  mBackgroundContent = image;
-  if( mBackgroundContent )
+  else
   {
-    mBackgroundContent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-    mBackgroundContent.SetParentOrigin( ParentOrigin::TOP_LEFT );
-    mBackgroundContent.SetPosition( 0.f, 0.f );
+    newContent = ImageActor::New();
   }
-  ResetImageLayers();
-  OnBackgroundImageSet();
 
-  RelayoutRequest();
-}
+  if( newContent )
+  {
+    SetupContent( mUnselectedContent, newContent );
 
-Actor Button::GetBackgroundImage() const
-{
-  return mBackgroundContent;
+    mUnselectedContent.SetColor( mUnselectedColor );
+
+    OnUnselectedImageSet();
+    RelayoutRequest();
+  }
 }
 
-Actor& Button::GetBackgroundImage()
+Actor& Button::GetUnselectedImage()
 {
-  return mBackgroundContent;
+  return mUnselectedContent;
 }
 
-void Button::SetSelectedBackgroundImage( Actor image )
+void Button::SetSelectedImage( const std::string& filename )
 {
-  StopTransitionAnimation();
-
-  if( mSelectedBackgroundContent && mSelectedBackgroundContent.GetParent() )
+  ImageActor newContent;
+  if( !filename.empty() )
   {
-    Self().Remove( mSelectedBackgroundContent );
+    Image resourceimage = Dali::ResourceImage::New( filename );
+    if( resourceimage )
+    {
+      newContent = ImageActor::New( resourceimage );
+    }
   }
-
-  mSelectedBackgroundContent = image;
-  if( mSelectedBackgroundContent )
+  else
   {
-    mSelectedBackgroundContent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-    mSelectedBackgroundContent.SetParentOrigin( ParentOrigin::TOP_LEFT );
-    mSelectedBackgroundContent.SetPosition( 0.f, 0.f );
+    newContent = ImageActor::New();
   }
-  ResetImageLayers();
-  OnSelectedBackgroundImageSet();
 
-  RelayoutRequest();
+  if( newContent )
+  {
+    SetupContent( mSelectedContent, newContent );
+
+    mSelectedContent.SetColor( mSelectedColor );
+
+    OnSelectedImageSet();
+    RelayoutRequest();
+  }
 }
 
-Actor Button::GetSelectedBackgroundImage() const
+Actor& Button::GetSelectedImage()
 {
-  return mSelectedBackgroundContent;
+  return mSelectedContent;
 }
 
-Actor& Button::GetSelectedBackgroundImage()
+void Button::SetBackgroundImage( const std::string& filename )
 {
-  return mSelectedBackgroundContent;
+  Image resourceimage = Dali::ResourceImage::New( filename );
+  if( resourceimage )
+  {
+    SetupContent( mBackgroundContent, ImageActor::New( resourceimage ) );
+
+    OnBackgroundImageSet();
+    RelayoutRequest();
+  }
 }
 
-void Button::SetDisabledImage( Actor image )
+Actor& Button::GetBackgroundImage()
 {
-  StopTransitionAnimation();
+  return mBackgroundContent;
+}
 
-  if( mDisabledContent && mDisabledContent.GetParent() )
+void Button::SetSelectedBackgroundImage( const std::string& filename )
+{
+  Image resourceimage = Dali::ResourceImage::New( filename );
+  if( resourceimage )
   {
-    Self().Remove( mDisabledContent );
-  }
+    SetupContent( mSelectedBackgroundContent, ImageActor::New( resourceimage ) );
 
-  mDisabledContent = image;
-  if( mDisabledContent )
-  {
-    mDisabledContent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-    mDisabledContent.SetParentOrigin( ParentOrigin::TOP_LEFT );
-    mDisabledContent.SetPosition( 0.f, 0.f );
+    OnSelectedBackgroundImageSet();
+    RelayoutRequest();
   }
+}
 
-  ResetImageLayers();
-  OnDisabledImageSet();
+Actor& Button::GetSelectedBackgroundImage()
+{
+  return mSelectedBackgroundContent;
 }
 
-Actor Button::GetDisabledImage() const
+void Button::SetDisabledImage( const std::string& filename )
 {
-  return mDisabledContent;
+  Image resourceimage = Dali::ResourceImage::New( filename );
+  if( resourceimage )
+  {
+    SetupContent( mDisabledContent, ImageActor::New( resourceimage ) );
+
+    OnDisabledImageSet();
+    RelayoutRequest();
+  }
 }
 
 Actor& Button::GetDisabledImage()
@@ -594,65 +668,129 @@ Actor& Button::GetDisabledImage()
   return mDisabledContent;
 }
 
-void Button::SetDisabledSelectedImage( Actor image )
+void Button::SetDisabledSelectedImage( const std::string& filename )
 {
-  StopTransitionAnimation();
-
-  if( mDisabledSelectedContent && mDisabledSelectedContent.GetParent() )
+  Image resourceimage = Dali::ResourceImage::New( filename );
+  if( resourceimage )
   {
-    Self().Remove( mDisabledSelectedContent );
+    SetupContent( mDisabledSelectedContent, ImageActor::New( resourceimage ) );
+
+    OnDisabledSelectedImageSet();
+    RelayoutRequest();
   }
+}
 
-  mDisabledSelectedContent = image;
-  if( mDisabledSelectedContent )
+Actor& Button::GetDisabledSelectedImage()
+{
+  return mDisabledSelectedContent;
+}
+
+void Button::SetDisabledBackgroundImage( const std::string& filename )
+{
+  Image resourceimage = Dali::ResourceImage::New( filename );
+  if( resourceimage )
   {
-    mDisabledSelectedContent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-    mDisabledSelectedContent.SetParentOrigin( ParentOrigin::TOP_LEFT );
-    mDisabledSelectedContent.SetPosition( 0.f, 0.f );
+    SetupContent( mDisabledBackgroundContent, ImageActor::New( resourceimage ) );
+
+    OnDisabledBackgroundImageSet();
+    RelayoutRequest();
   }
+}
 
-  ResetImageLayers();
-  OnDisabledSelectedImageSet();
+Actor& Button::GetDisabledBackgroundImage()
+{
+  return mDisabledBackgroundContent;
 }
 
-Actor Button::GetDisabledSelectedImage() const
+std::string Button::GetUnselectedImageFilename() const
 {
-  return mDisabledSelectedContent;
+  if( mUnselectedContent )
+  {
+    ResourceImage image = ResourceImage::DownCast( mUnselectedContent );
+    if( image )
+    {
+      return image.GetUrl();
+    }
+  }
+  return std::string();
 }
 
-Actor& Button::GetDisabledSelectedImage()
+std::string Button::GetSelectedImageFilename() const
 {
-  return mDisabledSelectedContent;
+  if( mSelectedContent )
+  {
+    ResourceImage image = ResourceImage::DownCast( mSelectedContent );
+    if( image )
+    {
+      return image.GetUrl();
+    }
+  }
+  return std::string();
 }
 
-void Button::SetDisabledBackgroundImage( Actor image )
+std::string Button::GetBackgroundImageFilename() const
 {
-  StopTransitionAnimation();
+  if( mBackgroundContent )
+  {
+    ResourceImage image = ResourceImage::DownCast( mBackgroundContent );
+    if( image )
+    {
+      return image.GetUrl();
+    }
+  }
+  return std::string();
+}
 
-  if( mDisabledBackgroundContent && mDisabledBackgroundContent.GetParent() )
+std::string Button::GetSelectedBackgroundImageFilename() const
+{
+  if( mSelectedBackgroundContent )
   {
-    Self().Remove( mDisabledBackgroundContent );
+    ResourceImage image = ResourceImage::DownCast( mSelectedBackgroundContent );
+    if( image )
+    {
+      return image.GetUrl();
+    }
   }
+  return std::string();
+}
 
-  mDisabledBackgroundContent = image;
-  if( mDisabledBackgroundContent )
+std::string Button::GetDisabledImageFilename() const
+{
+  if( mDisabledContent )
   {
-    mDisabledBackgroundContent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-    mDisabledBackgroundContent.SetParentOrigin( ParentOrigin::TOP_LEFT );
-    mDisabledBackgroundContent.SetPosition( 0.f, 0.f );
+    ResourceImage image = ResourceImage::DownCast( mDisabledContent );
+    if( image )
+    {
+      return image.GetUrl();
+    }
   }
-  ResetImageLayers();
-  OnDisabledBackgroundImageSet();
+  return std::string();
 }
 
-Actor Button::GetDisabledBackgroundImage() const
+std::string Button::GetDisabledSelectedImageFilename() const
 {
-  return mDisabledBackgroundContent;
+  if( mDisabledSelectedContent )
+  {
+    ResourceImage image = ResourceImage::DownCast( mDisabledSelectedContent );
+    if( image )
+    {
+      return image.GetUrl();
+    }
+  }
+  return std::string();
 }
 
-Actor& Button::GetDisabledBackgroundImage()
+std::string Button::GetDisabledBackgroundImageFilename() const
 {
-  return mDisabledBackgroundContent;
+  if( mDisabledBackgroundContent )
+  {
+    ResourceImage image = ResourceImage::DownCast( mDisabledBackgroundContent );
+    if( image )
+    {
+      return image.GetUrl();
+    }
+  }
+  return std::string();
 }
 
 bool Button::DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes )
@@ -963,9 +1101,9 @@ void Button::Pressed()
     StopTransitionAnimation();
 
     // Notifies the derived class the button has been pressed.
-     OnPressed();
+    OnPressed();
 
-     //Layer Order
+    //Layer Order
     //(4) mSelectedContent (Inserted)
     //(3) mUnselectedContent
     //(2) mSelectedBackgroundContent (Inserted)
@@ -975,8 +1113,12 @@ void Button::Pressed()
     TransitionButtonImage( mSelectedBackgroundContent );
     AddButtonImage( mUnselectedContent );
     TransitionButtonImage( mSelectedContent );
+
+    AddButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
+    TransitionButtonImage( mDecoration[ SELECTED_DECORATION ] );
     ReAddLabel();
 
+    TransitionOut( mDecoration[ UNSELECTED_DECORATION ] );
     TransitionOut( mUnselectedContent );
     TransitionOut( mDisabledContent );
     TransitionOut( mDisabledSelectedContent );
@@ -1005,8 +1147,12 @@ void Button::Released()
     AddButtonImage( mBackgroundContent );
     AddButtonImage( mSelectedContent );
     TransitionButtonImage( mUnselectedContent );
+
+    AddButtonImage( mDecoration[ SELECTED_DECORATION ] );
+    TransitionButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
     ReAddLabel();
 
+    TransitionOut( mDecoration[ SELECTED_DECORATION ] );
     TransitionOut( mSelectedContent );
     TransitionOut( mSelectedBackgroundContent );
     TransitionOut( mDisabledContent );
@@ -1056,6 +1202,7 @@ void Button::AddButtonImage( Actor& actor )
 {
   if( actor )
   {
+    actor.Unparent();
     Self().Add( actor );
   }
 }
@@ -1115,6 +1262,7 @@ void Button::ResetImageLayers()
       //(2) mUnselectedContent
       //(1) mBackgroundContent
 
+      RemoveButtonImage( mDecoration[ SELECTED_DECORATION ] );
       RemoveButtonImage( mSelectedContent );
       RemoveButtonImage( mSelectedBackgroundContent );
       RemoveButtonImage( mDisabledContent );
@@ -1123,6 +1271,9 @@ void Button::ResetImageLayers()
 
       PrepareAddButtonImage( mBackgroundContent );
       PrepareAddButtonImage( mUnselectedContent );
+
+      PrepareAddButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
+      ReAddLabel();
       break;
     }
     case SelectedState:
@@ -1132,6 +1283,7 @@ void Button::ResetImageLayers()
       //(2) mSelectedBackgroundContent
       //(1) mBackgroundContent
 
+      RemoveButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
       RemoveButtonImage( mUnselectedContent );
       RemoveButtonImage( mDisabledContent );
       RemoveButtonImage( mDisabledSelectedContent );
@@ -1140,6 +1292,8 @@ void Button::ResetImageLayers()
       PrepareAddButtonImage( mBackgroundContent );
       PrepareAddButtonImage( mSelectedBackgroundContent );
       PrepareAddButtonImage( mSelectedContent );
+
+      PrepareAddButtonImage( mDecoration[ SELECTED_DECORATION ] );
       ReAddLabel();
       break;
     }
@@ -1149,14 +1303,18 @@ void Button::ResetImageLayers()
       //(2) mDisabledContent
       //(1) mDisabledBackgroundContent
 
+      RemoveButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
       RemoveButtonImage( mUnselectedContent );
       RemoveButtonImage( mBackgroundContent );
+      RemoveButtonImage( mDecoration[ SELECTED_DECORATION ] );
       RemoveButtonImage( mSelectedContent );
       RemoveButtonImage( mDisabledSelectedContent );
       RemoveButtonImage( mSelectedBackgroundContent );
 
       PrepareAddButtonImage( mDisabledBackgroundContent ? mDisabledBackgroundContent : mBackgroundContent );
       PrepareAddButtonImage( mDisabledContent ? mDisabledContent : mUnselectedContent );
+
+      PrepareAddButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
       ReAddLabel();
       break;
     }
@@ -1166,7 +1324,9 @@ void Button::ResetImageLayers()
       // (2) mDisabledSelectedContent
       // (1) mDisabledBackgroundContent
 
+      RemoveButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
       RemoveButtonImage( mUnselectedContent );
+      RemoveButtonImage( mDecoration[ SELECTED_DECORATION ] );
       RemoveButtonImage( mSelectedContent );
       RemoveButtonImage( mBackgroundContent );
       RemoveButtonImage( mSelectedBackgroundContent );
@@ -1183,6 +1343,8 @@ void Button::ResetImageLayers()
       }
 
       PrepareAddButtonImage( mDisabledSelectedContent ? mDisabledSelectedContent : mSelectedContent );
+
+      PrepareAddButtonImage( mDecoration[ SELECTED_DECORATION ] );
       ReAddLabel();
       break;
     }
@@ -1271,27 +1433,39 @@ void Button::SetProperty( BaseObject* object, Property::Index index, const Prope
         break;
       }
 
-      case Toolkit::Button::Property::NORMAL_STATE_ACTOR:
+      case Toolkit::Button::Property::UNSELECTED_STATE_IMAGE:
+      {
+        GetImplementation( button ).SetUnselectedImage( value.Get< std::string >() );
+        break;
+      }
+
+      case Toolkit::Button::Property::SELECTED_STATE_IMAGE:
+      {
+        GetImplementation( button ).SetSelectedImage( value.Get< std::string >() );
+        break;
+      }
+
+      case Toolkit::Button::Property::DISABLED_STATE_IMAGE:
       {
-        GetImplementation( button ).SetButtonImage( Scripting::NewActor( value.Get< Property::Map >() ) );
+        GetImplementation( button ).SetDisabledImage( value.Get< std::string >() );
         break;
       }
 
-      case Toolkit::Button::Property::SELECTED_STATE_ACTOR:
+      case Toolkit::Button::Property::UNSELECTED_COLOR:
       {
-        GetImplementation( button ).SetSelectedImage( Scripting::NewActor( value.Get< Property::Map >() ) );
+        GetImplementation( button ).SetUnselectedColor( value.Get< Vector4 >() );
         break;
       }
 
-      case Toolkit::Button::Property::DISABLED_STATE_ACTOR:
+      case Toolkit::Button::Property::SELECTED_COLOR:
       {
-        GetImplementation( button ).SetDisabledImage( Scripting::NewActor( value.Get< Property::Map >() ) );
+        GetImplementation( button ).SetSelectedColor( value.Get< Vector4 >() );
         break;
       }
 
-      case Toolkit::Button::Property::LABEL_ACTOR:
+      case Toolkit::Button::Property::LABEL_TEXT:
       {
-        GetImplementation( button ).SetLabel( Scripting::NewActor( value.Get< Property::Map >() ) );
+        GetImplementation( button ).SetLabelText( value.Get< std::string >() );
         break;
       }
     }
@@ -1344,35 +1518,39 @@ Property::Value Button::GetProperty( BaseObject* object, Property::Index propert
         break;
       }
 
-      case Toolkit::Button::Property::NORMAL_STATE_ACTOR:
+      case Toolkit::Button::Property::UNSELECTED_STATE_IMAGE:
       {
-        Property::Map map;
-        Scripting::CreatePropertyMap( GetImplementation( button ).mUnselectedContent, map );
-        value = map;
+        value = GetImplementation( button ).GetUnselectedImageFilename();
         break;
       }
 
-      case Toolkit::Button::Property::SELECTED_STATE_ACTOR:
+      case Toolkit::Button::Property::SELECTED_STATE_IMAGE:
       {
-        Property::Map map;
-        Scripting::CreatePropertyMap( GetImplementation( button ).mSelectedContent, map );
-        value = map;
+        value = GetImplementation( button ).GetSelectedImageFilename();
         break;
       }
 
-      case Toolkit::Button::Property::DISABLED_STATE_ACTOR:
+      case Toolkit::Button::Property::DISABLED_STATE_IMAGE:
       {
-        Property::Map map;
-        Scripting::CreatePropertyMap( GetImplementation( button ).mDisabledContent, map );
-        value = map;
+        value = GetImplementation( button ).GetDisabledImageFilename();
         break;
       }
 
-      case Toolkit::Button::Property::LABEL_ACTOR:
+      case Toolkit::Button::Property::UNSELECTED_COLOR:
       {
-        Property::Map map;
-        Scripting::CreatePropertyMap( GetImplementation( button ).mLabel, map );
-        value = map;
+        value = GetImplementation( button ).GetUnselectedColor();
+        break;
+      }
+
+      case Toolkit::Button::Property::SELECTED_COLOR:
+      {
+        value = GetImplementation( button ).GetSelectedColor();
+        break;
+      }
+
+      case Toolkit::Button::Property::LABEL_TEXT:
+      {
+        value = GetImplementation( button ).GetLabelText();
         break;
       }
     }
@@ -1381,6 +1559,132 @@ Property::Value Button::GetProperty( BaseObject* object, Property::Index propert
   return value;
 }
 
+// Deprecated API
+
+void Button::SetLabel( Actor label )
+{
+  if( mLabel != label )
+  {
+    if( mLabel && mLabel.GetParent() )
+    {
+      mLabel.GetParent().Remove( mLabel );
+    }
+
+    mLabel = label;
+    mLabel.SetProperty( Toolkit::Control::Property::STYLE_NAME, STYLE_BUTTON_LABEL );
+    mLabel.SetPosition( 0.f, 0.f );
+
+    // label should be the top of the button
+    Self().Add( mLabel );
+
+    OnLabelSet();
+
+    RelayoutRequest();
+  }
+}
+
+void Button::SetButtonImage( Actor image )
+{
+  if( image )
+  {
+    StopTransitionAnimation();
+
+    SetupContent( mUnselectedContent, image );
+
+    OnUnselectedImageSet();
+    RelayoutRequest();
+  }
+}
+
+void Button::SetSelectedImage( Actor image )
+{
+  if( image )
+  {
+    StopTransitionAnimation();
+
+    SetupContent( mSelectedContent, image );
+
+    OnSelectedImageSet();
+    RelayoutRequest();
+  }
+}
+
+void Button::SetBackgroundImage( Actor image )
+{
+  if( image )
+  {
+    StopTransitionAnimation();
+
+    SetupContent( mBackgroundContent, image );
+
+    OnBackgroundImageSet();
+    RelayoutRequest();
+  }
+}
+
+void Button::SetSelectedBackgroundImage( Actor image )
+{
+  if( image )
+  {
+    StopTransitionAnimation();
+
+    SetupContent( mSelectedBackgroundContent, image );
+
+    OnSelectedBackgroundImageSet();
+    RelayoutRequest();
+  }
+}
+
+void Button::SetDisabledImage( Actor image )
+{
+  if( image )
+  {
+    StopTransitionAnimation();
+
+    SetupContent( mDisabledContent, image );
+
+    OnDisabledImageSet();
+    RelayoutRequest();
+  }
+}
+
+void Button::SetDisabledSelectedImage( Actor image )
+{
+  if( image )
+  {
+    StopTransitionAnimation();
+
+    SetupContent( mDisabledSelectedContent, image );
+
+    OnDisabledSelectedImageSet();
+    RelayoutRequest();
+  }
+}
+
+void Button::SetDisabledBackgroundImage( Actor image )
+{
+  if( image )
+  {
+    StopTransitionAnimation();
+
+    SetupContent( mDisabledBackgroundContent, image );
+
+    OnDisabledBackgroundImageSet();
+    RelayoutRequest();
+  }
+}
+
+Actor Button::GetButtonImage() const
+{
+  return mUnselectedContent;
+}
+
+Actor Button::GetSelectedImage() const
+{
+  return mSelectedContent;
+}
+
+
 } // namespace Internal
 
 } // namespace Toolkit
index a17d058..a8e9c6b 100644 (file)
@@ -128,147 +128,194 @@ public:
   float GetAnimationTime() const;
 
   /**
-   * @copydoc Dali::Toolkit::Button::SetLabel( const std::string& label )
+   * @copydoc Dali::Toolkit::Button::SetLabelText
    */
-  void SetLabel( const std::string& label );
+  void SetLabelText( const std::string& label );
 
   /**
-   * @copydoc Dali::Toolkit::Button::SetLabel( Actor label )
+   * @copydoc Dali::Toolkit::Button::GetLabelText
    */
-  void SetLabel( Actor label );
+  std::string GetLabelText() const;
 
   /**
-   * @copydoc Dali::Toolkit::Button::GetLabel()
+   * @copydoc Dali::Toolkit::PushButton::SetUnselectedImage
    */
-  Actor GetLabel() const;
+  void SetUnselectedImage( const std::string& filename );
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetButtonImage( Actor image )
+   * @copydoc Dali::Toolkit::PushButton::SetSelectedImage
    */
-  void SetButtonImage( Actor image );
+  void SetSelectedImage( const std::string& filename );
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::GetButtonImage()
+   * @copydoc Dali::Toolkit::PushButton::SetBackgroundImage
    */
-  Actor GetButtonImage() const;
+  void SetBackgroundImage( const std::string& filename );
 
   /**
-   * Internal use only.
-   * @return A reference to the button image.
+   * @copydoc Dali::Toolkit::PushButton::SetSelectedBackgroundImage
    */
-  Actor& GetButtonImage();
+  void SetSelectedBackgroundImage( const std::string& filename );
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetSelectedImage( Actor image )
+   * @copydoc Dali::Toolkit::PushButton::SetDisabledImage
    */
-  void SetSelectedImage( Actor image );
+  void SetDisabledImage( const std::string& filename );
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::GetSelectedImage()
+   * @copydoc Dali::Toolkit::CheckBoxButton::SetDisabledSelectedImage
    */
-  Actor GetSelectedImage() const;
+  void SetDisabledSelectedImage( const std::string& filename );
 
   /**
-   * Internal use only.
-   * @return A reference to the selected image.
+   * @copydoc Dali::Toolkit::PushButton::SetDisabledBackgroundImage
    */
-  Actor& GetSelectedImage();
+  void SetDisabledBackgroundImage( const std::string& filename );
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetBackgroundImage( Actor image )
+   * @return The filename used for the button image.
    */
-  void SetBackgroundImage( Actor image );
+  std::string GetUnselectedImageFilename() const;
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::GetBackgroundImage()
+   * @return The filename used for the selected image.
    */
-  Actor GetBackgroundImage() const;
+  std::string GetSelectedImageFilename() const;
 
   /**
-   * Internal use only.
-   * @return A reference to the background image.
+   * @return The filename used for the background image.
    */
-  Actor& GetBackgroundImage();
+  std::string GetBackgroundImageFilename() const;
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetSelectedBackgroundImage( Actor image )
+   * @return The filename used for the selected background image.
    */
-  void SetSelectedBackgroundImage( Actor image );
+  std::string GetSelectedBackgroundImageFilename() const;
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::GetSelectedBackgroundImage()
+   * @return The filename used for the disabled button image.
    */
-  Actor GetSelectedBackgroundImage() const;
+  std::string GetDisabledImageFilename() const;
 
   /**
-   * Internal use only.
-   * @return A reference to the selected background image.
+   * @return The filename used for the disabled selected image.
    */
-  Actor& GetSelectedBackgroundImage();
+  std::string GetDisabledSelectedImageFilename() const;
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetDisabledImage( Actor image )
+   * @return The filename used for the disabled background image.
    */
-  void SetDisabledImage( Actor image );
+  std::string GetDisabledBackgroundImageFilename() const;
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::GetDisabledImage()
+   * Performs actions as requested using the action name.
+   * @param[in] object The object on which to perform the action.
+   * @param[in] actionName The action to perform.
+   * @param[in] attributes The attributes with which to perfrom this action.
+   * @return true if action has been accepted by this control
    */
-  Actor GetDisabledImage() const;
+  static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes );
+
+public: // Deprecated API
 
   /**
-   * Internal use only.
-   * @return A reference to the disabled button image.
+   * @copydoc Dali::Toolkit::Button::SetLabel( Actor label )
    */
-  Actor& GetDisabledImage();
+  void SetLabel( Actor label );
 
   /**
-   * @copydoc Dali::Toolkit::CheckBoxButton::SetDisabledSelectedImage( Actor image )
+   * @deprecated Sets the unselected image with an Actor.
+   * @param[in] image The Actor to use.
    */
-  void SetDisabledSelectedImage( Actor image );
+  void SetButtonImage( Actor image );
 
   /**
-   * @copydoc Dali::Toolkit::CheckBoxButton::GetDisabledSelectedImage()
+   * @deprecated Sets the selected image with an Actor.
+   * @param[in] image The Actor to use.
    */
-  Actor GetDisabledSelectedImage() const;
+  void SetSelectedImage( Actor image );
 
   /**
-   * Internal use only.
-   * @return A reference to the disabled selected image.
+   * @deprecated Sets the background image with an Actor.
+   * @param[in] image The Actor to use.
    */
-  Actor& GetDisabledSelectedImage();
+  void SetBackgroundImage( Actor image );
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetDisabledBackgroundImage( Actor image )
+   * @deprecated Sets the selected background image with an Actor.
+   * @param[in] image The Actor to use.
    */
-  void SetDisabledBackgroundImage( Actor image );
+  void SetSelectedBackgroundImage( Actor image );
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::GetDisabledBackgroundImage()
+   * @deprecated Sets the disabled image with an Actor.
+   * @param[in] image The Actor to use.
    */
-  Actor GetDisabledBackgroundImage() const;
+  void SetDisabledImage( Actor image );
 
   /**
-   * Internal use only.
-   * @return A reference to the disabled background image.
+   * @deprecated Sets the disabled selected image with an Actor.
+   * @param[in] image The Actor to use.
    */
-  Actor& GetDisabledBackgroundImage();
+  void SetDisabledSelectedImage( Actor image );
 
   /**
-   * Performs actions as requested using the action name.
-   * @param[in] object The object on which to perform the action.
-   * @param[in] actionName The action to perform.
-   * @param[in] attributes The attributes with which to perfrom this action.
-   * @return true if action has been accepted by this control
+   * @deprecated Sets the disabled background image with an Actor.
+   * @param[in] image The Actor to use.
    */
-  static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes );
+  void SetDisabledBackgroundImage( Actor image );
+
+  /**
+   * @copydoc Dali::Toolkit::Button::GetButtonImage()
+   */
+  Actor GetButtonImage() const;
+
+  /**
+   * @copydoc Dali::Toolkit::Button::GetSelectedImage()
+   */
+  Actor GetSelectedImage() const;
 
 protected:
 
   /**
    * @return A reference to the label actor.
    */
-  Actor& GetLabel();
+  Actor& GetLabelActor();
+
+  /**
+   * @return A reference to the unselected button image.
+   */
+  Actor& GetUnselectedImage();
+
+  /**
+   * @return A reference to the selected image.
+   */
+  Actor& GetSelectedImage();
+
+  /**
+   * @return A reference to the background image.
+   */
+  Actor& GetBackgroundImage();
+
+  /**
+   * @return A reference to the selected background image.
+   */
+  Actor& GetSelectedBackgroundImage();
+
+  /**
+   * @return A reference to the disabled button image.
+   */
+  Actor& GetDisabledImage();
+
+  /**
+   * @return A reference to the disabled selected image.
+   */
+  Actor& GetDisabledSelectedImage();
+
+  /**
+   * @return A reference to the disabled background image.
+   */
+  Actor& GetDisabledBackgroundImage();
 
 private:
 
@@ -291,9 +338,9 @@ private:
   virtual void OnLabelSet() {}
 
   /**
-   * This method is called when the button image is set
+   * This method is called when the unselected button image is set
    */
-  virtual void OnButtonImageSet() {}
+  virtual void OnUnselectedImageSet() {}
 
   /**
    * This method is called when the selected image is set
@@ -497,6 +544,40 @@ private:
    */
   void Released();
 
+  /**
+   * Used to perform common setup applied to images within button.
+   * This will replace the current image with the specifed one.
+   * @param[in]  actorToModify The image to replace.
+   * @param[out] newActor The new image to use.
+   */
+  void SetupContent( Actor& actorToModify, Actor newActor );
+
+  /**
+   * Sets the color of the unselected image.
+   * If no image exists, it is created.
+   * @param[in]  color The color to use.
+   */
+  void SetUnselectedColor( const Vector4& color );
+
+  /**
+   * Gets the unselected content color.
+   * @return     The currently used unselected color.
+   */
+  const Vector4 GetUnselectedColor() const;
+
+  /**
+   * Sets the color of the selected image.
+   * If no image exists, it is created.
+   * @param[in]  color The color to use.
+   */
+  void SetSelectedColor( const Vector4& color );
+
+  /**
+   * Gets the selected content color.
+   * @return     The currently used selected color.
+   */
+  const Vector4 GetSelectedColor() const;
+
 protected:
 
   enum ButtonState
@@ -516,8 +597,21 @@ protected:
     DisabledSelectedState,        ///< The button is disabled and selected.
   };
 
+  /**
+   * Enum to specify which decoration when getting and setting decorations.
+   */
+  enum DecorationState
+  {
+    UNSELECTED_DECORATION = 0,
+    SELECTED_DECORATION,
+    DECORATION_STATES
+  };
+
   ButtonState GetState();
   PaintState GetPaintState();
+  void SetDecoration( DecorationState state, Actor actor );
+  Actor& GetDecoration( DecorationState state );
+
 
   /**
    * Returns the animation to be used for transitioning creating the animation if needed.
@@ -554,6 +648,7 @@ protected:
   virtual void OnTransitionOut( Actor actor ) {}
 
 private:
+
   /**
    * Starts the transition animation.
    * Button::TransitionFinished is called when the animation finishes.
@@ -634,6 +729,8 @@ private:
 
   Actor mLabel;                                ///< Stores the button label.
 
+  Actor mDecoration[ DECORATION_STATES ];      ///< Stores the decorations for both selected and unselected states.
+
   Actor mUnselectedContent;                    ///< Stores the unselected content.
   Actor mSelectedContent;                      ///< Stores the selected content.
   Actor mBackgroundContent;                    ///< Stores the background content.
@@ -646,6 +743,9 @@ private:
 
   TapGestureDetector mTapDetector;
 
+  Vector4          mUnselectedColor;           ///< Color to use for unselected content.
+  Vector4          mSelectedColor;             ///< Color to use for selected content.
+
   bool             mDisabled;                  ///< Stores the disabled property.
   bool             mAutoRepeating;             ///< Stores the autorepeating property.
   bool             mTogglableButton;           ///< Stores the togglable property.
index b1f7474..0aa4e83 100644 (file)
@@ -86,20 +86,15 @@ void CheckBoxButton::OnButtonInitialize()
   // Wrap around all children
   Self().SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
 
-  Image buttonImage = Dali::ResourceImage::New( UNSELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER );
-  Image selectedImage = Dali::ResourceImage::New( SELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER );
-  Image disabledImage = Dali::ResourceImage::New( DISABLED_UNSELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER );
-  Image disabledSelectedImage = Dali::ResourceImage::New( DISABLED_SELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER );
-
-  SetButtonImage( ImageActor::New( buttonImage ) );
-  SetSelectedImage( ImageActor::New( selectedImage ) );
-  SetDisabledImage( ImageActor::New( disabledImage ) );
-  SetDisabledSelectedImage( ImageActor::New( disabledSelectedImage ) );
+  SetUnselectedImage( UNSELECTED_BUTTON_IMAGE_DIR );
+  SetSelectedImage( SELECTED_BUTTON_IMAGE_DIR );
+  SetDisabledImage( DISABLED_UNSELECTED_BUTTON_IMAGE_DIR );
+  SetDisabledSelectedImage( DISABLED_SELECTED_BUTTON_IMAGE_DIR );
 }
 
 void CheckBoxButton::OnLabelSet()
 {
-  Actor& label = GetLabel();
+  Actor& label = GetLabelActor();
 
   if( label )
   {
@@ -118,9 +113,9 @@ void CheckBoxButton::OnLabelSet()
     {
       label.SetX( GetSelectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
     }
-    else if( GetButtonImage() )
+    else if( GetUnselectedImage() )
     {
-      label.SetX( GetButtonImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
+      label.SetX( GetUnselectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
     }
     else
     {
@@ -134,7 +129,7 @@ void CheckBoxButton::OnDisabled()
   Actor& backgroundImage = GetBackgroundImage();
   Actor& disabledBackgroundImage = GetDisabledBackgroundImage();
 
-  Actor& label = GetLabel();
+  Actor& label = GetLabelActor();
   if( label )
   {
     if( IsDisabled() && disabledBackgroundImage )
@@ -149,9 +144,9 @@ void CheckBoxButton::OnDisabled()
     {
       label.SetX( GetSelectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
     }
-    else if( GetButtonImage() )
+    else if( GetUnselectedImage() )
     {
-      label.SetX( GetButtonImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
+      label.SetX( GetUnselectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
     }
     else
     {
index b6efdf8..7a8ec5d 100644 (file)
@@ -21,7 +21,9 @@
 // EXTERNAL INCLUDES
 #include <dali/public-api/actors/image-actor.h>
 #include <dali/public-api/object/type-registry.h>
+#include <dali/devel-api/object/type-registry-helper.h>
 #include <dali/public-api/images/resource-image.h>
+#include <dali/devel-api/scripting/scripting.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/text-controls/text-label.h>
@@ -38,15 +40,36 @@ namespace Internal
 namespace
 {
 
-const float TEXT_PADDING = 12.0f;
-const float ANIMATION_TIME( 0.2f );
+const float   ANIMATION_TIME( 0.2f );
+const Padding DEFAULT_LABEL_PADDING( 12.0f, 12.0f, 12.0f, 12.0f );
+const Padding DEFAULT_ICON_PADDING( 12.0f, 12.0f, 12.0f, 12.0f );
 
 BaseHandle Create()
 {
   return Toolkit::PushButton::New();
 }
 
-TypeRegistration typeRegistration( typeid(Toolkit::PushButton), typeid(Toolkit::Button), Create );
+// Properties
+
+DALI_TYPE_REGISTRATION_BEGIN( Toolkit::PushButton, Toolkit::Button, Create )
+
+DALI_PROPERTY_REGISTRATION( Toolkit, PushButton, "unselected-icon", STRING, UNSELECTED_ICON )
+DALI_PROPERTY_REGISTRATION( Toolkit, PushButton, "selected-icon", STRING, SELECTED_ICON )
+DALI_PROPERTY_REGISTRATION( Toolkit, PushButton, "icon-alignment", STRING, ICON_ALIGNMENT )
+DALI_PROPERTY_REGISTRATION( Toolkit, PushButton, "label-padding", STRING, LABEL_PADDING )
+DALI_PROPERTY_REGISTRATION( Toolkit, PushButton, "icon-padding", STRING, ICON_PADDING )
+
+DALI_TYPE_REGISTRATION_END()
+
+/*
+ * Table to define Text-to-enum conversions for IconAlignment.
+ */
+const Dali::Scripting::StringEnum IconAlignmentTable[] = {
+  { "LEFT",   Toolkit::Internal::PushButton::LEFT },
+  { "RIGHT",  Toolkit::Internal::PushButton::RIGHT },
+  { "TOP",    Toolkit::Internal::PushButton::TOP },
+  { "BOTTOM", Toolkit::Internal::PushButton::BOTTOM },
+}; const unsigned int IconAlignmentTableCount = sizeof( IconAlignmentTable ) / sizeof( IconAlignmentTable[0] );
 
 const char* const UNSELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "button-up.9.png";
 const char* const SELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "button-down.9.png";
@@ -92,6 +115,9 @@ Dali::Toolkit::PushButton PushButton::New()
 
 PushButton::PushButton()
 : Button(),
+  mLabelPadding( DEFAULT_LABEL_PADDING ),
+  mIconPadding( DEFAULT_ICON_PADDING ),
+  mIconAlignment( RIGHT ),
   mSize()
 {
   SetAnimationTime( ANIMATION_TIME );
@@ -110,78 +136,191 @@ void PushButton::OnButtonInitialize()
   // Set resize policy to natural size so that buttons will resize to background images
   self.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
 
-  Image buttonImage = Dali::ResourceImage::New( UNSELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER );
-  Image selectedImage = Dali::ResourceImage::New( SELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER );
-  Image disabledImage = Dali::ResourceImage::New( DISABLED_UNSELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER );
-  Image disabledSelectedImage = Dali::ResourceImage::New( DISABLED_SELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER );
+  SetUnselectedImage( UNSELECTED_BUTTON_IMAGE_DIR );
+  SetSelectedImage( SELECTED_BUTTON_IMAGE_DIR );
+  SetDisabledImage( DISABLED_UNSELECTED_BUTTON_IMAGE_DIR );
+  SetDisabledSelectedImage( DISABLED_SELECTED_BUTTON_IMAGE_DIR );
+}
+
+void PushButton::SetIcon( DecorationState state, const std::string iconFilename )
+{
+  mIconName[ state ] = iconFilename;
+  SetDecoration( state, ImageActor::New( Dali::ResourceImage::New( iconFilename ) ) );
+  ConfigureSizeNegotiation();
+}
+
+std::string& PushButton::GetIcon( DecorationState state )
+{
+  return mIconName[ state ];
+}
+
+void PushButton::SetIconAlignment( const PushButton::IconAlignment iconAlignment )
+{
+  mIconAlignment = iconAlignment;
+  ConfigureSizeNegotiation();
+}
+
+const PushButton::IconAlignment PushButton::GetIconAlignment() const
+{
+  return mIconAlignment;
+}
 
-  SetButtonImage( ImageActor::New( buttonImage ) );
-  SetSelectedImage( ImageActor::New( selectedImage ) );
-  SetDisabledImage( ImageActor::New( disabledImage ) );
-  SetDisabledSelectedImage( ImageActor::New( disabledSelectedImage ) );
+void PushButton::SetLabelPadding( const Vector4& padding )
+{
+  mLabelPadding = Padding( padding.x, padding.y, padding.z, padding.w );
+  ConfigureSizeNegotiation();
+}
+
+Vector4 PushButton::GetLabelPadding()
+{
+  return Vector4( mLabelPadding.left, mLabelPadding.right, mLabelPadding.top, mLabelPadding.bottom );
+}
+
+void PushButton::SetIconPadding( const Vector4& padding )
+{
+  mIconPadding = Padding( padding.x, padding.y, padding.z, padding.w );
+  ConfigureSizeNegotiation();
+}
+
+Vector4 PushButton::GetIconPadding()
+{
+  return Vector4( mIconPadding.left, mIconPadding.right, mIconPadding.top, mIconPadding.bottom );
+}
+
+void PushButton::SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )
+{
+  Toolkit::PushButton pushButton = Toolkit::PushButton::DownCast( Dali::BaseHandle( object ) );
+
+  if ( pushButton )
+  {
+    PushButton& pushButtonImpl( GetImplementation( pushButton ) );
+
+    switch ( propertyIndex )
+    {
+      case Toolkit::PushButton::Property::UNSELECTED_ICON:
+      {
+        pushButtonImpl.SetIcon( UNSELECTED_DECORATION, value.Get< std::string >() );
+        break;
+      }
+      case Toolkit::PushButton::Property::SELECTED_ICON:
+      {
+        pushButtonImpl.SetIcon( SELECTED_DECORATION, value.Get< std::string >() );
+        break;
+      }
+      case Toolkit::PushButton::Property::ICON_ALIGNMENT:
+      {
+        IconAlignment iconAlignment;
+        if( Scripting::GetEnumeration< IconAlignment >( value.Get< std::string >().c_str(), IconAlignmentTable, IconAlignmentTableCount, iconAlignment ) )
+        {
+          pushButtonImpl.SetIconAlignment( iconAlignment );
+        }
+        break;
+      }
+      case Toolkit::PushButton::Property::LABEL_PADDING:
+      {
+        pushButtonImpl.SetLabelPadding( value.Get< Vector4 >() );
+        break;
+      }
+      case Toolkit::PushButton::Property::ICON_PADDING:
+      {
+        pushButtonImpl.SetIconPadding( value.Get< Vector4 >() );
+        break;
+      }
+    }
+  }
+}
+
+Property::Value PushButton::GetProperty( BaseObject* object, Property::Index propertyIndex )
+{
+  Property::Value value;
+
+  Toolkit::PushButton pushButton = Toolkit::PushButton::DownCast( Dali::BaseHandle( object ) );
+
+  if ( pushButton )
+  {
+    PushButton& pushButtonImpl( GetImplementation( pushButton ) );
+
+    switch ( propertyIndex )
+    {
+      case Toolkit::PushButton::Property::UNSELECTED_ICON:
+      {
+        value = pushButtonImpl.GetIcon( UNSELECTED_DECORATION );
+        break;
+      }
+      case Toolkit::PushButton::Property::SELECTED_ICON:
+      {
+        value = pushButtonImpl.GetIcon( UNSELECTED_DECORATION );
+        break;
+      }
+      case Toolkit::PushButton::Property::ICON_ALIGNMENT:
+      {
+        value = Scripting::GetLinearEnumerationName< IconAlignment >( pushButtonImpl.GetIconAlignment(), IconAlignmentTable, IconAlignmentTableCount );
+        break;
+      }
+      case Toolkit::PushButton::Property::LABEL_PADDING:
+      {
+        value = pushButtonImpl.GetLabelPadding();
+        break;
+      }
+      case Toolkit::PushButton::Property::ICON_PADDING:
+      {
+        value = pushButtonImpl.GetIconPadding();
+        break;
+      }
+    }
+  }
+
+  return value;
 }
 
 void PushButton::OnLabelSet()
 {
-  Actor& label = GetLabel();
+  Actor& label = GetLabelActor();
 
   if( label )
   {
-    label.SetAnchorPoint( AnchorPoint::CENTER );
-    label.SetParentOrigin( ParentOrigin::CENTER );
-
     Toolkit::TextLabel textLabel = Toolkit::TextLabel::DownCast( label );
     if( textLabel )
     {
-      textLabel.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
-      textLabel.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
-      textLabel.SetProperty( Toolkit::TextLabel::Property::MULTI_LINE, true );
+      textLabel.SetProperty( Toolkit::TextLabel::Property::MULTI_LINE, false );
     }
-
-    ConfigureSizeNegotiation();
   }
+  ConfigureSizeNegotiation();
 }
 
 void PushButton::OnButtonImageSet()
 {
   ConfigureSizeNegotiation();
-  RelayoutRequest();
 }
 
 void PushButton::OnSelectedImageSet()
 {
   ConfigureSizeNegotiation();
-  RelayoutRequest();
 }
 
 void PushButton::OnBackgroundImageSet()
 {
   ConfigureSizeNegotiation();
-  RelayoutRequest();
 }
 
 void PushButton::OnSelectedBackgroundImageSet()
 {
   ConfigureSizeNegotiation();
-  RelayoutRequest();
 }
 
 void PushButton::OnDisabledImageSet()
 {
   ConfigureSizeNegotiation();
-  RelayoutRequest();
 }
 
 void PushButton::OnDisabledSelectedImageSet()
 {
   ConfigureSizeNegotiation();
-  RelayoutRequest();
 }
 
 void PushButton::OnDisabledBackgroundImageSet()
 {
   ConfigureSizeNegotiation();
-  RelayoutRequest();
 }
 
 void PushButton::OnSizeSet( const Vector3& targetSize )
@@ -190,7 +329,7 @@ void PushButton::OnSizeSet( const Vector3& targetSize )
   {
     mSize = targetSize;
 
-    Actor& label = GetLabel();
+    Actor& label = GetLabelActor();
 
     if( label )
     {
@@ -238,19 +377,56 @@ Vector3 PushButton::GetNaturalSize()
   Vector3 size;
 
   // If label, test against it's size
-  Toolkit::TextLabel label = Toolkit::TextLabel::DownCast( GetLabel() );
-  if( label )
+  Toolkit::TextLabel label = Toolkit::TextLabel::DownCast( GetLabelActor() );
+
+  Actor icon = GetDecoration( UNSELECTED_DECORATION );
+  if( label || icon )
   {
-    Padding padding( 0.0f, 0.0f, 0.0f, 0.0f );
-    label.GetPadding( padding );
-    size = label.GetNaturalSize();
-    size.width += padding.x + padding.width;
-    size.height += padding.y + padding.height;
+    Vector3 labelSize( Vector3::ZERO );
+    Vector3 iconSize( Vector3::ZERO );
+
+    if( label )
+    {
+      Vector3 labelNaturalSize = label.GetNaturalSize();
+      labelSize.width = labelNaturalSize.width + mLabelPadding.left + mLabelPadding.right;
+      labelSize.height = labelNaturalSize.height + mLabelPadding.top + mLabelPadding.bottom;
+    }
+
+    if( icon )
+    {
+      Vector3 iconNaturalSize = icon.GetNaturalSize();
+      iconSize.width = iconNaturalSize.width + mIconPadding.left + mIconPadding.right;
+      iconSize.height = iconNaturalSize.height + mIconPadding.top + mIconPadding.bottom;
+
+      switch( mIconAlignment )
+      {
+        case LEFT:
+        case RIGHT:
+        {
+          size.width = labelSize.width + iconSize.width;
+          size.height = std::max( labelSize.height, iconSize.height );
+          break;
+        }
+        case TOP:
+        case BOTTOM:
+        {
+          size.width = std::max( labelSize.width, iconSize.width );
+          size.height = labelSize.height + iconSize.height;
+          break;
+        }
+      }
+    }
+    else
+    {
+      // No icon, so size is the same as label size.
+      // (If there is no label this is zero).
+      size = labelSize;
+    }
   }
   else
   {
     // Check Image and Background image and use the largest size as the control's Natural size.
-    SizeOfActorIfLarger( GetButtonImage(), size );
+    SizeOfActorIfLarger( GetUnselectedImage(), size );
     SizeOfActorIfLarger( GetBackgroundImage(), size );
   }
 
@@ -267,7 +443,7 @@ void PushButton::ConfigureSizeNegotiation()
   std::vector< Actor > images;
   images.reserve( 7 );
 
-  images.push_back( GetButtonImage() );
+  images.push_back( GetUnselectedImage() );
   images.push_back( GetSelectedImage() );
   images.push_back( GetSelectedBackgroundImage() );
   images.push_back( GetBackgroundImage() );
@@ -275,31 +451,110 @@ void PushButton::ConfigureSizeNegotiation()
   images.push_back( GetDisabledSelectedImage() );
   images.push_back( GetDisabledBackgroundImage() );
 
-  Actor label = GetLabel();
+  Actor label = GetLabelActor();
 
   for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i )
   {
     ConfigureSizeNegotiationDimension( static_cast< Dimension::Type >( 1 << i ), images, label );
   }
 
+  // Add any vertical padding directly to the actors.
+  Actor icon = GetDecoration( UNSELECTED_DECORATION );
+  Actor selectedIcon = GetDecoration( SELECTED_DECORATION );
+  bool iconExists = icon || selectedIcon;
+
   if( label )
   {
-    Padding padding;
+    label.SetPadding( mLabelPadding );
+  }
+  if( icon )
+  {
+    icon.SetPadding( mIconPadding );
+  }
+  if( selectedIcon )
+  {
+    selectedIcon.SetPadding( mIconPadding );
+  }
 
-    if( label.GetResizePolicy( Dimension::WIDTH ) == ResizePolicy::USE_NATURAL_SIZE )
-    {
-      padding.left = TEXT_PADDING;
-      padding.right = TEXT_PADDING;
-    }
+  // Calculate and apply horizontal alignments and offsets
+  // to text and icon (depending on existence).
+  Vector3 iconPosition( Vector3::ZERO );
+  Vector3 labelPosition( Vector3::ZERO );
+  Vector3 iconAnchoring( AnchorPoint::CENTER );
+  Vector3 labelAnchoring( AnchorPoint::CENTER );
+  std::string horizontalLabelAlignment = "CENTER";
+  std::string verticalLabelAlignment = "CENTER";
 
-    if( label.GetResizePolicy( Dimension::HEIGHT ) == ResizePolicy::USE_NATURAL_SIZE )
+  if( iconExists && label )
+  {
+    // There is an icon and a label to lay out.
+    switch( mIconAlignment )
     {
-      padding.top = TEXT_PADDING;
-      padding.bottom = TEXT_PADDING;
+      case LEFT:
+      {
+        iconPosition.x = mIconPadding.left;
+        labelPosition.x = -mLabelPadding.right;
+        iconAnchoring = AnchorPoint::CENTER_LEFT;
+        labelAnchoring = AnchorPoint::CENTER_RIGHT;
+        horizontalLabelAlignment = "END";
+        break;
+      }
+      case RIGHT:
+      {
+        iconPosition.x = -mIconPadding.right;
+        labelPosition.x = mLabelPadding.left;
+        iconAnchoring = AnchorPoint::CENTER_RIGHT;
+        labelAnchoring = AnchorPoint::CENTER_LEFT;
+        horizontalLabelAlignment = "BEGIN";
+        break;
+      }
+      case TOP:
+      {
+        iconPosition.y = mIconPadding.top;
+        labelPosition.y = -mLabelPadding.bottom;
+        iconAnchoring = AnchorPoint::TOP_CENTER;
+        labelAnchoring = AnchorPoint::BOTTOM_CENTER;
+        verticalLabelAlignment = "BOTTOM";
+        break;
+      }
+      case BOTTOM:
+      {
+        iconPosition.y = -mIconPadding.bottom;
+        labelPosition.y = mLabelPadding.top;
+        iconAnchoring = AnchorPoint::BOTTOM_CENTER;
+        labelAnchoring = AnchorPoint::TOP_CENTER;
+        verticalLabelAlignment = "TOP";
+        break;
+      }
     }
+  }
 
-    label.SetPadding( padding );
+  // Note: If there is only an icon, or only a label, the default values are now correct.
+  // Setup the icon(s) with the precalculated values.
+  if( icon )
+  {
+    icon.SetPosition( iconPosition );
+    icon.SetParentOrigin( iconAnchoring );
+    icon.SetAnchorPoint( iconAnchoring );
   }
+  if( selectedIcon )
+  {
+    selectedIcon.SetPosition( iconPosition );
+    selectedIcon.SetParentOrigin( iconAnchoring );
+    selectedIcon.SetAnchorPoint( iconAnchoring );
+  }
+
+  // Setup the label.
+  if( label )
+  {
+    label.SetPosition( labelPosition );
+    label.SetParentOrigin( labelAnchoring );
+    label.SetAnchorPoint( labelAnchoring );
+    label.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, horizontalLabelAlignment );
+    label.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, verticalLabelAlignment );
+  }
+
+  RelayoutRequest();
 }
 
 void PushButton::ConfigureSizeNegotiationDimension( Dimension::Type dimension, const std::vector< Actor >& images, Actor& label )
@@ -307,28 +562,17 @@ void PushButton::ConfigureSizeNegotiationDimension( Dimension::Type dimension, c
   ResizePolicy::Type imageResizePolicy = ResizePolicy::FILL_TO_PARENT;
   ResizePolicy::Type labelResizePolicy = ResizePolicy::FILL_TO_PARENT;
 
-  switch( Self().GetResizePolicy( dimension ) )
+  ResizePolicy::Type resizePolicy = Self().GetResizePolicy( dimension );
+
+  if( resizePolicy == ResizePolicy::FIT_TO_CHILDREN || resizePolicy == ResizePolicy::USE_NATURAL_SIZE )
   {
-    case ResizePolicy::FIT_TO_CHILDREN:
-    {
-      imageResizePolicy = labelResizePolicy = ResizePolicy::USE_NATURAL_SIZE;
-      break;
-    }
-    case ResizePolicy::USE_NATURAL_SIZE:
+    if( label )
     {
-      if( label )
-      {
-        labelResizePolicy = ResizePolicy::USE_NATURAL_SIZE;
-      }
-      else
-      {
-        imageResizePolicy = ResizePolicy::USE_NATURAL_SIZE;
-      }
-      break;
+      labelResizePolicy = ResizePolicy::USE_NATURAL_SIZE;
     }
-    default:
+    else
     {
-      break;
+      imageResizePolicy = ResizePolicy::USE_NATURAL_SIZE;
     }
   }
 
@@ -347,6 +591,7 @@ void PushButton::ConfigureSizeNegotiationDimension( Dimension::Type dimension, c
   }
 }
 
+
 } // namespace Internal
 
 } // namespace Toolkit
index 51164b5..f1925a3 100644 (file)
@@ -61,6 +61,38 @@ protected:
    */
   virtual ~PushButton();
 
+public:
+
+  // Properties
+
+  /**
+   * Enum for the alignment modes of the icon.
+   */
+  enum IconAlignment
+  {
+    LEFT,
+    RIGHT,
+    TOP,
+    BOTTOM,
+    DEFAULT = RIGHT
+  };
+
+  /**
+   * Called when a property of an object of this type is set.
+   * @param[in] object The object whose property is set.
+   * @param[in] index The property index.
+   * @param[in] value The new property value.
+   */
+  static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
+
+  /**
+   * Called to retrieve a property of an object of this type.
+   * @param[in] object The object whose property is to be retrieved.
+   * @param[in] index The property index.
+   * @return The current value of the property.
+   */
+  static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
+
 private: // From Button
 
   /**
@@ -168,6 +200,64 @@ private:
    */
   void ConfigureSizeNegotiationDimension( Dimension::Type dimension, const std::vector< Actor >& images, Actor& label );
 
+  /**
+   * @brief Sets either the selected or unselected icon.
+   *
+   * @param[in] state The icon state to set
+   * @param[in] iconFilename The filename of the icon
+   */
+  void SetIcon( DecorationState state, const std::string iconFilename );
+
+  /**
+   * @brief Gets either the selected or unselected icon.
+   *
+   * @param[in] state The icon state to get
+   * @return    The filename of the icon
+   */
+  std::string& GetIcon( DecorationState state );
+
+  /**
+   * @brief Sets the alignment mode to use to align the icon to the label.
+   *
+   * @param[in] iconAlignment The alignment mode to use
+   */
+  void SetIconAlignment( const PushButton::IconAlignment iconAlignment );
+
+  /**
+   * @brief Gets the alignment mode used to align the icon to the label.
+   *
+   * @return The alignment mode in use
+   */
+  const PushButton::IconAlignment GetIconAlignment() const;
+
+  /**
+   * @brief Sets the padding for the label.
+   *
+   * @param[in] padding The padding to set
+   */
+  void SetLabelPadding( const Vector4& padding );
+
+  /**
+   * @brief Gets the padding for the label.
+   *
+   * @return The label padding
+   */
+  Vector4 GetLabelPadding();
+
+  /**
+   * @brief Sets the padding for the icon.
+   *
+   * @param[in] padding The padding to set
+   */
+  void SetIconPadding( const Vector4& padding );
+
+  /**
+   * @brief Gets the padding for the icon.
+   *
+   * @return The icon padding
+   */
+  Vector4 GetIconPadding();
+
 private:
 
   // Undefined
@@ -178,7 +268,11 @@ private:
 
 private:
 
-  Vector3               mSize;                      ///< The button's size.
+  std::string    mIconName[ DECORATION_STATES ]; ///< The original filenames for the icons.
+  Padding        mLabelPadding;                  ///< The padding around the label (if present).
+  Padding        mIconPadding;                   ///< The padding around the icon (if present).
+  IconAlignment  mIconAlignment;                 ///< The alignment of the icon against the label.
+  Vector3        mSize;                          ///< The button's size.
 };
 
 } // namespace Internal
index 1e51ce3..739972a 100644 (file)
@@ -81,15 +81,10 @@ void RadioButton::OnButtonInitialize()
   // Wrap size of radio button around all its children
   self.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
 
-  Image buttonImage = Dali::ResourceImage::New( UNSELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER );
-  Image selectedImage = Dali::ResourceImage::New( SELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER );
-  Image disabledImage = Dali::ResourceImage::New( DISABLED_UNSELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER );
-  Image disabledSelectedImage = Dali::ResourceImage::New( DISABLED_SELECTED_BUTTON_IMAGE_DIR, ResourceImage::ON_DEMAND, ResourceImage::NEVER );
-
-  SetButtonImage( ImageActor::New( buttonImage ) );
-  SetSelectedImage( ImageActor::New( selectedImage ) );
-  SetDisabledImage( ImageActor::New( disabledImage ) );
-  SetDisabledSelectedImage( ImageActor::New( disabledSelectedImage ) );
+  SetUnselectedImage( UNSELECTED_BUTTON_IMAGE_DIR );
+  SetSelectedImage( SELECTED_BUTTON_IMAGE_DIR );
+  SetDisabledImage( DISABLED_UNSELECTED_BUTTON_IMAGE_DIR );
+  SetDisabledSelectedImage( DISABLED_SELECTED_BUTTON_IMAGE_DIR );
 
   RelayoutRequest();
 }
@@ -108,7 +103,7 @@ void RadioButton::OnButtonUp()
 
 void RadioButton::OnLabelSet()
 {
-  Actor& label = GetLabel();
+  Actor& label = GetLabelActor();
 
   if( label )
   {
@@ -125,9 +120,9 @@ void RadioButton::OnLabelSet()
     {
       label.SetX( GetSelectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
     }
-    else if( GetButtonImage() )
+    else if( GetUnselectedImage() )
     {
-      label.SetX( GetButtonImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
+      label.SetX( GetUnselectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
     }
     else
     {
@@ -138,7 +133,7 @@ void RadioButton::OnLabelSet()
 
 void RadioButton::OnSelected()
 {
-  Actor& label = GetLabel();
+  Actor& label = GetLabelActor();
 
   PaintState paintState = GetPaintState();
   switch( paintState )
@@ -167,7 +162,7 @@ void RadioButton::OnSelected()
     }
     case SelectedState:
     {
-      Actor& buttonImage = GetButtonImage();
+      Actor& buttonImage = GetUnselectedImage();
       if( label && buttonImage )
       {
         label.SetX( buttonImage.GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
index c70b792..c4d2840 100644 (file)
@@ -457,11 +457,14 @@ void ItemView::DeactivateCurrentLayout()
 
 void ItemView::OnRefreshNotification(PropertyNotification& source)
 {
-  if(mRefreshEnabled || mScrollAnimation)
+  // Cancel scroll animation to prevent any fighting of setting the scroll position property by scroll bar during fast scroll.
+  if(!mRefreshEnabled && mScrollAnimation)
   {
-    // Only refresh the cache during normal scrolling
-    DoRefresh(GetCurrentLayoutPosition(0), true);
+    RemoveAnimation(mScrollAnimation);
   }
+
+  // Only cache extra items when it is not a fast scroll
+  DoRefresh(GetCurrentLayoutPosition(0), mRefreshEnabled || mScrollAnimation);
 }
 
 void ItemView::Refresh()
@@ -957,7 +960,6 @@ void ItemView::OnChildAdd(Actor& child)
                                         Toolkit::Scrollable::Property::SCROLL_POSITION_MIN_Y,
                                         Toolkit::Scrollable::Property::SCROLL_POSITION_MAX_Y,
                                         Toolkit::ItemView::Property::SCROLL_CONTENT_SIZE);
-      scrollBar.ScrollPositionIntervalReachedSignal().Connect( this, &ItemView::OnScrollPositionChanged );
     }
   }
 }
@@ -1625,18 +1627,6 @@ void ItemView::GetItemsRange(ItemRange& range)
   }
 }
 
-void ItemView::OnScrollPositionChanged( float position )
-{
-  // Cancel scroll animation to prevent any fighting of setting the scroll position property.
-  if(!mRefreshEnabled)
-  {
-    RemoveAnimation(mScrollAnimation);
-  }
-
-  // Refresh the cache immediately when the scroll position is changed.
-  DoRefresh(position, false); // No need to cache extra items.
-}
-
 bool ItemView::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
 {
   Dali::BaseHandle handle( object );
index b6a2d96..9fc58aa 100644 (file)
@@ -559,12 +559,6 @@ private:
    */
   void OnRefreshNotification(PropertyNotification& source);
 
-  /**
-   * This is called when the change of scroll position is notified by ScrollBar.
-   * @param[in] position The new scroll position
-   */
-  void OnScrollPositionChanged( float position );
-
 private:
 
   ItemFactory& mItemFactory;
index 3ff907b..bc54dca 100644 (file)
@@ -47,7 +47,8 @@ namespace
 // todo Move this to adaptor??
 #define GET_LOCALE_TEXT(string) dgettext("elementary", string)
 
-const std::string TEXT_SELECTION_POPUP_LABEL = "textselectionpopuplabel";
+const std::string TEXT_SELECTION_POPUP_LABEL( "textselectionpopuplabel" );
+const Dali::Vector4 DEFAULT_OPTION_PRESSED_COLOR( Dali::Vector4( 0.24f, 0.72f, 0.8f, 1.0f ) );
 
 #ifdef DGETTEXT_ENABLED
 
@@ -96,9 +97,10 @@ DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-copy-button-imag
 DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-paste-button-image", STRING, POPUP_PASTE_BUTTON_ICON_IMAGE )
 DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-select-button-image", STRING, POPUP_SELECT_BUTTON_ICON_IMAGE )
 DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-select-all-button-image", STRING, POPUP_SELECT_ALL_BUTTON_ICON_IMAGE )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-divider-color", VECTOR4, DIVIDER_COLOR )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-icon-color", VECTOR4, ICON_COLOR )
-DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-pressed-color", VECTOR4, PRESSED_COLOR )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-divider-color", VECTOR4, POPUP_DIVIDER_COLOR )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-icon-color", VECTOR4, POPUP_ICON_COLOR )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-pressed-color", VECTOR4, POPUP_PRESSED_COLOR )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popup-pressed-image", STRING, POPUP_PRESSED_IMAGE )
 
 DALI_TYPE_REGISTRATION_END()
 
@@ -188,21 +190,26 @@ void TextSelectionPopup::SetProperty( BaseObject* object, Property::Index index,
         impl.SetButtonImage( Toolkit::TextSelectionPopup::SELECT_ALL, image );
         break;
       }
-      case Toolkit::TextSelectionPopup::Property::DIVIDER_COLOR:
+      case Toolkit::TextSelectionPopup::Property::POPUP_DIVIDER_COLOR:
       {
         impl.mDividerColor = value.Get< Vector4 >();
         break;
       }
-      case Toolkit::TextSelectionPopup::Property::ICON_COLOR:
+      case Toolkit::TextSelectionPopup::Property::POPUP_ICON_COLOR:
       {
         impl.mIconColor = value.Get< Vector4 >();
         break;
       }
-      case Toolkit::TextSelectionPopup::Property::PRESSED_COLOR:
+      case Toolkit::TextSelectionPopup::Property::POPUP_PRESSED_COLOR:
       {
         impl.mPressedColor = value.Get< Vector4 >();
         break;
       }
+      case Toolkit::TextSelectionPopup::Property::POPUP_PRESSED_IMAGE:
+      {
+        impl.SetPressedImage( value.Get< std::string >() );
+        break;
+      }
     } // switch
   } // TextSelectionPopup
 }
@@ -293,6 +300,11 @@ Property::Value TextSelectionPopup::GetProperty( BaseObject* object, Property::I
         }
         break;
       }
+      case Toolkit::TextSelectionPopup::Property::POPUP_PRESSED_IMAGE:
+      {
+        value = impl.GetPressedImage();
+        break;
+      }
     } // switch
   }
   return value;
@@ -530,6 +542,16 @@ Dali::Image TextSelectionPopup::GetButtonImage( Toolkit::TextSelectionPopup::But
   return Dali::Image();
 }
 
+void TextSelectionPopup::SetPressedImage( const std::string& filename )
+{
+  mPressedImage = filename;
+}
+
+std::string TextSelectionPopup::GetPressedImage() const
+{
+  return mPressedImage;
+}
+
  void TextSelectionPopup::CreateOrderedListOfPopupOptions()
  {
    mOrderListOfButtons.clear();
@@ -549,85 +571,11 @@ Dali::Image TextSelectionPopup::GetButtonImage( Toolkit::TextSelectionPopup::But
 
  void TextSelectionPopup::AddOption( const ButtonRequirement& button, bool showDivider, bool showIcons, bool showCaption  )
  {
-   const std::string& name = button.name;
-   const std::string& caption = button.caption;
-   Image iconImage = button.icon;
-
-   // 1. Create the backgrounds for the popup option both normal and pressed.
-   // Both containers will be added to a button.
-
-   Toolkit::TableView optionContainer = Toolkit::TableView::New( (showIcons&showCaption)?2:1 , 1 );
-   optionContainer.SetFitHeight( 0 );
-   optionContainer.SetFitWidth( 0 );
-
-   Toolkit::TableView  optionPressedContainer = Toolkit::TableView::New( (showIcons&showCaption)?2:1 , 1 );
-   optionPressedContainer.SetFitHeight( 0 );
-   optionPressedContainer.SetFitWidth( 0 );
-   optionPressedContainer.SetBackgroundColor( mPressedColor );
-
-#ifdef DECORATOR_DEBUG
-   optionContainer.SetName("optionContainer");
-   optionPressedContainer.SetName("optionPressedContainer");
-#endif
-   // 2. Add text.
-
-   if ( showCaption )
-   {
-     Toolkit::TextLabel captionTextLabel = Toolkit::TextLabel::New();
-     captionTextLabel.SetStyleName( TEXT_SELECTION_POPUP_LABEL );
-     captionTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, caption );
-     captionTextLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
-
-     Toolkit::TextLabel pressedCaptionTextLabel = Toolkit::TextLabel::New();
-     pressedCaptionTextLabel.SetStyleName( TEXT_SELECTION_POPUP_LABEL );
-     pressedCaptionTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, caption );
-     pressedCaptionTextLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
-
-     Padding padding;
-     padding.left = 24.0f;
-     padding.right = 24.0f;
-     padding.top = 14.0f;
-     padding.bottom = 14.0f;
-     captionTextLabel.SetPadding( padding );
-     pressedCaptionTextLabel.SetPadding( padding );
-
-     optionContainer.AddChild( captionTextLabel, Toolkit::TableView::CellPosition(( showIcons&showCaption)?1:0, 0 )  );
-     optionPressedContainer.AddChild( pressedCaptionTextLabel, Toolkit::TableView::CellPosition(( showIcons&showCaption)?1:0, 0 ) );
-   }
-
-   int depth = Self().GetHierarchyDepth();
-   // 3. Create the icons
-   if ( showIcons && iconImage )
-   {
-     ImageActor pressedIcon = ImageActor::New(  iconImage );
-     ImageActor icon = ImageActor::New(  iconImage );
-     icon.SetSortModifier( DECORATION_DEPTH_INDEX + depth - 1 );
-     pressedIcon.SetSortModifier( DECORATION_DEPTH_INDEX + depth - 1 );
-
-     icon.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
-     pressedIcon.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
-     icon.SetColor( mIconColor );
-
-     if ( showCaption & showIcons )
-     {
-       optionContainer.SetFitHeight( 1 );
-       optionContainer.SetFitWidth( 1 );
-       optionPressedContainer.SetFitHeight( 1 );
-       optionPressedContainer.SetFitWidth( 1 );
-     }
-
-     optionContainer.AddChild( icon, Toolkit::TableView::CellPosition( 0, 0 )  );
-     optionPressedContainer.AddChild( pressedIcon, Toolkit::TableView::CellPosition( 0, 0 )  );
-
-     icon.SetPadding( Padding( 10.0f, 10.0f, 10.0f, 10.0f ) );
-     pressedIcon.SetPadding( Padding( 10.0f, 10.0f, 10.0f, 10.0f ) );
-   }
-
-   // 4. Create a option.
+   // 1. Create a option.
    Toolkit::PushButton option = Toolkit::PushButton::New();
-   option.SetName( name );
+   option.SetName( button.name );
    option.SetAnimationTime( 0.0f );
-   option.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
+   option.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
 
    switch( button.id )
    {
@@ -668,16 +616,34 @@ Dali::Image TextSelectionPopup::GetButtonImage( Toolkit::TextSelectionPopup::But
      }
    }
 
-   // 5. Set the normal option image.
-   option.SetButtonImage( optionContainer );
+   // 2. Set the options contents.
+   if( showCaption )
+   {
+     option.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 24.0f, 24.0f, 14.0f, 14.0f ) );
+     option.SetLabelText( button.caption );
+   }
+   if( showIcons )
+   {
+     option.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, Vector4( 10.0f, 10.0f, 10.0f, 10.0f ) );
+     option.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "TOP" );
+
+     // TODO: This is temporarily disabled until the text-selection-popup image API is changed to strings.
+     //option.SetProperty( Toolkit::PushButton::Property::SELECTED_ICON, button.icon );
+     //option.SetProperty( Toolkit::PushButton::Property::UNSELECTED_ICON, button.icon );
+   }
+
+   // 3. Set the normal option image (blank / Transparent).
+   option.SetUnselectedImage( "" );
 
-   // 6. Set the pressed option image
-   option.SetSelectedImage( optionPressedContainer );
+   // 4. Set the pressed option image.
+   // The image can be blank, the color can be used regardless.
+   option.SetSelectedImage( mPressedImage );
+   option.SetProperty( Toolkit::Button::Property::SELECTED_COLOR, mPressedColor );
 
-   // 7 Add option to tool bar
+   // 5 Add option to tool bar
    mToolbar.AddOption( option );
 
-   // 8. Add the divider
+   // 6. Add the divider
    if( showDivider )
    {
      const Size size( mOptionDividerSize.width, 0.0f ); // Height FILL_TO_PARENT
@@ -689,7 +655,7 @@ Dali::Image TextSelectionPopup::GetButtonImage( Toolkit::TextSelectionPopup::But
      divider.SetSize( size );
      divider.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
      divider.SetColor( mDividerColor );
-     divider.SetSortModifier( DECORATION_DEPTH_INDEX + depth );
+     divider.SetSortModifier( DECORATION_DEPTH_INDEX );
      mToolbar.AddDivider( divider );
    }
  }
@@ -745,9 +711,9 @@ TextSelectionPopup::TextSelectionPopup( TextSelectionPopupCallbackInterface* cal
   mOptionDividerSize(),
   mEnabledButtons( Toolkit::TextSelectionPopup::NONE ),
   mCallbackInterface( callbackInterface ),
+  mPressedColor( DEFAULT_OPTION_PRESSED_COLOR ),
   mDividerColor( Color::WHITE ),
-  mIconColor(  Color::WHITE ),
-  mPressedColor(  Color::WHITE ),
+  mIconColor( Color::WHITE ),
   mSelectOptionPriority( 1 ),
   mSelectAllOptionPriority ( 2 ),
   mCutOptionPriority ( 4 ),
index 619dc37..8e0141a 100644 (file)
@@ -220,6 +220,20 @@ private: // Implementation
    */
   Dali::Image GetButtonImage( Toolkit::TextSelectionPopup::Buttons button );
 
+  /**
+   * @brief Sets the image for the pressed state of a popup option.
+   *
+   * @param[in]  filename The image filename to use.
+   */
+  void SetPressedImage( const std::string& filename);
+
+  /**
+   * @brief Gets the image used for the pressed state of a popup option.
+   *
+   * @return     The image filename used.
+   */
+  std::string GetPressedImage() const;
+
   void CreateOrderedListOfPopupOptions();
 
   void AddOption( const ButtonRequirement& button, bool showDivider, bool showIcons, bool showCaption );
@@ -261,18 +275,19 @@ private: // Data
   Image mSelectIconImage;
   Image mSelectAllIconImage;
 
-  Size mOptionMaxSize;                 // Maximum size of an Option button
-  Size mOptionMinSize;                 // Minimum size of an Option button
-  Size mOptionDividerSize;             // Size of divider line
+  Size mOptionMaxSize;                  // Maximum size of an Option button
+  Size mOptionMinSize;                  // Minimum size of an Option button
+  Size mOptionDividerSize;              // Size of divider line
 
   std::vector<ButtonRequirement> mOrderListOfButtons; // List of buttons in the order to be displayed and a flag to indicate if needed.
 
   Toolkit::TextSelectionPopup::Buttons mEnabledButtons; // stores enabled buttons
   Toolkit::TextSelectionPopupCallbackInterface* mCallbackInterface;
 
+  std::string mPressedImage;            // Image used for the popup option when pressed.
+  Vector4 mPressedColor;                // Color of the popup option when pressed.
   Vector4 mDividerColor;                // Color of the divider between buttons
   Vector4 mIconColor;                   // Color of the popup icon.
-  Vector4 mPressedColor;                // Color of the popup option when pressed.
 
   // Priority of Options/Buttons in the Cut and Paste pop-up, higher priority buttons are displayed first, left to right.
   std::size_t mSelectOptionPriority;    // Position of Select Button
index aff18be..fd85439 100644 (file)
@@ -231,15 +231,33 @@ void ReorderLines( const Vector<BidirectionalParagraphInfoRun>& bidirectionalInf
 }
 
 bool GetMirroredText( const Vector<Character>& text,
-                      Vector<Character>& mirroredText )
+                      Vector<Character>& mirroredText,
+                      const Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo )
 {
+  bool hasTextMirrored = false;
+
   // Handle to the bidirectional info module in text-abstraction.
   TextAbstraction::BidirectionalSupport bidirectionalSupport = TextAbstraction::BidirectionalSupport::Get();
 
   mirroredText = text;
 
-  return bidirectionalSupport.GetMirroredText( mirroredText.Begin(),
-                                               mirroredText.Count() );
+  Character* mirroredTextBuffer = mirroredText.Begin();
+
+  // Traverse the paragraphs and mirror the right to left ones.
+  for( Vector<BidirectionalParagraphInfoRun>::ConstIterator it = bidirectionalInfo.Begin(),
+         endIt = bidirectionalInfo.End();
+       it != endIt;
+       ++it )
+  {
+    const BidirectionalParagraphInfoRun& run = *it;
+
+    const bool tmpMirrored = bidirectionalSupport.GetMirroredText( mirroredTextBuffer + run.characterRun.characterIndex,
+                                                                   run.characterRun.numberOfCharacters );
+
+    hasTextMirrored = hasTextMirrored || tmpMirrored;
+  }
+
+  return hasTextMirrored;
 }
 
 void GetCharactersDirection( const Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo,
index 2f3b251..72b147a 100644 (file)
@@ -71,15 +71,17 @@ void ReorderLines( const Vector<BidirectionalParagraphInfoRun>& bidirectionalInf
                    Vector<BidirectionalLineInfoRun>& lineInfoRuns );
 
 /**
- * @brief Replaces any character which could be mirrored.
+ * @brief Replaces any character in the right to left paragraphs which could be mirrored.
  *
  * @param[in] text The text.
  * @param[in] mirroredText The mirroredText.
+ * @param[in] bidirectionalInfo Vector with the bidirectional infor for each paragraph.
  *
  * @return @e true if a character has been replaced.
  */
 bool GetMirroredText( const Vector<Character>& text,
-                      Vector<Character>& mirroredText );
+                      Vector<Character>& mirroredText,
+                      const Vector<BidirectionalParagraphInfoRun>& bidirectionalInfo );
 
 /**
  * @brief Retrieves the character's directions.
index 01a5786..442b631 100644 (file)
@@ -580,7 +580,7 @@ struct LayoutEngine::Impl
         lineRun.numberOfGlyphs = layout.numberOfGlyphs;
         lineRun.characterRun.characterIndex = layout.characterIndex;
         lineRun.characterRun.numberOfCharacters = layout.numberOfCharacters;
-        if( isLastLine )
+        if( isLastLine && !layoutParameters.isLastNewParagraph )
         {
           const float width = layout.extraBearing + layout.length + layout.extraWidth + layout.wsLengthEndOfLine;
           if( MULTI_LINE_BOX == mLayout )
@@ -623,8 +623,36 @@ struct LayoutEngine::Impl
 
         // Increase the glyph index.
         index += layout.numberOfGlyphs;
+
+        if( isLastLine &&
+            layoutParameters.isLastNewParagraph &&
+            ( mLayout == MULTI_LINE_BOX ) )
+        {
+          // Need to add a new line with no characters but with height to increase the actualSize.height
+          const GlyphInfo& glyphInfo = *( layoutParameters.glyphsBuffer + layoutParameters.totalNumberOfGlyphs - 1u );
+
+          Text::FontMetrics fontMetrics;
+          mFontClient.GetFontMetrics( glyphInfo.fontId, fontMetrics );
+
+          LineRun lineRun;
+          lineRun.glyphIndex = 0u;
+          lineRun.numberOfGlyphs = 0u;
+          lineRun.characterRun.characterIndex = 0u;
+          lineRun.characterRun.numberOfCharacters = 0u;
+          lineRun.width = 0.f;
+          lineRun.ascender = fontMetrics.ascender;
+          lineRun.descender = fontMetrics.descender;
+          lineRun.extraLength = 0.f;
+          lineRun.alignmentOffset = 0.f;
+          lineRun.direction = !RTL;
+          lineRun.ellipsis = false;
+
+          actualSize.height += ( lineRun.ascender + -lineRun.descender );
+
+          lines.PushBack( lineRun );
+        }
       }
-    }
+    } // end for() traversing glyphs.
 
     DALI_LOG_INFO( gLogFilter, Debug::Verbose, "<--LayoutText\n\n" );
 
index 8a49a91..78746ff 100644 (file)
@@ -73,7 +73,8 @@ struct LayoutParameters
     charactersToGlyphsBuffer( NULL ),
     glyphsPerCharacterBuffer( NULL ),
     lineBidirectionalInfoRunsBuffer( NULL ),
-    numberOfBidirectionalInfoRuns( 0u )
+    numberOfBidirectionalInfoRuns( 0u ),
+    isLastNewParagraph( false )
   {}
 
   Vector2                         boundingBox;
@@ -89,6 +90,7 @@ struct LayoutParameters
   Length*                         glyphsPerCharacterBuffer;        ///< The number of glyphs per character.
   BidirectionalLineInfoRun*       lineBidirectionalInfoRunsBuffer; ///< Bidirectional conversion tables per line.
   Length                          numberOfBidirectionalInfoRuns;   ///< The number of lines with bidirectional info.
+  bool                            isLastNewParagraph;              ///< Whether the last character is a new paragraph character.
 };
 
 } // namespace Text
index 3fa8f6f..5284a3b 100644 (file)
@@ -194,7 +194,6 @@ Text::MultilanguageSupport MultilanguageSupport::Get()
 }
 
 void MultilanguageSupport::SetScripts( const Vector<Character>& text,
-                                       const Vector<LineBreakInfo>& lineBreakInfo,
                                        Vector<ScriptRun>& scripts )
 {
   const Length numberOfCharacters = text.Count();
@@ -214,8 +213,8 @@ void MultilanguageSupport::SetScripts( const Vector<Character>& text,
   // Reserve some space to reduce the number of reallocations.
   scripts.Reserve( numberOfCharacters << 2u );
 
-  // Whether the first valid script need to be set.
-  bool firstValidScript = true;
+  // Whether the first valid script needs to be set.
+  bool isFirstScriptToBeSet = true;
 
   // Whether the first valid script is a right to left script.
   bool isParagraphRTL = false;
@@ -224,14 +223,15 @@ void MultilanguageSupport::SetScripts( const Vector<Character>& text,
   Length numberOfAllScriptCharacters = 0u;
 
   // Pointers to the text and break info buffers.
-  const Character* textBuffer = text.Begin();
-  const LineBreakInfo* breakInfoBuffer = lineBreakInfo.Begin();
+  const Character* const textBuffer = text.Begin();
 
   // Traverse all characters and set the scripts.
   for( Length index = 0u; index < numberOfCharacters; ++index )
   {
     Character character = *( textBuffer + index );
-    LineBreakInfo breakInfo = *( breakInfoBuffer + index );
+
+    // Get the script of the character.
+    Script script = TextAbstraction::GetCharacterScript( character );
 
     // Some characters (like white spaces) are valid for many scripts. The rules to set a script
     // for them are:
@@ -244,19 +244,25 @@ void MultilanguageSupport::SetScripts( const Vector<Character>& text,
     // Skip those characters valid for many scripts like white spaces or '\n'.
     bool endOfText = index == numberOfCharacters;
     while( !endOfText &&
-           TextAbstraction::IsCommonScript( character ) )
+           ( TextAbstraction::COMMON == script ) )
     {
       // Count all these characters to be added into a script.
       ++numberOfAllScriptCharacters;
 
-      if( TextAbstraction::LINE_MUST_BREAK == breakInfo )
+      if( TextAbstraction::IsNewParagraph( character ) )
       {
-        // The next character is a new paragraph.
-        // Know when there is a new paragraph is needed because if there is a white space
+        // The character is a new paragraph.
+        // To know when there is a new paragraph is needed because if there is a white space
         // between two scripts with different directions, it is added to the script with
         // the same direction than the first script of the paragraph.
-        firstValidScript = true;
-        isParagraphRTL = false;
+        isFirstScriptToBeSet = true;
+
+        // Characters common to all scripts at the end of the paragraph are added to the last script (if the last one is not unknown).
+        if( TextAbstraction::UNKNOWN != currentScriptRun.script )
+        {
+          currentScriptRun.characterRun.numberOfCharacters += numberOfAllScriptCharacters;
+          numberOfAllScriptCharacters = 0u;
+        }
       }
 
       // Get the next character.
@@ -265,7 +271,7 @@ void MultilanguageSupport::SetScripts( const Vector<Character>& text,
       if( !endOfText )
       {
         character = *( textBuffer + index );
-        breakInfo = *( breakInfoBuffer + index );
+        script = TextAbstraction::GetCharacterScript( character );
       }
     }
 
@@ -276,25 +282,33 @@ void MultilanguageSupport::SetScripts( const Vector<Character>& text,
       break;
     }
 
-    // Get the script of the character.
-    Script script = TextAbstraction::GetCharacterScript( character );
-
     // Check if it is the first character of a paragraph.
-    if( firstValidScript &&
-        ( TextAbstraction::UNKNOWN != script ) )
+    if( isFirstScriptToBeSet &&
+        ( TextAbstraction::UNKNOWN != script ) &&
+        ( TextAbstraction::COMMON != script ) )
     {
       // Sets the direction of the first valid script.
       isParagraphRTL = TextAbstraction::IsRightToLeftScript( script );
-      firstValidScript = false;
+      isFirstScriptToBeSet = false;
     }
 
-    if( script != currentScriptRun.script )
+    if( ( script != currentScriptRun.script ) &&
+        ( TextAbstraction::COMMON != script ) )
     {
       // Current run needs to be stored and a new one initialized.
 
-      if( isParagraphRTL != TextAbstraction::IsRightToLeftScript( script ) )
+      if( ( isParagraphRTL == TextAbstraction::IsRightToLeftScript( currentScriptRun.script ) ) &&
+          ( TextAbstraction::UNKNOWN != currentScriptRun.script ) )
       {
-        // Current script has different direction than the first script of the paragraph.
+        // Previous script has the same direction than the first script of the paragraph.
+        // All the previously skipped characters need to be added to the previous script before it's stored.
+        currentScriptRun.characterRun.numberOfCharacters += numberOfAllScriptCharacters;
+        numberOfAllScriptCharacters = 0u;
+      }
+      else if( ( TextAbstraction::IsRightToLeftScript( currentScriptRun.script ) == TextAbstraction::IsRightToLeftScript( script ) ) &&
+               ( TextAbstraction::UNKNOWN != currentScriptRun.script ) )
+      {
+        // Current script and previous one have the same direction.
         // All the previously skipped characters need to be added to the previous script before it's stored.
         currentScriptRun.characterRun.numberOfCharacters += numberOfAllScriptCharacters;
         numberOfAllScriptCharacters = 0u;
@@ -308,26 +322,22 @@ void MultilanguageSupport::SetScripts( const Vector<Character>& text,
 
       // Initialize the new one.
       currentScriptRun.characterRun.characterIndex = currentScriptRun.characterRun.characterIndex + currentScriptRun.characterRun.numberOfCharacters;
-      currentScriptRun.characterRun.numberOfCharacters = numberOfAllScriptCharacters; // Adds the white spaces which are at the begining of the script.
+      currentScriptRun.characterRun.numberOfCharacters = numberOfAllScriptCharacters + 1u; // Adds the white spaces which are at the begining of the script.
       currentScriptRun.script = script;
       numberOfAllScriptCharacters = 0u;
     }
     else
     {
-      // Adds white spaces between characters.
-      currentScriptRun.characterRun.numberOfCharacters += numberOfAllScriptCharacters;
-      numberOfAllScriptCharacters = 0u;
-    }
+      if( TextAbstraction::UNKNOWN != currentScriptRun.script )
+      {
+        // Adds white spaces between characters.
+        currentScriptRun.characterRun.numberOfCharacters += numberOfAllScriptCharacters;
+        numberOfAllScriptCharacters = 0u;
 
-    if( TextAbstraction::LINE_MUST_BREAK == breakInfo )
-    {
-      // The next character is a new paragraph.
-      firstValidScript = true;
-      isParagraphRTL = false;
+        // Add one more character to the run.
+        ++currentScriptRun.characterRun.numberOfCharacters;
+      }
     }
-
-    // Add one more character to the run.
-    ++currentScriptRun.characterRun.numberOfCharacters;
   }
 
   // Add remaining characters into the last script.
index ee91aae..4dfc85c 100644 (file)
@@ -94,7 +94,6 @@ public:
    * @copydoc Dali::MultilanguageSupport::SetScripts()
    */
   void SetScripts( const Vector<Character>& text,
-                   const Vector<LineBreakInfo>& lineBreakInfo,
                    Vector<ScriptRun>& scripts );
 
   /**
index 8c28dd5..46d2cb5 100644 (file)
@@ -49,11 +49,9 @@ MultilanguageSupport MultilanguageSupport::Get()
 }
 
 void MultilanguageSupport::SetScripts( const Vector<Character>& text,
-                                       const Vector<LineBreakInfo>& lineBreakInfo,
                                        Vector<ScriptRun>& scripts )
 {
   GetImplementation( *this ).SetScripts( text,
-                                         lineBreakInfo,
                                          scripts );
 }
 
index a22676c..5c8ea1d 100644 (file)
@@ -91,11 +91,9 @@ public:
    *   script of the first character of the paragraph with a defined script.
    *
    * @param[in] text Vector of UTF-32 characters.
-   * @param[in] lineBreakInfo Vector with the line break info.
    * @param[out] scripts Vector containing the script runs for the whole text.
    */
   void SetScripts( const Vector<Character>& text,
-                   const Vector<LineBreakInfo>& lineBreakInfo,
                    Vector<ScriptRun>& scripts );
 
   /**
index 9ca8e9f..0f4a114 100644 (file)
@@ -49,7 +49,8 @@ void ShapeText( const Vector<Character>& text,
                 const Vector<FontRun>& fonts,
                 Vector<GlyphInfo>& glyphs,
                 Vector<CharacterIndex>& glyphToCharacterMap,
-                Vector<Length>& charactersPerGlyph )
+                Vector<Length>& charactersPerGlyph,
+                Vector<GlyphIndex>& newParagraphGlyphs )
 {
   const Length numberOfCharacters = text.Count();
 
@@ -74,7 +75,7 @@ void ShapeText( const Vector<Character>& text,
 
   // The text needs to be split in chunks of consecutive characters.
   // Each chunk must contain characters with the same font id and script set.
-  // A chunk of consecutive characters must not contain a LINE_MUST_BREAK, if there is one a new chunk have to be created.
+  // A chunk of consecutive characters must not contain a LINE_MUST_BREAK, if there is one a new chunk has to be created.
 
   TextAbstraction::Shaping shaping = TextAbstraction::Shaping::Get();
 
@@ -100,8 +101,8 @@ void ShapeText( const Vector<Character>& text,
   // The actual number of glyphs.
   Length totalNumberOfGlyphs = 0u;
 
-  const Character* textBuffer = text.Begin();
-  const LineBreakInfo* lineBreakInfoBuffer = lineBreakInfo.Begin();
+  const Character* const textBuffer = text.Begin();
+  const LineBreakInfo* const lineBreakInfoBuffer = lineBreakInfo.Begin();
   GlyphInfo* glyphsBuffer = glyphs.Begin();
   CharacterIndex* glyphToCharacterMapBuffer = glyphToCharacterMap.Begin();
 
@@ -121,33 +122,26 @@ void ShapeText( const Vector<Character>& text,
 
     // Check if there is a line must break.
     bool mustBreak = false;
+
+    // Check if the current index is a new paragraph character.
+    // A new paragraph character is going to be shaped in order to not to mess the conversion tables.
+    // However, the metrics need to be changed in order to not to draw a square.
+    bool isNewParagraph = false;
+
     for( CharacterIndex index = previousIndex; index < currentIndex; ++index )
     {
       mustBreak = TextAbstraction::LINE_MUST_BREAK == *( lineBreakInfoBuffer + index );
       if( mustBreak )
       {
-        currentIndex = index;
+        isNewParagraph = TextAbstraction::IsNewParagraph( *( textBuffer + index ) );
+        currentIndex = index + 1u;
         break;
       }
     }
 
-    // Check if the current index is a new paragraph character.
-    // A \n is going to be shaped in order to not to mess the conversion tables.
-    // After the \n character is shaped, the glyph is going to be reset to its
-    // default in order to not to get any metric or font index for it.
-    const bool isNewParagraph = TextAbstraction::IsNewParagraph( *( textBuffer + currentIndex ) );
-
-    // The last character is always a must-break even if it's not a \n.
-    Length numberOfCharactersToShape = currentIndex - previousIndex;
-    if( mustBreak )
-    {
-      // Add one more character to shape.
-      ++numberOfCharactersToShape;
-    }
-
     // Shape the text for the current chunk.
     const Length numberOfGlyphs = shaping.Shape( textBuffer + previousIndex,
-                                                 numberOfCharactersToShape,
+                                                 ( currentIndex - previousIndex ), // The number of characters to shape.
                                                  currentFontId,
                                                  currentScript );
 
@@ -172,14 +166,9 @@ void ShapeText( const Vector<Character>& text,
 
     if( isNewParagraph )
     {
-      // TODO : This is a work around to avoid drawing a square in the
-      //        place of a new line character.
-
-      // If the last character is a \n, it resets the glyph to the default
-      // to avoid getting any metric for it.
-      GlyphInfo& glyph = *( glyphsBuffer + glyphIndex + ( numberOfGlyphs - 1u ) );
-
-      glyph = GlyphInfo();
+      // Add the index of the new paragraph glyph to a vector.
+      // Their metrics will be updated in a following step.
+      newParagraphGlyphs.PushBack( totalNumberOfGlyphs - 1u );
     }
 
     // Update indices.
@@ -202,8 +191,8 @@ void ShapeText( const Vector<Character>& text,
       ++scriptRunIt;
     }
 
-    // Update the previous index. Jumps the \n if needed.
-    previousIndex = mustBreak ? currentIndex + 1u : currentIndex;
+    // Update the previous index.
+    previousIndex = currentIndex;
   }
 
   // Add the number of characters per glyph.
index f07cf49..70e2e58 100644 (file)
@@ -47,6 +47,7 @@ class VisualModel;
  * @param[out] glyphs Vector of glyphs in the visual order.
  * @param[out] glyphToCharacterMap Vector containing the first character in the logical model that each glyph relates to.
  * @param[out] charactersPerGlyph Vector containing the number of characters per glyph.
+ * @param[out] newParagraphGlyphs Vector containing the indices to the new paragraph glyphs.
  */
 void ShapeText( const Vector<Character>& text,
                 const Vector<LineBreakInfo>& lineBreakInfo,
@@ -54,7 +55,8 @@ void ShapeText( const Vector<Character>& text,
                 const Vector<FontRun>& fonts,
                 Vector<GlyphInfo>& glyphs,
                 Vector<CharacterIndex>& glyphToCharacterMap,
-                Vector<Length>& charactersPerGlyph );
+                Vector<Length>& charactersPerGlyph,
+                Vector<GlyphIndex>& newParagraphGlyphs );
 
 } // namespace Text
 
index c36b1d8..76e42ca 100644 (file)
@@ -329,7 +329,6 @@ void Controller::Impl::UpdateModel( OperationsMask operationsRequired )
     {
       // Retrieves the scripts used in the text.
       multilanguageSupport.SetScripts( utf32Characters,
-                                       lineBreakInfo,
                                        scripts );
     }
 
@@ -352,13 +351,12 @@ void Controller::Impl::UpdateModel( OperationsMask operationsRequired )
 
   Vector<Character> mirroredUtf32Characters;
   bool textMirrored = false;
+  Length numberOfParagraphs = 0u;
   if( BIDI_INFO & operations )
   {
     // Count the number of LINE_NO_BREAK to reserve some space for the vector of paragraph's
     // bidirectional info.
 
-    Length numberOfParagraphs = 0u;
-
     const TextAbstraction::LineBreakInfo* lineBreakInfoBuffer = lineBreakInfo.Begin();
     for( Length index = 0u; index < numberOfCharacters; ++index )
     {
@@ -382,7 +380,9 @@ void Controller::Impl::UpdateModel( OperationsMask operationsRequired )
       // This paragraph has right to left text. Some characters may need to be mirrored.
       // TODO: consider if the mirrored string can be stored as well.
 
-      textMirrored = GetMirroredText( utf32Characters, mirroredUtf32Characters );
+      textMirrored = GetMirroredText( utf32Characters,
+                                      mirroredUtf32Characters,
+                                      bidirectionalInfo );
 
       // Only set the character directions if there is right to left characters.
       Vector<CharacterDirection>& directions = mLogicalModel->mCharacterDirections;
@@ -401,6 +401,9 @@ void Controller::Impl::UpdateModel( OperationsMask operationsRequired )
   Vector<GlyphInfo>& glyphs = mVisualModel->mGlyphs;
   Vector<CharacterIndex>& glyphsToCharactersMap = mVisualModel->mGlyphsToCharacters;
   Vector<Length>& charactersPerGlyph = mVisualModel->mCharactersPerGlyph;
+  Vector<GlyphIndex> newParagraphGlyphs;
+  newParagraphGlyphs.Reserve( numberOfParagraphs );
+
   if( SHAPE_TEXT & operations )
   {
     const Vector<Character>& textToShape = textMirrored ? mirroredUtf32Characters : utf32Characters;
@@ -411,7 +414,8 @@ void Controller::Impl::UpdateModel( OperationsMask operationsRequired )
                validFonts,
                glyphs,
                glyphsToCharactersMap,
-               charactersPerGlyph );
+               charactersPerGlyph,
+               newParagraphGlyphs );
 
     // Create the 'number of glyphs' per character and the glyph to character conversion tables.
     mVisualModel->CreateGlyphsPerCharacterTable( numberOfCharacters );
@@ -422,7 +426,19 @@ void Controller::Impl::UpdateModel( OperationsMask operationsRequired )
 
   if( GET_GLYPH_METRICS & operations )
   {
-    mFontClient.GetGlyphMetrics( glyphs.Begin(), numberOfGlyphs );
+    GlyphInfo* glyphsBuffer = glyphs.Begin();
+    mFontClient.GetGlyphMetrics( glyphsBuffer, numberOfGlyphs );
+
+    // Update the width and advance of all new paragraph characters.
+    for( Vector<GlyphIndex>::ConstIterator it = newParagraphGlyphs.Begin(), endIt = newParagraphGlyphs.End(); it != endIt; ++it )
+    {
+      const GlyphIndex index = *it;
+      GlyphInfo& glyph = *( glyphsBuffer + index );
+
+      glyph.xBearing = 0.f;
+      glyph.width = 0.f;
+      glyph.advance = 0.f;
+    }
   }
 }
 
index 8b2b476..ef8b746 100644 (file)
@@ -811,7 +811,7 @@ bool Controller::DoRelayout( const Size& size,
     // after the first time the text has been laid out.
     // Fill the vectors again.
 
-    Length numberOfGlyphs = mImpl->mVisualModel->mGlyphs.Count();
+    const Length numberOfGlyphs = mImpl->mVisualModel->mGlyphs.Count();
 
     if( 0u == numberOfGlyphs )
     {
@@ -820,16 +820,17 @@ bool Controller::DoRelayout( const Size& size,
       return true;
     }
 
-    Vector<LineBreakInfo>& lineBreakInfo = mImpl->mLogicalModel->mLineBreakInfo;
-    Vector<WordBreakInfo>& wordBreakInfo = mImpl->mLogicalModel->mWordBreakInfo;
-    Vector<CharacterDirection>& characterDirection = mImpl->mLogicalModel->mCharacterDirections;
-    Vector<GlyphInfo>& glyphs = mImpl->mVisualModel->mGlyphs;
-    Vector<CharacterIndex>& glyphsToCharactersMap = mImpl->mVisualModel->mGlyphsToCharacters;
-    Vector<Length>& charactersPerGlyph = mImpl->mVisualModel->mCharactersPerGlyph;
+    const Vector<LineBreakInfo>& lineBreakInfo = mImpl->mLogicalModel->mLineBreakInfo;
+    const Vector<WordBreakInfo>& wordBreakInfo = mImpl->mLogicalModel->mWordBreakInfo;
+    const Vector<CharacterDirection>& characterDirection = mImpl->mLogicalModel->mCharacterDirections;
+    const Vector<GlyphInfo>& glyphs = mImpl->mVisualModel->mGlyphs;
+    const Vector<CharacterIndex>& glyphsToCharactersMap = mImpl->mVisualModel->mGlyphsToCharacters;
+    const Vector<Length>& charactersPerGlyph = mImpl->mVisualModel->mCharactersPerGlyph;
+    const Character* const textBuffer = mImpl->mLogicalModel->mText.Begin();
 
     // Set the layout parameters.
     LayoutParameters layoutParameters( size,
-                                       mImpl->mLogicalModel->mText.Begin(),
+                                       textBuffer,
                                        lineBreakInfo.Begin(),
                                        wordBreakInfo.Begin(),
                                        ( 0u != characterDirection.Count() ) ? characterDirection.Begin() : NULL,
@@ -854,6 +855,9 @@ bool Controller::DoRelayout( const Size& size,
     Vector<Vector2>& glyphPositions = mImpl->mVisualModel->mGlyphPositions;
     glyphPositions.Resize( numberOfGlyphs );
 
+    // Whether the last character is a new paragraph character.
+    layoutParameters.isLastNewParagraph = TextAbstraction::IsNewParagraph( *( textBuffer + ( mImpl->mLogicalModel->mText.Count() - 1u ) ) );
+
     // Update the visual model.
     viewUpdated = mImpl->mLayoutEngine.LayoutText( layoutParameters,
                                                    glyphPositions,
@@ -991,16 +995,7 @@ void Controller::SetVerticalAlignment( LayoutEngine::VerticalAlignment alignment
     // Set the alignment.
     mImpl->mLayoutEngine.SetVerticalAlignment( alignment );
 
-    // Set the flag to redo the alignment operation.
-    // TODO : Is not needed re-layout and reorder again but with the current implementation it is.
-    //        Im working on a different patch to fix an issue with the alignment. When that patch
-    //        is in, this issue can be fixed.
-    const OperationsMask layoutOperations =  static_cast<OperationsMask>( LAYOUT             |
-                                                                          UPDATE_ACTUAL_SIZE |
-                                                                          ALIGN              |
-                                                                          REORDER );
-
-    mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | layoutOperations );
+    mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | ALIGN );
 
     mImpl->RequestRelayout();
   }
index c7b7b89..f472375 100644 (file)
@@ -128,64 +128,49 @@ float Button::GetAnimationTime() const
   return Dali::Toolkit::GetImplementation( *this ).GetAnimationTime();
 }
 
-void Button::SetLabel( const std::string& label )
+void Button::SetLabelText( const std::string& label )
 {
-  Dali::Toolkit::GetImplementation( *this ).SetLabel( label );
-}
-
-void Button::SetLabel( Actor label )
-{
-  Dali::Toolkit::GetImplementation( *this ).SetLabel( label );
+  Dali::Toolkit::GetImplementation( *this ).SetLabelText( label );
 }
 
-Actor Button::GetLabel() const
+std::string Button::GetLabelText() const
 {
-  return Dali::Toolkit::GetImplementation( *this ).GetLabel();
+  return Dali::Toolkit::GetImplementation( *this ).GetLabelText();
 }
 
-void Button::SetButtonImage( Image image )
+void Button::SetUnselectedImage( const std::string& filename )
 {
-  Actor imageActor = ImageActor::New( image );
-  Dali::Toolkit::GetImplementation( *this ).SetButtonImage( imageActor );
+  Dali::Toolkit::GetImplementation( *this ).SetUnselectedImage( filename );
 }
 
-void Button::SetBackgroundImage( Image image )
+void Button::SetBackgroundImage( const std::string& filename )
 {
-  Actor imageActor = ImageActor::New( image );
-  Dali::Toolkit::GetImplementation( *this ).SetBackgroundImage( imageActor );
+  Dali::Toolkit::GetImplementation( *this ).SetBackgroundImage( filename );
 }
 
-void Button::SetSelectedImage( Image image )
+void Button::SetSelectedImage( const std::string& filename )
 {
-  Actor imageActor = ImageActor::New( image );
-  imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
-  Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( imageActor );
+  Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( filename );
 }
 
-void Button::SetSelectedBackgroundImage( Image image )
+void Button::SetSelectedBackgroundImage( const std::string& filename )
 {
-  Dali::Toolkit::GetImplementation( *this ).SetSelectedBackgroundImage( ImageActor::New( image ) );
+  Dali::Toolkit::GetImplementation( *this ).SetSelectedBackgroundImage( filename );
 }
 
-void Button::SetDisabledBackgroundImage( Image image )
+void Button::SetDisabledBackgroundImage( const std::string& filename )
 {
-  Actor imageActor = ImageActor::New( image );
-  imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
-  Dali::Toolkit::GetImplementation( *this ).SetDisabledBackgroundImage( imageActor );
+  Dali::Toolkit::GetImplementation( *this ).SetDisabledBackgroundImage( filename );
 }
 
-void Button::SetDisabledImage( Image image )
+void Button::SetDisabledImage( const std::string& filename )
 {
-  Actor imageActor = ImageActor::New( image );
-  imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
-  Dali::Toolkit::GetImplementation( *this ).SetDisabledImage( imageActor );
+  Dali::Toolkit::GetImplementation( *this ).SetDisabledImage( filename );
 }
 
-void Button::SetDisabledSelectedImage( Image image )
+void Button::SetDisabledSelectedImage( const std::string& filename )
 {
-  Actor imageActor = ImageActor::New( image );
-  imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
-  Dali::Toolkit::GetImplementation( *this ).SetDisabledSelectedImage( imageActor );
+  Dali::Toolkit::GetImplementation( *this ).SetDisabledSelectedImage( filename );
 }
 
 Button::ButtonSignalType& Button::PressedSignal()
@@ -208,6 +193,38 @@ Button::ButtonSignalType& Button::StateChangedSignal()
   return Dali::Toolkit::GetImplementation( *this ).StateChangedSignal();
 }
 
+// Deprecated API
+
+void Button::SetLabel( Actor label )
+{
+  Dali::Toolkit::GetImplementation( *this ).SetLabel( label );
+}
+
+void Button::SetButtonImage( Image image )
+{
+  Actor imageActor = ImageActor::New( image );
+  imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
+  Dali::Toolkit::GetImplementation( *this ).SetButtonImage( imageActor );
+}
+
+void Button::SetSelectedImage( Image image )
+{
+  Actor imageActor = ImageActor::New( image );
+  imageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
+  Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( imageActor );
+}
+
+Actor Button::GetButtonImage() const
+{
+  return Dali::Toolkit::GetImplementation( *this ).GetButtonImage();
+}
+
+Actor Button::GetSelectedImage() const
+{
+  return Dali::Toolkit::GetImplementation( *this ).GetSelectedImage();
+}
+
+
 Button::Button( Internal::Button& implementation )
 : Control( implementation )
 {
index baad4dc..9ba5348 100644 (file)
@@ -37,11 +37,33 @@ class Button;
  *
  * This class provides the disabled property and the clicked signal.
  *
- * A ClickedSignal() is emitted when the button is touched and the touch
- * point doesn't leave the boundary of the button.
+ * A ClickedSignal() is emitted when the button is touched and the touch point doesn't leave the boundary of the button.
  *
  * When the \e disabled property is set to \e true, no signal is emitted.
  *
+ * Button provides the following properties which modify the signals emitted:
+ * <ul>
+ *   <li>\e autorepeating
+ *       When \e autorepeating is set to \e true, a Button::PressedSignal(), Button::ReleasedSignal() and Button::ClickedSignal() signals are emitted at regular
+ *       intervals while the button is touched.
+ *       The intervals could be modified with the Button::SetInitialAutoRepeatingDelay and Button::SetNextAutoRepeatingDelay methods.
+ *
+ *       A \e togglable button can't be \e autorepeating. If the \e autorepeating property is set to \e true, then the \e togglable property is set to
+ *       false but no signal is emitted.
+ *
+ *   <li>\e togglable
+ *       When \e togglable is set to \e true, a Button::StateChangedSignal() signal is emitted, with the selected state.
+ * </ul>
+ *
+ * The button's appearance can be modified by setting properties for the various image filenames.
+ *
+ * The \e background is always shown and doesn't change if the button is pressed or released. The \e button image is shown over the \e background image when the
+ * button is not pressed and is replaced by the \e selected image when the button is pressed. The text label is placed always on the top of all images.
+ *
+ * When the button is disabled, \e background, \e button and \e selected images are replaced by their \e disabled images.
+ *
+ * Is not mandatory set all images. A button could be defined only by setting its \e background image or by setting its \e background and \e selected images.
+ *
  * Signals
  * | %Signal Name      | Method                      |
  * |-------------------|-----------------------------|
@@ -81,10 +103,12 @@ public:
       NEXT_AUTO_REPEATING_DELAY,       ///< name "next-auto-repeating-delay",    @see SetNextAutoRepeatingDelay(),    type float
       TOGGLABLE,                       ///< name "togglable",                    @see SetTogglableButton(),           type bool
       SELECTED,                        ///< name "selected",                     @see SetSelected(),                  type bool
-      NORMAL_STATE_ACTOR,              ///< name "normal-state-actor",           @see SetButtonImage(),               type Map
-      SELECTED_STATE_ACTOR,            ///< name "selected-state-actor",         @see SetSelectedImage(),             type Map
-      DISABLED_STATE_ACTOR,            ///< name "disabled-state-actor",         @see SetDisabledImage(),             type Map
-      LABEL_ACTOR,                     ///< name "label-actor",                  @see SetLabel(),                     type Map
+      UNSELECTED_STATE_IMAGE,          ///< name "unselected-state-image",       @see SetUnselectedImage(),           type std::string
+      SELECTED_STATE_IMAGE,            ///< name "selected-state-image",         @see SetSelectedImage(),             type std::string
+      DISABLED_STATE_IMAGE,            ///< name "disabled-state-image",         @see SetDisabledImage(),             type std::string
+      UNSELECTED_COLOR,                ///< name "unselected-color",             @see SetUnselectedColor(),           type Vector4
+      SELECTED_COLOR,                  ///< name "selected-color",               @see SetSelectedColor(),             type Vector4
+      LABEL_TEXT,                      ///< name "label-text",                   @see SetLabelText(),                 type std::string
     };
   };
 
@@ -218,7 +242,7 @@ public:
   /**
    * @brief Sets the animation time.
    *
-   * @param [in] animationTime The animation time in seconds.
+   * @param[in] animationTime The animation time in seconds.
    */
   void SetAnimationTime( float animationTime );
 
@@ -230,72 +254,99 @@ public:
   float GetAnimationTime() const;
 
   /**
-   * @brief Sets the button label.
+   * @brief Sets the button's label.
    *
-   * @param[in] label The button label.
-   */
-  void SetLabel( const std::string& label );
-
-  /**
-   * @copydoc SetLabel( const std::string& label )
+   * @param[in] label The label text.
    */
-  void SetLabel( Actor label );
+  void SetLabelText( const std::string& label );
 
   /**
    * @brief Gets the label.
    *
-   * @return An actor with the label.
+   * @return The label text.
    */
-  Actor GetLabel() const;
+  std::string GetLabelText() const;
 
   /**
-   * @brief Sets the button image.
+   * @brief Sets the unselected button image.
    *
-   * @param[in] image The button image.
+   * @param[in] filename The button image.
    */
-  void SetButtonImage( Image image );
+  void SetUnselectedImage( const std::string& filename );
 
   /**
    * @brief Sets the background image.
    *
-   * @param[in] image The background image.
+   * @param[in] filename The background image.
    */
-  void SetBackgroundImage( Image image );
+  void SetBackgroundImage( const std::string& filename );
 
   /**
    * @brief Sets the selected image.
    *
-   * @param[in] image The selected image.
+   * @param[in] filename The selected image.
    */
-  void SetSelectedImage( Image image );
+  void SetSelectedImage( const std::string& filename );
 
   /**
    * @brief Sets the selected background image.
    *
-   * @param[in] image The selected background image.
+   * @param[in] filename The selected background image.
    */
-  void SetSelectedBackgroundImage( Image image );
+  void SetSelectedBackgroundImage( const std::string& filename );
 
   /**
    * @brief Sets the disabled background image.
    *
-   * @param[in] image The disabled background image.
+   * @param[in] filename The disabled background image.
    */
-  void SetDisabledBackgroundImage( Image image );
+  void SetDisabledBackgroundImage( const std::string& filename );
 
   /**
    * @brief Sets the disabled button image.
    *
-   * @param[in] image The disabled button image.
+   * @param[in] filename The disabled button image.
    */
-  void SetDisabledImage( Image image );
+  void SetDisabledImage( const std::string& filename );
 
   /**
    * @brief Sets the disabled selected button image.
    *
-   * @param[in] image The disabled selected button image.
+   * @param[in] filename The disabled selected button image.
+   */
+  void SetDisabledSelectedImage( const std::string& filename );
+
+  // Deprecated API
+
+  /**
+   * @deprecated Sets the label with an actor.
+   * @param[in]  label The actor to use as a label
+   */
+  void SetLabel( Actor label );
+
+  /**
+   * @deprecated Sets the button image.
+   * @param[in]  image The button image.
+   */
+  void SetButtonImage( Image image );
+
+  /**
+   * @deprecated Sets the selected image.
+   * @param[in]  image The selected image.
+   */
+  void SetSelectedImage( Image image );
+
+  /**
+   * @deprecated Gets the button image.
+   * @return     An actor with the button image.
+   */
+  Actor GetButtonImage() const;
+
+  /**
+   * @deprecated Gets the selected image.
+   * @return     An actor with the selected image.
    */
-  void SetDisabledSelectedImage( Image image );
+  Actor GetSelectedImage() const;
 
 public: //Signals
 
index d3f21d7..24b98b5 100644 (file)
@@ -74,64 +74,41 @@ PushButton PushButton::DownCast( BaseHandle handle )
   return Control::DownCast<PushButton, Internal::PushButton>(handle);
 }
 
+// Deprecated API
+
 void PushButton::SetButtonImage( Actor image )
 {
   Dali::Toolkit::GetImplementation( *this ).SetButtonImage( image );
 }
 
-Actor PushButton::GetButtonImage() const
-{
-  return Dali::Toolkit::GetImplementation( *this ).GetButtonImage();
-}
-
 void PushButton::SetBackgroundImage( Actor image )
 {
   Dali::Toolkit::GetImplementation( *this ).SetBackgroundImage( image );
 }
 
-Actor PushButton::GetBackgroundImage() const
-{
-  return Dali::Toolkit::GetImplementation( *this ).GetBackgroundImage();
-}
-
 void PushButton::SetSelectedImage( Actor image )
 {
   Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( image );
 }
 
-Actor PushButton::GetSelectedImage() const
-{
-  return Dali::Toolkit::GetImplementation( *this ).GetSelectedImage();
-}
-
 void PushButton::SetSelectedBackgroundImage( Actor image )
 {
   Dali::Toolkit::GetImplementation( *this ).SetSelectedBackgroundImage( image );
 }
 
-Actor PushButton::GetSelectedBackgroundImage() const
-{
-  return Dali::Toolkit::GetImplementation( *this ).GetSelectedBackgroundImage();
-}
-
 void PushButton::SetDisabledBackgroundImage( Actor image )
 {
   Dali::Toolkit::GetImplementation( *this ).SetDisabledBackgroundImage( image );
 }
 
-Actor PushButton::GetDisabledBackgroundImage() const
-{
-  return Dali::Toolkit::GetImplementation( *this ).GetDisabledBackgroundImage();
-}
-
 void PushButton::SetDisabledImage( Actor image )
 {
   Dali::Toolkit::GetImplementation( *this ).SetDisabledImage( image );
 }
 
-Actor PushButton::GetDisabledImage() const
+void PushButton::SetDisabledSelectedImage( Actor image )
 {
-  return Dali::Toolkit::GetImplementation( *this ).GetDisabledImage();
+  Dali::Toolkit::GetImplementation( *this ).SetDisabledSelectedImage( image );
 }
 
 } // namespace Toolkit
index a74610a..0e53a9c 100644 (file)
@@ -42,44 +42,39 @@ class PushButton;
  * By default a PushButton emits a Button::PressedSignal() signal when the button is pressed, a Button::ClickedSignal() signal when it's clicked
  * and a Button::ReleasedSignal() signal when it's released or having pressed it, the touch point leaves the boundary of the button.
  *
- * PushButton provides the following properties which modify signals emitted:
- * <ul>
- *   <li>\e autorepeating
- *
- *       When \e autorepeating is set to \e true, a Button::PressedSignal(), Button::ReleasedSignal() and Button::ClickedSignal() signals are emitted at regular
- *       intervals while the button is touched.
- *
- *       The intervals could be modified with the PushButton::SetInitialAutoRepeatingDelay and PushButton::SetNextAutoRepeatingDelay methods.
- *
- *       A \e togglable button can't be \e autorepeating. If the \e autorepeating property is set to \e true, then the \e togglable property is set to
- *       false but no signal is emitted.
- *
- *   <li>\e togglable
- *
- *       When \e togglable is set to \e true, a Button::StateChangedSignal() signal is emitted, with the selected state, every time the button is touched instead
- *       of emit Button::PressedSignal(), Button::ClickedSignal() and Button::ReleasedSignal() signals.
- *
- *       An \e autorepeating button can't be \e togglable. If the \e togglable property is set to \e true, then the \e autorepeating property is set to false.
- * </ul>
- *
- * The button's appearance could be modified by setting images or actors with PushButton::SetButtonImage, PushButton::SetBackgroundImage,
- * PushButton::SetSelectedImage, PushButton::SetDisabledBackgroundImage and  PushButton::SetDisabledImage or setting a text with
- * PushButton::SetLabel.
- *
- * The \e background is always shown and doesn't change if the button is pressed or released. The \e button image is shown over the \e background image when the
- * button is not pressed and is replaced by the \e selected image when the button is pressed. The text label is placed always on the top of all images.
- *
- * When the button is disabled, \e background, \e button and \e selected images are replaced by their \e disabled images.
- *
- * The methods used to modify the button's appearance could receive Dali::Actor objects as a parameter, so more complex images could be defined.
- *
- * Is not mandatory set all images. A button could be defined only by setting its \e background image or by setting its \e background and \e selected images.
+ * See Button for more detail on signals and modifying appearance via properties.
  */
 class DALI_IMPORT_API PushButton : public Button
 {
 public:
 
   /**
+   * @brief The start and end property ranges for this control.
+   */
+  enum PropertyRange
+  {
+    PROPERTY_START_INDEX = Button::PROPERTY_END_INDEX + 1,
+    PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000              ///< Reserving 1000 property indices
+  };
+
+  /**
+   * @brief An enumeration of properties belonging to the PushButton class.
+   */
+  struct Property
+  {
+    enum
+    {
+      UNSELECTED_ICON = PROPERTY_START_INDEX, ///< Property, name "unselected-icon", type std::string
+      SELECTED_ICON,                          ///< Property, name "selected-icon",   type std::string
+      ICON_ALIGNMENT,                         ///< Property, name "icon-alignment",  type std::string
+      LABEL_PADDING,                          ///< Property, name "label-padding",   type Vector4
+      ICON_PADDING,                           ///< Property, name "icon-padding",    type Vector4
+    };
+  };
+
+public:
+
+  /**
    * @brief Create an uninitialized PushButton; this can be initialized with PushButton::New().
    *
    * Calling member functions with an uninitialized Dali::Object is not allowed.
@@ -121,99 +116,65 @@ public:
    */
   static PushButton DownCast( BaseHandle handle );
 
+
+  // Deprecated API
+
   using Button::SetButtonImage;
 
   /**
-   * @brief SetButtonImage
-   *
-   * @param[in] image The Actor to be used as the button image.
-   *
-   * The natural size of the button would be the size of this Actor
-   * if it's larger than the background and label
+   * @deprecated Sets the unselected image with an Actor.
+   * @param[in] image The Actor to use.
    */
   void SetButtonImage( Actor image );
 
-  /**
-   * @brief Gets the button image.
-   *
-   * @return An actor with the button image.
-   */
-  Actor GetButtonImage() const;
-
   using Button::SetBackgroundImage;
 
   /**
-   * @brief SetBackgroundImage
-   *
-   * @param[in] image The Actor to be used as the background image.
-   *
-   * The natural size of the button would be the size of this Actor
-   * if it's larger than the button and label
+   * @deprecated Sets the background image with an Actor.
+   * @param[in] image The Actor to use.
    */
   void SetBackgroundImage( Actor image );
 
-  /**
-   * @brief Gets the background image.
-   *
-   * @return An actor with the background image.
-   */
-  Actor GetBackgroundImage() const;
-
   using Button::SetSelectedImage;
 
   /**
-   * @copydoc SetSelectedImage( Image image )
+   * @deprecated Sets the selected image with an Actor.
+   * @param[in] image The Actor to use.
    */
   void SetSelectedImage( Actor image );
 
-  /**
-   * @brief Gets the selected image.
-   *
-   * @return An actor with the selected image.
-   */
-  Actor GetSelectedImage() const;
-
   using Button::SetSelectedBackgroundImage;
 
   /**
-   * @copydoc SetSelectedBackgroundImage( Image image )
+   * @deprecated Sets the selected background image with an Actor.
+   * @param[in] image The Actor to use.
    */
   void SetSelectedBackgroundImage( Actor image );
 
-  /**
-   * @brief Gets the selected background image.
-   *
-   * @return An actor with the selected background image.
-   */
-  Actor GetSelectedBackgroundImage() const;
-
   using Button::SetDisabledBackgroundImage;
 
   /**
-   * @copydoc SetDisabledBackgroundImage( Image image )
+   * @deprecated Sets the disabled background image with an Actor.
+   * @param[in] image The Actor to use.
    */
   void SetDisabledBackgroundImage( Actor image );
 
-  /**
-   * @brief Gets the disabled background image.
-   *
-   * @return An actor with the disabled background image.
-   */
-  Actor GetDisabledBackgroundImage() const;
-
   using Button::SetDisabledImage;
 
   /**
-   * @copydoc SetDisabledImage( Image image )
+   * @deprecated Sets the disabled image with an Actor.
+   * @param[in] image The Actor to use.
    */
   void SetDisabledImage( Actor image );
 
+  using Button::SetDisabledSelectedImage;
+
   /**
-   * @brief Gets the disabled image.
-   *
-   * @return An actor with the disabled image.
+   * @deprecated Sets the disabled selected image with an Actor.
+   * @param[in] image The Actor to use.
    */
-  Actor GetDisabledImage() const;
+  void SetDisabledSelectedImage( Actor image );
+
 
 public: // Not intended for application developers
 
index b43523d..0802b74 100644 (file)
@@ -71,14 +71,7 @@ RadioButton RadioButton::New()
 RadioButton RadioButton::New( const std::string& label )
 {
   RadioButton radioButton = Internal::RadioButton::New();
-  radioButton.SetLabel( label );
-  return radioButton;
-}
-
-RadioButton RadioButton::New( Actor label )
-{
-  RadioButton radioButton = Internal::RadioButton::New();
-  radioButton.SetLabel( label );
+  radioButton.SetLabelText( label );
   return radioButton;
 }
 
index 2dc26b1..20ec386 100644 (file)
@@ -97,15 +97,6 @@ class DALI_IMPORT_API RadioButton: public Button
   static RadioButton New( const std::string& label );
 
   /**
-   * @brief Create an initialized RadioButton with existing Actor.
-   *
-   * @param[in] label An Actor with the label.
-   *
-   * @return A handle to a newly allocated Dali resource.
-   */
-  static RadioButton New( Actor label );
-
-  /**
    * @brief Downcast an Object handle to RadioButton.
    *
    * If handle points to a RadioButton the downcast produces valid
index 639774f..821a981 100644 (file)
@@ -21,9 +21,6 @@
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/control.h>
 
-// EXTERNAL INCLUDES
-#include <dali/devel-api/rendering/renderer.h>
-
 namespace Dali
 {