[dali_1.2.5] Merge branch 'devel/master' 19/87819/1
authorXiangyin Ma <x1.ma@samsung.com>
Fri, 9 Sep 2016 13:03:13 +0000 (14:03 +0100)
committerXiangyin Ma <x1.ma@samsung.com>
Fri, 9 Sep 2016 13:03:13 +0000 (14:03 +0100)
Change-Id: I0e2d3ace33c6cc23cc72a86e20e9e2c523f502a4

55 files changed:
automated-tests/src/dali-toolkit-internal/CMakeLists.txt
automated-tests/src/dali-toolkit-internal/utc-Dali-VisualFactoryResolveUrl.cpp [new file with mode: 0644]
automated-tests/src/dali-toolkit/CMakeLists.txt
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.h
automated-tests/src/dali-toolkit/utc-Dali-Model3dView.cpp
automated-tests/src/dali-toolkit/utc-Dali-ProgressBar.cpp [new file with mode: 0644]
automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp
build/tizen/dali-toolkit/Makefile.am
dali-toolkit/devel-api/controls/progress-bar/progress-bar.cpp [new file with mode: 0644]
dali-toolkit/devel-api/controls/progress-bar/progress-bar.h [new file with mode: 0644]
dali-toolkit/devel-api/file.list
dali-toolkit/devel-api/visual-factory/visual-base.h
dali-toolkit/internal/controls/buttons/button-impl.cpp
dali-toolkit/internal/controls/image-view/image-view-impl.cpp
dali-toolkit/internal/controls/image-view/image-view-impl.h
dali-toolkit/internal/controls/model3d-view/model3d-view-impl.cpp
dali-toolkit/internal/controls/progress-bar/progress-bar-impl.cpp [new file with mode: 0755]
dali-toolkit/internal/controls/progress-bar/progress-bar-impl.h [new file with mode: 0755]
dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp
dali-toolkit/internal/controls/text-controls/text-selection-toolbar-impl.cpp
dali-toolkit/internal/controls/text-controls/text-selection-toolbar-impl.h
dali-toolkit/internal/file.list
dali-toolkit/internal/visuals/border/border-visual.cpp
dali-toolkit/internal/visuals/border/border-visual.h
dali-toolkit/internal/visuals/color/color-visual.cpp
dali-toolkit/internal/visuals/color/color-visual.h
dali-toolkit/internal/visuals/gradient/gradient-visual.cpp
dali-toolkit/internal/visuals/gradient/gradient-visual.h
dali-toolkit/internal/visuals/image/batch-image-visual.cpp
dali-toolkit/internal/visuals/image/image-visual.cpp
dali-toolkit/internal/visuals/image/image-visual.h
dali-toolkit/internal/visuals/mesh/mesh-visual.cpp
dali-toolkit/internal/visuals/mesh/mesh-visual.h
dali-toolkit/internal/visuals/npatch/npatch-visual.cpp
dali-toolkit/internal/visuals/npatch/npatch-visual.h
dali-toolkit/internal/visuals/primitive/primitive-visual.cpp
dali-toolkit/internal/visuals/primitive/primitive-visual.h
dali-toolkit/internal/visuals/svg/svg-visual.cpp
dali-toolkit/internal/visuals/svg/svg-visual.h
dali-toolkit/internal/visuals/visual-base-impl.cpp
dali-toolkit/internal/visuals/visual-base-impl.h
dali-toolkit/internal/visuals/visual-factory-impl.cpp
dali-toolkit/internal/visuals/visual-factory-resolve-url.h [new file with mode: 0644]
dali-toolkit/internal/visuals/wireframe/wireframe-visual.cpp
dali-toolkit/internal/visuals/wireframe/wireframe-visual.h
dali-toolkit/public-api/controls/control-impl.cpp
dali-toolkit/public-api/controls/control-impl.h
dali-toolkit/public-api/dali-toolkit-version.cpp
dali-toolkit/styles/1920x1080/dali-toolkit-default-theme.json
dali-toolkit/styles/480x800/dali-toolkit-default-theme.json
dali-toolkit/styles/720x1280/dali-toolkit-default-theme.json
packaging/dali-addon.spec
packaging/dali-toolkit.spec
plugins/dali-script-v8/src/constants/constants-wrapper.cpp

index bb55422..d2316e8 100644 (file)
@@ -18,6 +18,7 @@ SET(TC_SOURCES
  utc-Dali-VisualModel.cpp
  utc-Dali-Text-Layout.cpp
  utc-Dali-Text-Controller.cpp
+ utc-Dali-VisualFactoryResolveUrl.cpp
 )
 
 # Append list of test harness files (Won't get parsed for test cases)
diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-VisualFactoryResolveUrl.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-VisualFactoryResolveUrl.cpp
new file mode 100644 (file)
index 0000000..f859b74
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2016 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/internal/visuals/visual-factory-resolve-url.h>
+
+using namespace Dali::Toolkit::Internal;
+
+int UtcDaliResolveUrlRegularImage(void)
+{
+  tet_infoline( "UtcDaliResolveUrl REGULAR_IMAGE" );
+
+  DALI_TEST_EQUALS( UrlType::REGULAR_IMAGE, ResolveUrlType("foobar.jpeg"), TEST_LOCATION );
+
+  DALI_TEST_EQUALS( UrlType::REGULAR_IMAGE, ResolveUrlType("foobar.gif"), TEST_LOCATION );
+
+  DALI_TEST_EQUALS( UrlType::REGULAR_IMAGE, ResolveUrlType("foobar.PNG"), TEST_LOCATION );
+
+  DALI_TEST_EQUALS( UrlType::REGULAR_IMAGE, ResolveUrlType("foobar.Png123"), TEST_LOCATION );
+
+  DALI_TEST_EQUALS( UrlType::REGULAR_IMAGE, ResolveUrlType("foobar.Png1.23"), TEST_LOCATION );
+
+  DALI_TEST_EQUALS( UrlType::REGULAR_IMAGE, ResolveUrlType(""), TEST_LOCATION );
+
+  DALI_TEST_EQUALS( UrlType::REGULAR_IMAGE, ResolveUrlType(" "), TEST_LOCATION );
+
+  DALI_TEST_EQUALS( UrlType::REGULAR_IMAGE, ResolveUrlType("."), TEST_LOCATION );
+
+  DALI_TEST_EQUALS( UrlType::REGULAR_IMAGE, ResolveUrlType("9"), TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliResolveUrlSvg(void)
+{
+  tet_infoline( "UtcDaliResolveUrl SVG" );
+
+  DALI_TEST_EQUALS( UrlType::SVG, ResolveUrlType("foobar.svg"), TEST_LOCATION );
+
+  DALI_TEST_EQUALS( UrlType::SVG, ResolveUrlType("foobar.svg.svg"), TEST_LOCATION );
+
+  DALI_TEST_EQUALS( UrlType::SVG, ResolveUrlType("foobar.svG"), TEST_LOCATION );
+
+  DALI_TEST_EQUALS( UrlType::SVG, ResolveUrlType("foobar.SVG"), TEST_LOCATION );
+
+  DALI_TEST_EQUALS( UrlType::SVG, ResolveUrlType(".SvG"), TEST_LOCATION );
+
+  // SVGs aren't N-patch
+  DALI_TEST_EQUALS( UrlType::SVG, ResolveUrlType("foobar.9.svg"), TEST_LOCATION );
+
+  DALI_TEST_EQUALS( UrlType::REGULAR_IMAGE, ResolveUrlType("svg.png"), TEST_LOCATION );
+
+  // maybe controversial, but for now we expect the suffix to be exactly .svg
+  DALI_TEST_EQUALS( UrlType::REGULAR_IMAGE, ResolveUrlType("svg.svg1"), TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliResolveUrlNPatch(void)
+{
+  tet_infoline( "UtcDaliResolveUrl N_PATCH" );
+
+  DALI_TEST_EQUALS( UrlType::N_PATCH, ResolveUrlType("foobar.9.gif"), TEST_LOCATION );
+
+  DALI_TEST_EQUALS( UrlType::N_PATCH, ResolveUrlType("foobar.#.png"), TEST_LOCATION );
+
+  DALI_TEST_EQUALS( UrlType::N_PATCH, ResolveUrlType("foobar.9.9.bmp"), TEST_LOCATION );
+
+  DALI_TEST_EQUALS( UrlType::N_PATCH, ResolveUrlType("foobar.9.9.jpg[]=$$"), TEST_LOCATION );
+
+  DALI_TEST_EQUALS( UrlType::N_PATCH, ResolveUrlType("foobar.9.#.#.9.wbpm123"), TEST_LOCATION );
+
+  DALI_TEST_EQUALS( UrlType::REGULAR_IMAGE, ResolveUrlType("svg.##.png"), TEST_LOCATION );
+
+  DALI_TEST_EQUALS( UrlType::REGULAR_IMAGE, ResolveUrlType("svg.99.jpeg"), TEST_LOCATION );
+
+  END_TEST;
+}
index c3723e0..3b39bd0 100644 (file)
@@ -42,6 +42,7 @@ SET(TC_SOURCES
    utc-Dali-KeyboardFocusManager.cpp
    utc-Dali-Magnifier.cpp
    utc-Dali-Popup.cpp
+   utc-Dali-ProgressBar.cpp
    utc-Dali-PushButton.cpp
    utc-Dali-RadioButton.cpp
    utc-Dali-ScrollViewEffect.cpp
index 3f2e6e5..0054e59 100644 (file)
@@ -130,6 +130,18 @@ bool TraceCallStack::FindMethodAndParams(std::string method, const NamedParams&
   return FindIndexFromMethodAndParams( method, params ) > -1;
 }
 
+bool TraceCallStack::FindMethodAndParamsFromStartIndex( std::string method, std::string params, size_t& startIndex ) const
+{
+  for( size_t i = startIndex; i < mCallStack.size(); ++i )
+  {
+    if( ( mCallStack[i].method.compare( method ) == 0 ) && ( mCallStack[i].paramList.compare( params ) == 0 ) )
+    {
+      startIndex = i;
+      return true;
+    }
+  }
+  return false;
+}
 
 /**
  * Search for a method in the stack with the given parameter list
index 137bfaf..e1882ea 100644 (file)
@@ -102,6 +102,19 @@ public:
   bool FindMethodAndParams(std::string method, const NamedParams& params) const;
 
   /**
+   * Search for a method in the stack with the given parameter list.
+   * The search is done from a given index.
+   * This allows the order of methods and parameters to be checked.
+   * @param[in] method The name of the method
+   * @param[in] params A comma separated list of parameter values
+   * @param[in/out] startIndex The method index to start looking from.
+   *                This is updated if a method is found so subsequent
+   *                calls can search for methods occuring after this one.
+   * @return True if the method was in the stack
+   */
+  bool FindMethodAndParamsFromStartIndex( std::string method, std::string params, size_t& startIndex ) const;
+
+  /**
    * Search for a method in the stack with the given parameter list
    * @param[in] method The name of the method
    * @param[in] params A comma separated list of parameter values
index 15737f4..0d699f6 100644 (file)
@@ -38,9 +38,9 @@ void model_view_cleanup(void)
 
 namespace
 {
-const char * TEST_OBJ_FILE_NAME = "Dino.obj";
-const char * TEST_MTL_FILE_NAME = "Dino.mtl";
-//const char * TEST_IMG_PATH = "";
+const char* TEST_OBJ_FILE_NAME = TEST_RESOURCE_DIR "/Cube.obj";
+const char* TEST_MTL_FILE_NAME = TEST_RESOURCE_DIR "/ToyRobot-Metal.mtl";
+const char* TEST_RESOURCE_LOCATION = TEST_RESOURCE_DIR "/";
 }
 
 // Negative test case for a method
@@ -118,8 +118,12 @@ int UtcDaliModelViewPropertyNames(void)
   DALI_TEST_CHECK( val.Get( obj_file_name ) );
   DALI_TEST_EQUALS( obj_file_name, TEST_MTL_FILE_NAME, TEST_LOCATION );
 
-  //modelView.SetProperty( Model3dView::Property::MTL_URL, Dali::Property::Value( mtlUrl ) );
-  //modelView.SetProperty( Model3dView::Property::IMAGES_URL, Dali::Property::Value( imagesUrl ) );
+  view.SetProperty( Model3dView::Property::IMAGES_URL, Dali::Property::Value( TEST_RESOURCE_LOCATION ) );
+  val = view.GetProperty( Model3dView::Property::IMAGES_URL );
+  DALI_TEST_CHECK( val.Get( obj_file_name ) );
+  DALI_TEST_EQUALS( obj_file_name, TEST_RESOURCE_LOCATION, TEST_LOCATION );
+
+  Stage::GetCurrent().Add(view);
 
   END_TEST;
 }
diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ProgressBar.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ProgressBar.cpp
new file mode 100644 (file)
index 0000000..2a2ae20
--- /dev/null
@@ -0,0 +1,282 @@
+/*
+ * Copyright (c) 2016 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 <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/controls/progress-bar/progress-bar.h>
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+using Dali::Toolkit::ProgressBar;
+
+
+void utc_dali_toolkit_progressbar_startup(void)
+{
+  test_return_value = TET_UNDEF;
+}
+
+void utc_dali_toolkit_progressbar_cleanup(void)
+{
+  test_return_value = TET_PASS;
+}
+
+namespace
+{
+
+static bool gObjectCreatedCallBackCalled;
+
+static void TestCallback(BaseHandle handle)
+{
+  gObjectCreatedCallBackCalled = true;
+}
+
+}
+
+int UtcDaliProgressBarNew(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliProgressBarNew");
+
+  // Create the ProgressBar actor
+  ProgressBar progressBar;
+
+  DALI_TEST_CHECK( !progressBar );
+
+  progressBar = ProgressBar::New();
+
+  DALI_TEST_CHECK( progressBar );
+
+  ProgressBar progressBar2(progressBar);
+
+  DALI_TEST_CHECK( progressBar2 == progressBar );
+
+  ProgressBar progressBar3;
+  progressBar3 = progressBar2;
+
+  DALI_TEST_CHECK( progressBar3 == progressBar2 );
+
+  //Additional check to ensure object is created by checking if it's registered
+  ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
+  DALI_TEST_CHECK( registry );
+
+  gObjectCreatedCallBackCalled = false;
+  registry.ObjectCreatedSignal().Connect( &TestCallback );
+  {
+    ProgressBar progressBar = ProgressBar::New();
+  }
+  DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
+  END_TEST;
+}
+
+int UtcDaliProgressBarDestructor(void)
+{
+  ToolkitTestApplication application;
+
+  ProgressBar* progressBar = new ProgressBar();
+  delete progressBar;
+
+  DALI_TEST_CHECK( true );
+  END_TEST;
+}
+
+int UtcDaliProgressBarDownCast(void)
+{
+  ToolkitTestApplication application;
+
+  Handle handle = ProgressBar::New();
+
+  ProgressBar progressBar = ProgressBar::DownCast( handle );
+
+  DALI_TEST_CHECK( progressBar == handle );
+  END_TEST;
+}
+
+static bool gProgressBarValueChangedCallBackCalled = false;
+
+static void OnProgressBarValueChanged( ProgressBar progressBar, float value )
+{
+  gProgressBarValueChangedCallBackCalled = true;
+}
+
+int UtcDaliProgressBarSignals(void)
+{
+  ToolkitTestApplication application;  // Exceptions require ToolkitTestApplication
+  tet_infoline(" UtcDaliProgressBarSignals");
+
+  // Create the ProgressBar actor
+  ProgressBar progressBar = ProgressBar::New();
+  Stage::GetCurrent().Add( progressBar );
+  progressBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
+  progressBar.SetAnchorPoint(ParentOrigin::TOP_LEFT);
+  progressBar.SetSize( Vector2( Stage::GetCurrent().GetSize().x, 20.0f ) );
+  progressBar.SetPosition( 0.0f, 0.0f );
+
+  progressBar.ValueChangedSignal().Connect( &OnProgressBarValueChanged );
+  progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.2f);
+
+  application.SendNotification();
+  application.Render();
+
+  //gProgressBarValueChangedCallBackCalled = false;
+
+  DALI_TEST_CHECK(gProgressBarValueChangedCallBackCalled);
+  END_TEST;
+}
+
+int UtcDaliProgressBarSetPropertyP(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline( "UtcDaliProgressBarSetPropertyP" );
+
+  ProgressBar progressBar = ProgressBar::New();
+  progressBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
+  progressBar.SetAnchorPoint(ParentOrigin::TOP_LEFT);
+  progressBar.SetSize( Vector2( Stage::GetCurrent().GetSize().x, 20.0f ) );
+  progressBar.SetPosition( 0.0f, 0.0f );
+
+  Stage::GetCurrent().Add(progressBar);
+  application.SendNotification();
+  application.Render();
+
+  float val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+  DALI_TEST_EQUALS(val, 0.0f, TEST_LOCATION);
+
+  progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.2f);
+  val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+  DALI_TEST_EQUALS(val, 0.2f, TEST_LOCATION);
+
+  progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.8f);
+  val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+  DALI_TEST_EQUALS(val, 0.8f, TEST_LOCATION);
+
+  progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.4f);
+  val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+  DALI_TEST_EQUALS(val, 0.4f, TEST_LOCATION);
+
+  progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.0f);
+  val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+  DALI_TEST_EQUALS(val, 0.0f, TEST_LOCATION);
+
+  progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 1.0f);
+  val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+  DALI_TEST_EQUALS(val, 1.0f, TEST_LOCATION);
+
+  progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, -1.0f);
+  val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+  DALI_TEST_EQUALS(val, 1.0f, TEST_LOCATION);
+
+  progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.9f);
+  val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+  DALI_TEST_EQUALS(val, 0.9f, TEST_LOCATION);
+
+  progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 1.1f);
+  val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+  DALI_TEST_EQUALS(val, 0.9f, TEST_LOCATION);
+
+  progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 2.0f);
+  val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+  DALI_TEST_EQUALS(val, 0.9f, TEST_LOCATION);
+
+  progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.0f);
+  val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+  DALI_TEST_EQUALS(val, 0.0f, TEST_LOCATION);
+
+  progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.9f);
+  val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+  DALI_TEST_EQUALS(val, 0.9f, TEST_LOCATION);
+
+  progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.09f);
+  val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+  DALI_TEST_EQUALS(val, 0.09f, TEST_LOCATION);
+
+  progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.1f);
+  val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+  DALI_TEST_EQUALS(val, 0.1f, TEST_LOCATION);
+
+  {
+    Property::Map map;
+    map["rendererType"] = "image";
+    map["size"] = Vector2(200, 200);
+    map["url"] = "track2.png";
+    progressBar.SetProperty(ProgressBar::Property::TRACK_VISUAL, map);
+    map["url"] = "progress2.png";
+    progressBar.SetProperty(ProgressBar::Property::PROGRESS_VISUAL, map);
+
+    Property::Value value = progressBar.GetProperty(ProgressBar::Property::TRACK_VISUAL);
+    Property::Map* resultMap = value.GetMap();
+    DALI_TEST_CHECK( resultMap );
+    Property::Value* url = resultMap->Find("url");
+    DALI_TEST_CHECK( url ) ;
+    DALI_TEST_EQUALS( *url, "track2.png", TEST_LOCATION );
+
+    value = progressBar.GetProperty(ProgressBar::Property::PROGRESS_VISUAL);
+    resultMap = value.GetMap();
+    DALI_TEST_CHECK( resultMap );
+    url = resultMap->Find("url");
+    DALI_TEST_CHECK( url ) ;
+    DALI_TEST_EQUALS( *url, "progress2.png", TEST_LOCATION );
+
+   }
+
+  END_TEST;
+}
+
+int UtcDaliProgressBarSetPropertyP1(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline( "UtcDaliProgressBarSetPropertyP1" );
+
+  ProgressBar progressBar = ProgressBar::New();
+  progressBar.SetParentOrigin(ParentOrigin::TOP_LEFT);
+  progressBar.SetAnchorPoint(ParentOrigin::TOP_LEFT);
+  progressBar.SetSize( Vector2( Stage::GetCurrent().GetSize().x, 20.0f ) );
+  progressBar.SetPosition( 0.0f, 0.0f );
+
+  Stage::GetCurrent().Add(progressBar);
+  application.SendNotification();
+  application.Render();
+
+  float val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+  DALI_TEST_EQUALS(val, 0.0f, TEST_LOCATION);
+
+  // test to download a file of 100k in chunks
+  float lowerBound = 0, upperBound = 100, progressValue = 0, chunkValue = 0;
+
+  while( chunkValue <= upperBound )
+  {
+    progressValue = (chunkValue - lowerBound ) / ( upperBound - lowerBound );
+    progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, progressValue);
+    val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+    DALI_TEST_EQUALS(val, progressValue, TEST_LOCATION);
+    chunkValue = chunkValue + 10;
+  }
+
+  // test to download a file of 1000k in chunks
+  lowerBound = 0, upperBound = 1000, progressValue = 0, chunkValue = 0;
+
+  while( chunkValue <= upperBound )
+  {
+    progressValue = (chunkValue - lowerBound ) / ( upperBound - lowerBound );
+    progressBar.SetProperty(ProgressBar::Property::PROGRESS_VALUE, progressValue);
+    val = progressBar.GetProperty<float>(ProgressBar::Property::PROGRESS_VALUE);
+    DALI_TEST_EQUALS(val, progressValue, TEST_LOCATION);
+    chunkValue = chunkValue + 100;
+  }
+
+  END_TEST;
+}
+
index fe4c588..b3c6795 100644 (file)
@@ -1117,7 +1117,8 @@ int UtcDaliVisualFactoryGetSvgVisual(void)
   application.SendNotification();
   application.Render();
 
-  DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+  // renderer is not added to actor until the rasterization is completed.
+  DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
 
   EventThreadCallback* eventTrigger = EventThreadCallback::Get();
   CallbackBase* callback = eventTrigger->GetCallback();
@@ -1125,6 +1126,7 @@ int UtcDaliVisualFactoryGetSvgVisual(void)
   eventTrigger->WaitingForTrigger( 1 );// waiting until the svg image is rasterized.
   CallbackBase::Execute( *callback );
 
+  // renderer is added to actor
   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
 
   // waiting for the resource uploading
index 99c1821..18944e5 100644 (file)
@@ -103,6 +103,7 @@ develapibubbleemitterdir =      $(develapicontrolsdir)/bubble-effect
 develapieffectsviewdir =        $(develapicontrolsdir)/effects-view
 develapimagnifierdir =          $(develapicontrolsdir)/magnifier
 develapipopupdir =              $(develapicontrolsdir)/popup
+develapiprogressbardir =        $(develapicontrolsdir)/progress-bar
 develapishadowviewdir =         $(develapicontrolsdir)/shadow-view
 develapisuperblurviewdir =      $(develapicontrolsdir)/super-blur-view
 develapifocusmanagerdir =       $(develapidir)/focus-manager
@@ -125,6 +126,7 @@ develapifocusmanager_HEADERS =      $(devel_api_focus_manager_header_files)
 develapiimageatlas_HEADERS =        $(devel_api_image_atlas_header_files)
 develapimagnifier_HEADERS =         $(devel_api_magnifier_header_files)
 develapipopup_HEADERS =             $(devel_api_popup_header_files)
+develapiprogressbar_HEADERS =       $(devel_api_progress_bar_header_files)
 develapivisualfactory_HEADERS =     $(devel_api_visual_factory_header_files)
 develapiscripting_HEADERS =         $(devel_api_scripting_header_files)
 develapishadowview_HEADERS =        $(devel_api_shadow_view_header_files)
diff --git a/dali-toolkit/devel-api/controls/progress-bar/progress-bar.cpp b/dali-toolkit/devel-api/controls/progress-bar/progress-bar.cpp
new file mode 100644 (file)
index 0000000..cfc4dfe
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2016 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/devel-api/controls/progress-bar/progress-bar.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/controls/progress-bar/progress-bar-impl.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+ProgressBar::ProgressBar()
+{
+}
+
+ProgressBar::ProgressBar( const ProgressBar& handle )
+: Control( handle )
+{
+}
+
+ProgressBar& ProgressBar::operator=( const ProgressBar& handle )
+{
+  if( &handle != this )
+  {
+    Control::operator=( handle );
+  }
+  return *this;
+}
+
+ProgressBar::ProgressBar(Internal::ProgressBar& implementation)
+: Control(implementation)
+{
+}
+
+ProgressBar::ProgressBar( Dali::Internal::CustomActor* internal )
+: Control( internal )
+{
+  VerifyCustomActorPointer<Internal::ProgressBar>(internal);
+}
+
+ProgressBar ProgressBar::New()
+{
+  return Internal::ProgressBar::New();
+}
+
+ProgressBar::~ProgressBar()
+{
+}
+
+ProgressBar::ValueChangedSignalType& ProgressBar::ValueChangedSignal()
+{
+  return GetImpl( *this ).ValueChangedSignal();
+}
+
+ProgressBar ProgressBar::DownCast( BaseHandle handle )
+{
+  return Control::DownCast<ProgressBar, Internal::ProgressBar>(handle);
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/devel-api/controls/progress-bar/progress-bar.h b/dali-toolkit/devel-api/controls/progress-bar/progress-bar.h
new file mode 100644 (file)
index 0000000..b487029
--- /dev/null
@@ -0,0 +1,178 @@
+#ifndef DALI_TOOLKIT_PROGRESS_BAR_H
+#define DALI_TOOLKIT_PROGRESS_BAR_H
+
+/*
+ * Copyright (c) 2016 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 ProgressBar;
+}
+
+/**
+ * @brief ProgressBar is a control to give the user an indication of the progress of an operation.
+ *
+ * Also progress value percentage is shown as text inside the progress bar.
+ *
+ * Signals
+ * | %Signal Name      | Method                        |
+ * |-------------------|-------------------------------|
+ * | valueChanged      | @ref ValueChangedSignal()     |
+ */
+class DALI_IMPORT_API ProgressBar : public Control
+{
+public:
+
+  // Properties
+
+  /**
+   * @brief The start and end property ranges for this control.
+   */
+  enum PropertyRange
+  {
+    PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, ///< Start Index
+    PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000              ///< Reserve property indices
+  };
+
+  /**
+   * @brief An enumeration of properties belonging to the ProgressBar class.
+   */
+  struct Property
+  {
+    enum
+    {
+
+      /**
+       * @brief The progress value of progress bar, progress runs form 0 to 1.
+       * @details Name "progressValue", type Property::FLOAT.
+       * @note Optional. If not supplied, the default is 0.
+       * @note Value should be between 0 to 1.
+       * @note If Value is set to 0, progress bar will be set to beginning.
+       * @note If Value is set to 1, progress bar will be set to end.
+       * @note Any Value outside of the range is ignored.
+       */
+      PROGRESS_VALUE = PROPERTY_START_INDEX,
+
+      /**
+       * @brief The track Visual value of progress bar, it's a full progress area and it's shown behind PROGRESS_VISUAL.
+       * @details Name "trackVisual", type Property::STRING if it is a url, map otherwise.
+       * @note Optional. If not supplied, the default track visual will be shown.
+       */
+      TRACK_VISUAL,
+
+      /**
+       * @brief The progress Visual value of progress bar, size of the progress visual is changed based on PROGRESS_VALUE.
+       * @details Name "progressVisual", type Property::STRING if it is a url, map otherwise.
+       * @note Optional. If not supplied, the default progress visual will be shown.
+       */
+      PROGRESS_VISUAL,
+    };
+  };
+
+public:
+
+  /**
+   * @brief Creates the ProgressBar control.
+   * @return A handle to the ProgressBar control
+   */
+  static ProgressBar New();
+
+  /**
+   * @brief Creates an empty ProgressBar handle.
+   */
+  ProgressBar();
+
+  /**
+   * @brief Copy constructor.
+   *
+   * Creates another handle that points to the same real object.
+   */
+  ProgressBar( const ProgressBar& handle );
+
+  /**
+   * @brief Assignment operator.
+   *
+   * Changes this handle to point to another real object.
+   */
+  ProgressBar& operator=( const ProgressBar& handle );
+
+  /**
+   * @brief Destructor.
+   *
+   * This is non-virtual since derived Handle types must not contain data or virtual methods.
+   */
+  ~ProgressBar();
+
+  /**
+   * @brief Downcast an Object handle to ProgressBar.
+   *
+   * If handle points to a ProgressBar the
+   * downcast produces valid handle. If not the returned handle is left uninitialized.
+   * @param[in] handle Handle to an object
+   * @return handle to a ProgressBar or an uninitialized handle
+   */
+  static ProgressBar DownCast( BaseHandle handle );
+
+public:  // Signals
+
+  /**
+   * @brief Value changed signal type.
+   */
+  typedef Signal< void ( ProgressBar, float ) > ValueChangedSignalType;
+
+  /**
+   * @brief Signal emitted when the ProgressBar value changes.
+   *
+   * A callback of the following type may be connected:
+   * @code
+   *   void YourCallbackName( ProgressBar progressBar, float value );
+   * @endcode
+   * @return The signal to connect to
+   */
+  ValueChangedSignalType& ValueChangedSignal();
+
+public: // Not intended for application developers
+
+  /// @cond internal
+  /**
+   * @brief Creates a handle using the Toolkit::Internal implementation.
+   * @param[in]  implementation  The Control implementation
+   */
+  DALI_INTERNAL ProgressBar(Internal::ProgressBar& implementation);
+
+  /**
+   * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
+   * @param[in]  internal  A pointer to the internal CustomActor
+   */
+  explicit DALI_INTERNAL ProgressBar( Dali::Internal::CustomActor* internal );
+  /// @endcond
+};
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_PROGRESS_BAR_H
index 0dca497..e4abc92 100755 (executable)
@@ -10,6 +10,7 @@ devel_api_src_files = \
   $(devel_api_src_dir)/controls/magnifier/magnifier.cpp \
   $(devel_api_src_dir)/controls/popup/confirmation-popup.cpp \
   $(devel_api_src_dir)/controls/popup/popup.cpp \
+  $(devel_api_src_dir)/controls/progress-bar/progress-bar.cpp \
   $(devel_api_src_dir)/controls/shadow-view/shadow-view.cpp \
   $(devel_api_src_dir)/controls/super-blur-view/super-blur-view.cpp \
   $(devel_api_src_dir)/controls/text-controls/text-selection-popup.cpp \
@@ -51,6 +52,9 @@ devel_api_popup_header_files = \
   $(devel_api_src_dir)/controls/popup/confirmation-popup.h \
   $(devel_api_src_dir)/controls/popup/popup.h
 
+devel_api_progress_bar_header_files = \
+  $(devel_api_src_dir)/controls/progress-bar/progress-bar.h
+
 devel_api_visual_factory_header_files = \
   $(devel_api_src_dir)/visual-factory/visual-factory.h \
   $(devel_api_src_dir)/visual-factory/visual-base.h
index 40864e5..74ca640 100644 (file)
@@ -116,7 +116,7 @@ public:
   float GetDepthIndex() const;
 
   /**
-   * @brief Visual needs to know when when the control is put on to the stage to add the renderer.
+   * @brief Visual needs to know when the control is put on to the stage to add the renderer.
    *
    * This function should be called when the control is put on to the stage.
    *
@@ -126,7 +126,7 @@ public:
   void SetOnStage( Actor& actor );
 
   /**
-   * @brief Visual needs to know when when the control is removed from the stage to remove the renderer.
+   * @brief Visual needs to know when the control is removed from the stage to remove the renderer.
    *
    * This function should be called when the control is removed from the stage
    *
index 53ccf41..9bf32ef 100644 (file)
@@ -576,7 +576,6 @@ void Button::SetColor( const Vector4& color, Button::PaintState selectedState )
       visual = visualFactory.CreateVisual( map );
 
       RegisterVisual( visualIndex, placementActor, visual );
-      visual.SetOnStage( placementActor );
 
       SetupContent( *contentActor, placementActor ); //
       contentActor->SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
index 7962e2e..251e317 100644 (file)
@@ -82,7 +82,8 @@ void ImageView::SetImage( Image image )
     mImage = image;
 
     Actor self( Self() );
-    InitializeVisual( self, mVisual, image );
+    mVisual =  Toolkit::VisualFactory::Get().CreateVisual( image );
+    RegisterVisual( Toolkit::ImageView::Property::IMAGE, self, mVisual  );
     mImageSize = image ? ImageDimensions( image.GetWidth(), image.GetHeight() ) : ImageDimensions( 0, 0 );
 
     RelayoutRequest();
@@ -96,7 +97,8 @@ void ImageView::SetImage( Property::Map map )
   mPropertyMap = map;
 
   Actor self( Self() );
-  InitializeVisual( self, mVisual, mPropertyMap );
+  mVisual =  Toolkit::VisualFactory::Get().CreateVisual( mPropertyMap );
+  RegisterVisual( Toolkit::ImageView::Property::IMAGE, self, mVisual  );
 
   Property::Value* widthValue = mPropertyMap.Find( "width" );
   if( widthValue )
@@ -138,7 +140,8 @@ void ImageView::SetImage( const std::string& url, ImageDimensions size )
     }
 
     Actor self( Self() );
-    InitializeVisual( self, mVisual, url, size );
+    mVisual =  Toolkit::VisualFactory::Get().CreateVisual( url, size );
+    RegisterVisual( Toolkit::ImageView::Property::IMAGE, self, mVisual  );
 
     mVisual.SetSize( mSizeSet );
 
@@ -231,28 +234,6 @@ float ImageView::GetWidthForHeight( float height )
 // Private methods
 //
 
-void ImageView::OnStageConnection( int depth )
-{
-  Control::OnStageConnection( depth );
-
-  if( mVisual )
-  {
-    CustomActor self = Self();
-    mVisual.SetOnStage( self );
-  }
-}
-
-void ImageView::OnStageDisconnection()
-{
-  if( mVisual )
-  {
-    CustomActor self = Self();
-    mVisual.SetOffStage( self );
-  }
-
-  Control::OnStageDisconnection();
-}
-
 void ImageView::OnSizeSet( const Vector3& targetSize )
 {
   Control::OnSizeSet( targetSize );
index 669a84f..f4f38b6 100644 (file)
@@ -123,16 +123,6 @@ public:
 private: // From Control
 
   /**
-   * @copydoc Toolkit::Control::OnStageConnect()
-   */
-  virtual void OnStageConnection( int depth );
-
-  /**
-   * @copydoc Toolkit::Control::OnStageDisconnection()
-   */
-  virtual void OnStageDisconnection();
-
-  /**
    * @copydoc Toolkit::Control::OnSizeSet()
    */
   virtual void OnSizeSet( const Vector3& targetSize );
index 38e7d3e..d451976 100644 (file)
@@ -536,6 +536,7 @@ void Model3dView::CreateGeometry()
     {
       mRenderer.SetGeometry( mMesh );
       mRenderer.SetProperty( Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::ON );
+      mRenderer.SetProperty( Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::ON );
     }
   }
 }
diff --git a/dali-toolkit/internal/controls/progress-bar/progress-bar-impl.cpp b/dali-toolkit/internal/controls/progress-bar/progress-bar-impl.cpp
new file mode 100755 (executable)
index 0000000..338cef7
--- /dev/null
@@ -0,0 +1,467 @@
+/*
+ * Copyright (c) 2016 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/internal/controls/progress-bar/progress-bar-impl.h>
+
+// EXTERNAL INCLUDES
+#include <cstring> // for strcmp
+#include <sstream>
+#include <algorithm>
+#include <dali/public-api/object/type-registry-helper.h>
+#include <dali/public-api/size-negotiation/relayout-container.h>
+#include <dali/public-api/math/math-utils.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+namespace // Unnamed namespace
+{
+
+BaseHandle Create()
+{
+  return Dali::Toolkit::ProgressBar::New();
+}
+
+// Setup properties, signals and actions using the type-registry.
+DALI_TYPE_REGISTRATION_BEGIN( Toolkit::ProgressBar, Toolkit::Control, Create )
+
+DALI_PROPERTY_REGISTRATION( Toolkit, ProgressBar, "progressValue",          FLOAT,    PROGRESS_VALUE         )
+DALI_PROPERTY_REGISTRATION( Toolkit, ProgressBar, "trackVisual",            MAP,      TRACK_VISUAL           )
+DALI_PROPERTY_REGISTRATION( Toolkit, ProgressBar, "progressVisual",         MAP,      PROGRESS_VISUAL        )
+DALI_SIGNAL_REGISTRATION(   Toolkit, ProgressBar, "valueChanged",                     SIGNAL_VALUE_CHANGED   )
+
+DALI_TYPE_REGISTRATION_END()
+
+const char* SKINNED_TRACK_VISUAL = DALI_IMAGE_DIR "slider-skin.9.png";
+const char* SKINNED_PROGRESS_VISUAL = DALI_IMAGE_DIR "slider-skin-progress.9.png";
+
+float DEFAULT_VALUE = 0.0f;
+float DEFAULT_LOWER_BOUND = 0.0f;
+float DEFAULT_UPPER_BOUND = 1.0f;
+float DEFAULT_PADDING = 24.0f;
+
+} // Unnamed namespace
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// ProgressBar
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+Dali::Toolkit::ProgressBar ProgressBar::New()
+{
+  // Create the implementation
+  ProgressBarPtr progressBar( new ProgressBar() );
+
+  // Pass ownership to CustomActor via derived handle
+  Dali::Toolkit::ProgressBar handle( *progressBar );
+
+  // Second-phase init of the implementation
+  // This can only be done after the CustomActor connection has been made...
+  progressBar->Initialize();
+
+  return handle;
+}
+
+ProgressBar::ProgressBar()
+: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
+  mTrackVisual(""),
+  mProgressVisual(""),
+  mTrackMap(),
+  mTrackVisualSize(),
+  mProgressVisualSize(),
+  mValue( DEFAULT_VALUE )
+{
+}
+
+ProgressBar::~ProgressBar()
+{
+}
+
+void ProgressBar::OnInitialize()
+{
+  // Setup
+  CreateChildren();
+
+  // Properties
+  SetTrackVisual( SKINNED_TRACK_VISUAL );
+  SetProgressVisual( SKINNED_PROGRESS_VISUAL );
+
+  DisplayValue( mValue, false );       // Run this last to display the correct value
+}
+
+void ProgressBar::OnRelayout( const Vector2& size, RelayoutContainer& container )
+{
+  Vector2 trackSize( size );
+  trackSize.width = std::max( 0.0f, size.width - DEFAULT_PADDING ); // Ensure we don't go negative
+
+  // Track
+  if( mTrack )
+  {
+    container.Add( mTrack, trackSize );
+
+    // mValueTextLabel will have its relayout method called automatically as it's a child of mTrack,
+    // which is added to the container
+  }
+
+  // Progress bar
+  if( mProgress )
+  {
+    mDomain = CalcDomain( trackSize );
+
+    Vector2 progressSize( trackSize );
+
+    // If no progress, then we do not want a n-patch image shown incorrectly
+    progressSize.width = std::max( mProgressVisualSize.width, mDomain.from.x + mValue * ( mDomain.to.x - mDomain.from.x ) );
+    progressSize.width = std::min( progressSize.width, trackSize.width ); // We should not exceed given size
+
+    container.Add( mProgress, progressSize );
+  }
+}
+
+Vector3 ProgressBar::GetNaturalSize()
+{
+  // Return the maximum width/height combinations of our visuals
+
+  Vector3 naturalSize;
+  naturalSize.width = std::max( mTrackVisualSize.width, mProgressVisualSize.width );
+  naturalSize.height = std::max( mTrackVisualSize.height, mProgressVisualSize.height );
+  return naturalSize;
+}
+
+ProgressBar::Domain ProgressBar::CalcDomain( const Vector2& currentSize )
+{
+   return Domain( Vector2( 0.0f, 0.0f ), currentSize );
+}
+
+void ProgressBar::DisplayValue( float value, bool raiseSignals )
+{
+  // Signals
+  if( raiseSignals )
+  {
+    Toolkit::ProgressBar self = Toolkit::ProgressBar::DownCast( Self() );
+    mValueChangedSignal.Emit( self, value );
+  }
+
+  // Change the value of the text label
+  if( mValueTextLabel )
+  {
+    std::stringstream ss;
+    ss.precision( 0 );
+    ss << std::fixed << ( value * 100 ) << "%";
+
+    std::string label = mValueTextLabel.GetProperty<std::string>( Toolkit::TextLabel::Property::TEXT );
+    if( label.compare(ss.str()) )
+    {
+      mValueTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, ss.str() );
+    }
+  }
+}
+
+Toolkit::ImageView ProgressBar::CreateTrack()
+{
+  Toolkit::ImageView track = Toolkit::ImageView::New();
+  track.SetParentOrigin( ParentOrigin::CENTER );
+  track.SetAnchorPoint( AnchorPoint::CENTER );
+  track.SetResizePolicy(ResizePolicy::USE_ASSIGNED_SIZE, Dimension::ALL_DIMENSIONS );
+
+  return track;
+}
+
+void ProgressBar::SetTrackVisual( const std::string& filename )
+{
+  if( mTrack && filename.size() > 0 )
+  {
+    mTrack.SetImage( filename );
+    mTrackVisual = filename;
+    mTrackVisualSize = Vector2::ZERO;
+    RelayoutRequest();
+  }
+}
+
+void ProgressBar::SetTrackVisual( Property::Map map )
+{
+  bool relayoutRequired = false;
+
+  Property::Value* imageValue = map.Find( "url" );
+  if( imageValue )
+  {
+    mTrackVisual.clear();
+    std::string filename;
+    if( imageValue->Get( filename ) )
+    {
+      if( mTrack && ( filename.size() > 0 ) )
+      {
+        mTrack.SetImage( filename );
+        mTrackMap = map;
+        relayoutRequired = true;
+      }
+    }
+  }
+
+  Property::Value* sizeValue = map.Find( "size" );
+  if( sizeValue )
+  {
+    Vector2 size;
+    if( sizeValue->Get( size ) )
+    {
+      mTrackVisualSize = size;
+      relayoutRequired = true;
+    }
+  }
+
+  // Visual and/or visual size changed so we need to relayout
+  if( relayoutRequired )
+  {
+    RelayoutRequest();
+  }
+}
+
+std::string ProgressBar::GetTrackVisual()
+{
+  return mTrackVisual;
+}
+
+Toolkit::ImageView ProgressBar::CreateProgress()
+{
+  Toolkit::ImageView progress = Toolkit::ImageView::New();
+  progress.SetParentOrigin( ParentOrigin::CENTER_LEFT );
+  progress.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
+  progress.SetResizePolicy(ResizePolicy::USE_ASSIGNED_SIZE, Dimension::ALL_DIMENSIONS );
+
+  return progress;
+}
+
+void ProgressBar::SetProgressVisual( const std::string& filename )
+{
+  if( mProgress && ( filename.size() > 0 ) )
+  {
+    mProgress.SetImage( filename );
+    mProgressVisual = filename;
+    mProgressVisualSize = Vector2::ZERO;
+    RelayoutRequest();
+  }
+}
+
+void ProgressBar::SetProgressVisual( Property::Map map )
+{
+  bool relayoutRequired = false;
+
+  Property::Value* imageValue = map.Find( "url" );
+  if( imageValue )
+  {
+    mProgressVisual.clear();
+    std::string filename;
+    if( imageValue->Get( filename ) )
+    {
+      if( mProgress && ( filename.size() > 0 ) )
+      {
+        mProgress.SetImage( filename );
+        mProgressMap = map;
+        relayoutRequired = true;
+      }
+    }
+  }
+
+  Property::Value* sizeValue = map.Find( "size" );
+  if( sizeValue )
+  {
+    Vector2 size;
+    if( sizeValue->Get( size ) )
+    {
+      mProgressVisualSize = size;
+      relayoutRequired = true;
+    }
+  }
+
+  // Visual and/or visual size changed so we need to relayout
+  if( relayoutRequired )
+  {
+    RelayoutRequest();
+  }
+}
+
+std::string ProgressBar::GetProgressVisual()
+{
+  return mProgressVisual;
+}
+
+Toolkit::ProgressBar::ValueChangedSignalType& ProgressBar::ValueChangedSignal()
+{
+  return mValueChangedSignal;
+}
+
+void ProgressBar::CreateChildren()
+{
+  Actor self = Self();
+
+  // Track
+  mTrack = CreateTrack();
+  self.Add( mTrack ); // Needs to be a direct child as we want to manipulate its size
+
+  // Progress bar
+  mProgress = CreateProgress();
+  self.Add( mProgress ); // Needs to be a direct child as we want to manipulate its size
+
+  // Value Text
+  mValueTextLabel = Toolkit::TextLabel::New();
+  mValueTextLabel.SetName( "ProgressBarValueTextLabel" );
+  mValueTextLabel.SetStyleName( "ProgressBarValueTextLabel" );
+  mValueTextLabel.SetParentOrigin( ParentOrigin::CENTER );
+  mValueTextLabel.SetAnchorPoint( AnchorPoint::CENTER );
+  mValueTextLabel.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
+  mValueTextLabel.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
+  mTrack.Add( mValueTextLabel ); // Add to mTrack and let it automatically set its size
+}
+
+void ProgressBar::SetProgressValue( float value )
+{
+  // update the progress bar value (taking float precision errors into account)
+  if( ( mValue != value ) &&
+      ( ( value >= DEFAULT_LOWER_BOUND ) || ( Equals( value, DEFAULT_LOWER_BOUND ) ) ) &&
+      ( ( value <= DEFAULT_UPPER_BOUND ) || ( Equals( value, DEFAULT_UPPER_BOUND ) ) ) )
+  {
+    mValue = Clamp( value, DEFAULT_LOWER_BOUND, DEFAULT_UPPER_BOUND );
+    DisplayValue( mValue, true );
+    RelayoutRequest();
+  }
+}
+
+float ProgressBar::GetProgressValue() const
+{
+  return mValue;
+}
+
+// Static class method to support script connecting signals
+bool ProgressBar::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+{
+  Dali::BaseHandle handle( object );
+
+  bool connected = true;
+  Toolkit::ProgressBar ProgressBar = Toolkit::ProgressBar::DownCast( handle );
+
+  if( 0 == strcmp( signalName.c_str(), SIGNAL_VALUE_CHANGED ) )
+  {
+    ProgressBar.ValueChangedSignal().Connect( tracker, functor );
+  }
+  else
+  {
+    // signalName does not match any signal
+    connected = false;
+  }
+
+  return connected;
+}
+
+void ProgressBar::SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )
+{
+  Toolkit::ProgressBar progressBar = Toolkit::ProgressBar::DownCast( Dali::BaseHandle( object ) );
+
+  if ( progressBar )
+  {
+    ProgressBar& progressBarImpl( GetImpl( progressBar ) );
+
+    switch ( propertyIndex )
+    {
+      case Toolkit::ProgressBar::Property::PROGRESS_VALUE:
+      {
+        progressBarImpl.SetProgressValue( value.Get< float >() );
+        break;
+      }
+
+      case Toolkit::ProgressBar::Property::TRACK_VISUAL:
+      {
+        Property::Map map;
+        if( value.Get( map ) )
+        {
+          progressBarImpl.SetTrackVisual( map );
+        }
+        break;
+      }
+
+      case Toolkit::ProgressBar::Property::PROGRESS_VISUAL:
+      {
+        Property::Map map;
+        if( value.Get( map ) )
+        {
+          progressBarImpl.SetProgressVisual( map );
+        }
+        break;
+      }
+    }
+  }
+}
+
+Property::Value ProgressBar::GetProperty( BaseObject* object, Property::Index propertyIndex )
+{
+  Property::Value value;
+
+  Toolkit::ProgressBar progressBar = Toolkit::ProgressBar::DownCast( Dali::BaseHandle( object ) );
+
+  if ( progressBar )
+  {
+    ProgressBar& progressBarImpl( GetImpl( progressBar ) );
+
+    switch ( propertyIndex )
+    {
+      case Toolkit::ProgressBar::Property::PROGRESS_VALUE:
+      {
+        value = progressBarImpl.GetProgressValue();
+        break;
+      }
+
+      case Toolkit::ProgressBar::Property::TRACK_VISUAL:
+      {
+        if( !progressBarImpl.mTrackVisual.empty() )
+        {
+          value = progressBarImpl.GetTrackVisual();
+        }
+        else if( !progressBarImpl.mTrackMap.Empty() )
+        {
+          value = progressBarImpl.mTrackMap;
+        }
+        break;
+      }
+
+      case Toolkit::ProgressBar::Property::PROGRESS_VISUAL:
+      {
+        if( !progressBarImpl.mProgressVisual.empty() )
+        {
+          value = progressBarImpl.GetProgressVisual();
+        }
+        else if( !progressBarImpl.mProgressMap.Empty() )
+        {
+          value = progressBarImpl.mProgressMap;
+        }
+        break;
+      }
+    }
+  }
+
+  return value;
+}
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/internal/controls/progress-bar/progress-bar-impl.h b/dali-toolkit/internal/controls/progress-bar/progress-bar-impl.h
new file mode 100755 (executable)
index 0000000..f5f7e91
--- /dev/null
@@ -0,0 +1,294 @@
+#ifndef DALI_TOOLKIT_INTERNAL_PROGRESS_BAR_H
+#define DALI_TOOLKIT_INTERNAL_PROGRESS_BAR_H
+
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/property-map.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/control-impl.h>
+#include <dali-toolkit/devel-api/controls/progress-bar/progress-bar.h>
+#include <dali-toolkit/public-api/controls/image-view/image-view.h>
+#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+class ProgressBar;
+
+typedef Dali::IntrusivePtr< ProgressBar > ProgressBarPtr;
+
+/**
+ * @copydoc Toolkit::ProgressBar
+ */
+class ProgressBar : public Control
+{
+public:
+
+  /**
+   * Create a new ProgressBar.
+   *
+   * @return A public handle to the newly allocated ProgressBar.
+   */
+  static Dali::Toolkit::ProgressBar New();
+
+public:
+
+  // Properties
+
+  /**
+   * Set the value of the ProgressBar
+   *
+   * @param[in] value The value to set. Will be clamped to [lowerBound .. upperBound]
+   */
+
+  void SetProgressValue( float value );
+
+  /**
+   * Get the value of the ProgressBar
+   *
+   * @return The current value of the ProgressBar
+   */
+  float GetProgressValue() const;
+
+public:
+  //Signals
+
+  /**
+   * @copydoc Toolkit::ProgressBar::ValueChangedSignal()
+   */
+  Toolkit::ProgressBar::ValueChangedSignalType& ValueChangedSignal();
+
+  /**
+   * Connects a callback function with the object's signals.
+   * @param[in] object The object providing the signal.
+   * @param[in] tracker Used to disconnect the signal.
+   * @param[in] signalName The signal to connect to.
+   * @param[in] functor A newly allocated FunctorDelegate.
+   * @return True if the signal was connected.
+   * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
+   */
+  static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName,
+                               FunctorDelegate* functor );
+
+  // 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 );
+
+protected:
+
+  /**
+   * Construct a new ProgressBar.
+   */
+  ProgressBar();
+
+  /**
+   * A reference counted object may only be deleted by calling Unreference()
+   */
+  virtual ~ProgressBar();
+
+  /**
+   * @copydoc CustomActorImpl::OnRelayout()
+   */
+  virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
+
+  /**
+   * @copydoc CustomActorImpl::GetNaturalSize()
+   */
+  virtual Vector3 GetNaturalSize();
+
+private:
+
+  /**
+   * Domain is a from/to pair
+   */
+  struct Domain
+  {
+    Vector2 from;
+    Vector2 to;
+
+    Domain()
+    {
+    }
+    Domain( Vector2 fromVal, Vector2 toVal )
+        : from( fromVal ), to( toVal )
+    {
+    }
+  };
+
+private:
+
+  /**
+   * @copydoc Toolkit::Control::OnInitialize()
+   */
+  virtual void OnInitialize();
+
+  /**
+   * Get the range of the valid values the ProgressBar handle can move between
+   *
+   * @param[in] currentSize The current size of the ProgressBar
+   * @return The range as a domain pair
+   */
+  Domain CalcDomain( const Vector2& currentSize );
+
+  /**
+   * Create the track for the ProgressBar
+   *
+   * @return The track actor
+   */
+  Toolkit::ImageView CreateTrack();
+
+  /**
+   * Create the progress track for the ProgressBar
+   *
+   * @return The track actor
+   */
+  Toolkit::ImageView CreateProgress();
+
+  /**
+   * Create all the children
+   */
+  void CreateChildren();
+
+  /**
+   * Set value choosing whether to fire signals or not
+   *
+   * @paramp[in] value The value to set
+   * @param[in] raiseSignals Configure signals to be raised or not.
+   */
+  void DisplayValue( float value, bool raiseSignals );
+
+  /**
+   * Create the image for the track
+   *
+   * @param[in] filename The track image
+   */
+  void SetTrackVisual( const std::string& filename );
+
+  /**
+   * @brief Set the track visual from an Dali::Property::Map
+   *
+   * @param[in] map The Dali::Property::Map to use for to display
+   */
+  void SetTrackVisual( Dali::Property::Map map );
+
+  /**
+   * @brief Return the track image.
+   *
+   * @return The track image.
+   */
+  std::string GetTrackVisual();
+
+  /**
+   * Create the image for the progress bar
+   *
+   * @param[in] filename The progress bar image
+   */
+  void SetProgressVisual( const std::string& filename );
+
+  /**
+   * @brief Set the progress visual from an Dali::Property::Map
+   *
+   * @param[in] map The Dali::Property::Map to use for to display
+   */
+  void SetProgressVisual( Dali::Property::Map map );
+
+  /**
+   * @brief Return the progress bar image.
+   *
+   * @return The progress bar image if it exists.
+   */
+  std::string GetProgressVisual();
+
+private:
+
+  // Undefined
+  ProgressBar( const ProgressBar& );
+
+  // Undefined
+  ProgressBar& operator=( const ProgressBar& rhs );
+
+private:
+
+  Domain mDomain;                           ///< Current domain of the handle
+
+  Toolkit::ImageView mTrack;                ///< Track image
+  Toolkit::ImageView mProgress;             ///< Progress bar
+  Toolkit::TextLabel mValueTextLabel;       ///< Text value to show progress percentage
+  Toolkit::ProgressBar::ValueChangedSignalType mValueChangedSignal;       ///< Signal emitted when the value is changed
+
+  std::string mTrackVisual;           ///< Image for track image
+  std::string mProgressVisual;        ///< Image for progress bar image
+
+  Property::Map mTrackMap;         ///< the Property::Map if the image came from a Property::Map, empty otherwise
+  Property::Map mProgressMap;      ///< the Property::Map if the image came from a Property::Map, empty otherwise
+
+  Vector2 mTrackVisualSize;      ///< Size of the track image used
+  Vector2 mProgressVisualSize;   ///< Size of progress image used
+
+  float mValue;             ///< Current value of ProgressBar
+};
+
+} // namespace Internal
+
+// Helpers for public-api forwarding methods
+
+inline Toolkit::Internal::ProgressBar& GetImpl( Toolkit::ProgressBar& pub )
+{
+  DALI_ASSERT_ALWAYS( pub );
+
+  Dali::RefObject& handle = pub.GetImplementation();
+
+  return static_cast< Toolkit::Internal::ProgressBar& >( handle );
+}
+
+inline const Toolkit::Internal::ProgressBar& GetImpl( const Toolkit::ProgressBar& pub )
+{
+  DALI_ASSERT_ALWAYS( pub );
+
+  const Dali::RefObject& handle = pub.GetImplementation();
+
+  return static_cast< const Toolkit::Internal::ProgressBar& >( handle );
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_INTERNAL_PROGRESS_BAR_H
index 2248668..f3670fd 100644 (file)
@@ -386,6 +386,10 @@ void TextSelectionPopup::OnInitialize()
   Actor self = Self();
   self.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
   self.SetProperty( Actor::Property::COLOR_ALPHA, 0.0f );
+
+  // The Popup Control background is a nine-patch image. We clip against this so the
+  // contents are correctly clipped against the edges of the nine-patch.
+  self.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
 }
 
 void TextSelectionPopup::OnStageConnection( int depth )
index b87dab2..b217be5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
@@ -163,10 +163,10 @@ void TextSelectionToolbar::OnStageConnection( int depth )
 void TextSelectionToolbar::SetPopupMaxSize( const Size& maxSize )
 {
   mMaxSize = maxSize;
-  if (mScrollView && mStencilLayer )
+  if (mScrollView && mToolbarLayer )
   {
     mScrollView.SetMaximumSize( mMaxSize );
-    mStencilLayer.SetMaximumSize( mMaxSize );
+    mToolbarLayer.SetMaximumSize( mMaxSize );
   }
 }
 
@@ -198,23 +198,18 @@ void TextSelectionToolbar::SetUpScrollView()
 void TextSelectionToolbar::SetUp()
 {
   Actor self = Self();
-  self.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
 
-  // Create Layer and Stencil.  Layer enable's clipping when content exceed maximum defined width.
-  mStencilLayer = Layer::New();
-  mStencilLayer.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
-  mStencilLayer.SetParentOrigin( ParentOrigin::CENTER );
+  self.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
 
-  BufferImage stencilImage = BufferImage::WHITE(); // ImageView needs an Image or does nothing
-  Toolkit::ImageView stencil = Toolkit::ImageView::New(stencilImage);
-  stencil.SetDrawMode( DrawMode::STENCIL );
-  stencil.SetVisible( true );
-  stencil.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
-  stencil.SetParentOrigin( ParentOrigin::CENTER );
+  // Create Layer to house the toolbar.
+  mToolbarLayer = Layer::New();
+  mToolbarLayer.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
+  mToolbarLayer.SetAnchorPoint( AnchorPoint::CENTER );
+  mToolbarLayer.SetParentOrigin( ParentOrigin::CENTER );
 
-  if ( !mScrollView )
+  if( !mScrollView )
   {
-    mScrollView  = Toolkit::ScrollView::New();
+    mScrollView = Toolkit::ScrollView::New();
   }
   SetUpScrollView();
 
@@ -224,10 +219,10 @@ void TextSelectionToolbar::SetUp()
   mTableOfButtons.SetParentOrigin( ParentOrigin::CENTER_LEFT );
   mTableOfButtons.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
 
-  mStencilLayer.Add( stencil );
-  mStencilLayer.Add( mScrollView );
   mScrollView.Add( mTableOfButtons );
-  self.Add( mStencilLayer );
+  mToolbarLayer.Add( mScrollView );
+
+  self.Add( mToolbarLayer );
 }
 
 void TextSelectionToolbar::OnScrollStarted( const Vector2& position )
@@ -265,7 +260,7 @@ void TextSelectionToolbar::ResizeDividers( Size& size )
 
 void TextSelectionToolbar::RaiseAbove( Layer target )
 {
-  mStencilLayer.RaiseAbove( target );
+  mToolbarLayer.RaiseAbove( target );
 }
 
 void TextSelectionToolbar::ConfigureScrollview( const Property::Map& properties )
index 7997bfa..46e633b 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_TOOLBAR_H__
-#define __DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_TOOLBAR_H__
+#ifndef DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_TOOLBAR_H
+#define DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_TOOLBAR_H
 
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
@@ -160,7 +160,7 @@ private:
 
 private: // Data
 
-  Layer mStencilLayer;                                ///< The stencil layer
+  Layer mToolbarLayer;                                ///< The layer used to house the toolbar.
   Toolkit::TableView mTableOfButtons;                 ///< Actor which holds all the buttons, sensitivity can be set on buttons via this actor
   Toolkit::ScrollView mScrollView;                    ///< Provides scrolling of Toolbar when content does not fit.
   RulerPtr mRulerX;                                   ///< Ruler to clamp horizontal scrolling. Updates on Relayout
@@ -196,4 +196,4 @@ inline const Toolkit::Internal::TextSelectionToolbar& GetImpl( const Toolkit::Te
 
 } // namespace Dali
 
-#endif // __DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_TOOLBAR_H__
+#endif // DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_TOOLBAR_H
index e644d65..0b13dfb 100644 (file)
@@ -51,6 +51,7 @@ toolkit_src_files = \
    $(toolkit_src_dir)/controls/page-turn-view/page-turn-effect.cpp \
    $(toolkit_src_dir)/controls/page-turn-view/page-turn-landscape-view-impl.cpp \
    $(toolkit_src_dir)/controls/page-turn-view/page-turn-view-impl.cpp \
+   $(toolkit_src_dir)/controls/progress-bar/progress-bar-impl.cpp \
    $(toolkit_src_dir)/controls/scroll-bar/scroll-bar-impl.cpp \
    $(toolkit_src_dir)/controls/scrollable/bouncing-effect-actor.cpp \
    $(toolkit_src_dir)/controls/scrollable/item-view/depth-layout.cpp \
index f5d8053..7f7c7b5 100644 (file)
@@ -147,6 +147,8 @@ void BorderVisual::DoSetOnStage( Actor& actor )
     mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
   }
   mBorderSizeIndex = (mImpl->mRenderer).RegisterProperty( Toolkit::BorderVisual::Property::SIZE, SIZE_NAME, mBorderSize );
