From: Richard Huang Date: Mon, 13 Feb 2017 14:25:21 +0000 (+0000) Subject: Fix control properties for C# custom view X-Git-Tag: dali_1.2.27~12 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=159563699a1d8ac7fb2fc516fdb0e9c5be69016a Fix control properties for C# custom view Change-Id: I7034d61dcca047d9e7120870998524d228cacf8c --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ControlWrapper.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ControlWrapper.cpp index 32076f1..8caf518 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ControlWrapper.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ControlWrapper.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -216,8 +217,12 @@ struct TestCustomControl : public Toolkit::Internal::ControlWrapper 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 @@ -227,9 +232,10 @@ int UtcDaliControlWrapperConstructor(void) DALI_TEST_CHECK( !ControlWrapper::DownCast( controlWrapper ) ); - controlWrapper = ControlWrapper::New( *controlWrapperImpl ); + controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl ); DALI_TEST_CHECK( ControlWrapper::DownCast( controlWrapper ) ); + END_TEST; } @@ -237,7 +243,7 @@ int UtcDaliControlWrapperDestructor(void) { 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 ); @@ -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 ); - ControlWrapper controlWrapper = ControlWrapper::New( *controlWrapperImpl ); + ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl ); 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 ); - ControlWrapper controlWrapper = ControlWrapper::New( *controlWrapperImpl ); + ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl ); 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 ); - ControlWrapper controlWrapper = ControlWrapper::New( *controlWrapperImpl ); + ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl ); 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 ); - ControlWrapper controlWrapper = ControlWrapper::New( *controlWrapperImpl ); + ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl ); 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 ); - ControlWrapper controlWrapper = ControlWrapper::New( *controlWrapperImpl ); + ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl ); bool v = false; @@ -371,7 +377,7 @@ int UtcDaliControlWrapperRegisterVisualToSelf(void) { 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 ); @@ -404,7 +410,7 @@ int UtcDaliControlWrapperRegisterDisabledVisual(void) 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; @@ -446,7 +452,7 @@ int UtcDaliControlWrapperRegisterUnregisterVisual(void) 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; @@ -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 ); - ControlWrapper controlWrapper = ControlWrapper::New( *controlWrapperImpl ); + ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl ); //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 ); - ControlWrapper controlWrapper = ControlWrapper::New( *controlWrapperImpl ); + ControlWrapper controlWrapper = ControlWrapper::New( customControlTypeName, *controlWrapperImpl ); 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)Visual::COLOR, TEST_LOCATION ); + DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) ); + DALI_TEST_EQUALS( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get(), 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; +} diff --git a/dali-toolkit/devel-api/controls/control-wrapper-impl.cpp b/dali-toolkit/devel-api/controls/control-wrapper-impl.cpp index 48019fe..d3fcc56 100755 --- a/dali-toolkit/devel-api/controls/control-wrapper-impl.cpp +++ b/dali-toolkit/devel-api/controls/control-wrapper-impl.cpp @@ -18,8 +18,13 @@ // CLASS HEADER #include -// INTERNAL INCLUDES +// EXTERNAL INCLUDES #include +#include +#include +#include + +// INTERNAL INCLUDES #include #include #include @@ -34,11 +39,26 @@ namespace Toolkit 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. */ -Dali::Toolkit::ControlWrapper ControlWrapper::New( ControlWrapper* controlWrapper ) +Dali::Toolkit::ControlWrapper ControlWrapper::New( const std::string& typeName, ControlWrapper* 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(); + // 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; } diff --git a/dali-toolkit/devel-api/controls/control-wrapper-impl.h b/dali-toolkit/devel-api/controls/control-wrapper-impl.h index fa9173f..33905a5 100755 --- a/dali-toolkit/devel-api/controls/control-wrapper-impl.h +++ b/dali-toolkit/devel-api/controls/control-wrapper-impl.h @@ -64,9 +64,13 @@ public: /** * 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. */ - static Dali::Toolkit::ControlWrapper New( ControlWrapper* controlWrapper ); + static Dali::Toolkit::ControlWrapper New( const std::string& typeName, ControlWrapper* controlWrapper ); public: // From CustomActorImpl diff --git a/dali-toolkit/devel-api/controls/control-wrapper.cpp b/dali-toolkit/devel-api/controls/control-wrapper.cpp index 7f8db27..0c6be01 100644 --- a/dali-toolkit/devel-api/controls/control-wrapper.cpp +++ b/dali-toolkit/devel-api/controls/control-wrapper.cpp @@ -31,9 +31,9 @@ namespace Toolkit // 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() diff --git a/dali-toolkit/devel-api/controls/control-wrapper.h b/dali-toolkit/devel-api/controls/control-wrapper.h index a45c4b5..b50852b 100644 --- a/dali-toolkit/devel-api/controls/control-wrapper.h +++ b/dali-toolkit/devel-api/controls/control-wrapper.h @@ -45,9 +45,12 @@ public: /** * @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. */ - static ControlWrapper New( Internal::ControlWrapper& implementation ); + static ControlWrapper New( const std::string& typeName, Internal::ControlWrapper& implementation ); /** * @brief Creates an empty ControlWrapper handle. diff --git a/plugins/dali-swig/examples/custom-control.cs b/plugins/dali-swig/examples/custom-control.cs index 20531a2..2da7ea4 100644 --- a/plugins/dali-swig/examples/custom-control.cs +++ b/plugins/dali-swig/examples/custom-control.cs @@ -31,7 +31,21 @@ namespace MyCSharpExample 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) { + System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor (typeof(MyCSharpExample.StarRating).TypeHandle); + Example example = new Example(Application.NewApplication()); example.MainLoop (); } diff --git a/plugins/dali-swig/examples/dali-test.cs b/plugins/dali-swig/examples/dali-test.cs index 9c02eee..274b97a 100644 --- a/plugins/dali-swig/examples/dali-test.cs +++ b/plugins/dali-swig/examples/dali-test.cs @@ -39,9 +39,10 @@ namespace MyCSharpExample public void Initialize(object source, NUIApplicationInitEventArgs e) { - OperatorTests(); + CustomViewPropertyTest(); + 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 (); diff --git a/plugins/dali-swig/manual/cpp/view-wrapper-impl-wrap.cpp b/plugins/dali-swig/manual/cpp/view-wrapper-impl-wrap.cpp index 3354408..9bf6950 100644 --- a/plugins/dali-swig/manual/cpp/view-wrapper-impl-wrap.cpp +++ b/plugins/dali-swig/manual/cpp/view-wrapper-impl-wrap.cpp @@ -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 ; - 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; - 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 { - 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(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 ; - Dali::Toolkit::Internal::ControlWrapper *arg1 = 0 ; + std::string arg1 ; + Dali::Toolkit::Internal::ControlWrapper *arg2 = 0 ; 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 { - 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(e.what())); return 0; diff --git a/plugins/dali-swig/manual/csharp/CustomView.cs b/plugins/dali-swig/manual/csharp/CustomView.cs index 7e84f5b..9c54cdd 100644 --- a/plugins/dali-swig/manual/csharp/CustomView.cs +++ b/plugins/dali-swig/manual/csharp/CustomView.cs @@ -19,7 +19,7 @@ namespace Dali { 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); diff --git a/plugins/dali-swig/manual/csharp/ManualPINVOKE.cs b/plugins/dali-swig/manual/csharp/ManualPINVOKE.cs index 3433213..6d7f471 100755 --- a/plugins/dali-swig/manual/csharp/ManualPINVOKE.cs +++ b/plugins/dali-swig/manual/csharp/ManualPINVOKE.cs @@ -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 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); @@ -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 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(); diff --git a/plugins/dali-swig/manual/csharp/ViewRegistry.cs b/plugins/dali-swig/manual/csharp/ViewRegistry.cs index 29ece3a..c2be678 100644 --- a/plugins/dali-swig/manual/csharp/ViewRegistry.cs +++ b/plugins/dali-swig/manual/csharp/ViewRegistry.cs @@ -98,7 +98,7 @@ namespace Dali /// /// 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 @@ -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.Instance.Register("Spin", CreateInstance, typeof(Spin) ); + /// ViewRegistry.Instance.Register(CreateInstance, typeof(Spin) ); /// } /// /// - 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 - _constructorMap.Add (viewName, createFunction); + _constructorMap.Add (viewType.Name, createFunction); // 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()) @@ -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) - 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 - 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); diff --git a/plugins/dali-swig/manual/csharp/ViewWrapper.cs b/plugins/dali-swig/manual/csharp/ViewWrapper.cs index 76281fa..f0660b1 100644 --- a/plugins/dali-swig/manual/csharp/ViewWrapper.cs +++ b/plugins/dali-swig/manual/csharp/ViewWrapper.cs @@ -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(); diff --git a/plugins/dali-swig/manual/csharp/ViewWrapperImpl.cs b/plugins/dali-swig/manual/csharp/ViewWrapperImpl.cs index 45c0175..0f42e4e 100644 --- a/plugins/dali-swig/manual/csharp/ViewWrapperImpl.cs +++ b/plugins/dali-swig/manual/csharp/ViewWrapperImpl.cs @@ -141,9 +141,9 @@ namespace Dali 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; } diff --git a/plugins/dali-swig/views/spin.cs b/plugins/dali-swig/views/spin.cs index 06a0210..f31a49d 100644 --- a/plugins/dali-swig/views/spin.cs +++ b/plugins/dali-swig/views/spin.cs @@ -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.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) { }