Merge "C# CustomView Implementation (C++ wrappers, manual bindings, C# wrappers)...
authorDavid Steele <david.steele@samsung.com>
Wed, 16 Nov 2016 11:17:25 +0000 (03:17 -0800)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Wed, 16 Nov 2016 11:17:25 +0000 (03:17 -0800)
22 files changed:
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/mesh-builder.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-actor-utils.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-sync-abstraction.h
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-ItemLayout.cpp
dali-toolkit/internal/controls/scrollable/item-view/depth-layout.cpp
dali-toolkit/internal/controls/scrollable/item-view/grid-layout.cpp
dali-toolkit/internal/image-loader/image-load-thread.h
dali-toolkit/internal/scripting/script-plugin-proxy.h
dali-toolkit/internal/text/multi-language-support-impl.cpp
dali-toolkit/internal/text/rendering/atlas/atlas-mesh-factory.cpp
dali-toolkit/internal/text/text-controller-impl.cpp
dali-toolkit/internal/visuals/gradient/gradient-visual.cpp
dali-toolkit/internal/visuals/image/image-visual.cpp
dali-toolkit/internal/visuals/npatch-loader.cpp
dali-toolkit/internal/visuals/visual-base-impl.cpp
dali-toolkit/public-api/controls/control-impl.cpp
plugins/dali-swig/examples/dali-test.cs
plugins/dali-swig/manual/csharp/Color.cs

index 9e0364b..a3149f4 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_TEST_SUITE_UTILS_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.
@@ -516,9 +516,7 @@ class ObjectDestructionTracker : public ConnectionTracker
 public:
 
   /**
-   * @brief
-   *
-   * Call in main part of code
+   * @brief Call in main part of code
    */
   ObjectDestructionTracker();
 
@@ -531,6 +529,7 @@ public:
 
   /**
    * @brief Call to check if Actor alive or destroyed.
+   *
    * @return bool true if Actor was destroyed
    */
   bool IsDestroyed();