+
+  actor.AddRenderer( mImpl->mRenderer );
 }
 
 void BorderVisual::DoCreatePropertyMap( Property::Map& map ) const
index b7ca048..8a44250 100644 (file)
@@ -64,17 +64,17 @@ public:
 protected:
 
   /**
-   * @copydoc Visual::DoInitialize
+   * @copydoc Visual::Base::DoInitialize
    */
   virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
 
   /**
-   * @copydoc Visual::DoSetOnStage
+   * @copydoc Visual::Base::DoSetOnStage
    */
   virtual void DoSetOnStage( Actor& actor );
 
   /**
-   * @copydoc Visual::CreatePropertyMap
+   * @copydoc Visual::Base::CreatePropertyMap
    */
   virtual void DoCreatePropertyMap( Property::Map& map ) const;
 
index 572220b..6406bcc 100644 (file)
@@ -94,6 +94,8 @@ void ColorVisual::SetSize( const Vector2& size )
 void ColorVisual::DoSetOnStage( Actor& actor )
 {
   InitializeRenderer();
+
+  actor.AddRenderer( mImpl->mRenderer );
 }
 
 void ColorVisual::DoCreatePropertyMap( Property::Map& map ) const
index 9367ffa..2805d6a 100644 (file)
@@ -58,24 +58,24 @@ public:
 public:  // from Visual
 
   /**
-   * @copydoc Visual::SetSize
+   * @copydoc Visual::Base::SetSize
    */
   virtual void SetSize( const Vector2& size );
 
   /**
-   * @copydoc Visual::CreatePropertyMap
+   * @copydoc Visual::Base::CreatePropertyMap
    */
   virtual void DoCreatePropertyMap( Property::Map& map ) const;
 
 protected:
 
   /**
-   * @copydoc Visual::DoInitialize
+   * @copydoc Visual::Base::DoInitialize
    */
   virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
 
   /**
-   * @copydoc Visual::DoSetOnStage
+   * @copydoc Visual::Base::DoSetOnStage
    */
   virtual void DoSetOnStage( Actor& actor );
 
