Fix control properties for C# custom view 08/114508/6
authorRichard Huang <r.huang@samsung.com>
Mon, 13 Feb 2017 14:25:21 +0000 (14:25 +0000)
committerRichard Huang <r.huang@samsung.com>
Tue, 14 Feb 2017 11:39:54 +0000 (11:39 +0000)
Change-Id: I7034d61dcca047d9e7120870998524d228cacf8c

14 files changed:
automated-tests/src/dali-toolkit/utc-Dali-ControlWrapper.cpp
dali-toolkit/devel-api/controls/control-wrapper-impl.cpp
dali-toolkit/devel-api/controls/control-wrapper-impl.h
dali-toolkit/devel-api/controls/control-wrapper.cpp
dali-toolkit/devel-api/controls/control-wrapper.h
plugins/dali-swig/examples/custom-control.cs
plugins/dali-swig/examples/dali-test.cs
plugins/dali-swig/manual/cpp/view-wrapper-impl-wrap.cpp
plugins/dali-swig/manual/csharp/CustomView.cs
plugins/dali-swig/manual/csharp/ManualPINVOKE.cs
plugins/dali-swig/manual/csharp/ViewRegistry.cs
plugins/dali-swig/manual/csharp/ViewWrapper.cs
plugins/dali-swig/manual/csharp/ViewWrapperImpl.cs
plugins/dali-swig/views/spin.cs

index 32076f1..8caf518 100644 (file)
@@ -23,6 +23,7 @@
 #include <dali-toolkit-test-suite-utils.h>
 
 #include <dali.h>
 #include <dali-toolkit-test-suite-utils.h>
 
 #include <dali.h>
+#include <dali/public-api/dali-core.h>
 #include <dali-toolkit/dali-toolkit.h>
 #include <dali-toolkit/devel-api/controls/control-wrapper.h>
 #include <dali-toolkit/devel-api/controls/control-wrapper-impl.h>
 #include <dali-toolkit/dali-toolkit.h>
 #include <dali-toolkit/devel-api/controls/control-wrapper.h>
 #include <dali-toolkit/devel-api/controls/control-wrapper-impl.h>
@@ -216,8 +217,12 @@ struct TestCustomControl : public Toolkit::Internal::ControlWrapper
   bool mNego;
   unsigned int mDepth;
 };
   bool mNego;
   unsigned int mDepth;
 };
+
 }
 
 }
 
+static std::string customControlTypeName = "TestCustomControl";
+static TypeRegistration customControl( customControlTypeName, typeid(Dali::Toolkit::Control), NULL );
+
 int UtcDaliControlWrapperConstructor(void)
 {
   ToolkitTestApplication application;  // Exceptions require ToolkitTestApplication
 int UtcDaliControlWrapperConstructor(void)
 {
   ToolkitTestApplication application;  // Exceptions require ToolkitTestApplication
@@ -227,9 +232,10 @@ int UtcDaliControlWrapperConstructor(void)
 
   DALI_TEST_CHECK( !ControlWrapper::DownCast( controlWrapper ) );
 
 
   DALI_TEST_CHECK( !ControlWrapper::DownCast( controlWrapper ) );
 
-  controlWrapper = ControlWrapper::New( *controlWrapperImpl );
+  controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
 
   DALI_TEST_CHECK( ControlWrapper::DownCast( controlWrapper ) );
 
   DALI_TEST_CHECK( ControlWrapper::DownCast( controlWrapper ) );
+
   END_TEST;
 }
 
   END_TEST;
 }
 