index f8d7bf8..6e2e204 100644 (file)
@@ -30,6 +30,7 @@ namespace Dali
 
 namespace
 {
+
 const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
   attribute mediump vec2 aPosition;\n
   uniform mediump mat4 uMvpMatrix;\n
index 10c3264..9bed832 100644 (file)
@@ -956,10 +956,11 @@ public:
   inline void GetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source)
   {
     const std::string shaderSource = mShaderSources[shader];
-    if( static_cast<int>(shaderSource.length()) < bufsize )
+    const int shaderSourceLength = static_cast<int>(shaderSource.length());
+    if( shaderSourceLength < bufsize )
     {
-      strcpy(source, shaderSource.c_str());
-      *length = shaderSource.length();
+      strncpy( source, shaderSource.c_str(), shaderSourceLength );
+      *length = shaderSourceLength;
     }
     else
     {
index 278bcd7..8ce96a4 100644 (file)
@@ -2,7 +2,7 @@
 #define __TEST_GL_SYNC_ABSTRACTION_H__
 
 /*
- * Copyright (c) 2014 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.
@@ -108,6 +108,10 @@ public: // TEST FUNCTIONS
   int GetNumberOfSyncObjects();
 
 private:
+
+  TestGlSyncAbstraction( const TestGlSyncAbstraction& ); ///< Undefined
+  TestGlSyncAbstraction& operator=( const TestGlSyncAbstraction& ); ///< Undefined
+
   typedef std::vector<TestSyncObject*>   SyncContainer;
   typedef SyncContainer::iterator SyncIter;
   SyncContainer mSyncObjects;  ///< The sync objects
index 0054e59..76ccff7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 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.
@@ -101,6 +101,21 @@ bool TraceCallStack::FindMethod(std::string method) const
   return found;
 }
 
+bool TraceCallStack::FindMethodAndGetParameters(std::string method, std::string& params ) const
+{
+  bool found = false;
+  for( size_t i=0; i < mCallStack.size(); i++ )
+  {
+    if( 0 == mCallStack[i].method.compare(method) )
+    {
+      found = true;
+      params = mCallStack[i].paramList;
+      break;
+    }
+  }
+  return found;
+}
+
 int TraceCallStack::CountMethod(std::string method) const
 {
   int numCalls = 0;
index e1882ea..c3f3358 100644 (file)
@@ -79,6 +79,14 @@ public:
   bool FindMethod(std::string method) const;
 
   /**
+   * Search for a method in the stack and return its parameters if found
+   * @param[in] method The name of the method
+   * @param[out] params of the method
+   * @return true if the method was in the stack
+   */
+  bool FindMethodAndGetParameters(std::string method, std::string& params ) const;
+
+  /**
    * Count how many times a method was called
    * @param[in] method The name of the method
    * @return The number of times it was called
index 447c78a..aa51150 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.
@@ -291,6 +291,9 @@ int UtcDaliItemLayoutSetAndGetOrientation(void)
 
   DALI_TEST_CHECK(flickSpeedFactor != 0.0f);
 
+  // White box test here: -( itemId / NoOfItemsPerRow(default 4) ) * NoOfItemsPerRow
+  DALI_TEST_EQUALS( -1.0f, gridLayout->GetItemScrollToPosition( 1 ), TEST_LOCATION );
+
   ItemLayoutPtr depthLayout = DefaultItemLayout::New( DefaultItemLayout::DEPTH );
   view.AddLayout(*depthLayout);
 
index 557a089..613af0a 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.
@@ -390,7 +390,7 @@ float DepthLayout::GetClosestAnchorPosition(float layoutPosition) const
 
 float DepthLayout::GetItemScrollToPosition(unsigned int itemId) const
 {
-  float rowIndex = static_cast<float>(itemId / mImpl->mNumberOfColumns);
+  float rowIndex = static_cast< float >( itemId ) / mImpl->mNumberOfColumns;
   return -rowIndex * static_cast<float>(mImpl->mNumberOfColumns);
 }
 
index e1ca4d0..4ef642c 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.
@@ -390,7 +390,7 @@ float GridLayout::GetClosestAnchorPosition(float layoutPosition) const
 
 float GridLayout::GetItemScrollToPosition(unsigned int itemId) const
 {
-  float rowIndex = static_cast<float>(itemId / mImpl->mNumberOfColumns);
+  float rowIndex = static_cast< float >( itemId ) / mImpl->mNumberOfColumns;
   return -rowIndex * static_cast<float>(mImpl->mNumberOfColumns);
 }
 
index 4eddce7..85ea419 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_TOOLKIT_IMAGE_LOAD_THREAD_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.
@@ -83,6 +83,8 @@ public:
    * Add a task in to the loading queue
    *
    * @param[in] task The task added to the queue.
+   *
+   * @note This class takes ownership of the task object
    */
   void AddTask( LoadingTask* task );
 
index 2c359c7..eff47e3 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_SCRIPT_PLUGIN_PROXY_H__
 
 /*
- * Copyright (c) 2014 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.
@@ -79,6 +79,10 @@ public:
   bool IsInitialized() const;
 
 private:
+
+  ScriptPluginProxy( const ScriptPluginProxy& ); ///< Undefined
+  ScriptPluginProxy& operator=( const ScriptPluginProxy& ); ///< Undefined
+
   /**
    * @brief Dynamically loads the script plugin.
    */
index ae9a68b..32e7c38 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.
@@ -565,7 +565,6 @@ void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
           // At this point the character common for all scripts has no font assigned.
           // If there is a valid previously cached default font for it, use that one.
           fontId = cachedDefaultFontId;
-          isValidFont = true;
         }
       }
       else