index 1588b83..41999cc 100644 (file)
@@ -232,6 +232,8 @@ void GradientVisual::SetSize( const Vector2& size )
 void GradientVisual::DoSetOnStage( Actor& actor )
 {
   InitializeRenderer();
+
+  actor.AddRenderer( mImpl->mRenderer );
 }
 
 void GradientVisual::DoCreatePropertyMap( Property::Map& map ) const
index 9f2cad4..2f5d06c 100644 (file)
@@ -94,23 +94,23 @@ public:
 public:  // from Visual
 
   /**
-   * @copydoc Visual::SetSize
+   * @copydoc Visual::Base::SetSize
    */
   virtual void SetSize( const Vector2& size );
 
   /**
-   * @copydoc Visual::CreatePropertyMap
+   * @copydoc Visual::Base::CreatePropertyMap
    */
   virtual void DoCreatePropertyMap( Property::Map& map ) const;
 
 protected:
   /**
-   * @copydoc Visual::DoInitialize
+   * @copydoc Visual::Base::DoInitialize
    */
   virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
 
   /**
-   * @copydoc Visual::DoSetOnStage
+   * @copydoc Visual::Base::DoSetOnStage
    */
   virtual void DoSetOnStage( Actor& actor );
 
index 30eeeda..1ce668b 100644 (file)
@@ -227,6 +227,8 @@ void BatchImageVisual::DoSetOnStage( Actor& actor )
   }
   // Turn batching on, to send message it must be on stage
   mImpl->mRenderer.SetProperty( Dali::Renderer::Property::BATCHING_ENABLED, true );