@@ -237,7 +243,7 @@ int UtcDaliControlWrapperDestructor(void)
 {
   TestApplication application;
 
 {
   TestApplication application;
 
-  ControlWrapper control = ControlWrapper::New( *( new Toolkit::Internal::ControlWrapper( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT ) ) );
+  ControlWrapper control = ControlWrapper::New( customControlTypeName, *( new Toolkit::Internal::ControlWrapper( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT ) ) );
 
   ControlWrapper control2( control );
 
 
   ControlWrapper control2( control );
 
@@ -259,7 +265,7 @@ int UtcDaliControlWrapperRelayoutRequest(void)
   DALI_TEST_EQUALS( gOnRelayout, false, TEST_LOCATION );
 
   Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
   DALI_TEST_EQUALS( gOnRelayout, false, TEST_LOCATION );
 
   Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
-  ControlWrapper controlWrapper = ControlWrapper::New( *controlWrapperImpl );
+  ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
 
   Stage::GetCurrent().Add( controlWrapper );
 
 
   Stage::GetCurrent().Add( controlWrapper );
 
@@ -283,7 +289,7 @@ int UtcDaliControlWrapperImplGetHeightForWidthBase(void)
   TestApplication application;
 
   Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
   TestApplication application;
 
   Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
-  ControlWrapper controlWrapper = ControlWrapper::New( *controlWrapperImpl );
+  ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
 
   float width = 300.0f;
   float v = 0.0f;
 
   float width = 300.0f;
   float v = 0.0f;
@@ -303,7 +309,7 @@ int UtcDaliControlWrapperGetWidthForHeightBase(void)
   TestApplication application;
 
   Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
   TestApplication application;
 
   Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
-  ControlWrapper controlWrapper = ControlWrapper::New( *controlWrapperImpl );
+  ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
 
   float height = 300.0f;
   float v = 0.0f;
 
   float height = 300.0f;
   float v = 0.0f;
@@ -323,7 +329,7 @@ int UtcDaliControlWrapperCalculateChildSizeBase(void)
   TestApplication application;
 
   Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
   TestApplication application;
 
   Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
-  ControlWrapper controlWrapper = ControlWrapper::New( *controlWrapperImpl );
+  ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
 
   Actor child = Actor::New();
   child.SetResizePolicy( Dali::ResizePolicy::FIXED, Dali::Dimension::ALL_DIMENSIONS );
 
   Actor child = Actor::New();
   child.SetResizePolicy( Dali::ResizePolicy::FIXED, Dali::Dimension::ALL_DIMENSIONS );
@@ -344,7 +350,7 @@ int UtcDaliControlWrapperRelayoutDependentOnChildrenBase(void)
   TestApplication application;
 
   Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
   TestApplication application;
 
   Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
-  ControlWrapper controlWrapper = ControlWrapper::New( *controlWrapperImpl );
+  ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
 
   bool v = false;
 
 
   bool v = false;
 
@@ -371,7 +377,7 @@ int UtcDaliControlWrapperRegisterVisualToSelf(void)
 
   {
     Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
 
   {
     Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
-    ControlWrapper controlWrapper = ControlWrapper::New( *controlWrapperImpl );
+    ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
 
     objectDestructionTracker.Start( controlWrapper );
 
 
     objectDestructionTracker.Start( controlWrapper );
 
@@ -404,7 +410,7 @@ int UtcDaliControlWrapperRegisterDisabledVisual(void)
   ToolkitTestApplication application;
 
   Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
   ToolkitTestApplication application;
 
   Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
-  ControlWrapper controlWrapper = ControlWrapper::New( *controlWrapperImpl );
+  ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
 
   Property::Index TEST_PROPERTY = 1;
 
 
   Property::Index TEST_PROPERTY = 1;
 
@@ -446,7 +452,7 @@ int UtcDaliControlWrapperRegisterUnregisterVisual(void)
   ToolkitTestApplication application;
 
   Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
   ToolkitTestApplication application;
 
   Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
-  ControlWrapper controlWrapper = ControlWrapper::New( *controlWrapperImpl );
+  ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
 
   Property::Index index = 1;
 
 
   Property::Index index = 1;
 
@@ -491,7 +497,7 @@ int UtcDaliControlWrapperTransitionDataMap1N(void)
   Dali::Toolkit::TransitionData transition = TransitionData::New( map );
 
   Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
   Dali::Toolkit::TransitionData transition = TransitionData::New( map );
 
   Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
-  ControlWrapper controlWrapper = ControlWrapper::New( *controlWrapperImpl );
+  ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
 
   //DummyControl actor = DummyControl::New();
   controlWrapper.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
 
   //DummyControl actor = DummyControl::New();
   controlWrapper.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
@@ -544,10 +550,56 @@ int UtcDaliControlWrapperApplyThemeStyle(void)
   ToolkitTestApplication application;
 
   Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
   ToolkitTestApplication application;
 
   Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
-  ControlWrapper controlWrapper = ControlWrapper::New( *controlWrapperImpl );
+  ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
 
   controlWrapperImpl->ApplyThemeStyle();
 
   DALI_TEST_CHECK( true );
   END_TEST;
 }
 
   controlWrapperImpl->ApplyThemeStyle();
 
   DALI_TEST_CHECK( true );
   END_TEST;
 }
+
+int UtcDaliControlWrapperTestControlProperties(void)
+{
+  ToolkitTestApplication application;
+
+  Impl::TestCustomControl* controlWrapperImpl = new ::Impl::TestCustomControl( Toolkit::Internal::ControlWrapper::CONTROL_BEHAVIOUR_DEFAULT );
+  ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl );
+
+  Stage::GetCurrent().Add( controlWrapper );
+
+  // "background" property
+  Property::Map rendererMap;
+  rendererMap[Visual::Property::TYPE] = Visual::COLOR;
+  rendererMap[ColorVisual::Property::MIX_COLOR] = Color::RED;
+  controlWrapper.SetProperty( Control::Property::BACKGROUND, rendererMap );
+  Property::Value propertyValue = controlWrapper.GetProperty( Control::Property::BACKGROUND );
+  Property::Map* resultMap = propertyValue.GetMap();
+  DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE ) );
+  DALI_TEST_EQUALS( resultMap->Find( Visual::Property::TYPE )->Get<int>(), (int)Visual::COLOR, TEST_LOCATION );
+  DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
+  DALI_TEST_EQUALS( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>(), Color::RED, TEST_LOCATION );
+
+  // "keyInputFocus" property
+  controlWrapper.SetProperty( Control::Property::KEY_INPUT_FOCUS, true );
+  DALI_TEST_EQUALS( true, controlWrapper.GetProperty( Control::Property::KEY_INPUT_FOCUS ).Get< bool >(), TEST_LOCATION );
+
+  // "styleName" property
+  controlWrapper.SetProperty( Control::Property::STYLE_NAME, "MyCustomStyle" );
+  DALI_TEST_EQUALS( "MyCustomStyle", controlWrapper.GetProperty( Control::Property::STYLE_NAME ).Get< std::string >(), TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliControlWrapperTypeRegistryCreation(void)
+{
+  ToolkitTestApplication application;
+
+  TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "ControlWrapper" );
+  DALI_TEST_CHECK( typeInfo )
+
+  // Check that we can't create a ControlWrapper instance
+  BaseHandle baseHandle = typeInfo.CreateInstance();
+  DALI_TEST_CHECK( !baseHandle )
+
+  END_TEST;
+}
index 48019fe..d3fcc56 100755 (executable)
 // CLASS HEADER
 #include <dali-toolkit/devel-api/controls/control-wrapper-impl.h>
 
 // CLASS HEADER
 #include <dali-toolkit/devel-api/controls/control-wrapper-impl.h>
 