index 4da6c1f..4017f79 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.
@@ -83,6 +83,9 @@ void CreateQuad( SizeType imageWidth,
   Vector2 topLeft = Vector2( position.x - 0.5f, position.y - 0.5f );
 
   float fBlockX = texelBlockWidth * static_cast< float >( block % atlasWidthInBlocks );
+
+  // In the next expression, we have purposely made ( block / atlasWidthInBlocks ) yield an integer value and then convert to float as
+  // we do not want the remainder in that expression to affect the value of fBlockY
   float fBlockY = texelBlockHeight * static_cast< float >( block / atlasWidthInBlocks );
 
   // Add on texture filtering compensation ( half a texel plus compensation for filled pixel in top left corner )
index 6d2a022..ee7c4ac 100644 (file)
@@ -75,6 +75,7 @@ EventData::EventData( DecoratorPtr decorator )
   mPlaceholderTextColor( 0.8f, 0.8f, 0.8f, 0.8f ),
   mEventQueue(),
   mInputStyleChangedQueue(),
+  mPreviousState( INACTIVE ),
   mState( INACTIVE ),
   mPrimaryCursorPosition( 0u ),
   mLeftSelectionPosition( 0u ),
index 6f50a9a..bfc9130 100644 (file)
@@ -449,7 +449,7 @@ bool GradientVisual::NewGradient(Type gradientType, const Property::Map& propert
   if( spread )
   {
     Toolkit::GradientVisual::SpreadMethod::Type spreadMethod = Toolkit::GradientVisual::SpreadMethod::PAD;
-    if( Scripting::GetEnumerationProperty( *spread, SPREAD_METHOD_TABLE, SPREAD_METHOD_TABLE_COUNT, spreadMethod ) );
+    if( Scripting::GetEnumerationProperty( *spread, SPREAD_METHOD_TABLE, SPREAD_METHOD_TABLE_COUNT, spreadMethod ) )
     {
       mGradient->SetSpreadMethod( spreadMethod );
     }
index 54527de..084491a 100644 (file)
@@ -522,7 +522,7 @@ TextureSet ImageVisual::CreateTextureSet( Vector4& textureRect, const std::strin
 
 void ImageVisual::InitializeRenderer( const std::string& imageUrl )
 {
-  mImpl->mRenderer.Reset();
+  DALI_ASSERT_DEBUG( !mImpl->mRenderer && "Renderer should have been removed from stage and already reset before initialization" );
 
   mImageUrl = imageUrl;
   mImpl->mFlags &= ~Impl::IS_ATLASING_APPLIED;
@@ -586,8 +586,9 @@ void ImageVisual::InitializeRenderer( const std::string& imageUrl )
 
 void ImageVisual::InitializeRenderer( const Image& image )
 {
+  DALI_ASSERT_DEBUG( !mImpl->mRenderer && "Renderer should have been removed from stage and already reset before initialization" );
+
   mImpl->mFlags &= ~Impl::IS_FROM_CACHE;
-  mImpl->mRenderer.Reset();
 
   // don't reuse CreateTextureSet
   TextureSet textures = TextureSet::New();
index 026450d..6e3c8ec 100644 (file)
@@ -59,12 +59,12 @@ std::size_t NPatchLoader::Load( const std::string& url )
   NinePatchImage ninePatch = NinePatchImage::New( url );
   if( ninePatch )
   {
-    Data* data = new Data();
-    data->hash = hash;
-    data->url = url;
     BufferImage croppedImage = ninePatch.CreateCroppedBufferImage();
     if( croppedImage )
     {
+      Data* data = new Data();
+      data->hash = hash;
+      data->url = url;
       data->textureSet = TextureSet::New();
       TextureSetImage( data->textureSet, 0u, croppedImage );
       data->croppedWidth = croppedImage.GetWidth();
index 9cd41e0..e8ed4a3 100644 (file)
@@ -130,15 +130,18 @@ 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 );
-
-  if( mImpl->mRenderer )
+  if( !IsOnStage() )
   {
-    mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, IsPreMultipliedAlphaEnabled());
-    mImpl->mRenderer.SetProperty( Renderer::Property::DEPTH_INDEX, mImpl->mDepthIndex );
-    mImpl->mFlags |= Impl::IS_ON_STAGE; // Only sets the flag if renderer exists
+    // 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 );
+
+    if( mImpl->mRenderer )
+    {
+      mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, IsPreMultipliedAlphaEnabled());
+      mImpl->mRenderer.SetProperty( Renderer::Property::DEPTH_INDEX, mImpl->mDepthIndex );
+      mImpl->mFlags |= Impl::IS_ON_STAGE; // Only sets the flag if renderer exists
+    }
   }
 }
 
index a01cc5e..90b3bb6 100644 (file)
@@ -803,6 +803,7 @@ void Control::EnableVisual( Property::Index index, bool enable )
   {
     if (  (*iter)->enabled == enable )
     {
+      DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::EnableVisual Visual Already enabled set (%s) \n", enable?"enabled":"disabled");
       return;
     }
 
@@ -812,11 +813,12 @@ void Control::EnableVisual( Property::Index index, bool enable )
     {
       if ( enable )
       {
-
+        DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::EnableVisual Setting Visual(%d) on stage \n", index );
         Toolkit::GetImplementation((*iter)->visual).SetOnStage( parentActor );
       }
       else
       {
+        DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::EnableVisual Setting Visual(%d) off stage \n", index );
         Toolkit::GetImplementation((*iter)->visual).SetOffStage( parentActor );  // No need to call if control not staged.
       }
     }
@@ -1084,11 +1086,14 @@ void Control::EmitKeyInputFocusSignal( bool focusGained )
 
 void Control::OnStageConnection( int depth )
 {
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::OnStageConnection number of registered visuals(%d)\n",  mImpl->mVisuals.Size() );
+
   for(RegisteredVisualContainer::Iterator iter = mImpl->mVisuals.Begin(); iter!= mImpl->mVisuals.End(); iter++)
   {
     // Check whether the visual is empty and enabled
     if( (*iter)->visual && (*iter)->enabled )
     {
+      DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::OnStageConnection Setting visual(%d) on stage\n", (*iter)->index );
       Actor self( Self() );
       Toolkit::GetImplementation((*iter)->visual).SetOnStage( self );
     }
@@ -1102,6 +1107,7 @@ void Control::OnStageDisconnection()
     // Check whether the visual is empty
     if( (*iter)->visual )
     {
+      DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::OnStageDisconnection Setting visual(%d) off stage\n", (*iter)->index );
       Actor self( Self() );
       Toolkit::GetImplementation((*iter)->visual).SetOffStage( self );
     }
index 27b04bf..d13b4ea 100644 (file)
@@ -62,7 +62,7 @@ namespace MyCSharpExample
       Console.WriteLine("Actor name: " + actor.Name);
 
       Stage stage = Stage.GetCurrent();
-      stage.BackgroundColor =  new Color("white") ;
+      stage.BackgroundColor =  new Color(Colors.White) ;
 
       Size stageSize = stage.Size;
       Console.WriteLine("Stage size: " + stageSize.x + ", " + stageSize.y);
index 0082950..3115a71 100644 (file)
@@ -2,6 +2,22 @@ namespace Dali {
 
 using System;
 
+
+public enum Colors
+{
+  Red,
+  White,
+  Blue,
+  Green,
+  Black,
+  Grey,
+  Yellow,
+  Azure,
+  Rose
+}
+
+
+
 public class Color : Vector4
        {
   /**
@@ -77,6 +93,49 @@ public class Color : Vector4
                        break;
                }
            }
+
+
+  /**
+   * @brief constructor
+   *
+   * @since 1.0.0
+   * @param [in] color as enum Colors.
+   */
+           public Color(Colors color)
+               : base(0, 0, 0, 0)
+           {
+               switch (color)
+               {
+                   case Colors.Red:
+                       SetColor(255, 0, 0, 255);
+                       break;
+                   case Colors.White:
+                       SetColor(255, 255, 255, 255);
+                       break;
+                   case Colors.Blue:
+                       SetColor(0, 0, 255, 255);
+                       break;
+                   case Colors.Green:
+                       SetColor(0, 255, 0, 255);
+                       break;
+                   case Colors.Black:
+                       SetColor(0, 0, 0, 255);
+                       break;
+                   case Colors.Grey:
+                       SetColor(128, 128, 128, 255);
+                       break;
+                   case Colors.Yellow:
+                       SetColor(255, 255, 0, 255);
+                       break;
+                   case Colors.Azure:
+                       SetColor(0, 255, 255, 255);
+                       break;
+                   case Colors.Rose:
+                       SetColor(255, 0, 255, 255);
+                       break;
+               }
+           }
+
    
   /**
    * @brief SetColor