+
+  actor.AddRenderer( mImpl->mRenderer );
 }
 
 void BatchImageVisual::DoSetOffStage( Actor& actor )
index 0984326..540f7c2 100644 (file)
@@ -588,6 +588,8 @@ void ImageVisual::DoSetOnStage( Actor& actor )
   {
     mImpl->mRenderer.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, mPixelArea );
   }
+
+  actor.AddRenderer( mImpl->mRenderer );
 }
 
 void ImageVisual::DoSetOffStage( Actor& actor )
index 64b3f4b..2c48913 100644 (file)
@@ -91,28 +91,28 @@ public:
 public:  // from Visual
 
   /**
-   * @copydoc Visual::GetNaturalSize
+   * @copydoc Visual::Base::GetNaturalSize
    */
   virtual void GetNaturalSize( Vector2& naturalSize ) const;
 
   /**
-   * @copydoc Visual::CreatePropertyMap
+   * @copydoc Visual::Base::CreatePropertyMap
    */
   virtual void DoCreatePropertyMap( Property::Map& map ) const;
 
 protected:
   /**
-   * @copydoc Visual::DoInitialize
+   * @copydoc Visual::Base::DoInitialize
    */
   virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
 
   /**
-   * @copydoc Visual::DoSetOnStage
+   * @copydoc Visual::Base::DoSetOnStage
    */
   virtual void DoSetOnStage( Actor& actor );
 
   /**
-   * @copydoc Visual::DoSetOffStage
+   * @copydoc Visual::Base::DoSetOffStage
    */
   virtual void DoSetOffStage( Actor& actor );
 