-// INTERNAL INCLUDES
+// EXTERNAL INCLUDES
 #include <dali/public-api/animation/animation.h>
 #include <dali/public-api/animation/animation.h>
+#include <dali/public-api/object/type-registry.h>
+#include <dali/public-api/object/type-registry-helper.h>
+#include <dali/devel-api/object/handle-devel.h>
+
+// INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/control-impl.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
 #include <dali-toolkit/public-api/styling/style-manager.h>
 #include <dali-toolkit/public-api/controls/control-impl.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
 #include <dali-toolkit/public-api/styling/style-manager.h>
@@ -34,11 +39,26 @@ namespace Toolkit
 namespace Internal
 {
 
 namespace Internal
 {
 
+namespace
+{
+
+BaseHandle Create()
+{
+  // empty handle as we cannot create control wrapper
+  return BaseHandle();
+}
+
+// Setup type-registry.
+DALI_TYPE_REGISTRATION_BEGIN( Toolkit::ControlWrapper, Toolkit::Control, Create )
+DALI_TYPE_REGISTRATION_END()
+
+}
+
 /*
  * Implementation.
  */
 
 /*
  * Implementation.
  */
 
-Dali::Toolkit::ControlWrapper ControlWrapper::New( ControlWrapper* controlWrapper )
+Dali::Toolkit::ControlWrapper ControlWrapper::New( const std::string& typeName, ControlWrapper* controlWrapper )
 {
   ControlWrapperPtr wrapper( controlWrapper );
 
 {
   ControlWrapperPtr wrapper( controlWrapper );
 
@@ -49,6 +69,19 @@ Dali::Toolkit::ControlWrapper ControlWrapper::New( ControlWrapper* controlWrappe
   // This can only be done after the CustomActor connection has been made.
   wrapper->Initialize();
 
   // This can only be done after the CustomActor connection has been made.
   wrapper->Initialize();
 
+  // Different types of C# custom view registered themselves using type registry,
+  // but their type names are registered per type not per instance, so they still
+  // have the same wrong type name in native side when type registry queries the
+  // unique type name of each instance using typeid() because of the binding.
+  // Therefore, we have to link each instance with its correct type info if already
+  // pre-registered.
+
+  TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeName );
+  if(typeInfo)
+  {
+    Dali::DevelHandle::SetTypeInfo( handle, typeInfo );
+  }
+
   return handle;
 }
 
   return handle;
 }
 
index fa9173f..33905a5 100755 (executable)
@@ -64,9 +64,13 @@ public:
 
   /**
    * Create a new ControlWrapper.
 
   /**
    * Create a new ControlWrapper.
+   *
+   * @param[in] typeName The name of the type that is registered with this control
+   * @param[in] controlWrapper The implementation of this control
+   *
    * @return A public handle to the newly allocated ControlWrapper.
    */
    * @return A public handle to the newly allocated ControlWrapper.
    */
-  static Dali::Toolkit::ControlWrapper New( ControlWrapper* controlWrapper );
+  static Dali::Toolkit::ControlWrapper New( const std::string& typeName, ControlWrapper* controlWrapper );
 
 public: // From CustomActorImpl
 
 
 public: // From CustomActorImpl
 
index 7f8db27..0c6be01 100644 (file)
@@ -31,9 +31,9 @@ namespace Toolkit
 // ControlWrapper
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 // ControlWrapper
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-ControlWrapper ControlWrapper::New( Internal::ControlWrapper& implementation )
+ControlWrapper ControlWrapper::New( const std::string& typeName, Internal::ControlWrapper& implementation )
 {
 {
-  return Internal::ControlWrapper::New( &implementation );
+  return Internal::ControlWrapper::New( typeName, &implementation );
 }
 
 ControlWrapper::ControlWrapper()
 }
 
 ControlWrapper::ControlWrapper()
index a45c4b5..b50852b 100644 (file)
@@ -45,9 +45,12 @@ public:
   /**
    * @brief Create a new instance of a ControlWrapper.
    *
   /**
    * @brief Create a new instance of a ControlWrapper.
    *
+   * @param[in] typeName The name of the type that is registered with this control
+   * @param[in] implementation The implementation of this control
+   *
    * @return A handle to a new ControlWrapper.
    */
    * @return A handle to a new ControlWrapper.
    */
-  static ControlWrapper New( Internal::ControlWrapper& implementation );
+  static ControlWrapper New( const std::string& typeName, Internal::ControlWrapper& implementation );
 
   /**
    * @brief Creates an empty ControlWrapper handle.
 
   /**
    * @brief Creates an empty ControlWrapper handle.
index 20531a2..2da7ea4 100644 (file)
@@ -31,7 +31,21 @@ namespace MyCSharpExample
         private int _myRating;
         private bool _myDragEnabled;
 
         private int _myRating;
         private bool _myDragEnabled;
 
-        public StarRating() : base(ViewWrapperImpl.CustomViewBehaviour.VIEW_BEHAVIOUR_DEFAULT)
+        // Called by DALi Builder if it finds a StarRating control in a JSON file
+        static CustomView CreateInstance()
+        {
+          return new StarRating();
+        }
+
+        // static constructor registers the control type (only runs once)
+        static StarRating()
+        {
+          // ViewRegistry registers control type with DALi type registery
+          // also uses introspection to find any properties that need to be registered with type registry
+          ViewRegistry.Instance.Register(CreateInstance, typeof(StarRating) );
+        }
+
+        public StarRating() : base(typeof(StarRating).Name, ViewWrapperImpl.CustomViewBehaviour.VIEW_BEHAVIOUR_DEFAULT)
         {
         }
 
         {
         }
 
@@ -229,6 +243,8 @@ namespace MyCSharpExample
         [STAThread]
         static void Main(string[] args)
         {
         [STAThread]
         static void Main(string[] args)
         {
+            System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor (typeof(MyCSharpExample.StarRating).TypeHandle);
+
             Example example = new Example(Application.NewApplication());
             example.MainLoop ();
         }
             Example example = new Example(Application.NewApplication());
             example.MainLoop ();
         }
index 9c02eee..274b97a 100644 (file)
@@ -39,9 +39,10 @@ namespace MyCSharpExample
 
     public void Initialize(object source, NUIApplicationInitEventArgs e)
     {
 
     public void Initialize(object source, NUIApplicationInitEventArgs e)
     {
-
       OperatorTests();
 
       OperatorTests();
 
+      CustomViewPropertyTest();
+
       Handle handle = new Handle();
       int myPropertyIndex = handle.RegisterProperty("myProperty", new Property.Value(10.0f), Property.AccessMode.READ_WRITE);
       float myProperty = 0.0f;
       Handle handle = new Handle();
       int myPropertyIndex = handle.RegisterProperty("myProperty", new Property.Value(10.0f), Property.AccessMode.READ_WRITE);
       float myProperty = 0.0f;
@@ -338,6 +339,52 @@ namespace MyCSharpExample
 
   }
 
 
   }
 
+    public void CustomViewPropertyTest()
+    {
+        // Create a Spin control
+        Spin spin = new Spin();
+
+        // Background property
+        Property.Map background = new Property.Map();
+        background.Add( Dali.Constants.Visual.Property.Type, new Property.Value((int)Dali.Constants.Visual.Type.Color) )
+                  .Add( Dali.Constants.ColorVisualProperty.MixColor, new Property.Value(Color.Red) );
+        spin.Background = background;
+
+        background = spin.Background;
+        Vector4 backgroundColor = new Vector4();
+        background.Find(Dali.Constants.ColorVisualProperty.MixColor).Get(backgroundColor);
+        if( backgroundColor == Color.Red )
+        {
+            Console.WriteLine ("Custom View Background property : test passed");
+        }
+        else
+        {
+            Console.WriteLine ("Custom View Background property : test failed");
+        }
+
+        // BackgroundColor property
+        spin.BackgroundColor = Color.Yellow;
+        if(spin.BackgroundColor == Color.Yellow)
+        {
+            Console.WriteLine ("Custom View BackgroundColor property : test passed");
+        }
+        else
+        {
+            Console.WriteLine ("Custom View BackgroundColor property : test failed");
+        }
+
+        // StyleName property
+        spin.StyleName = "MyCustomStyle";
+        if(spin.StyleName == "MyCustomStyle")
+        {
+            Console.WriteLine ("Custom View StyleName property : test passed");
+        }
+        else
+        {
+            Console.WriteLine ("Custom View StyleName property : test failed");
+        }
+    }
+
     public void MainLoop()
     {
       _application.MainLoop ();
     public void MainLoop()
     {
       _application.MainLoop ();
index 3354408..9bf6950 100644 (file)
@@ -649,15 +649,21 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_new_ViewWrapperImpl(int jarg1) {
 }
 
 
 }
 
 
-SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_ViewWrapperImpl_New(void * jarg1) {
+SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_ViewWrapperImpl_New(char * jarg1, void * jarg2) {
   void * jresult ;
   void * jresult ;
-  Dali::Toolkit::Internal::ControlWrapper *arg1 = (Dali::Toolkit::Internal::ControlWrapper *) 0 ;
+  std::string arg1 ;
+  Dali::Toolkit::Internal::ControlWrapper *arg2 = (Dali::Toolkit::Internal::ControlWrapper *) 0 ;
   Dali::Toolkit::ControlWrapper result;
 
   Dali::Toolkit::ControlWrapper result;
 
-  arg1 = (Dali::Toolkit::Internal::ControlWrapper *)jarg1;
+  if (!jarg1) {
+    SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
+    return 0;
+  }
+  (&arg1)->assign(jarg1);
+  arg2 = (Dali::Toolkit::Internal::ControlWrapper *)jarg2;
   {
     try {
   {
     try {
-      result = Dali::Toolkit::Internal::ControlWrapper::New(arg1);
+      result = Dali::Toolkit::Internal::ControlWrapper::New(arg1,arg2);
     } catch (std::out_of_range& e) {
       {
         SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return 0;
     } catch (std::out_of_range& e) {
       {
         SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return 0;
@@ -745,19 +751,25 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_GetControlWrapperImpl__SWIG_0(void * j
 }
 
 
 }
 
 
-SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_ViewWrapper_New(void * jarg1) {
+SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_ViewWrapper_New(char * jarg1, void * jarg2) {
   void * jresult ;
   void * jresult ;
-  Dali::Toolkit::Internal::ControlWrapper *arg1 = 0 ;
+  std::string arg1 ;
+  Dali::Toolkit::Internal::ControlWrapper *arg2 = 0 ;
   Dali::Toolkit::ControlWrapper result;
 
   Dali::Toolkit::ControlWrapper result;
 
-  arg1 = (Dali::Toolkit::Internal::ControlWrapper *)jarg1;
-  if (!arg1) {
+  if (!jarg1) {
+    SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
+    return 0;
+  }
+  (&arg1)->assign(jarg1);
+  arg2 = (Dali::Toolkit::Internal::ControlWrapper *)jarg2;
+  if (!arg2) {
     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Toolkit::Internal::ControlWrapper & type is null", 0);
     return 0;
   }
   {
     try {
     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Dali::Toolkit::Internal::ControlWrapper & type is null", 0);
     return 0;
   }
   {
     try {
-      result = Dali::Toolkit::ControlWrapper::New(*arg1);
+      result = Dali::Toolkit::ControlWrapper::New(arg1,*arg2);
     } catch (std::out_of_range& e) {
       {
         SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return 0;
     } catch (std::out_of_range& e) {
       {
         SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return 0;
index 7e84f5b..9c54cdd 100644 (file)
@@ -19,7 +19,7 @@ namespace Dali
 {
     public class CustomView : ViewWrapper
     {
 {
     public class CustomView : ViewWrapper
     {
-        public CustomView(ViewWrapperImpl.CustomViewBehaviour behaviour) : base(new ViewWrapperImpl(behaviour))
+        public CustomView(string typeName, ViewWrapperImpl.CustomViewBehaviour behaviour) : base(typeName, new ViewWrapperImpl(behaviour))
         {
             // Registering CustomView virtual functions to viewWrapperImpl delegates.
             viewWrapperImpl.OnStageConnection = new ViewWrapperImpl.OnStageConnectionDelegate(OnStageConnection);
         {
             // Registering CustomView virtual functions to viewWrapperImpl delegates.
             viewWrapperImpl.OnStageConnection = new ViewWrapperImpl.OnStageConnectionDelegate(OnStageConnection);
index 3433213..6d7f471 100755 (executable)
@@ -104,7 +104,7 @@ namespace Dali
         public static extern global::System.IntPtr new_ViewWrapperImpl(int jarg1);
 
         [global::System.Runtime.InteropServices.DllImport("NDalic", EntryPoint="CSharp_Dali_ViewWrapperImpl_New")]
         public static extern global::System.IntPtr new_ViewWrapperImpl(int jarg1);
 
         [global::System.Runtime.InteropServices.DllImport("NDalic", EntryPoint="CSharp_Dali_ViewWrapperImpl_New")]
-        public static extern global::System.IntPtr ViewWrapperImpl_New(global::System.Runtime.InteropServices.HandleRef jarg1);
+        public static extern global::System.IntPtr ViewWrapperImpl_New(string jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
 
         [global::System.Runtime.InteropServices.DllImport("NDalic", EntryPoint="CSharp_Dali_delete_ViewWrapperImpl")]
         public static extern void delete_ViewWrapperImpl(global::System.Runtime.InteropServices.HandleRef jarg1);
 
         [global::System.Runtime.InteropServices.DllImport("NDalic", EntryPoint="CSharp_Dali_delete_ViewWrapperImpl")]
         public static extern void delete_ViewWrapperImpl(global::System.Runtime.InteropServices.HandleRef jarg1);
@@ -116,7 +116,7 @@ namespace Dali
         public static extern global::System.IntPtr GetControlWrapperImpl__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1);
 
         [global::System.Runtime.InteropServices.DllImport("NDalic", EntryPoint="CSharp_Dali_ViewWrapper_New")]
         public static extern global::System.IntPtr GetControlWrapperImpl__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1);
 
         [global::System.Runtime.InteropServices.DllImport("NDalic", EntryPoint="CSharp_Dali_ViewWrapper_New")]
-        public static extern global::System.IntPtr ViewWrapper_New(global::System.Runtime.InteropServices.HandleRef jarg1);
+        public static extern global::System.IntPtr ViewWrapper_New(string jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
 
         [global::System.Runtime.InteropServices.DllImport("NDalic", EntryPoint="CSharp_Dali_new_ViewWrapper__SWIG_0")]
         public static extern global::System.IntPtr new_ViewWrapper__SWIG_0();
 
         [global::System.Runtime.InteropServices.DllImport("NDalic", EntryPoint="CSharp_Dali_new_ViewWrapper__SWIG_0")]
         public static extern global::System.IntPtr new_ViewWrapper__SWIG_0();
index 29ece3a..c2be678 100644 (file)
@@ -98,7 +98,7 @@ namespace Dali
   ///
   ///  static Spin()
   ///  {
   ///
   ///  static Spin()
   ///  {
-  ///     ViewRegistry.Instance.RegisterControl("Spin", CreateInstance, typeof(Spin) );
+  ///     ViewRegistry.Instance.Register(CreateInstance, typeof(Spin) );
   ///  }
   ///
   ///  The control should also provide a CreateInstance function, which gets passed to the ViewRegistry
   ///  }
   ///
   ///  The control should also provide a CreateInstance function, which gets passed to the ViewRegistry
@@ -293,17 +293,17 @@ namespace Dali
     /// {
     ///   ViewRegistry registers control type with DALi type registery
     ///   also uses introspection to find any properties that need to be registered with type registry
     /// {
     ///   ViewRegistry registers control type with DALi type registery
     ///   also uses introspection to find any properties that need to be registered with type registry
-    ///   ViewRegistry.Instance.Register("Spin", CreateInstance, typeof(Spin) );
+    ///   ViewRegistry.Instance.Register(CreateInstance, typeof(Spin) );
     /// }
     ///
     /// </summary>
     /// }
     ///
     /// </summary>
-    public void Register(string viewName, Func< CustomView > createFunction, System.Type viewType )
+    public void Register(Func< CustomView > createFunction, System.Type viewType )
     {
       // add the mapping between the view name and it's create function
     {
       // add the mapping between the view name and it's create function
-      _constructorMap.Add (viewName, createFunction);
+      _constructorMap.Add (viewType.Name, createFunction);
 
       // Call into DALi C++ to register the control with the type registry
 
       // Call into DALi C++ to register the control with the type registry
-      TypeRegistration.RegisterControl( viewName, _createCallback );
+      TypeRegistration.RegisterControl( viewType.Name, _createCallback );
 
       // Cycle through each property in the class
       foreach (System.Reflection.PropertyInfo propertyInfo in viewType.GetProperties())
 
       // Cycle through each property in the class
       foreach (System.Reflection.PropertyInfo propertyInfo in viewType.GetProperties())
@@ -324,14 +324,14 @@ namespace Dali
               ScriptableProperty scriptableProp = attr as ScriptableProperty;
 
               // we get the start property index, based on the type and it's heirachy, e.g. DateView (70,000)-> Spin (60,000) -> View (50,000)
               ScriptableProperty scriptableProp = attr as ScriptableProperty;
 
               // we get the start property index, based on the type and it's heirachy, e.g. DateView (70,000)-> Spin (60,000) -> View (50,000)
-              int propertyIndex =  _propertyRangeManager.GetPropertyIndex( viewName, viewType, scriptableProp.type );
+              int propertyIndex =  _propertyRangeManager.GetPropertyIndex( viewType.Name, viewType, scriptableProp.type );
 
               // get the enum for the property type... E.g. registering a string property returns Dali.PropertyType.String
               Dali.Property.Type propertyType = GetDaliPropertyType( propertyInfo.PropertyType.Name );
 
               // Example   RegisterProperty("spin","maxValue", 50001, FLOAT, set, get );
               // Native call to register the property
 
               // get the enum for the property type... E.g. registering a string property returns Dali.PropertyType.String
               Dali.Property.Type propertyType = GetDaliPropertyType( propertyInfo.PropertyType.Name );
 
               // Example   RegisterProperty("spin","maxValue", 50001, FLOAT, set, get );
               // Native call to register the property
-              TypeRegistration.RegisterProperty (viewName, propertyInfo.Name , propertyIndex, propertyType, _setPropertyCallback, _getPropertyCallback);
+              TypeRegistration.RegisterProperty (viewType.Name, propertyInfo.Name , propertyIndex, propertyType, _setPropertyCallback, _getPropertyCallback);
             }
           }
           // Console.WriteLine ("property name = " + propertyInfo.Name);
             }
           }
           // Console.WriteLine ("property name = " + propertyInfo.Name);
index 76281fa..f0660b1 100644 (file)
@@ -55,7 +55,7 @@ namespace Dali
             }
         }
 
             }
         }
 
-        public ViewWrapper (ViewWrapperImpl implementation) : this (NDalicManualPINVOKE.ViewWrapper_New(ViewWrapperImpl.getCPtr(implementation)), true)
+        public ViewWrapper (string typeName, ViewWrapperImpl implementation) : this (NDalicManualPINVOKE.ViewWrapper_New(typeName, ViewWrapperImpl.getCPtr(implementation)), true)
         {
             viewWrapperImpl = implementation;
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         {
             viewWrapperImpl = implementation;
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
index 45c0175..0f42e4e 100644 (file)
@@ -141,9 +141,9 @@ namespace Dali
             DirectorConnect();
         }
 
             DirectorConnect();
         }
 
-        public static ViewWrapper New(ViewWrapperImpl viewWrapper)
+        public static ViewWrapper New(string typeName, ViewWrapperImpl viewWrapper)
         {
         {
-            ViewWrapper ret = new ViewWrapper(NDalicManualPINVOKE.ViewWrapperImpl_New(ViewWrapperImpl.getCPtr(viewWrapper)), true);
+            ViewWrapper ret = new ViewWrapper(NDalicManualPINVOKE.ViewWrapperImpl_New(typeName, ViewWrapperImpl.getCPtr(viewWrapper)), true);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
         }
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
         }
index 06a0210..f31a49d 100644 (file)
@@ -52,9 +52,10 @@ public class Spin : CustomView
     {
       // ViewRegistry registers control type with DALi type registery
       // also uses introspection to find any properties that need to be registered with type registry
     {
       // ViewRegistry registers control type with DALi type registery
       // also uses introspection to find any properties that need to be registered with type registry
-      ViewRegistry.Instance.Register("Spin", CreateInstance, typeof(Spin) );
+      ViewRegistry.Instance.Register(CreateInstance, typeof(Spin) );
     }
     }
-    public Spin() : base(ViewWrapperImpl.CustomViewBehaviour.REQUIRES_KEYBOARD_NAVIGATION_SUPPORT | ViewWrapperImpl.CustomViewBehaviour.DISABLE_STYLE_CHANGE_SIGNALS)
+
+    public Spin() : base(typeof(Spin).Name, ViewWrapperImpl.CustomViewBehaviour.REQUIRES_KEYBOARD_NAVIGATION_SUPPORT | ViewWrapperImpl.CustomViewBehaviour.DISABLE_STYLE_CHANGE_SIGNALS)
     {
 
     }
     {
 
     }