[dali_1.0.50] Merge branch 'devel/master' 87/44587/1
authorRichard Huang <r.huang@samsung.com>
Thu, 23 Jul 2015 10:56:38 +0000 (11:56 +0100)
committerRichard Huang <r.huang@samsung.com>
Thu, 23 Jul 2015 10:56:38 +0000 (11:56 +0100)
Change-Id: I3947d89a7e366a0c25a4e5278d53d47b9fada3d4

58 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-ImageView.cpp [new file with mode: 0644]
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]
build/tizen/dali-toolkit/Makefile.am
dali-toolkit/dali-toolkit.h
dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h
dali-toolkit/internal/atlas-manager/atlas-manager-impl.cpp
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/image-view/image-view-impl.cpp [new file with mode: 0644]
dali-toolkit/internal/controls/image-view/image-view-impl.h [new file with mode: 0644]
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/file.list
dali-toolkit/internal/text/bidirectional-support.cpp
dali-toolkit/internal/text/bidirectional-support.h
dali-toolkit/internal/text/decorator/text-decorator.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/rendering/atlas/atlas-glyph-manager-impl.cpp
dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp
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-impl.h
dali-toolkit/internal/text/text-controller.cpp
dali-toolkit/internal/text/text-view-interface.h
dali-toolkit/internal/text/text-view.cpp
dali-toolkit/internal/text/text-view.h
dali-toolkit/internal/text/visual-model-impl.h
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.cpp [new file with mode: 0644]
dali-toolkit/public-api/controls/image-view/image-view.h [new file with mode: 0644]
dali-toolkit/public-api/dali-toolkit-version.cpp
dali-toolkit/public-api/file.list
packaging/dali-toolkit.spec

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 aae9626..2b1858e 100644 (file)
@@ -15,6 +15,7 @@ SET(TC_SOURCES
    utc-Dali-CubeTransitionEffect.cpp
    utc-Dali-EffectsView.cpp
    utc-Dali-GaussianBlurView.cpp
+   utc-Dali-ImageView.cpp
    utc-Dali-JsonParser.cpp
    utc-Dali-KeyInputFocusManager.cpp
    utc-Dali-PageTurnView.cpp
@@ -45,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;
+}
diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp
new file mode 100644 (file)
index 0000000..8e9f8fe
--- /dev/null
@@ -0,0 +1,452 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// Need to override adaptor classes for toolkit test harness, so include
+// test harness headers before dali headers.
+#include <dali-toolkit-test-suite-utils.h>
+
+#include <dali-toolkit/dali-toolkit.h>
+
+using namespace Dali;
+using namespace Toolkit;
+
+void utc_dali_toolkit_image_view_startup(void)
+{
+  test_return_value = TET_UNDEF;
+}
+
+void utc_dali_toolkit_image_view_cleanup(void)
+{
+  test_return_value = TET_PASS;
+}
+
+namespace
+{
+const char* TEST_IMAGE_FILE_NAME =  "gallery_image_01.jpg";
+} // namespace
+
+int UtcDaliImageViewNewP(void)
+{
+  TestApplication application;
+
+  ImageView imageView = ImageView::New();
+
+  DALI_TEST_CHECK( imageView );
+
+  END_TEST;
+}
+
+int UtcDaliImageViewNewImageP(void)
+{
+  TestApplication application;
+
+  Image image = CreateBufferImage( 100, 200, Vector4( 1.f, 1.f, 1.f, 1.f ) );
+  ImageView imageView = ImageView::New( image );
+
+  DALI_TEST_CHECK( imageView );
+  DALI_TEST_EQUALS( image, imageView.GetImage(), TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliImageViewNewUrlP(void)
+{
+  TestApplication application;
+
+  ImageView imageView = ImageView::New( TEST_IMAGE_FILE_NAME );
+  DALI_TEST_CHECK( imageView );
+  DALI_TEST_CHECK( imageView.GetImage() );
+
+  Property::Value val = imageView.GetProperty( imageView.GetPropertyIndex( "resource-url" ) );
+  std::string resource_url;
+  DALI_TEST_CHECK( val.Get( resource_url ) );
+  DALI_TEST_EQUALS( resource_url, TEST_IMAGE_FILE_NAME, TEST_LOCATION );
+
+  Image image = imageView.GetImage();
+  DALI_TEST_CHECK( image );
+
+  ResourceImage resourceImage = ResourceImage::DownCast( image );
+  DALI_TEST_CHECK( resourceImage );
+  DALI_TEST_EQUALS( resourceImage.GetUrl(), TEST_IMAGE_FILE_NAME, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliImageViewConstructorP(void)
+{
+  TestApplication application;
+
+  ImageView imageView;
+
+  DALI_TEST_CHECK( !imageView );
+
+  END_TEST;
+}
+
+int UtcDaliImageViewCopyConstructorP(void)
+{
+  TestApplication application;
+
+  // Initialize an object, ref count == 1
+  ImageView imageView = ImageView::New();
+
+  ImageView copy( imageView );
+  DALI_TEST_CHECK( copy );
+
+  END_TEST;
+}
+
+int UtcDaliImageViewAssignmentOperatorP(void)
+{
+  TestApplication application;
+
+  ImageView imageView = ImageView::New();
+
+  ImageView copy( imageView );
+  DALI_TEST_CHECK( copy );
+  DALI_TEST_EQUALS( imageView, copy, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliImageViewDownCastP(void)
+{
+  TestApplication application;
+
+  ImageView imageView = ImageView::New();
+
+  BaseHandle object(imageView);
+
+  ImageView imageView2 = ImageView::DownCast( object );
+  DALI_TEST_CHECK(imageView2);
+
+  ImageView imageView3 = DownCast< ImageView >( object );
+  DALI_TEST_CHECK(imageView3);
+
+  END_TEST;
+}
+
+int UtcDaliImageViewDownCastN(void)
+{
+  TestApplication application;
+
+  BaseHandle unInitializedObject;
+
+  ImageView imageView1 = ImageView::DownCast( unInitializedObject );
+  DALI_TEST_CHECK( !imageView1 );
+
+  ImageView imageView2 = DownCast< ImageView >( unInitializedObject );
+  DALI_TEST_CHECK( !imageView2 );
+
+  END_TEST;
+}
+
+int UtcDaliImageViewTypeRegistry(void)
+{
+  ToolkitTestApplication application;
+
+  TypeRegistry typeRegistry = TypeRegistry::Get();
+  DALI_TEST_CHECK( typeRegistry );
+
+  TypeInfo typeInfo = typeRegistry.GetTypeInfo( "ImageView" );
+  DALI_TEST_CHECK( typeInfo );
+
+  BaseHandle handle = typeInfo.CreateInstance();
+  DALI_TEST_CHECK( handle );
+
+  ImageView imageView = ImageView::DownCast( handle );
+  DALI_TEST_CHECK( imageView );
+
+  END_TEST;
+}
+
+int UtcDaliImageViewSetGetProperty(void)
+{
+  ToolkitTestApplication application;
+
+  ImageView imageView = ImageView::New();
+
+  Property::Index idx = imageView.GetPropertyIndex( "resource-url" );
+  DALI_TEST_EQUALS( idx, ImageView::Property::RESOURCE_URL, TEST_LOCATION );
+
+  imageView.SetProperty( idx, TEST_IMAGE_FILE_NAME );
+  Property::Value val = imageView.GetProperty( idx );
+  std::string resource_url;
+  DALI_TEST_CHECK( val.Get( resource_url ) );
+  DALI_TEST_EQUALS( resource_url, TEST_IMAGE_FILE_NAME, TEST_LOCATION );
+
+  Image image = imageView.GetImage();
+  DALI_TEST_CHECK( image );
+
+  ResourceImage resourceImage = ResourceImage::DownCast( image );
+  DALI_TEST_CHECK( resourceImage );
+  DALI_TEST_EQUALS( resourceImage.GetUrl(), TEST_IMAGE_FILE_NAME, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliImageViewSizeWithBackground(void)
+{
+  ToolkitTestApplication application;
+
+  int width = 100;
+  int height = 200;
+  Image image = CreateBufferImage( width, height, Vector4(1.f, 1.f, 1.f, 1.f) );
+  ImageView imageView = ImageView::New();
+  imageView.SetBackgroundImage( image );
+
+  Stage::GetCurrent().Add( imageView );
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( imageView.GetCurrentSize().width, width, TEST_LOCATION );
+  DALI_TEST_EQUALS( imageView.GetCurrentSize().height, height, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliImageViewSizeWithBackgroundAndImage(void)
+{
+  ToolkitTestApplication application;
+
+  int widthBackground = 100;
+  int heightBackground = 200;
+  int width = 300;
+  int height = 400;
+  Image imageBackground = CreateBufferImage( widthBackground, heightBackground, Vector4(1.f, 1.f, 1.f, 1.f) );
+  Image image = CreateBufferImage( width, height, Vector4(1.f, 1.f, 1.f, 1.f) );
+
+  ImageView imageView = ImageView::New();
+  imageView.SetBackgroundImage( imageBackground );
+  imageView.SetImage( image );
+
+  Stage::GetCurrent().Add( imageView );
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( imageView.GetCurrentSize().width, width, TEST_LOCATION );
+  DALI_TEST_EQUALS( imageView.GetCurrentSize().height, height, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliImageViewHeightForWidthBackground(void)
+{
+  ToolkitTestApplication application;
+
+  int widthBackground = 100;
+  int heightBackground = 200;
+  Image imageBackground = CreateBufferImage( widthBackground, heightBackground, Vector4(1.f, 1.f, 1.f, 1.f) );
+
+  ImageView imageView = ImageView::New();
+  imageView.SetBackgroundImage( imageBackground );
+
+  Stage::GetCurrent().Add( imageView );
+  application.SendNotification();
+  application.Render();
+
+  Control control = Control::DownCast( imageView );
+  DALI_TEST_CHECK( control );
+  DALI_TEST_EQUALS( imageView.GetHeightForWidth( 123.f ), control.GetHeightForWidth( 123.f ), TEST_LOCATION );
+  DALI_TEST_EQUALS( imageView.GetWidthForHeight( 321.f ), control.GetWidthForHeight( 321.f ), TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliImageViewHeightForWidthBackgroundAndImage(void)
+{
+  ToolkitTestApplication application;
+
+  int widthBackground = 100;
+  int heightBackground = 200;
+  int width = 300;
+  int height = 400;
+  Image imageBackground = CreateBufferImage( widthBackground, heightBackground, Vector4(1.f, 1.f, 1.f, 1.f) );
+  Image image = CreateBufferImage( width, height, Vector4(1.f, 1.f, 1.f, 1.f) );
+
+  ImageView imageView = ImageView::New();
+  imageView.SetBackgroundImage( imageBackground );
+  imageView.SetImage( image );
+
+  Stage::GetCurrent().Add( imageView );
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( imageView.GetHeightForWidth( width ), height, TEST_LOCATION );
+  DALI_TEST_EQUALS( imageView.GetWidthForHeight( height ), width, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliImageViewSetBufferImage(void)
+{
+  ToolkitTestApplication application;
+
+  int width = 300;
+  int height = 400;
+  Image image = CreateBufferImage( width, height, Vector4( 1.f, 1.f, 1.f, 1.f ) );
+  ImageView imageView = ImageView::New();
+  imageView.SetImage( image );
+
+  std::string resource_url;
+  Property::Value val = imageView.GetProperty( imageView.GetPropertyIndex( "resource-url" ) );
+  DALI_TEST_CHECK( val.Get( resource_url ) );
+  DALI_TEST_CHECK( resource_url.empty() );
+
+  END_TEST;
+}
+
+int UtcDaliImageViewSetResourceImage(void)
+{
+  ToolkitTestApplication application;
+
+  Image image = ResourceImage::New( TEST_IMAGE_FILE_NAME );
+  ImageView imageView = ImageView::New();
+  imageView.SetImage( image );
+
+  std::string resource_url;
+  Property::Value val = imageView.GetProperty( imageView.GetPropertyIndex( "resource-url" ) );
+  DALI_TEST_CHECK( val.Get( resource_url ) );
+  DALI_TEST_EQUALS( resource_url, TEST_IMAGE_FILE_NAME, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliImageViewSetImageOnstageP(void)
+{
+  ToolkitTestApplication application;
+
+  ImageView imageView = ImageView::New();
+
+  Stage::GetCurrent().Add( imageView );
+  application.SendNotification();
+  application.Render();
+
+  Image image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
+  imageView.SetImage( image1 );
+
+  Image image2 = imageView.GetImage();
+  DALI_TEST_EQUALS( image1, image2, TEST_LOCATION );
+
+  int width = 300;
+  int height = 400;
+  Image image3 = CreateBufferImage( width, height, Vector4( 1.f, 1.f, 1.f, 1.f ) );
+  imageView.SetImage( image3 );
+
+  Image image4 = imageView.GetImage();
+  DALI_TEST_EQUALS( image3, image4, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliImageViewSetImageOnstageN(void)
+{
+  ToolkitTestApplication application;
+
+  ImageView imageView = ImageView::New();
+
+  Stage::GetCurrent().Add( imageView );
+  application.SendNotification();
+  application.Render();
+
+  Image image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
+  imageView.SetImage( image1 );
+
+  Image image2 = imageView.GetImage();
+  DALI_TEST_EQUALS( image1, image2, TEST_LOCATION );
+
+  Image image3;
+  imageView.SetImage( image3 );
+
+  Image image4 = imageView.GetImage();
+  DALI_TEST_CHECK( !image4 );
+
+  END_TEST;
+}
+
+int UtcDaliImageViewSetImageOffstageP(void)
+{
+  ToolkitTestApplication application;
+
+  ImageView imageView = ImageView::New();
+
+  Stage::GetCurrent().Add( imageView );
+  application.SendNotification();
+  application.Render();
+  Stage::GetCurrent().Remove( imageView );
+
+  Image image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
+  imageView.SetImage( image1 );
+
+  Image image2 = imageView.GetImage();
+  DALI_TEST_EQUALS( image1, image2, TEST_LOCATION );
+
+  int width = 300;
+  int height = 400;
+  Image image3 = CreateBufferImage( width, height, Vector4( 1.f, 1.f, 1.f, 1.f ) );
+  imageView.SetImage( image3 );
+
+  Image image4 = imageView.GetImage();
+  DALI_TEST_EQUALS( image3, image4, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliImageViewSetImageOffstageN(void)
+{
+  ToolkitTestApplication application;
+
+  ImageView imageView = ImageView::New();
+
+  Stage::GetCurrent().Add( imageView );
+  application.SendNotification();
+  application.Render();
+  Stage::GetCurrent().Remove( imageView );
+
+  Image image1 = ResourceImage::New( TEST_IMAGE_FILE_NAME );
+  imageView.SetImage( image1 );
+
+  Image image2 = imageView.GetImage();
+  DALI_TEST_EQUALS( image1, image2, TEST_LOCATION );
+
+  Image image3;
+  imageView.SetImage( image3 );
+
+  Image image4 = imageView.GetImage();
+  DALI_TEST_CHECK( !image4 );
+
+  END_TEST;
+}
+
+int UtcDaliImageViewSetImageN(void)
+{
+  ToolkitTestApplication application;
+
+  Image image1;
+  ImageView imageView = ImageView::New();
+  imageView.SetImage( image1 );
+
+  Image image2 = imageView.GetImage();
+  DALI_TEST_CHECK( !image2 );
+
+  std::string resource_url;
+  Property::Value val = imageView.GetProperty( imageView.GetPropertyIndex( "resource-url" ) );
+  DALI_TEST_CHECK( val.Get( resource_url ) );
+  DALI_TEST_CHECK( resource_url.empty() );
+
+  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 17029e0..3ec8f92 100644 (file)
@@ -125,6 +125,7 @@ publicapialignmentdir =           $(publicapicontrolsdir)/alignment
 publicapibuttonsdir =             $(publicapicontrolsdir)/buttons
 publicapidefaultcontrolsdir =     $(publicapicontrolsdir)/default-controls
 publicapigaussianblurviewdir =    $(publicapicontrolsdir)/gaussian-blur-view
+publicapiimageviewdir =           $(publicapicontrolsdir)/image-view
 publicapiscrollbardir =           $(publicapicontrolsdir)/scroll-bar
 publicapiscrollabledir =          $(publicapicontrolsdir)/scrollable
 publicapiscrollviewdir =          $(publicapicontrolsdir)/scrollable/scroll-view
@@ -142,6 +143,7 @@ publicapialignment_HEADERS =           $(public_api_alignment_header_files)
 publicapibuttons_HEADERS =             $(public_api_buttons_header_files)
 publicapidefaultcontrols_HEADERS =     $(public_api_default_controls_header_files)
 publicapigaussianblurview_HEADERS =    $(public_api_gaussian_blur_view_header_files)
+publicapiimageview_HEADERS =           $(public_api_image_view_header_files)
 publicapiitemview_HEADERS =            $(public_api_item_view_header_files)
 publicapiscrollbar_HEADERS =           $(public_api_scroll_bar_header_files)
 publicapiscrollable_HEADERS =          $(public_api_scrollable_header_files)
index 74229e8..a8a3e1f 100644 (file)
@@ -30,6 +30,7 @@
 #include <dali-toolkit/public-api/controls/control.h>
 #include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
 #include <dali-toolkit/public-api/controls/gaussian-blur-view/gaussian-blur-view.h>
+#include <dali-toolkit/public-api/controls/image-view/image-view.h>
 #include <dali-toolkit/public-api/controls/scroll-bar/scroll-bar.h>
 #include <dali-toolkit/public-api/controls/scrollable/item-view/default-item-layout.h>
 #include <dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h>
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 dfdff15..71d0ae0 100644 (file)
@@ -50,13 +50,11 @@ namespace
   attribute mediump vec2    aPosition;
   attribute mediump vec2    aTexCoord;
   uniform   mediump mat4    uMvpMatrix;
-  uniform   mediump vec3    uSize;
   varying   mediump vec2    vTexCoord;
 
   void main()
   {
     mediump vec4 position = vec4( aPosition, 0.0, 1.0 );
-    position.xyz *= uSize;
     gl_Position = uMvpMatrix * position;
     vTexCoord = aTexCoord;
   }
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 );
diff --git a/dali-toolkit/internal/controls/image-view/image-view-impl.cpp b/dali-toolkit/internal/controls/image-view/image-view-impl.cpp
new file mode 100644 (file)
index 0000000..b6b97a4
--- /dev/null
@@ -0,0 +1,310 @@
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+
+// CLASS HEADER
+#include "image-view-impl.h"
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/image-view/image-view.h>
+
+// EXTERNAL INCLUDES
+#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/devel-api/scripting/scripting.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+namespace
+{
+
+#define MAKE_SHADER(A)#A
+
+const char* VERTEX_SHADER = MAKE_SHADER(
+  attribute mediump vec2 aPosition;
+  attribute highp vec2 aTexCoord;
+  varying mediump vec2 vTexCoord;
+  uniform mediump mat4 uMvpMatrix;
+  uniform mediump vec3 uSize;
+
+  void main()
+  {
+    mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
+    vertexPosition.xyz *= uSize;
+    vertexPosition = uMvpMatrix * vertexPosition;
+
+    vTexCoord = aTexCoord;
+    gl_Position = vertexPosition;
+  }
+);
+
+const char* FRAGMENT_SHADER = MAKE_SHADER(
+  varying mediump vec2 vTexCoord;
+  uniform sampler2D sTexture;
+  uniform lowp vec4 uColor;
+
+  void main()
+  {
+    gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;
+  }
+);
+
+//TODO: remove when RendererFactory is implemented, so if there are multiple images that render as quads we only end up with one instance of geometry
+Geometry CreateGeometry( int width, int height )
+{
+  // Create vertices
+  const float halfWidth = 0.5f;
+  const float halfHeight = 0.5f;
+  struct TexturedQuadVertex { Vector2 position; Vector2 textureCoordinates; };
+    TexturedQuadVertex texturedQuadVertexData[4] = { { Vector2(-halfWidth, -halfHeight), Vector2(0.f, 0.f) },
+                                                     { Vector2( halfWidth, -halfHeight), Vector2(1.f, 0.f) },
+                                                     { Vector2(-halfWidth, halfHeight), Vector2(0.f, 1.f) },
+                                                     { Vector2( halfWidth, halfHeight), Vector2(1.f, 1.f) } };
+
+  Property::Map texturedQuadVertexFormat;
+  texturedQuadVertexFormat["aPosition"] = Property::VECTOR2;
+  texturedQuadVertexFormat["aTexCoord"] = Property::VECTOR2;
+  PropertyBuffer texturedQuadVertices = PropertyBuffer::New( texturedQuadVertexFormat, 4 );
+  texturedQuadVertices.SetData(texturedQuadVertexData);
+
+  // Create indices
+  //TODO: replace with triangle strip when Geometry supports it
+  unsigned int indexData[6] = { 0, 3, 1, 0, 2, 3 };
+  Property::Map indexFormat;
+  indexFormat["indices"] = Property::INTEGER;
+  PropertyBuffer indices = PropertyBuffer::New( indexFormat, 6 );
+  indices.SetData(indexData);
+
+  // Create the geometry object
+  Geometry texturedQuadGeometry = Geometry::New();
+  texturedQuadGeometry.AddVertexBuffer( texturedQuadVertices );
+  texturedQuadGeometry.SetIndexBuffer( indices );
+
+  return texturedQuadGeometry;
+}
+
+BaseHandle Create()
+{
+  return Toolkit::ImageView::New();
+}
+
+// Setup properties, signals and actions using the type-registry.
+DALI_TYPE_REGISTRATION_BEGIN( Toolkit::ImageView, Toolkit::Control, Create );
+DALI_PROPERTY_REGISTRATION( Toolkit, ImageView, "resource-url", STRING, RESOURCE_URL )
+DALI_TYPE_REGISTRATION_END()
+
+} // anonymous namespace
+
+using namespace Dali;
+
+ImageView::ImageView()
+: Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) )
+{
+}
+
+ImageView::~ImageView()
+{
+}
+
+Toolkit::ImageView ImageView::New()
+{
+  ImageView* impl = new ImageView();
+
+  Dali::Toolkit::ImageView handle = Dali::Toolkit::ImageView( *impl );
+
+  // Second-phase init of the implementation
+  // This can only be done after the CustomActor connection has been made...
+  impl->Initialize();
+
+  return handle;
+}
+
+/////////////////////////////////////////////////////////////
+
+void ImageView::SetImage( Image image )
+{
+  mImage = image;
+
+  ResourceImage resourceImage = ResourceImage::DownCast( mImage );
+  if( resourceImage )
+  {
+    mImageUrl = resourceImage.GetUrl();
+  }
+  else
+  {
+    mImageUrl.clear();
+  }
+
+  if( mImage )
+  {
+    if( Self().OnStage() )
+    {
+      AttachImage();
+    }
+    RelayoutRequest();
+  }
+  else
+  {
+    if( mRenderer )
+    {
+      Self().RemoveRenderer( mRenderer );
+    }
+    mSampler.Reset();
+    mMaterial.Reset();
+    mMesh.Reset();
+    mRenderer.Reset();
+  }
+}
+
+Image ImageView::GetImage() const
+{
+  return mImage;
+}
+
+Vector3 ImageView::GetNaturalSize()
+{
+  // if no image then use Control's natural size
+  Vector3 size;
+
+  if( mImage )
+  {
+    size.x = mImage.GetWidth();
+    size.y = mImage.GetHeight();
+    size.z = std::min(size.x, size.y);
+  }
+  else
+  {
+    size = Control::GetNaturalSize();
+  }
+  return size;
+}
+
+float ImageView::GetHeightForWidth( float width )
+{
+  if( mImage )
+  {
+    return GetHeightForWidthBase( width );
+  }
+  else
+  {
+    return Control::GetHeightForWidth( width );
+  }
+}
+
+float ImageView::GetWidthForHeight( float height )
+{
+  if( mImage )
+  {
+    return GetWidthForHeightBase( height );
+  }
+  else
+  {
+    return Control::GetWidthForHeight( height );
+  }
+}
+
+///////////////////////////////////////////////////////////
+//
+// Private methods
+//
+
+void ImageView::AttachImage()
+{
+  if( !mRenderer )
+  {
+    Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
+    mMaterial = Material::New( shader );
+
+    mSampler = Sampler::New( mImage, "sTexture" );
+    mMaterial.AddSampler( mSampler );
+
+    Vector3 size = Self().GetCurrentSize();
+    mMesh = CreateGeometry( size.width, size.height );
+    mRenderer = Renderer::New( mMesh, mMaterial );
+    Self().AddRenderer( mRenderer );
+  }
+  else
+  {
+    mSampler.SetImage( mImage );
+  }
+}
+
+void ImageView::OnRelayout( const Vector2& size, RelayoutContainer& container )
+{
+  Control::OnRelayout( size, container );
+
+  if( mRenderer )
+  {
+    mMesh = CreateGeometry( size.width, size.height );
+    mRenderer.SetGeometry( mMesh );
+  }
+}
+
+void ImageView::OnStageConnection( int depth )
+{
+  if( mImage )
+  {
+    AttachImage();
+  }
+}
+
+///////////////////////////////////////////////////////////
+//
+// Properties
+//
+
+void ImageView::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
+{
+  Toolkit::ImageView imageView = Toolkit::ImageView::DownCast( Dali::BaseHandle( object ) );
+
+  if ( imageView )
+  {
+    switch ( index )
+    {
+      case Toolkit::ImageView::Property::RESOURCE_URL:
+      {
+        std::string imageUrl;
+        if( value.Get( imageUrl ) )
+        {
+          ImageView& impl = GetImpl( imageView );
+          impl.mImageUrl = imageUrl;
+
+          Image image = ResourceImage::New( imageUrl );
+          impl.SetImage( image );
+        }
+        break;
+      }
+    }
+  }
+}
+
+Property::Value ImageView::GetProperty( BaseObject* object, Property::Index propertyIndex )
+{
+  Property::Value value;
+
+  Toolkit::ImageView imageview = Toolkit::ImageView::DownCast( Dali::BaseHandle( object ) );
+
+  if ( imageview )
+  {
+    switch ( propertyIndex )
+    {
+      case Toolkit::ImageView::Property::RESOURCE_URL:
+      {
+        value = GetImpl( imageview ).mImageUrl;
+        break;
+      }
+    }
+  }
+
+  return value;
+}
+
+} // namespace Internal
+} // namespace Toolkit
+} // namespace Dali
diff --git a/dali-toolkit/internal/controls/image-view/image-view-impl.h b/dali-toolkit/internal/controls/image-view/image-view-impl.h
new file mode 100644 (file)
index 0000000..e912e4c
--- /dev/null
@@ -0,0 +1,152 @@
+#ifndef __DALI_TOOLKIT_INTERNAL_IMAGE_VIEW_H__
+#define __DALI_TOOLKIT_INTERNAL_IMAGE_VIEW_H__
+
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/devel-api/rendering/renderer.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/control-impl.h>
+#include <dali-toolkit/public-api/controls/image-view/image-view.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+class ImageView;
+
+namespace Internal
+{
+class ImageView : public Control
+{
+ protected:
+
+  /**
+   * Construct a new ImageView.
+   */
+  ImageView();
+
+  /**
+   * A reference counted object may only be deleted by calling Unreference()
+   */
+  virtual ~ImageView();
+
+public:
+  /**
+   * Create a new ImageView.
+   * @return A smart-pointer to the newly allocated ImageView.
+   */
+  static Toolkit::ImageView New();
+
+  /**
+   * @copydoc Dali::Toolkit::SetImage( Image image )
+   */
+  void SetImage( Image image );
+
+  /**
+   * @copydoc Dali::Toolkit::Image GetImage() const
+   */
+  Image GetImage() const;
+
+  // Properties
+  /**
+   * 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 Control
+
+  /**
+   * @copydoc Toolkit::Control::OnRelayout()
+   */
+  virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
+
+  /**
+   * @copydoc Toolkit::Control::OnStageConnect()
+   */
+  virtual void OnStageConnection( int depth );
+
+  /**
+   * @copydoc Toolkit::Control::GetNaturalSize
+   */
+  virtual Vector3 GetNaturalSize();
+
+  /**
+   * @copydoc Toolkit::Control::GetHeightForWidth()
+   */
+  virtual float GetHeightForWidth( float width );
+
+  /**
+   * @copydoc Toolkit::Control::GetWidthForHeight()
+   */
+  virtual float GetWidthForHeight( float height );
+
+private:
+  /**
+   * Attaches mImage member to the renderer, creating the renderers, samplers, meshes and materials if needed
+   *
+   * @pre mImage has been initialised
+   */
+  void AttachImage();
+
+private:
+
+  Sampler mSampler;
+  Material mMaterial;
+  Geometry mMesh;
+  Renderer mRenderer;
+  Image mImage;
+  std::string mImageUrl;
+};
+
+} // namespace Internal
+
+// Helpers for public-api forwarding methods
+inline Toolkit::Internal::ImageView& GetImpl( Toolkit::ImageView& obj )
+{
+  DALI_ASSERT_ALWAYS(obj);
+  Dali::RefObject& handle = obj.GetImplementation();
+  return static_cast<Toolkit::Internal::ImageView&>(handle);
+}
+
+inline const Toolkit::Internal::ImageView& GetImpl( const Toolkit::ImageView& obj )
+{
+  DALI_ASSERT_ALWAYS(obj);
+  const Dali::RefObject& handle = obj.GetImplementation();
+  return static_cast<const Toolkit::Internal::ImageView&>(handle);
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_INTERNAL_IMAGE_VIEW_H__
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 0b8b570..e96d299 100644 (file)
@@ -22,6 +22,7 @@ toolkit_src_files = \
    $(toolkit_src_dir)/controls/buttons/radio-button-impl.cpp \
    $(toolkit_src_dir)/controls/effects-view/effects-view-impl.cpp \
    $(toolkit_src_dir)/controls/gaussian-blur-view/gaussian-blur-view-impl.cpp \
+   $(toolkit_src_dir)/controls/image-view/image-view-impl.cpp \
    $(toolkit_src_dir)/controls/magnifier/magnifier-impl.cpp \
    $(toolkit_src_dir)/controls/popup/popup-impl.cpp \
    $(toolkit_src_dir)/controls/popup/popup-style-impl.cpp \
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 4a1fc5f..c77ec94 100644 (file)
@@ -126,9 +126,9 @@ public:
     virtual ~ControllerInterface() {};
 
     /**
-     * @brief An input event from one of the handles.
+     * @brief Query the target size of the UI control.
      *
-     * @param[out] targetSize The Size of the UI control the decorator is adding it's decorations to.
+     * @param[out] targetSize The size of the UI control the decorator is adding it's decorations to.
      */
     virtual void GetTargetSize( Vector2& targetSize ) = 0;
 
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 fe8da41..a141166 100644 (file)
@@ -35,13 +35,11 @@ const char* VERTEX_SHADER = MAKE_SHADER(
 attribute mediump vec2    aPosition;
 attribute mediump vec2    aTexCoord;
 uniform   mediump mat4    uMvpMatrix;
-uniform   mediump vec3    uSize;
 varying   mediump vec2    vTexCoord;
 
 void main()
 {
   mediump vec4 position = vec4( aPosition, 0.0, 1.0 );
-  position.xyz *= uSize;
   gl_Position = uMvpMatrix * position;
   vTexCoord = aTexCoord;
 }
@@ -60,13 +58,11 @@ void main()
 const char* VERTEX_SHADER_SHADOW = MAKE_SHADER(
 attribute mediump vec2    aPosition;
 attribute mediump vec2    aTexCoord;
-uniform   mediump vec3    uSize;
 varying   mediump vec2    vTexCoord;
 
 void main()
 {
   mediump vec4 position = vec4( aPosition, 0.0, 1.0 );
-  position.xyz *= uSize;
   gl_Position = position;
   vTexCoord = aTexCoord;
 }
index d0cedf4..e6d548f 100644 (file)
@@ -107,14 +107,9 @@ struct AtlasRenderer::Impl : public ConnectionTracker
     mQuadIndexFormat[ "indices" ] = Property::INTEGER;
   }
 
-  void AddGlyphs( const std::vector<Vector2>& positions,
+  void AddGlyphs( Text::ViewInterface& view,
+                  const std::vector<Vector2>& positions,
                   const Vector<GlyphInfo>& glyphs,
-                  const Vector4& textColor,
-                  const Vector2& shadowOffset,
-                  const Vector4& shadowColor,
-                  bool underlineEnabled,
-                  const Vector4& underlineColor,
-                  float underlineHeight,
                   int depth )
   {
     AtlasManager::AtlasSlot slot;
@@ -123,6 +118,15 @@ struct AtlasRenderer::Impl : public ConnectionTracker
     TextCacheEntry textCacheEntry;
     mDepth = depth;
 
+    const Vector2& actorSize( view.GetControlSize() );
+    Vector2 halfActorSize( actorSize * 0.5f );
+    const Vector4& textColor( view.GetTextColor() );
+    const Vector2& shadowOffset( view.GetShadowOffset() );
+    const Vector4& shadowColor( view.GetShadowColor() );
+    bool underlineEnabled( view.IsUnderlineEnabled() );
+    const Vector4& underlineColor( view.GetUnderlineColor() );
+    float underlineHeight( view.GetUnderlineHeight() );
+
     float currentUnderlinePosition = ZERO;
     float currentUnderlineThickness = underlineHeight;
     uint32_t currentBlockSize = 0;
@@ -182,9 +186,6 @@ struct AtlasRenderer::Impl : public ConnectionTracker
           }
         }
 
-        const Vector2& position = positions[ i ];
-        AtlasManager::Mesh2D newMesh;
-
         if ( !mGlyphManager.Cached( glyph.fontId, glyph.index, slot ) )
         {
           // Select correct size for new atlas if needed....?
@@ -238,7 +239,11 @@ struct AtlasRenderer::Impl : public ConnectionTracker
           mGlyphManager.AdjustReferenceCount( glyph.fontId, glyph.index, 1/*increment*/ );
         }
 
+        // Move the origin (0,0) of the mesh to the center of the actor
+        Vector2 position = positions[ i ] - halfActorSize;
+
         // Generate mesh data for this quad, plugging in our supplied position
+        AtlasManager::Mesh2D newMesh;
         mGlyphManager.GenerateMeshData( slot.mImageId, position, newMesh );
         textCacheEntry.mFontId = glyph.fontId;
         textCacheEntry.mImageId = slot.mImageId;
@@ -273,17 +278,16 @@ struct AtlasRenderer::Impl : public ConnectionTracker
     {
       for ( std::vector< MeshRecord >::iterator mIt = meshContainer.begin(); mIt != meshContainer.end(); ++mIt )
       {
-        Actor actor = CreateMeshActor( *mIt );
+        Actor actor = CreateMeshActor( *mIt, actorSize );
 
         // Create an effect if necessary
         if ( style == STYLE_DROP_SHADOW )
         {
-          actor.Add( GenerateShadow( *mIt, shadowOffset, shadowColor ) );
+          actor.Add( GenerateShadow( *mIt, actorSize, shadowOffset, shadowColor ) );
         }
 
         if( mActor )
         {
-          actor.SetParentOrigin( ParentOrigin::CENTER ); // Keep all of the origins aligned
           mActor.Add( actor );
         }
         else
@@ -325,7 +329,7 @@ struct AtlasRenderer::Impl : public ConnectionTracker
     mTextCache.Resize( 0 );
   }
 
-  Actor CreateMeshActor( const MeshRecord& meshRecord )
+  Actor CreateMeshActor( const MeshRecord& meshRecord, const Vector2& actorSize )
   {
     PropertyBuffer quadVertices = PropertyBuffer::New( mQuadVertexFormat, meshRecord.mMesh.mVertices.Size() );
     PropertyBuffer quadIndices = PropertyBuffer::New( mQuadIndexFormat, meshRecord.mMesh.mIndices.Size() );
@@ -344,7 +348,8 @@ struct AtlasRenderer::Impl : public ConnectionTracker
     actor.SetName( "Text renderable actor" );
 #endif
     actor.AddRenderer( renderer );
-    actor.SetSize( 1.0f, 1.0f );
+    actor.SetParentOrigin( ParentOrigin::CENTER ); // Keep all of the origins aligned
+    actor.SetSize( actorSize );
     actor.SetColor( meshRecord.mColor );
 
     if ( meshRecord.mIsUnderline )
@@ -555,6 +560,7 @@ struct AtlasRenderer::Impl : public ConnectionTracker
   }
 
   Actor GenerateShadow( MeshRecord& meshRecord,
+                        const Vector2& actorSize,
                         const Vector2& shadowOffset,
                         const Vector4& shadowColor )
   {
@@ -621,7 +627,8 @@ struct AtlasRenderer::Impl : public ConnectionTracker
     renderer.SetDepthIndex( CONTENT_DEPTH_INDEX + mDepth - 1 );
     Actor actor = Actor::New();
     actor.AddRenderer( renderer );
-    actor.SetSize( 1.0f, 1.0f );
+    actor.SetParentOrigin( ParentOrigin::CENTER ); // Keep all of the origins aligned
+    actor.SetSize( actorSize );
 
     // Create a sub actor to render the source with normalized vertex positions
     Vector< AtlasManager::Vertex2D > normVertexList;
@@ -648,7 +655,8 @@ struct AtlasRenderer::Impl : public ConnectionTracker
     Dali::Renderer normRenderer = Dali::Renderer::New( normGeometry, normMaterial );
     Actor subActor = Actor::New();
     subActor.AddRenderer( normRenderer );
-    subActor.SetSize( 1.0f, 1.0f );
+    subActor.SetParentOrigin( ParentOrigin::CENTER ); // Keep all of the origins aligned
+    subActor.SetSize( actorSize );
     subActor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
     subActor.SetColor( shadowColor );
 
@@ -723,14 +731,9 @@ Actor AtlasRenderer::Render( Text::ViewInterface& view, int depth )
     glyphs.Resize( numberOfGlyphs );
     positions.resize( numberOfGlyphs );
 
-    mImpl->AddGlyphs( positions,
+    mImpl->AddGlyphs( view,
+                      positions,
                       glyphs,
-                      view.GetTextColor(),
-                      view.GetShadowOffset(),
-                      view.GetShadowColor(),
-                      view.IsUnderlineEnabled(),
-                      view.GetUnderlineColor(),
-                      view.GetUnderlineHeight(),
                       depth );
   }
 
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 12fbb2f..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;
@@ -396,12 +396,14 @@ void Controller::Impl::UpdateModel( OperationsMask operationsRequired )
       // There is no right to left characters. Clear the directions vector.
       mLogicalModel->mCharacterDirections.Clear();
     }
-
-   }
+  }
 
   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;
@@ -412,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 );
@@ -423,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;
+    }
   }
 }
 
@@ -726,7 +741,7 @@ void Controller::Impl::OnHandleEvent( const Event& event )
       Vector2 position = mEventData->mDecorator->GetPosition( GRAB_HANDLE );
 
       // Position the grag handle close to either the left or right edge.
-      position.x = scrollRightDirection ? 0.f : mControlSize.width;
+      position.x = scrollRightDirection ? 0.f : mVisualModel->mControlSize.width;
 
       // Get the new handle position.
       // The grab handle's position is in decorator coords. Need to transforms to text coords.
@@ -747,7 +762,7 @@ void Controller::Impl::OnHandleEvent( const Event& event )
       Vector2 position = mEventData->mDecorator->GetPosition( leftSelectionHandleEvent ? Text::LEFT_SELECTION_HANDLE : Text::RIGHT_SELECTION_HANDLE );
 
       // Position the selection handle close to either the left or right edge.
-      position.x = scrollRightDirection ? 0.f : mControlSize.width;
+      position.x = scrollRightDirection ? 0.f : mVisualModel->mControlSize.width;
 
       // Get the new handle position.
       // The selection handle's position is in decorator coords. Need to transforms to text coords.
@@ -923,34 +938,103 @@ void Controller::Impl::RepositionSelectionHandles( CharacterIndex selectionStart
   const Length* const glyphsPerCharacterBuffer = mVisualModel->mGlyphsPerCharacter.Begin();
   const GlyphInfo* const glyphsBuffer = mVisualModel->mGlyphs.Begin();
   const Vector2* const positionsBuffer = mVisualModel->mGlyphPositions.Begin();
+  const Length* const charactersPerGlyphBuffer = mVisualModel->mCharactersPerGlyph.Begin();
+  const CharacterIndex* const glyphToCharacterBuffer = mVisualModel->mGlyphsToCharacters.Begin();
+  const CharacterDirection* const modelCharacterDirectionsBuffer = ( 0u != mLogicalModel->mCharacterDirections.Count() ) ? mLogicalModel->mCharacterDirections.Begin() : NULL;
 
   // TODO: Better algorithm to create the highlight box.
   // TODO: Multi-line.
 
+  // Get the height of the line.
   const Vector<LineRun>& lines = mVisualModel->mLines;
   const LineRun& firstLine = *lines.Begin();
   const float height = firstLine.ascender + -firstLine.descender;
 
+  // Swap the indices if the start is greater than the end.
   const bool indicesSwapped = ( selectionStart > selectionEnd );
   if( indicesSwapped )
   {
     std::swap( selectionStart, selectionEnd );
   }
 
+  // Get the indices to the first and last selected glyphs.
+  const CharacterIndex selectionEndMinusOne = selectionEnd - 1u;
   const GlyphIndex glyphStart = *( charactersToGlyphBuffer + selectionStart );
-  const Length numberOfGlyphs = *( glyphsPerCharacterBuffer + ( selectionEnd - 1u ) );
-  const GlyphIndex glyphEnd = *( charactersToGlyphBuffer + ( selectionEnd - 1u ) ) + ( ( numberOfGlyphs > 0 ) ? numberOfGlyphs - 1u : 0u );
+  const Length numberOfGlyphs = *( glyphsPerCharacterBuffer + selectionEndMinusOne );
+  const GlyphIndex glyphEnd = *( charactersToGlyphBuffer + selectionEndMinusOne ) + ( ( numberOfGlyphs > 0 ) ? numberOfGlyphs - 1u : 0u );
+
+  // Check if the first glyph is a ligature that must be broken like Latin ff, fi, or Arabic ﻻ, etc which needs special code.
+  const Length numberOfCharactersStart = *( charactersPerGlyphBuffer + glyphStart );
+  bool splitStartGlyph = ( numberOfCharactersStart > 1u ) && HasLigatureMustBreak( mLogicalModel->GetScript( selectionStart ) );
+
+  // Check if the last glyph is a ligature that must be broken like Latin ff, fi, or Arabic ﻻ, etc which needs special code.
+  const Length numberOfCharactersEnd = *( charactersPerGlyphBuffer + glyphEnd );
+  bool splitEndGlyph = ( glyphStart != glyphEnd ) && ( numberOfCharactersEnd > 1u ) && HasLigatureMustBreak( mLogicalModel->GetScript( selectionEndMinusOne ) );
 
+  // Tell the decorator to swap the selection handles if needed.
   mEventData->mDecorator->SwapSelectionHandlesEnabled( firstLine.direction != indicesSwapped );
 
   const Vector2 offset = mEventData->mScrollPosition + mAlignmentOffset;
 
+  // Traverse the glyphs.
   for( GlyphIndex index = glyphStart; index <= glyphEnd; ++index )
   {
-    // TODO: Fix the LATIN ligatures. i.e ff, fi, etc...
     const GlyphInfo& glyph = *( glyphsBuffer + index );
     const Vector2& position = *( positionsBuffer + index );
 
+    if( splitStartGlyph )
+    {
+      // If the first glyph is a ligature that must be broken it may be needed to add only part of the glyph to the highlight box.
+
+      const float glyphAdvance = glyph.advance / static_cast<float>( numberOfCharactersStart );
+      const CharacterIndex interGlyphIndex = selectionStart - *( glyphToCharacterBuffer + glyphStart );
+      // Get the direction of the character.
+      CharacterDirection isCurrentRightToLeft = false;
+      if( NULL != modelCharacterDirectionsBuffer ) // If modelCharacterDirectionsBuffer is NULL, it means the whole text is left to right.
+      {
+        isCurrentRightToLeft = *( modelCharacterDirectionsBuffer + selectionStart );
+      }
+
+      // The end point could be in the middle of the ligature.
+      // Calculate the number of characters selected.
+      const Length numberOfCharacters = ( glyphStart == glyphEnd ) ? ( selectionEnd - selectionStart ) : ( numberOfCharactersStart - interGlyphIndex );
+
+      const float xPosition = position.x - glyph.xBearing + offset.x + glyphAdvance * static_cast<float>( isCurrentRightToLeft ? ( numberOfCharactersStart - interGlyphIndex - numberOfCharacters ) : interGlyphIndex );
+
+      mEventData->mDecorator->AddHighlight( xPosition,
+                                            offset.y,
+                                            xPosition + static_cast<float>( numberOfCharacters ) * glyphAdvance,
+                                            height );
+
+      splitStartGlyph = false;
+      continue;
+    }
+
+    if( splitEndGlyph && ( index == glyphEnd ) )
+    {
+      // Equally, if the last glyph is a ligature that must be broken it may be needed to add only part of the glyph to the highlight box.
+
+      const float glyphAdvance = glyph.advance / static_cast<float>( numberOfCharactersEnd );
+      const CharacterIndex interGlyphIndex = selectionEnd - *( glyphToCharacterBuffer + glyphEnd );
+      // Get the direction of the character.
+      CharacterDirection isCurrentRightToLeft = false;
+      if( NULL != modelCharacterDirectionsBuffer ) // If modelCharacterDirectionsBuffer is NULL, it means the whole text is left to right.
+      {
+        isCurrentRightToLeft = *( modelCharacterDirectionsBuffer + selectionEnd );
+      }
+
+      const Length numberOfCharacters = numberOfCharactersEnd - interGlyphIndex;
+
+      const float xPosition = position.x - glyph.xBearing + offset.x + ( isCurrentRightToLeft ? ( glyphAdvance * static_cast<float>( numberOfCharacters ) ) : 0.f );
+      mEventData->mDecorator->AddHighlight( xPosition,
+                                            offset.y,
+                                            xPosition + static_cast<float>( interGlyphIndex ) * glyphAdvance,
+                                            height );
+
+      splitEndGlyph = false;
+      continue;
+    }
+
     const float xPosition = position.x - glyph.xBearing + offset.x;
     mEventData->mDecorator->AddHighlight( xPosition, offset.y, xPosition + glyph.advance, height );
   }
@@ -1339,8 +1423,8 @@ CharacterIndex Controller::Impl::GetClosestCursorIndex( float visualX,
 
     const Vector2& position = *( positionsBuffer + glyphLogicalOrderIndex );
 
-    // Prevents to jump the whole Latin ligatures like fi, ff, ...
-    const Length numberOfCharactersInLigature = ( TextAbstraction::LATIN == script ) ? *( charactersPerGlyphBuffer + glyphLogicalOrderIndex ) : 1u;
+    // Prevents to jump the whole Latin ligatures like fi, ff, or Arabic ﻻ...
+    const Length numberOfCharactersInLigature = HasLigatureMustBreak( script ) ? *( charactersPerGlyphBuffer + glyphLogicalOrderIndex ) : 1u;
     const float glyphAdvance = glyphMetrics.advance / static_cast<float>( numberOfCharactersInLigature );
 
     for( GlyphIndex index = 0u; !matched && ( index < numberOfCharactersInLigature ); ++index )
@@ -1414,7 +1498,7 @@ void Controller::Impl::GetCursorPosition( CharacterIndex logical,
   }
 
   // Get the line where the character is laid-out.
-  const LineRun* modelLines = mVisualModel->mLines.Begin();
+  const LineRun* const modelLines = mVisualModel->mLines.Begin();
 
   const LineIndex lineIndex = mVisualModel->GetLineOfCharacter( characterIndex );
   const LineRun& line = *( modelLines + lineIndex );
@@ -1455,10 +1539,16 @@ void Controller::Impl::GetCursorPosition( CharacterIndex logical,
     }
   }
 
+  const GlyphIndex* const charactersToGlyphBuffer = mVisualModel->mCharactersToGlyph.Begin();
+  const Length* const glyphsPerCharacterBuffer = mVisualModel->mGlyphsPerCharacter.Begin();
+  const Length* const charactersPerGlyphBuffer = mVisualModel->mCharactersPerGlyph.Begin();
+  const CharacterIndex* const glyphsToCharactersBuffer = mVisualModel->mGlyphsToCharacters.Begin();
+  const Vector2* const glyphPositionsBuffer = mVisualModel->mGlyphPositions.Begin();
+
   // Convert the cursor position into the glyph position.
-  const GlyphIndex primaryGlyphIndex = *( mVisualModel->mCharactersToGlyph.Begin() + index );
-  const Length primaryNumberOfGlyphs = *( mVisualModel->mGlyphsPerCharacter.Begin() + index );
-  const Length primaryNumberOfCharacters = *( mVisualModel->mCharactersPerGlyph.Begin() + primaryGlyphIndex );
+  const GlyphIndex primaryGlyphIndex = *( charactersToGlyphBuffer + index );
+  const Length primaryNumberOfGlyphs = *( glyphsPerCharacterBuffer + index );
+  const Length primaryNumberOfCharacters = *( charactersPerGlyphBuffer + primaryGlyphIndex );
 
   // Get the metrics for the group of glyphs.
   GlyphMetrics glyphMetrics;
@@ -1468,33 +1558,70 @@ void Controller::Impl::GetCursorPosition( CharacterIndex logical,
                     mVisualModel,
                     mFontClient );
 
-  float glyphAdvance = 0.f;
+  // Whether to add the glyph's advance to the cursor position.
+  // i.e if the paragraph is left to right and the logical cursor is zero, the position is the position of the first glyph and the advance is not added,
+  //     if the logical cursor is one, the position is the position of the first glyph and the advance is added.
+  // A 'truth table' was build and an online Karnaugh map tool was used to simplify the logic.
+  //
+  // FLCP A
+  // ------
+  // 0000 1
+  // 0001 1
+  // 0010 0
+  // 0011 0
+  // 0100 1
+  // 0101 0
+  // 0110 1
+  // 0111 0
+  // 1000 0
+  // 1001 x
+  // 1010 x
+  // 1011 1
+  // 1100 x
+  // 1101 x
+  // 1110 x
+  // 1111 x
+  //
+  // Where F -> isFirstPosition
+  //       L -> isLastPosition
+  //       C -> isCurrentRightToLeft
+  //       P -> isRightToLeftParagraph
+  //       A -> Whether to add the glyph's advance.
+
+  const bool addGlyphAdvance = ( ( isLastPosition && !isRightToLeftParagraph ) ||
+                                 ( isFirstPosition && isRightToLeftParagraph ) ||
+                                 ( !isFirstPosition && !isLastPosition && !isCurrentRightToLeft ) );
+
+  float glyphAdvance = addGlyphAdvance ? glyphMetrics.advance : 0.f;
+
   if( !isLastPosition &&
       ( primaryNumberOfCharacters > 1u ) )
   {
-    const CharacterIndex firstIndex = *( mVisualModel->mGlyphsToCharacters.Begin() + primaryGlyphIndex );
-    glyphAdvance = static_cast<float>( 1u + characterIndex - firstIndex ) * glyphMetrics.advance / static_cast<float>( primaryNumberOfCharacters );
-  }
-  else
-  {
-    glyphAdvance = glyphMetrics.advance;
+    const CharacterIndex firstIndex = *( glyphsToCharactersBuffer + primaryGlyphIndex );
+
+    bool isCurrentRightToLeft = false;
+    if( NULL != modelCharacterDirectionsBuffer ) // If modelCharacterDirectionsBuffer is NULL, it means the whole text is left to right.
+    {
+      isCurrentRightToLeft = *( modelCharacterDirectionsBuffer + index );
+    }
+
+    Length numberOfGlyphAdvance = ( isFirstPosition ? 0u : 1u ) + characterIndex - firstIndex;
+    if( isCurrentRightToLeft )
+    {
+      numberOfGlyphAdvance = primaryNumberOfCharacters - numberOfGlyphAdvance;
+    }
+
+    glyphAdvance = static_cast<float>( numberOfGlyphAdvance ) * glyphMetrics.advance / static_cast<float>( primaryNumberOfCharacters );
   }
 
   // Get the glyph position and x bearing.
-  const Vector2& primaryPosition = *( mVisualModel->mGlyphPositions.Begin() + primaryGlyphIndex );
+  const Vector2& primaryPosition = *( glyphPositionsBuffer + primaryGlyphIndex );
 
   // Set the primary cursor's height.
   cursorInfo.primaryCursorHeight = cursorInfo.isSecondaryCursor ? 0.5f * glyphMetrics.fontHeight : glyphMetrics.fontHeight;
 
   // Set the primary cursor's position.
-  if( isLastPosition )
-  {
-    cursorInfo.primaryPosition.x = -glyphMetrics.xBearing + primaryPosition.x + ( isRightToLeftParagraph ? 0.f : glyphMetrics.advance );
-  }
-  else
-  {
-    cursorInfo.primaryPosition.x = -glyphMetrics.xBearing + primaryPosition.x + ( ( ( isFirstPosition && !isCurrentRightToLeft ) || ( !isFirstPosition && isCurrentRightToLeft ) ) ? 0.f : glyphAdvance );
-  }
+  cursorInfo.primaryPosition.x = -glyphMetrics.xBearing + primaryPosition.x + glyphAdvance;
   cursorInfo.primaryPosition.y = line.ascender - glyphMetrics.ascender;
 
   // Calculate the secondary cursor.
@@ -1510,10 +1637,10 @@ void Controller::Impl::GetCursorPosition( CharacterIndex logical,
       index = ( isRightToLeftParagraph == isCurrentRightToLeft ) ? nextCharacterIndex : characterIndex;
     }
 
-    const GlyphIndex secondaryGlyphIndex = *( mVisualModel->mCharactersToGlyph.Begin() + index );
-    const Length secondaryNumberOfGlyphs = *( mVisualModel->mGlyphsPerCharacter.Begin() + index );
+    const GlyphIndex secondaryGlyphIndex = *( charactersToGlyphBuffer + index );
+    const Length secondaryNumberOfGlyphs = *( glyphsPerCharacterBuffer + index );
 
-    const Vector2& secondaryPosition = *( mVisualModel->mGlyphPositions.Begin() + index );
+    const Vector2& secondaryPosition = *( glyphPositionsBuffer + secondaryGlyphIndex );
 
     GetGlyphsMetrics( secondaryGlyphIndex,
                       secondaryNumberOfGlyphs,
@@ -1537,25 +1664,27 @@ CharacterIndex Controller::Impl::CalculateNewCursorIndex( CharacterIndex index )
 
   CharacterIndex cursorIndex = mEventData->mPrimaryCursorPosition;
 
-  const Script script = mLogicalModel->GetScript( index );
-  const GlyphIndex* charactersToGlyphBuffer = mVisualModel->mCharactersToGlyph.Begin();
-  const Length* charactersPerGlyphBuffer = mVisualModel->mCharactersPerGlyph.Begin();
+  const GlyphIndex* const charactersToGlyphBuffer = mVisualModel->mCharactersToGlyph.Begin();
+  const Length* const charactersPerGlyphBuffer = mVisualModel->mCharactersPerGlyph.Begin();
+
+  GlyphIndex glyphIndex = *( charactersToGlyphBuffer + index );
+  Length numberOfCharacters = *( charactersPerGlyphBuffer + glyphIndex );
 
-  Length numberOfCharacters = 0u;
-  if( TextAbstraction::LATIN == script )
+  if( numberOfCharacters > 1u )
   {
-    // Prevents to jump the whole Latin ligatures like fi, ff, ...
-    numberOfCharacters = 1u;
+    const Script script = mLogicalModel->GetScript( index );
+    if( HasLigatureMustBreak( script ) )
+    {
+      // Prevents to jump the whole Latin ligatures like fi, ff, or Arabic ﻻ,  ...
+      numberOfCharacters = 1u;
+    }
   }
   else
   {
-    GlyphIndex glyphIndex = *( charactersToGlyphBuffer + index );
-    numberOfCharacters = *( charactersPerGlyphBuffer + glyphIndex );
-
     while( 0u == numberOfCharacters )
     {
-      numberOfCharacters = *( charactersPerGlyphBuffer + glyphIndex );
       ++glyphIndex;
+      numberOfCharacters = *( charactersPerGlyphBuffer + glyphIndex );
     }
   }
 
@@ -1619,12 +1748,12 @@ void Controller::Impl::UpdateCursorPosition()
       }
       case LayoutEngine::HORIZONTAL_ALIGN_CENTER:
       {
-        cursorPosition.x = floor( 0.5f * mControlSize.width );
+        cursorPosition.x = floor( 0.5f * mVisualModel->mControlSize.width );
         break;
       }
       case LayoutEngine::HORIZONTAL_ALIGN_END:
       {
-        cursorPosition.x = mControlSize.width;
+        cursorPosition.x = mVisualModel->mControlSize.width;
         break;
       }
     }
@@ -1638,12 +1767,12 @@ void Controller::Impl::UpdateCursorPosition()
       }
       case LayoutEngine::VERTICAL_ALIGN_CENTER:
       {
-        cursorPosition.y = floorf( 0.5f * ( mControlSize.height - lineHeight ) );
+        cursorPosition.y = floorf( 0.5f * ( mVisualModel->mControlSize.height - lineHeight ) );
         break;
       }
       case LayoutEngine::VERTICAL_ALIGN_BOTTOM:
       {
-        cursorPosition.y = mControlSize.height - lineHeight;
+        cursorPosition.y = mVisualModel->mControlSize.height - lineHeight;
         break;
       }
     }
@@ -1728,9 +1857,9 @@ void Controller::Impl::UpdateSelectionHandle( HandleType handleType )
 void Controller::Impl::ClampHorizontalScroll( const Vector2& actualSize )
 {
   // Clamp between -space & 0 (and the text alignment).
-  if( actualSize.width > mControlSize.width )
+  if( actualSize.width > mVisualModel->mControlSize.width )
   {
-    const float space = ( actualSize.width - mControlSize.width ) + mAlignmentOffset.x;
+    const float space = ( actualSize.width - mVisualModel->mControlSize.width ) + mAlignmentOffset.x;
     mEventData->mScrollPosition.x = ( mEventData->mScrollPosition.x < -space ) ? -space : mEventData->mScrollPosition.x;
     mEventData->mScrollPosition.x = ( mEventData->mScrollPosition.x > -mAlignmentOffset.x ) ? -mAlignmentOffset.x : mEventData->mScrollPosition.x;
 
@@ -1745,9 +1874,9 @@ void Controller::Impl::ClampHorizontalScroll( const Vector2& actualSize )
 void Controller::Impl::ClampVerticalScroll( const Vector2& actualSize )
 {
   // Clamp between -space & 0 (and the text alignment).
-  if( actualSize.height > mControlSize.height )
+  if( actualSize.height > mVisualModel->mControlSize.height )
   {
-    const float space = ( actualSize.height - mControlSize.height ) + mAlignmentOffset.y;
+    const float space = ( actualSize.height - mVisualModel->mControlSize.height ) + mAlignmentOffset.y;
     mEventData->mScrollPosition.y = ( mEventData->mScrollPosition.y < -space ) ? -space : mEventData->mScrollPosition.y;
     mEventData->mScrollPosition.y = ( mEventData->mScrollPosition.y > -mAlignmentOffset.y ) ? -mAlignmentOffset.y : mEventData->mScrollPosition.y;
 
@@ -1769,9 +1898,9 @@ void Controller::Impl::ScrollToMakePositionVisible( const Vector2& position )
     mEventData->mScrollPosition.x += offset.x;
     updateDecorator = true;
   }
-  else if( position.x > mControlSize.width )
+  else if( position.x > mVisualModel->mControlSize.width )
   {
-    offset.x = mControlSize.width - position.x;
+    offset.x = mVisualModel->mControlSize.width - position.x;
     mEventData->mScrollPosition.x += offset.x;
     updateDecorator = true;
   }
index 79f56d3..83aafe4 100644 (file)
@@ -209,7 +209,6 @@ struct Controller::Impl
     mView(),
     mLayoutEngine(),
     mModifyEvents(),
-    mControlSize(),
     mTextColor( Color::BLACK ),
     mAlignmentOffset(),
     mOperationsPending( NO_OPERATION ),
@@ -466,7 +465,6 @@ struct Controller::Impl
   View mView;                              ///< The view interface to the rendering back-end.
   LayoutEngine mLayoutEngine;              ///< The layout engine.
   std::vector<ModifyEvent> mModifyEvents;  ///< Temporary stores the text set until the next relayout.
-  Size mControlSize;                       ///< The size of the control.
   Vector4 mTextColor;                      ///< The regular text color
   Vector2 mAlignmentOffset;                ///< Vertical and horizontal offset of the whole text inside the control due to alignment.
   OperationsMask mOperationsPending;       ///< Operations pending to be done to layout the text.
index 8425f56..ef8b746 100644 (file)
@@ -564,7 +564,7 @@ float Controller::GetHeightForWidth( float width )
   ProcessModifyEvents();
 
   Size layoutSize;
-  if( width != mImpl->mControlSize.width )
+  if( width != mImpl->mVisualModel->mControlSize.width )
   {
     // Operations that can be done only once until the text changes.
     const OperationsMask onlyOnceOperations = static_cast<OperationsMask>( CONVERT_TO_UTF32  |
@@ -621,9 +621,9 @@ bool Controller::Relayout( const Size& size )
     return glyphsRemoved;
   }
 
-  if( size != mImpl->mControlSize )
+  if( size != mImpl->mVisualModel->mControlSize )
   {
-    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "new size (previous size %f,%f)\n", mImpl->mControlSize.width, mImpl->mControlSize.height );
+    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "new size (previous size %f,%f)\n", mImpl->mVisualModel->mControlSize.width, mImpl->mVisualModel->mControlSize.height );
 
     // Operations that need to be done if the size changes.
     mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
@@ -632,7 +632,7 @@ bool Controller::Relayout( const Size& size )
                                                              UPDATE_ACTUAL_SIZE        |
                                                              REORDER );
 
-    mImpl->mControlSize = size;
+    mImpl->mVisualModel->mControlSize = size;
   }
 
   // Make sure the model is up-to-date before layouting
@@ -640,7 +640,7 @@ bool Controller::Relayout( const Size& size )
   mImpl->UpdateModel( mImpl->mOperationsPending );
 
   Size layoutSize;
-  bool updated = DoRelayout( mImpl->mControlSize,
+  bool updated = DoRelayout( mImpl->mVisualModel->mControlSize,
                              mImpl->mOperationsPending,
                              layoutSize );
 
@@ -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();
   }
@@ -1460,7 +1455,7 @@ void Controller::SelectEvent( float x, float y, bool selectAll )
 
 void Controller::GetTargetSize( Vector2& targetSize )
 {
-  targetSize = mImpl->mControlSize;
+  targetSize = mImpl->mVisualModel->mControlSize;
 }
 
 void Controller::AddDecoration( Actor& actor, bool needsClipping )
index d8e2ae6..55e4aca 100644 (file)
@@ -60,6 +60,13 @@ public:
   virtual ~ViewInterface();
 
   /**
+   * @brief Retrieves the target size of the UI control.
+   *
+   * @return The text's size.
+   */
+  virtual const Vector2& GetControlSize() const = 0;
+
+  /**
    * Retrieves the number of glyphs.
    *
    * @return The number of glyphs.
index 34c3f32..621f26d 100644 (file)
@@ -55,6 +55,16 @@ void View::SetVisualModel( VisualModelPtr visualModel )
   mImpl->mVisualModel = visualModel;
 }
 
+const Vector2& View::GetControlSize() const
+{
+  if ( mImpl->mVisualModel )
+  {
+    return mImpl->mVisualModel->mControlSize;
+  }
+
+  return Vector2::ZERO;
+}
+
 Length View::GetGlyphs( GlyphInfo* glyphs,
                         Vector2* glyphPositions,
                         GlyphIndex glyphIndex,
index 43506a5..b724faa 100644 (file)
@@ -58,6 +58,11 @@ public:
   void SetVisualModel( VisualModelPtr visualModel );
 
   /**
+   * @copydoc Dali::Toolkit::Text::ViewInterface::GetControlSize()
+   */
+  virtual const Vector2& GetControlSize() const;
+
+  /**
    * @copydoc Dali::Toolkit::Text::ViewInterface::GetNumberOfGlyphs()
    */
   virtual Length GetNumberOfGlyphs() const;
index f290ba5..57eaffd 100644 (file)
@@ -303,14 +303,13 @@ public:
   Vector<Vector2>        mGlyphPositions;       ///< For each glyph, the position.
   Vector<LineRun>        mLines;                ///< The laid out lines.
 
+  Vector2                mControlSize;           ///< The size of the UI control the decorator is adding it's decorations to.
   Vector4                mTextColor;            ///< The text color
   Vector4                mShadowColor;          ///< Color of drop shadow
   Vector4                mUnderlineColor;       ///< Color of underline
   Vector2                mShadowOffset;         ///< Offset for drop shadow, 0 indicates no shadow
   float                  mUnderlineHeight;      ///< Fixed height for underline to override font metrics.
 
-
-
 private:
 
   Size                   mNaturalSize;        ///< Size of the text with no line wrapping.
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
diff --git a/dali-toolkit/public-api/controls/image-view/image-view.cpp b/dali-toolkit/public-api/controls/image-view/image-view.cpp
new file mode 100644 (file)
index 0000000..8075764
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+
+#include <dali-toolkit/public-api/controls/image-view/image-view.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/controls/image-view/image-view-impl.h>
+
+// EXTERNAL INCLUDES
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+ImageView::ImageView()
+{
+}
+
+ImageView::ImageView( const ImageView& imageView )
+: Control( imageView )
+{
+}
+
+ImageView& ImageView::operator=( const ImageView& imageView )
+{
+  if( &imageView != this )
+  {
+    Control::operator=( imageView );
+  }
+  return *this;
+}
+
+ImageView::~ImageView()
+{
+}
+
+ImageView ImageView::New()
+{
+  return Internal::ImageView::New();
+}
+
+ImageView ImageView::New( Image image )
+{
+  ImageView imageView = Internal::ImageView::New();
+  imageView.SetImage( image );
+  return imageView;
+}
+
+ImageView ImageView::New( const std::string& url )
+{
+  ImageView imageView = Internal::ImageView::New();
+  imageView.SetProperty( ImageView::Property::RESOURCE_URL, Dali::Property::Value( url ) );
+  return imageView;
+}
+
+ImageView ImageView::DownCast( BaseHandle handle )
+{
+  return Control::DownCast<ImageView, Internal::ImageView>(handle);
+}
+
+void ImageView::SetImage( Image image )
+{
+  Dali::Toolkit::GetImpl( *this ).SetImage( image );
+}
+
+Image ImageView::GetImage() const
+{
+  return Dali::Toolkit::GetImpl( *this ).GetImage();
+}
+
+ImageView::ImageView( Internal::ImageView& implementation )
+ : Control( implementation )
+{
+}
+
+ImageView::ImageView( Dali::Internal::CustomActor* internal )
+ : Control( internal )
+{
+  VerifyCustomActorPointer<Internal::ImageView>( internal );
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/public-api/controls/image-view/image-view.h b/dali-toolkit/public-api/controls/image-view/image-view.h
new file mode 100644 (file)
index 0000000..821a981
--- /dev/null
@@ -0,0 +1,164 @@
+#ifndef __DALI_TOOLKIT_IMAGE_VIEW_H__
+#define __DALI_TOOLKIT_IMAGE_VIEW_H__
+
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/control.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal DALI_INTERNAL
+{
+class ImageView;
+}
+
+/**
+ *
+ * @brief ImageView is a class for displaying an Image.
+ */
+class DALI_IMPORT_API ImageView : public Control
+{
+public:
+  /**
+   * @brief The start and end property ranges for this control.
+   */
+  enum PropertyRange
+  {
+    PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
+    PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000              ///< Reserve property indices
+  };
+
+  /**
+   * @brief An enumeration of properties belonging to the ImageView class.
+   */
+  struct Property
+  {
+    enum
+    {
+      RESOURCE_URL = PROPERTY_START_INDEX, ///< name "resource-url", @see SetImage(), type string
+    };
+  };
+
+public:
+
+  /**
+   * @brief Create an uninitialized ImageView.
+   */
+  ImageView();
+
+  /**
+   * @brief Create an initialized ImageView.
+   *
+   * @return A handle to a newly allocated Dali ImageView.
+   */
+  static ImageView New();
+
+  /**
+   * @brief Create an initialized ImageView from an Image.
+   *
+   * If the handle is empty, ImageView will display nothing
+   * @param[in] image The Image to display.
+   * @return A handle to a newly allocated ImageView.
+   */
+  static ImageView New( Image image );
+
+  /**
+   * @brief Create an initialized ImageView from an Image resource url
+   *
+   * If the string is empty, ImageView will display nothing
+   * @param[in] url The url of the image resource to display.
+   * @return A handle to a newly allocated ImageView.
+   */
+  static ImageView New( const std::string& url );
+
+  /**
+   * @brief Destructor
+   *
+   * This is non-virtual since derived Handle types must not contain data or virtual methods.
+   */
+  ~ImageView();
+
+  /**
+   * @brief Copy constructor.
+   *
+   * @param[in] imageView ImageView to copy. The copied ImageView will point at the same implementation
+   */
+  ImageView( const ImageView& imageView );
+
+  /**
+   * @brief Assignment operator.
+   *
+   * @param[in] imageView The ImageView to assign from.
+   * @return The updated ImageView.
+   */
+  ImageView& operator=( const ImageView& imageView );
+
+  /**
+   * @brief Downcast an Object handle to ImageView.
+   *
+   * If handle points to a ImageView the downcast produces valid
+   * handle. If not the returned handle is left uninitialized.
+   *
+   * @param[in] handle Handle to an object
+   * @return handle to a ImageView or an uninitialized handle
+   */
+  static ImageView DownCast( BaseHandle handle );
+
+  /**
+   * @brief Sets this ImageView from an Image
+   *
+   * If the handle is empty, ImageView will display nothing
+   * @param[in] image The Image to display.
+   */
+  void SetImage( Image image );
+
+  /**
+   * @brief Gets the Image
+   *
+   * @return The Image currently set to this ImageView
+   */
+  Image GetImage() const;
+
+public: // Not intended for application developers
+
+  /**
+   * @brief Creates a handle using the Toolkit::Internal implementation.
+   *
+   * @param[in]  implementation  The ImageView implementation.
+   */
+  DALI_INTERNAL ImageView( Internal::ImageView& implementation );
+
+  /**
+   * @brief Allows the creation of this ImageView from an Internal::CustomActor pointer.
+   *
+   * @param[in]  internal  A pointer to the internal CustomActor.
+   */
+  DALI_INTERNAL ImageView( Dali::Internal::CustomActor* internal );
+
+};
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_IMAGE_VIEW_H__
index 6a07984..04f32ff 100644 (file)
@@ -31,7 +31,7 @@ namespace Toolkit
 
 const unsigned int TOOLKIT_MAJOR_VERSION = 1;
 const unsigned int TOOLKIT_MINOR_VERSION = 0;
-const unsigned int TOOLKIT_MICRO_VERSION = 49;
+const unsigned int TOOLKIT_MICRO_VERSION = 50;
 const char * const TOOLKIT_BUILD_DATE    = __DATE__ " " __TIME__;
 
 #ifdef DEBUG_ENABLED
index 0109380..5e096b9 100755 (executable)
@@ -9,6 +9,7 @@ public_api_src_files = \
   $(public_api_src_dir)/controls/buttons/push-button.cpp \
   $(public_api_src_dir)/controls/buttons/radio-button.cpp \
   $(public_api_src_dir)/controls/default-controls/solid-color-actor.cpp \
+  $(public_api_src_dir)/controls/image-view/image-view.cpp \
   $(public_api_src_dir)/controls/scroll-bar/scroll-bar.cpp \
   $(public_api_src_dir)/controls/scrollable/item-view/default-item-layout.cpp \
   $(public_api_src_dir)/controls/scrollable/item-view/item-layout.cpp \
@@ -52,6 +53,9 @@ public_api_default_controls_header_files = \
 public_api_gaussian_blur_view_header_files = \
   $(public_api_src_dir)/controls/gaussian-blur-view/gaussian-blur-view.h
 
+public_api_image_view_header_files = \
+  $(public_api_src_dir)/controls/image-view/image-view.h
+
 public_api_item_view_header_files = \
   $(public_api_src_dir)/controls/scrollable/item-view/default-item-layout.h \
   $(public_api_src_dir)/controls/scrollable/item-view/item-factory.h \
index c8b3dae..46b4e55 100644 (file)
@@ -1,6 +1,6 @@
 Name:       dali-toolkit
 Summary:    The OpenGLES Canvas Core Library Toolkit
-Version:    1.0.49
+Version:    1.0.50
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0