index 2c56eae..eafe9e8 100644 (file)
@@ -372,6 +372,8 @@ void MeshVisual::SetSize( const Vector2& size )
 void MeshVisual::DoSetOnStage( Actor& actor )
 {
   InitializeRenderer();
+
+  actor.AddRenderer( mImpl->mRenderer );
 }
 
 void MeshVisual::DoCreatePropertyMap( Property::Map& map ) const
@@ -425,6 +427,7 @@ void MeshVisual::InitializeRenderer()
   mImpl->mRenderer = Renderer::New( mGeometry, mShader );
   mImpl->mRenderer.SetTextures( mTextureSet );
   mImpl->mRenderer.SetProperty( Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::ON );
+  mImpl->mRenderer.SetProperty( Renderer::Property::DEPTH_TEST_MODE, DepthTestMode::ON );
 }
 
 void MeshVisual::SupplyEmptyGeometry()
index 67e1fe1..4a2927c 100644 (file)
@@ -70,24 +70,24 @@ public:
 public:  // from Visual
 
   /**
-   * @copydoc Visual::SetSize
+   * @copydoc Visual::Base::SetSize
    */
   virtual void SetSize( const Vector2& size );
 
   /**
-   * @copydoc Visual::CreatePropertyMap
+   * @copydoc Visual::Base::CreatePropertyMap
    */
   virtual void DoCreatePropertyMap( Property::Map& map ) const;
 
 protected:
 
   /**
-   * @copydoc Visual::DoInitialize
+   * @copydoc Visual::Base::DoInitialize
    */
   virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
 
   /**
-   * @copydoc Visual::DoSetOnStage
+   * @copydoc Visual::Base::DoSetOnStage
    */
   virtual void DoSetOnStage( Actor& actor );
 
index 5dc9e04..3bf5728 100644 (file)
@@ -379,6 +379,8 @@ void NPatchVisual::DoSetOnStage( Actor& actor )
   {
     ApplyImageToSampler();
   }
+
+  actor.AddRenderer( mImpl->mRenderer );
 }
 
 void NPatchVisual::DoSetOffStage( Actor& actor )
index 498bcc2..a993303 100644 (file)
@@ -68,29 +68,29 @@ public:
 public:  // from Visual
 
   /**
-   * @copydoc Visual::GetNaturalSize
+   * @copydoc Visual::Base::GetNaturalSize
    */
   virtual void GetNaturalSize( Vector2& naturalSize ) const;
 
   /**
-   * @copydoc Visual::CreatePropertyMap
+   * @copydoc Visual::Base::CreatePropertyMap
    */
   virtual void DoCreatePropertyMap( Property::Map& map ) const;
 
 protected:
 
   /**
-   * @copydoc Visual::DoInitialize
+   * @copydoc Visual::Base::DoInitialize
    */
   virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
 
   /**
-   * @copydoc Visual::DoSetOnStage
+   * @copydoc Visual::Base::DoSetOnStage
    */
   virtual void DoSetOnStage( Actor& actor );
 
   /**
-   * @copydoc Visual::DoSetOffStage
+   * @copydoc Visual::Base::DoSetOffStage
    */
   virtual void DoSetOffStage( Actor& actor );
 
index c85a7a0..6991f32 100644 (file)
@@ -74,7 +74,7 @@ const float   DEFAULT_SCALE_HEIGHT =        3.0; ///< For all conics
 const float   DEFAULT_SCALE_RADIUS =        1.0; ///< For cylinders
 const float   DEFAULT_BEVEL_PERCENTAGE =    0.0; ///< For bevelled cubes
 const float   DEFAULT_BEVEL_SMOOTHNESS =    0.0; ///< For bevelled cubes
-const Vector4 DEFAULT_COLOR =               Vector4( 0.5, 0.5, 0.5, 0.0 ); ///< Grey, for all.
+const Vector4 DEFAULT_COLOR =               Vector4( 0.5, 0.5, 0.5, 1.0 ); ///< Grey, for all.
 
 //Property limits
 const int   MIN_SLICES =           3;   ///< Minimum number of slices for spheres and conics
@@ -96,7 +96,7 @@ const char * const BEVELLED_CUBE_LABEL( "BEVELLED_CUBE" );
 
 //Shader properties
 const char * const OBJECT_MATRIX_UNIFORM_NAME( "uObjectMatrix" );
-const char * const COLOR_UNIFORM_NAME( "uColor" );
+const char * const COLOR_UNIFORM_NAME( "mixColor" );
 const char * const OBJECT_DIMENSIONS_UNIFORM_NAME( "uObjectDimensions" );
 const char * const STAGE_OFFSET_UNIFORM_NAME( "uStageOffset" );
 
@@ -151,10 +151,12 @@ const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
   precision mediump float;\n
   varying   mediump vec3  vIllumination;\n
   uniform   lowp    vec4  uColor;\n
+  uniform   lowp    vec4  mixColor;\n
 
   void main()\n
   {\n
-    gl_FragColor = vec4( vIllumination.rgb * uColor.rgb, uColor.a );\n
+    vec4 baseColor = mixColor * uColor;\n
+    gl_FragColor = vec4( vIllumination.rgb * baseColor.rgb, baseColor.a );\n
   }\n
 );
 
@@ -381,6 +383,8 @@ void PrimitiveVisual::GetNaturalSize( Vector2& naturalSize ) const
 void PrimitiveVisual::DoSetOnStage( Actor& actor )
 {
   InitializeRenderer();
+
+  actor.AddRenderer( mImpl->mRenderer );
 }
 
 void PrimitiveVisual::DoCreatePropertyMap( Property::Map& map ) const
index 45b536b..054e9f0 100644 (file)
@@ -111,29 +111,29 @@ public:
 public:  // from Visual
 
   /**
-   * @copydoc Visual::SetSize
+   * @copydoc Visual::Base::SetSize
    */
   virtual void SetSize( const Vector2& size );
 
   /**
-   * @copydoc Visual::GetNaturalSize
+   * @copydoc Visual::Base::GetNaturalSize
    */
   virtual void GetNaturalSize( Vector2& naturalSize ) const;
 
   /**
-   * @copydoc Visual::CreatePropertyMap
+   * @copydoc Visual::Base::CreatePropertyMap
    */
   virtual void DoCreatePropertyMap( Property::Map& map ) const;
 
 protected:
 
   /**
-   * @copydoc Visual::DoInitialize
+   * @copydoc Visual::Base::DoInitialize
    */
   virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
 
   /**
-   * @copydoc Visual::DoSetOnStage
+   * @copydoc Visual::Base::DoSetOnStage
    */
   virtual void DoSetOnStage( Actor& actor );
 
index 4179d4d..832fd19 100644 (file)
@@ -70,11 +70,6 @@ SvgVisual::~SvgVisual()
   }
 }
 
-bool SvgVisual::IsSvgUrl( const std::string& url )
-{
-  return url.substr( url.find_last_of(".") + 1 ) == "svg";
-}
-
 void SvgVisual::DoInitialize( Actor& actor, const Property::Map& propertyMap )
 {
   Property::Value* imageURLValue = propertyMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME );
@@ -109,6 +104,9 @@ void SvgVisual::DoSetOnStage( Actor& actor )
   {
     AddRasterizationTask( mImpl->mSize );
   }
+
+  // Hold the weak handle of the placement actor and delay the adding of renderer until the svg rasterization is finished.
+  mPlacementActor = actor;
 }
 
 void SvgVisual::DoSetOffStage( Actor& actor )
@@ -117,6 +115,7 @@ void SvgVisual::DoSetOffStage( Actor& actor )
 
   actor.RemoveRenderer( mImpl->mRenderer );
   mImpl->mRenderer.Reset();
+  mPlacementActor.Reset();
 }
 
 void SvgVisual::GetNaturalSize( Vector2& naturalSize ) const
@@ -237,11 +236,19 @@ void SvgVisual::ApplyRasterizedImage( PixelData rasterizedPixelData )
         TextureSetImage( textureSet, 0u, texture );
       }
     }
+
+    // Rasterized pixels are uploaded to texture. If weak handle is holding a placement actor, it is the time to add the renderer to actor.
+    Actor actor = mPlacementActor.GetHandle();
+    if( actor )
+    {
+      actor.AddRenderer( mImpl->mRenderer );
+      // reset the weak handle so that the renderer only get added to actor once
+      mPlacementActor.Reset();
+    }
   }
 }
 
 
-
 } // namespace Internal
 
 } // namespace Toolkit
index d841621..81672e5 100644 (file)
@@ -18,6 +18,9 @@
  *
  */
 
+//EXTERNAL INCLUDES
+#include <dali/devel-api/object/weak-handle.h>
+
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
 
