Merge "Update doxygen comments" into devel/master
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 8 Feb 2017 10:34:02 +0000 (02:34 -0800)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Wed, 8 Feb 2017 10:34:03 +0000 (02:34 -0800)
13 files changed:
automated-tests/src/dali-toolkit-internal/CMakeLists.txt
automated-tests/src/dali-toolkit-internal/utc-Dali-PropertyHelper.cpp [new file with mode: 0644]
automated-tests/src/dali-toolkit/utc-Dali-Control.cpp
automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp
dali-toolkit/internal/file.list
dali-toolkit/internal/helpers/property-helper.cpp [new file with mode: 0644]
dali-toolkit/internal/helpers/property-helper.h [new file with mode: 0644]
dali-toolkit/internal/text/text-vertical-scroller.cpp
dali-toolkit/internal/visuals/visual-base-data-impl.cpp
dali-toolkit/internal/visuals/visual-base-impl.cpp
dali-toolkit/public-api/controls/control-impl.cpp
dali-toolkit/public-api/visuals/visual-properties.h
docs/content/shared-javascript-and-cpp-documentation/visuals.md

index 4e3e0ff..f07653b 100755 (executable)
@@ -23,6 +23,7 @@ SET(TC_SOURCES
  utc-Dali-Text-ViewModel.cpp
  utc-Dali-DebugRendering.cpp
  utc-Dali-ItemView-internal.cpp
+ utc-Dali-PropertyHelper.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-PropertyHelper.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-PropertyHelper.cpp
new file mode 100644 (file)
index 0000000..58fc510
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2017 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/internal/helpers/property-helper.h>
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+
+void dali_property_helper_startup(void)
+{
+  test_return_value = TET_UNDEF;
+}
+
+void dali_property_helper_cleanup(void)
+{
+  test_return_value = TET_PASS;
+}
+
+int UtcDaliPropertyHelperGetStringFromPropertyWithString(void)
+{
+  tet_infoline( "Test to check if a simple string is parsed correctly" );
+
+  const std::string inputString = "Hello World";
+  Property::Value value( inputString );
+
+  std::string output;
+  DALI_TEST_CHECK( Toolkit::Internal::GetStringFromProperty( value, output ) );
+  DALI_TEST_EQUALS( output, inputString, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliPropertyHelperGetStringFromPropertyWithEmptyValue(void)
+{
+  tet_infoline( "Test to ensure if an empty value returns false" );
+
+  std::string output;
+  DALI_TEST_CHECK( ! Toolkit::Internal::GetStringFromProperty( Property::Value(), output ) );
+
+  END_TEST;
+}
+
+int UtcDaliPropertyHelperGetStringFromPropertyWithStringArray(void)
+{
+  tet_infoline( "Test to check if a string array is parsed correctly and adds new line characters too" );
+
+  Property::Value value( Property::Array().Add( "Hello World" )
+                                          .Add( "The Quick Brown Fox" )
+                                          .Add( "Jumps over the lazy dog" ) );
+
+  std::string output;
+  DALI_TEST_CHECK( Toolkit::Internal::GetStringFromProperty( value, output ) );
+  DALI_TEST_CHECK( output.find( "Hello World\n" ) != std::string::npos );
+  DALI_TEST_CHECK( output.find( "The Quick Brown Fox\n" ) != std::string::npos );
+  DALI_TEST_CHECK( output.find( "Jumps over the lazy dog\n" ) != std::string::npos );
+
+  END_TEST;
+}
+
+int UtcDaliPropertyHelperGetStringFromPropertyWithEmptyArray(void)
+{
+  tet_infoline( "Test to check if an empty array returns false" );
+
+  Property::Array array;
+
+  std::string output;
+  DALI_TEST_CHECK( ! Toolkit::Internal::GetStringFromProperty( Property::Value( array ), output ) );
+
+  END_TEST;
+}
+
+int UtcDaliPropertyHelperGetStringFromPropertyWithMultipleTypesInArray(void)
+{
+  tet_infoline( "Test to ensure an array with multiple types returns false" );
+
+  Property::Value value( Property::Array().Add( "Hello World" )
+                                          .Add( "The Quick Brown Fox" )
+                                          .Add( 1 )
+                                          .Add( "Jumps" )
+                                          .Add( 25 )
+                                          .Add( "Over" ) );
+
+  std::string output;
+  DALI_TEST_CHECK( ! Toolkit::Internal::GetStringFromProperty( value, output ) );
+  DALI_TEST_CHECK( output.empty() );
+
+  END_TEST;
+}
index 93ee34e..376ad0d 100644 (file)
@@ -24,6 +24,9 @@
 
 #include <dali.h>
 #include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
+#include <dali-toolkit/devel-api/align-enums.h>
+
 #include "dummy-control.h"
 
 using namespace Dali;
@@ -721,3 +724,41 @@ int UtcDaliControlAutoClippingWhenAlreadyOnStageN(void)
 
   END_TEST;
 }
+
+int UtcDaliControlSetTransformSize(void)
+{
+  ToolkitTestApplication application;
+  Control control = Control::New();
+
+  Property::Map transformMap;
+  transformMap.Add( DevelVisual::Transform::Property::OFFSET, Vector2( 10, 10 ) )
+              .Add( DevelVisual::Transform::Property::ANCHOR_POINT, Align::BOTTOM_END )
+              .Add( DevelVisual::Transform::Property::ORIGIN, Align::BOTTOM_END )
+              .Add( DevelVisual::Transform::Property::SIZE, Vector2( 10, 20 ) );
+
+  control.SetProperty( Control::Property::BACKGROUND, Property::Map().Add( Visual::Property::TYPE, Visual::COLOR )
+                                                                     .Add( DevelVisual::Property::TRANSFORM, transformMap ) );
+
+  tet_infoline( "Test to ensure that the control background transform does not get overwritten when adding to the stage" );
+
+  Stage::GetCurrent().Add( control );
+
+  application.SendNotification();
+  application.Render();
+
+  // Ensure the transform property still matches what we set
+  Property::Value value = control.GetProperty( Control::Property::BACKGROUND );
+  Property::Map* map = value.GetMap();
+  DALI_TEST_CHECK( map );
+  Property::Value* transformValue = map->Find( DevelVisual::Property::TRANSFORM );
+  DALI_TEST_CHECK( transformValue );
+
+  Property::Map* retMap = transformValue->GetMap();
+  DALI_TEST_CHECK( retMap );
+  DALI_TEST_EQUALS( retMap->Find( DevelVisual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 10, 10 ), TEST_LOCATION );
+  DALI_TEST_EQUALS( retMap->Find( DevelVisual::Transform::Property::ANCHOR_POINT )->Get< int >(), (int)Align::BOTTOM_END, TEST_LOCATION );
+  DALI_TEST_EQUALS( retMap->Find( DevelVisual::Transform::Property::ORIGIN )->Get< int >(), (int)Align::BOTTOM_END, TEST_LOCATION );
+  DALI_TEST_EQUALS( retMap->Find( DevelVisual::Transform::Property::SIZE )->Get< Vector2 >(), Vector2( 10, 20 ), TEST_LOCATION );
+
+  END_TEST;
+}
index 2bf846b..f0175c4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -1695,6 +1695,7 @@ static void TestTransform( ToolkitTestApplication& application, Visual::Base vis
 
   //Set a new transform
   transform.Clear();
+  transform = DefaultTransform();
   transform.Insert( DevelVisual::Transform::Property::OFFSET, Vector2(20.0f, 20.0f) );
   transform.Insert( DevelVisual::Transform::Property::SIZE, Vector2(100.0f, 100.0f) );
   transform.Insert( DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4(0.0f, 0.0f, 1.0f,1.0f) );
@@ -2083,8 +2084,8 @@ int UtcDaliVisualTextVisualRender(void)
   Renderer renderer = dummyControl.GetRendererAt(0u);
   Property::Index index = renderer.GetPropertyIndex("size");
 
-  tet_infoline( "Test that the TextVisual overrides anything set by developer" );
-  DALI_TEST_EQUALS( renderer.GetProperty<Vector2>(index), Vector2( 1.0, 1.0 ), 0.001f, TEST_LOCATION );
+  tet_infoline( "Test that the TextVisual has NOT overridden what was set by developer" );
+  DALI_TEST_EQUALS( renderer.GetProperty<Vector2>(index), Vector2( 0.5f, 0.5f ), 0.001f, TEST_LOCATION );
 
   END_TEST;
 }
index 27b079a..84f3214 100755 (executable)
@@ -88,6 +88,7 @@ toolkit_src_files = \
    \
    $(toolkit_src_dir)/focus-manager/keyboard-focus-manager-impl.cpp \
    $(toolkit_src_dir)/focus-manager/keyinput-focus-manager-impl.cpp \
+   $(toolkit_src_dir)/helpers/property-helper.cpp \
    $(toolkit_src_dir)/filters/blur-two-pass-filter.cpp \
    $(toolkit_src_dir)/filters/emboss-filter.cpp \
    $(toolkit_src_dir)/filters/image-filter.cpp \
diff --git a/dali-toolkit/internal/helpers/property-helper.cpp b/dali-toolkit/internal/helpers/property-helper.cpp
new file mode 100644 (file)
index 0000000..94be023
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2017 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.
+ *
+ */
+
+// HEADER
+#include <dali-toolkit/internal/helpers/property-helper.h>
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/property-array.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+bool GetStringFromProperty( const Property::Value& value, std::string& output )
+{
+  bool extracted = false;
+  if( value.Get( output ) )
+  {
+    extracted = true;
+  }
+  else
+  {
+    Property::Array* array = value.GetArray();
+    if( array )
+    {
+      const unsigned int arraySize = array->Size();
+      for( unsigned int i = 0; i < arraySize; ++i )
+      {
+        std::string element;
+        if( array->GetElementAt( i ).Get( element ) )
+        {
+          extracted = true;
+          output += element + '\n';
+        }
+        else
+        {
+          // If property in array is anything other than a string, then it is invalid so break and clear output.
+          output.clear();
+          extracted = false;
+          break;
+        }
+      }
+    }
+  }
+
+  return extracted;
+}
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/internal/helpers/property-helper.h b/dali-toolkit/internal/helpers/property-helper.h
new file mode 100644 (file)
index 0000000..e91062d
--- /dev/null
@@ -0,0 +1,52 @@
+#ifndef DALI_TOOLKIT_INTERNAL_PROPERTY_HELPER_H
+#define DALI_TOOLKIT_INTERNAL_PROPERTY_HELPER_H
+
+/*
+ * Copyright (c) 2017 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 <string>
+#include <dali/public-api/object/property.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+/**
+ * @brief Parses a Property::Value to retrieve the string.
+ *
+ * If value is a Property::STRING, then it simply extracts the required string.
+ * If value is a Property::ARRAY, then it combines all the strings it contains into one adding a newline character to each line.
+ * The second option allows users to write long strings over several lines in a JSON file.
+ *
+ * @return True if a string was extracted successfully.
+ */
+bool GetStringFromProperty( const Property::Value& value, std::string& output );
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+
+#endif // DALI_TOOLKIT_INTERNAL_PROPERTY_HELPER_H
index fabf035..b9d6606 100644 (file)
@@ -45,7 +45,8 @@ TextVerticalScrollerPtr TextVerticalScroller::New()
 }
 
 TextVerticalScroller::TextVerticalScroller()
-: mDuration( DEFAULT_VERTICAL_SCROLL_DURATION )
+: mDuration( DEFAULT_VERTICAL_SCROLL_DURATION ),
+  mScrollTo( 0.0f )
 {
 }
 
index 16044b7..8990c9a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -26,6 +26,7 @@
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
+#include <dali-toolkit/internal/helpers/property-helper.h>
 #include <dali-toolkit/internal/visuals/visual-string-constants.h>
 
 namespace Dali
@@ -116,7 +117,7 @@ void Internal::Visual::Base::Impl::CustomShader::SetPropertyMap( const Property:
   Property::Value* vertexShaderValue = shaderMap.Find( Toolkit::Visual::Shader::Property::VERTEX_SHADER, CUSTOM_VERTEX_SHADER );
   if( vertexShaderValue )
   {
-    if( !vertexShaderValue->Get( mVertexShader ) )
+    if( ! GetStringFromProperty( *vertexShaderValue, mVertexShader ) )
     {
       DALI_LOG_ERROR( "'%s' parameter does not correctly specify a string\n", CUSTOM_VERTEX_SHADER );
     }
@@ -125,7 +126,7 @@ void Internal::Visual::Base::Impl::CustomShader::SetPropertyMap( const Property:
   Property::Value* fragmentShaderValue = shaderMap.Find( Toolkit::Visual::Shader::Property::FRAGMENT_SHADER, CUSTOM_FRAGMENT_SHADER );
   if( fragmentShaderValue )
   {
-    if( !fragmentShaderValue->Get( mFragmentShader ) )
+    if( ! GetStringFromProperty( *fragmentShaderValue, mFragmentShader ) )
     {
       DALI_LOG_ERROR( "'%s' parameter does not correctly specify a string\n", CUSTOM_FRAGMENT_SHADER );
     }
index 68620ea..701da0e 100644 (file)
@@ -146,7 +146,7 @@ void Visual::Base::SetProperties( const Property::Map& propertyMap )
 void Visual::Base::SetTransformAndSize( const Property::Map& transform, Size controlSize )
 {
   mImpl->mControlSize = controlSize;
-  mImpl->mTransform.SetPropertyMap( transform );
+  mImpl->mTransform.UpdatePropertyMap( transform );
 
 #if defined(DEBUG_ENABLED)
   std::ostringstream oss;
index 18dd3fd..c94ebb1 100644 (file)
@@ -121,17 +121,6 @@ Toolkit::Visual::Base GetVisualByName(
   return visualHandle;
 }
 
-void SetDefaultTransform( Property::Map& propertyMap )
-{
-  propertyMap.Clear();
-  propertyMap
-    .Add( Toolkit::DevelVisual::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) )
-    .Add( Toolkit::DevelVisual::Transform::Property::SIZE, Vector2(1.0f, 1.0f) )
-    .Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::CENTER )
-    .Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER )
-    .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO );
-}
-
 /**
  * Creates control through type registry
  */
@@ -1212,9 +1201,7 @@ void Control::OnSizeSet(const Vector3& targetSize)
   if( visual )
   {
     Vector2 size( targetSize );
-    Property::Map transformMap;
-    SetDefaultTransform( transformMap );
-    visual.SetTransformAndSize( transformMap, size );
+    visual.SetTransformAndSize( Property::Map(), size ); // Send an empty map as we do not want to modify the visual's set transform
   }
 }
 
@@ -1253,10 +1240,7 @@ void Control::OnRelayout( const Vector2& size, RelayoutContainer& container )
   Toolkit::Visual::Base visual = GetVisual( Toolkit::Control::Property::BACKGROUND );
   if( visual )
   {
-    Vector2 controlSize( size );
-    Property::Map transformMap;
-    SetDefaultTransform( transformMap );
-    visual.SetTransformAndSize( transformMap, controlSize );
+    visual.SetTransformAndSize( Property::Map(), size ); // Send an empty map as we do not want to modify the visual's set transform
   }
 }
 