@@ -61,48 +64,40 @@ public:
 public:  // from Visual
 
   /**
-   * @copydoc Visual::GetNaturalSize
+   * @copydoc Visual::Base::GetNaturalSize
    */
   virtual void GetNaturalSize( Vector2& naturalSize ) const;
 
   /**
-   * @copydoc Visual::SetSize
+   * @copydoc Visual::Base::SetSize
    */
   virtual void SetSize( const Vector2& size );
 
   /**
-   * @copydoc Visual::CreatePropertyMap
+   * @copydoc Visual::Base::CreatePropertyMap
    */
   virtual void DoCreatePropertyMap( Property::Map& map ) const;
 
 protected:
 
   /**
-   * @copydoc Visual::DoInitialize
+   * @copydoc Visual::Base::DoInitialize
    */
   virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
 
   /**
-   * @copydoc Visual::DoSetOnStage
+   * @copydoc Visual::Base::DoSetOnStage
    */
   virtual void DoSetOnStage( Actor& actor );
 
   /**
-   * @copydoc Visual::DoSetOffStage
+   * @copydoc Visual::Base::DoSetOffStage
    */
   virtual void DoSetOffStage( Actor& actor );
 
 public:
 
   /**
-   * @brief Helper method to determine whether the url indicate that it is a svg image.
-   *
-   * @param [in] url The URL of the image file.
-   * @return true if it is a svg image
-   */
-  static bool IsSvgUrl( const std::string& url );
-
-  /**
    * @brief Sets the svg image of this visual to the resource at imageUrl
    * The visual will parse the svg image once it is set.
    * And rasterize it into BufferImage synchronously when the associated actor is put on stage, and destroy the BufferImage when it is off stage
@@ -137,6 +132,7 @@ private:
   Vector4              mAtlasRect;
   std::string          mImageUrl;
   NSVGimage*           mParsedImage;
+  WeakHandle<Actor>    mPlacementActor;
 
 };
 
index 58e4d38..8356de5 100644 (file)
@@ -105,12 +105,12 @@ float Visual::Base::GetDepthIndex() const
 
 void Visual::Base::SetOnStage( Actor& actor )
 {
+  // To display the actor correctly, renderer should not be added to actor until all required resources are ready.
+  // Thus the calling of actor.AddRenderer() should happen inside derived class as base class does not know the exact timing.
   DoSetOnStage( actor );
 
   mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, IsPreMultipliedAlphaEnabled());
   mImpl->mRenderer.SetProperty( Renderer::Property::DEPTH_INDEX, mImpl->mDepthIndex );
-  actor.AddRenderer( mImpl->mRenderer );
-
   mImpl->mFlags |= Impl::IS_ON_STAGE;
 }
 
@@ -146,10 +146,6 @@ bool Visual::Base::IsPreMultipliedAlphaEnabled() const
   return mImpl->mFlags & Impl::IS_PREMULTIPLIED_ALPHA;
 }
 
-void Visual::Base::DoSetOnStage( Actor& actor )
-{
-}
-
 void Visual::Base::DoSetOffStage( Actor& actor )
 {
   actor.RemoveRenderer( mImpl->mRenderer );
index 8068dd8..3820bd0 100644 (file)
@@ -170,9 +170,11 @@ protected:
   /**
    * @brief Called by SetOnStage() allowing sub classes to respond to the SetOnStage event
    *
+   * @note The derived class is required to create the renderer, and add it to the actor when all the resources are in place.
+   *
    * @param[in] actor The actor applying this visual.
    */
-  virtual void DoSetOnStage( Actor& actor );
+  virtual void DoSetOnStage( Actor& actor )=0;
 
   /**
    * @brief Called by SetOffStage() allowing sub classes to respond to the SetOffStage event
index e35c98b..bcc9acd 100644 (file)
@@ -40,6 +40,7 @@
 #include <dali-toolkit/internal/visuals/svg/svg-visual.h>
 #include <dali-toolkit/internal/visuals/wireframe/wireframe-visual.h>
 #include <dali-toolkit/internal/visuals/visual-factory-cache.h>
+#include <dali-toolkit/internal/visuals/visual-factory-resolve-url.h>
 #include <dali-toolkit/internal/visuals/visual-string-constants.h>
 
 namespace Dali
@@ -136,28 +137,33 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const Property::Map& property
       std::string imageUrl;
       if( imageURLValue && imageURLValue->Get( imageUrl ) )
       {
-        Property::Value* batchingEnabledValue = propertyMap.Find( Toolkit::ImageVisual::Property::BATCHING_ENABLED, BATCHING_ENABLED );
-        if( batchingEnabledValue  )
-        {
-          bool batchingEnabled( false );
-          batchingEnabledValue->Get( batchingEnabled );
-          if( batchingEnabled )
-          {
-            visualPtr = new BatchImageVisual( *( mFactoryCache.Get() ) );
-            break;
-          }
-        }
-        else if( NinePatchImage::IsNinePatchUrl( imageUrl ) )
+        // first resolve url type to know which visual to create
+        UrlType::Type type = ResolveUrlType( imageUrl );
+        if( UrlType::N_PATCH == type )
         {
           visualPtr = new NPatchVisual( *( mFactoryCache.Get() ) );
         }
-        else if( SvgVisual::IsSvgUrl( imageUrl ) )
+        else if( UrlType::SVG == type )
         {
           visualPtr = new SvgVisual( *( mFactoryCache.Get() ) );
         }
-        else
+        else // Regular image
         {
-          visualPtr = new ImageVisual( *( mFactoryCache.Get() ) );
+          Property::Value* batchingEnabledValue = propertyMap.Find( Toolkit::ImageVisual::Property::BATCHING_ENABLED, BATCHING_ENABLED );
+          if( batchingEnabledValue  )
+          {
+            bool batchingEnabled( false );
+            batchingEnabledValue->Get( batchingEnabled );
+            if( batchingEnabled )
+            {
+              visualPtr = new BatchImageVisual( *( mFactoryCache.Get() ) );
+              break;
+            }
+          }
+          else
+          {
+            visualPtr = new ImageVisual( *( mFactoryCache.Get() ) );
+          }
         }
       }
 
@@ -239,20 +245,22 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const std::string& url, Image
     return Toolkit::Visual::Base( new WireframeVisual( *( mFactoryCache.Get() ) ) );
   }
 
-  if( NinePatchImage::IsNinePatchUrl( url ) )
+  // first resolve url type to know which visual to create
+  UrlType::Type type = ResolveUrlType( url );
+  if( UrlType::N_PATCH == type )
   {
     NPatchVisual* visualPtr = new NPatchVisual( *( mFactoryCache.Get() ) );
     visualPtr->SetImage( url );
 
     return Toolkit::Visual::Base( visualPtr );
   }
-  else if( SvgVisual::IsSvgUrl( url ) )
+  else if( UrlType::SVG == type )
   {
     SvgVisual* visualPtr = new SvgVisual( *( mFactoryCache.Get() ) );
     visualPtr->SetImage( url, size );
     return Toolkit::Visual::Base( visualPtr );
   }
-  else
+  else // Regular image
   {
     ImageVisual* visualPtr = new ImageVisual( *( mFactoryCache.Get() ));
     Actor actor;
diff --git a/dali-toolkit/internal/visuals/visual-factory-resolve-url.h b/dali-toolkit/internal/visuals/visual-factory-resolve-url.h
new file mode 100644 (file)
index 0000000..1d3ffe3
--- /dev/null
@@ -0,0 +1,121 @@
+#ifndef DALI_TOOLKIT_VISUAL_FACTORY_URL_RESOLVE_H
+#define DALI_TOOLKIT_VISUAL_FACTORY_URL_RESOLVE_H
+
+/*
+ * Copyright (c) 2016 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 <ctype.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+namespace UrlType
+{
+  /**
+   * The type of the URL based on the string contents
+   */
+  enum Type
+  {
+    REGULAR_IMAGE,
+    N_PATCH,
+    SVG
+  };
+}
+
+/**
+ * Helper to resolve URL type from the string
+ * @param[in] url to check
+ * @return UrlType
+ */
+inline UrlType::Type ResolveUrlType( const std::string& url )
+{
+  // if only one char in string, can only be regular image
+  const std::size_t count = url.size();
+  if( count > 0 )
+  {
+    // parsing from the end for better chance of early outs
+    enum { SUFFIX, HASH, HASH_DOT } state = SUFFIX;
+    char SVG[ 4 ] = { 'g', 'v', 's', '.' };
+    unsigned int svgScore = 0;
+    int index = count;
+    while( --index >= 0 )
+    {
+      const char currentChar = url[ index ];
+      const std::size_t offsetFromEnd = count - index - 1u;
+      if( ( offsetFromEnd < sizeof(SVG) )&&( tolower( currentChar ) == SVG[ offsetFromEnd ] ) )
+      {
+        // early out if SVG as can't be used in N patch for now
+        if( ++svgScore == sizeof(SVG) )
+        {
+          return UrlType::SVG;
+        }
+      }
+      switch( state )
+      {
+        case SUFFIX:
+        {
+          if( '.' == currentChar )
+          {
+            state = HASH;
+          }
+          break;
+        }
+        case HASH:
+        {
+          if( ( '#' == currentChar ) || ( '9' == currentChar ) )
+          {
+            state = HASH_DOT;
+          }
+          else
+          {
+            // early out, not a valid N/9-patch URL
+            return UrlType::REGULAR_IMAGE;
+          }
+          break;
+        }
+        case HASH_DOT:
+        {
+          if( '.' == currentChar )
+          {
+            return UrlType::N_PATCH;
+          }
+          else
+          {
+            // early out, not a valid N/9-patch URL
+            return UrlType::REGULAR_IMAGE;
+          }
+          break;
+        }
+      }
+    }
+  }
+  // if we got here it is a regular image
+  return UrlType::REGULAR_IMAGE;
+}
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif /* DALI_TOOLKIT_VISUAL_FACTORY_URL_RESOLVE_H */
index 47474a6..4299eb6 100644 (file)
@@ -76,6 +76,8 @@ WireframeVisual::~WireframeVisual()
 void WireframeVisual::DoSetOnStage( Actor& actor )
 {
   InitializeRenderer();
+
+  actor.AddRenderer( mImpl->mRenderer );
 }
 
 void WireframeVisual::DoCreatePropertyMap( Property::Map& map ) const
index b14452a..c0d8682 100644 (file)
@@ -53,12 +53,12 @@ public:
 protected:
 
   /**
-   * @copydoc Visual::DoSetOnStage
+   * @copydoc Visual::Base::DoSetOnStage
    */
   virtual void DoSetOnStage( Actor& actor );
 
   /**
-   * @copydoc Visual::CreatePropertyMap
+   * @copydoc Visual::Base::CreatePropertyMap
    */
   virtual void DoCreatePropertyMap( Property::Map& map ) const;
 
index 23745bb..cc3546c 100644 (file)
@@ -28,6 +28,7 @@
 #include <dali/public-api/object/type-registry-helper.h>
 #include <dali/public-api/rendering/renderer.h>
 #include <dali/public-api/size-negotiation/relayout-container.h>
+#include <dali/devel-api/common/owner-container.h>
 #include <dali/devel-api/scripting/scripting.h>
 #include <dali/integration-api/debug.h>
 
@@ -63,14 +64,16 @@ struct RegisteredVisual
   RegisteredVisual( Property::Index aIndex, Toolkit::Visual::Base &aVisual, Actor &aPlacementActor) : index(aIndex), visual(aVisual), placementActor(aPlacementActor) {}
 };
 
+typedef Dali::OwnerContainer< RegisteredVisual* > RegisteredVisuals;
+
 /**
  *  Finds visual in given array, returning true if found along with the iterator for that visual as a out parameter
  */