index e5f7431..65d452a 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_VISUAL_PROPERTIES_H
 
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -87,7 +87,8 @@ enum
 {
   /**
    * @brief The vertex shader.
-   * @details Name "vertexShader", type Property::STRING.
+   * @details Name "vertexShader", type Property::STRING or Property::ARRAY of Property::STRING.
+   *          A Property::ARRAY of Property::STRING values can be used to split the shader string over multiple lines.
    * @SINCE_1_1.45
    * @note Optional
    * @note If not supplied, the visual's already set vertex shader is used.
@@ -96,7 +97,8 @@ enum
 
   /**
    * @brief The fragment shader.
-   * @details Name "fragmentShader", type Property::STRING.
+   * @details Name "fragmentShader", type Property::STRING or Property::ARRAY of Property::STRING.
+   *          A Property::ARRAY of Property::STRING values can be used to split the shader string over multiple lines.
    * @SINCE_1_1.45
    * @note Optional
    * @note If not supplied, the visual's already set fragment shader is used.
index 3db0bf4..71c45ef 100644 (file)
@@ -60,13 +60,13 @@ For example, an offsetSizeMode of [0, 0, 1, 1], an offset of (0, 0.25) and a siz
 Visuals also have a custom **shader** property. Whilst it's possible to change the shader, please note that some visuals rely on the vertex shader to perform certain functions. For example, the NPatch visual uses the vertex shader to perform the stretching. The **shader** property is a Property::Map with the following keys:
 
 
-| Property                                        | String   | Type    | Required | Description               |
-|-------------------------------------------------|----------|:-------:|:--------:|---------------------------|
-| Dali::Toolkit::Visual::Shader::Property::VERTEX_SHADER | vertexShader | STRING | No      | The vertex shader code. |
-| Dali::Toolkit::Visual::Shader::Property::FRAGMENT_SHADER | fragmentShader | STRING | No      | The fragment shader code. |
-| Dali::Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_X | subdivideGridX | INTEGER | No      | How to subdivide the grid along the X-Axis. Defaults to 1 |
-| Dali::Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_Y | subdivideGridY | INTEGER | No      | How to subdivide the grid along the Y-Axis. Defaults to 1 |
-| Dali::Toolkit::Visual::Shader::Property::HINTS | hints | INTEGER or ARRAY of STRING | No      | Shader hints bitmask [More info](@ref shader-hints) |
+| Property                                                  | String         | Type                       | Required | Description                                                                                |
+|-----------------------------------------------------------|----------------|:--------------------------:|:--------:|--------------------------------------------------------------------------------------------|
+| Dali::Toolkit::Visual::Shader::Property::VERTEX_SHADER    | vertexShader   | STRING or ARRAY of STRING  | No       | The vertex shader code. Can use an array of strings to split shader over multiple lines.   |
+| Dali::Toolkit::Visual::Shader::Property::FRAGMENT_SHADER  | fragmentShader | STRING or ARRAY of STRING  | No       | The fragment shader code. Can use an array of strings to split shader over multiple lines. |
+| Dali::Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_X | subdivideGridX | INTEGER                    | No       | How to subdivide the grid along the X-Axis. Defaults to 1.                                 |
+| Dali::Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_Y | subdivideGridY | INTEGER                    | No       | How to subdivide the grid along the Y-Axis. Defaults to 1.                                 |
+| Dali::Toolkit::Visual::Shader::Property::HINTS            | hints          | INTEGER or ARRAY of STRING | No       | Shader hints bitmask [More info](@ref shader-hints)                                        |
 
 ## Shader hints {#shader-hints}