-bool FindVisual( Property::Index targetIndex, std::vector<RegisteredVisual>& visuals, std::vector<RegisteredVisual>::iterator& iter )
+bool FindVisual( Property::Index targetIndex, RegisteredVisuals& visuals, RegisteredVisuals::Iterator& iter )
 {
-  for ( iter = visuals.begin(); iter != visuals.end(); iter++ )
+  for ( iter = visuals.Begin(); iter != visuals.End(); iter++ )
   {
-    if ( (*iter).index ==  targetIndex )
+    if ( (*iter)->index ==  targetIndex )
     {
       return true;
     }
@@ -394,7 +397,7 @@ public:
   // Data
 
   Control& mControlImpl;
-  std::vector<RegisteredVisual> mVisuals; // Stores visuals needed by the control, non trivial type so std::vector used.
+  RegisteredVisuals mVisuals; // Stores visuals needed by the control, non trivial type so std::vector used.
   std::string mStyleName;
   Toolkit::Visual::Base mBackgroundVisual;   ///< The visual to render the background
   Vector4 mBackgroundColor;                       ///< The color of the background visual
@@ -475,7 +478,8 @@ void Control::SetBackgroundColor( const Vector4& color )
   Property::Map map;
   map[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::COLOR;
   map[ Toolkit::ColorVisual::Property::MIX_COLOR ] = color;
-  InitializeVisual( self, mImpl->mBackgroundVisual, map );
+  mImpl->mBackgroundVisual = Toolkit::VisualFactory::Get().CreateVisual( map );
+  RegisterVisual( Toolkit::Control::Property::BACKGROUND, self, mImpl->mBackgroundVisual );
   if( mImpl->mBackgroundVisual )
   {
     mImpl->mBackgroundVisual.SetDepthIndex( DepthIndex::BACKGROUND );
@@ -490,7 +494,8 @@ Vector4 Control::GetBackgroundColor() const
 void Control::SetBackground( const Property::Map& map )
 {
   Actor self( Self() );
-  InitializeVisual( self, mImpl->mBackgroundVisual, map );
+  mImpl->mBackgroundVisual = Toolkit::VisualFactory::Get().CreateVisual( map );
+  RegisterVisual( Toolkit::Control::Property::BACKGROUND, self, mImpl->mBackgroundVisual );
   if( mImpl->mBackgroundVisual )
   {
     mImpl->mBackgroundVisual.SetDepthIndex( DepthIndex::BACKGROUND );
@@ -500,7 +505,8 @@ void Control::SetBackground( const Property::Map& map )
 void Control::SetBackgroundImage( Image image )
 {
   Actor self( Self() );
-  InitializeVisual( self, mImpl->mBackgroundVisual, image );
+  mImpl->mBackgroundVisual = Toolkit::VisualFactory::Get().CreateVisual( image );
+  RegisterVisual( Toolkit::Control::Property::BACKGROUND, self, mImpl->mBackgroundVisual );
   if( mImpl->mBackgroundVisual )
   {
     mImpl->mBackgroundVisual.SetDepthIndex( DepthIndex::BACKGROUND );
@@ -653,63 +659,79 @@ void Control::KeyboardEnter()
   OnKeyboardEnter();
 }
 
-void Control::RegisterVisual( Property::Index index, Actor placementActor, Toolkit::Visual::Base visual )
+void Control::RegisterVisual( Property::Index index, Actor& placementActor, Toolkit::Visual::Base& visual )
 {
   bool visualReplaced ( false );
   Actor actorToRegister; // Null actor, replaced if placement actor not Self
+  Actor self = Self();
 
-  if ( placementActor != Self() ) // Prevent increasing ref count if actor self
+  if ( placementActor != self ) // Prevent increasing ref count if actor self
   {
     actorToRegister = placementActor;
   }
 
-  if ( !mImpl->mVisuals.empty() )
+  if ( !mImpl->mVisuals.Empty() )
   {
-      std::vector<RegisteredVisual>::iterator iter;
+      RegisteredVisuals::Iterator iter;
       // Check if visual (index) is already registered.  Replace if so.
       if ( FindVisual( index, mImpl->mVisuals, iter ) )
       {
-        (*iter).visual = visual;
-        (*iter).placementActor = actorToRegister;
+        if( (*iter)->visual && self.OnStage() )
+        {
+          if( (*iter)->placementActor )
+          {
+            (*iter)->visual.SetOffStage( (*iter)->placementActor );
+          }
+          else
+          {
+            (*iter)->visual.SetOffStage( self );
+          }
+        }
+        (*iter)->visual = visual;
+        (*iter)->placementActor = actorToRegister;
         visualReplaced = true;
       }
   }
 
   if ( !visualReplaced ) // New registration entry
   {
-    RegisteredVisual newVisual = RegisteredVisual( index, visual, actorToRegister );
-    mImpl->mVisuals.push_back( newVisual );
+    mImpl->mVisuals.PushBack( new RegisteredVisual( index, visual, actorToRegister ) );
+  }
+
+  if( visual && self.OnStage() )
+  {
+    visual.SetOnStage( placementActor );
   }
 }
 
 void Control::UnregisterVisual( Property::Index index )
 {
-   std::vector< RegisteredVisual >::iterator iter;
+   RegisteredVisuals::Iterator iter;
    if ( FindVisual( index, mImpl->mVisuals, iter ) )
    {
-     mImpl->mVisuals.erase( iter );
+     mImpl->mVisuals.Erase( iter );
    }
 }
 
-Toolkit::Visual::Base Control::GetVisual( Property::Index index )
+Toolkit::Visual::Base Control::GetVisual( Property::Index index ) const
 {
-  std::vector< RegisteredVisual >::iterator iter;
+  RegisteredVisuals::Iterator iter;
   if ( FindVisual( index, mImpl->mVisuals, iter ) )
   {
-    return (*iter).visual;
+    return (*iter)->visual;
   }
 
   return Toolkit::Visual::Base();
 }
 
-Actor Control::GetPlacementActor( Property::Index index )
+Actor Control::GetPlacementActor( Property::Index index ) const
 {
-  std::vector< RegisteredVisual >::iterator iter;
+  RegisteredVisuals::Iterator iter;
   if ( FindVisual( index, mImpl->mVisuals, iter ) )
   {
-    if( (*iter).placementActor )
+    if( (*iter)->placementActor )
     {
-      return (*iter).placementActor;
+      return (*iter)->placementActor;
     }
     else
     {
@@ -905,19 +927,41 @@ void Control::EmitKeyInputFocusSignal( bool focusGained )
 
 void Control::OnStageConnection( int depth )
 {
-  if( mImpl->mBackgroundVisual)
+  for(RegisteredVisuals::Iterator iter = mImpl->mVisuals.Begin(); iter!= mImpl->mVisuals.End(); iter++)
   {
-    Actor self( Self() );
-    mImpl->mBackgroundVisual.SetOnStage( self );
+    // Check whether the visual is empty, as it is allowed to register a placement actor without visual.
+    if( (*iter)->visual )
+    {
+      if( (*iter)->placementActor )
+      {
+        (*iter)->visual.SetOnStage( (*iter)->placementActor );
+      }
+      else
+      {
+        Actor self( Self() );
+        (*iter)->visual.SetOnStage( self );
+      }
+    }
   }
 }
 
 void Control::OnStageDisconnection()
 {
-  if( mImpl->mBackgroundVisual )
+  for(RegisteredVisuals::Iterator iter = mImpl->mVisuals.Begin(); iter!= mImpl->mVisuals.End(); iter++)
   {
-    Actor self( Self() );
-    mImpl->mBackgroundVisual.SetOffStage( self );
+    // Check whether the visual is empty, as it is allowed to register a placement actor without visual.
+    if( (*iter)->visual )
+    {
+      if( (*iter)->placementActor )
+      {
+        (*iter)->visual.SetOffStage( (*iter)->placementActor );
+      }
+      else
+      {
+        Actor self( Self() );
+        (*iter)->visual.SetOffStage( self );
+      }
+    }
   }
 }
 
index e8a71fe..97ed7d1 100644 (file)
@@ -305,8 +305,9 @@ protected: // For derived classes to call
    * @param[in] index The Property index of the visual, used to reference visual
    * @param[in] placementActor The actor used to by the visual.
    * @param[in] visual The visual to register
+   * @note Derived class must NOT call visual.SetOnStage(placementActor). It is the responsibility of the base class to connect/disconnect registered visual to stage.
    */
-   void RegisterVisual( Property::Index index, Actor placementActor, Toolkit::Visual::Base visual );
+   void RegisterVisual( Property::Index index, Actor& placementActor, Toolkit::Visual::Base& visual );
 
    /**
     * @brief Erase the entry matching the given index from the list of registered visuals
@@ -325,7 +326,7 @@ protected: // For derived classes to call
     * @return The registered visual if exist, otherwise empty handle.
     * @note For managing object life-cycle, do not store the returned visual as a member which increments its reference count.
     */
-   Toolkit::Visual::Base GetVisual( Property::Index index );
+   Toolkit::Visual::Base GetVisual( Property::Index index ) const;
 
    /**
     * @brief Retrieve the placement actor associated with the given index.
@@ -336,7 +337,7 @@ protected: // For derived classes to call
     * @return Then placement actor if exist, otherwise empty handle.
     * @note For managing object life-cycle, do not store the returned placement actor as a member which increments its reference count.
     */
-   Actor GetPlacementActor( Property::Index index );
+   Actor GetPlacementActor( Property::Index index ) const;
 
   /**
    * @brief Emits KeyInputFocusGained signal if true else emits KeyInputFocusLost signal
index 3479fed..da3ae92 100644 (file)
@@ -31,7 +31,7 @@ namespace Toolkit
 
 const unsigned int TOOLKIT_MAJOR_VERSION = 1;
 const unsigned int TOOLKIT_MINOR_VERSION = 2;
-const unsigned int TOOLKIT_MICRO_VERSION = 4;
+const unsigned int TOOLKIT_MICRO_VERSION = 5;
 const char * const TOOLKIT_BUILD_DATE    = __DATE__ " " __TIME__;
 
 #ifdef DEBUG_ENABLED
index 8f472d8..19ac5bf 100644 (file)
       "grabHandleImage" : "{DALI_STYLE_IMAGE_DIR}cursor_handler_drop_center.png",
       "selectionHandleImageLeft" : {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_left.png" },
       "selectionHandleImageRight": {"filename":"{DALI_STYLE_IMAGE_DIR}selection_handle_drop_right.png" }
+    },
+    "ProgressBar":
+    {
+      "progressValue": 0,
+      "trackVisual":{
+        "url":"{DALI_IMAGE_DIR}slider-skin.9.png",
+        "size":[24,24]
+      },
+      "progressVisual":{
+        "url":"{DALI_IMAGE_DIR}slider-skin-progress.9.png",
+        "size":[24,24]
+      }
+    },
+    "ProgressBarValueTextLabel":
+    {
+      "textColor":[0.8,0.8,1,1]
     }
   }
 }
index 6d9eb61..7de04cc 100644 (file)
     "SliderHandleTextLabel":
     {
       "textColor":[0.8,0.8,1,1]
+    },
+    "ProgressBar":
+    {
+      "progressValue": 0,
+      "trackVisual":{
+        "url":"{DALI_IMAGE_DIR}slider-skin.9.png",
+        "size":[24,24]
+      },
+      "progressVisual":{
+        "url":"{DALI_IMAGE_DIR}slider-skin-progress.9.png",
+        "size":[24,24]
+      }
+    },
+    "ProgressBarValueTextLabel":
+    {
+      "textColor":[0.8,0.8,1,1]
     }
   }
 }
index 25b2375..404cc00 100644 (file)
     "SliderHandleTextLabel":
     {
       "textColor":[0.8,0.8,1,1]
+    },
+    "ProgressBar":
+    {
+      "progressValue": 0,
+      "trackVisual":{
+        "url":"{DALI_IMAGE_DIR}slider-skin.9.png",
+        "size":[24,24]
+      },
+      "progressVisual":{
+        "url":"{DALI_IMAGE_DIR}slider-skin-progress.9.png",
+        "size":[24,24]
+      }
+    },
+    "ProgressBarValueTextLabel":
+    {
+      "textColor":[0.8,0.8,1,1]
     }
   }
 }
index 6ecfaa9..74107a8 100644 (file)
@@ -1,6 +1,6 @@
 Name:       dali-addon
 Summary:    DALi module for Node.JS
-Version:    1.2.4
+Version:    1.2.5
 Release:    1
 Group:      Development/Libraries
 License:    Apache License, Version 2.0
index 65da60b..1e28096 100644 (file)
@@ -1,6 +1,6 @@
 Name:       dali-toolkit
 Summary:    The OpenGLES Canvas Core Library Toolkit
-Version:    1.2.4
+Version:    1.2.5
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0 and BSD-2-Clause and MIT
index 15252da..5ea93df 100644 (file)
@@ -159,7 +159,6 @@ const IntegerPair EnumTable[] =
 
     { "DRAW_MODE_NORMAL",                                   DrawMode::NORMAL     },
     { "DRAW_MODE_OVERLAY_2D",                               DrawMode::OVERLAY_2D },
-    { "DRAW_MODE_STENCIL",                                  DrawMode::STENCIL    },
 
     { "RESOURCE_LOADING",                                   Dali::ResourceLoading },
     { "RESOURCE_LOADING_SUCCEEDED",                         Dali::ResourceLoadingSucceeded  },
@@ -278,14 +277,11 @@ const IntegerPair EnumTable[] =
     { "ALPHA_FUNCTION_SIN",                   AlphaFunction::SIN                  },
     { "ALPHA_FUNCTION_EASE_OUT_BACK",         AlphaFunction::EASE_OUT_BACK        },
 
+    { "CLIPPING_MODE_DISABLED",                     ClippingMode::DISABLED                     },
+    { "CLIPPING_MODE_CLIP_CHILDREN",                ClippingMode::CLIP_CHILDREN                },
 };
 const unsigned int EnumTableCount = sizeof(EnumTable)/sizeof(EnumTable[0]);
 
-
-
-
-
-
 } // un-named name space