/// in MyControl.h
/// class MyControl : public Control
/// {
- /// struct Property
+ /// struct Property
+ /// {
+ /// enum
/// {
- /// enum
- /// {
- /// HOURS = Control::CONTROL_PROPERTY_END_INDEX + 1
- /// }
- /// }
- ///
+ /// HOURS = Control::CONTROL_PROPERTY_END_INDEX + 1
+ /// }
+ /// }
+ /// }
///
/// in MyControl-impl.cpp
///
///
/// 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
private PropertyRangeManager _propertyRangeManager;
/// <summary>
- /// Given a C++ custom control the dictionary allows us to find what CustomView it belongs to
+ /// Given a C++ control the dictionary allows us to find which C# control (View) it belongs to
/// </summary>
- private Dictionary<IntPtr, Dali.CustomView> _controlMap;
+ private Dictionary<IntPtr, Dali.View> _controlMap;
///<summary>
// Maps the name of a custom view to a create instance function
_getPropertyCallback = new GetPropertyDelegate (GetProperty);
_setPropertyCallback = new SetPropertyDelegate (SetProperty);
- _controlMap = new Dictionary<IntPtr, CustomView>();
+ _controlMap = new Dictionary<IntPtr, View>();
_constructorMap = new Dictionary<string, Func<CustomView>>();
_propertyRangeManager = new PropertyRangeManager();
}
/// <summary>
- /// Called directly from DALi C++ type registry to create a control (View) uses no marshalling.
+ /// Called directly from DALi C++ type registry to create a control (View) using no marshalling.
/// </summary>
/// <returns>Pointer to the Control (Views) handle </returns>
/// <param name="cPtrControlName"> C pointer to the Control (View) name</param>
{
// Create the control
CustomView newControl = controlConstructor ();
-
- // Store the mapping between this instance of the custom control and native part
- // We store a pointer to the RefObject for the control
- IntPtr cPtr = newControl.GetPtrfromActor();
- RefObject refObj = newControl.GetObjectPtr ();
- IntPtr refCptr = (IntPtr) RefObject.getCPtr(refObj);
-
- //Console.WriteLine ("________Storing ref object cptr in control map Hex: {0:X}", refCptr);
- Instance._controlMap.Add (refCptr , newControl );
-
- return cPtr; // return pointer to handle
+ return newControl.GetPtrfromActor(); // return pointer to handle
}
else
{
}
}
+ /// <summary>
+ /// Store the mapping between this instance of control (View) and native part.
+ /// </summary>
+ /// <param name="view"> The instance of control (View)</param>
+ public static void RegisterView( View view )
+ {
+ // We store a pointer to the RefObject for the control
+ RefObject refObj = view.GetObjectPtr();
+ IntPtr refCptr = (IntPtr) RefObject.getCPtr(refObj);
+
+ //Console.WriteLine ("________Storing ref object cptr in control map Hex: {0:X}", refCptr);
+ if ( !Instance._controlMap.ContainsKey(refCptr) )
+ {
+ Instance._controlMap.Add(refCptr, view );
+ }
+
+ return;
+ }
+
private static IntPtr GetProperty( IntPtr controlPtr, IntPtr propertyName )
{
string name = System.Runtime.InteropServices.Marshal.PtrToStringAnsi (propertyName);
}
}
- public static CustomView GetCustomViewFromActor( Actor actor )
+ public static View GetViewFromActor( Actor actor )
{
// we store a dictionary of ref-obects (C++ land) to custom views (C# land)
- Dali.CustomView view;
+ Dali.View view;
RefObject refObj = actor.GetObjectPtr ();
IntPtr refObjectPtr = (IntPtr) RefObject.getCPtr(refObj);
if ( Instance._controlMap.TryGetValue ( refObjectPtr, out view) )
{
-
- // call the get property function
-
return view;
}
else
/// {
/// 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>
- 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())
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);
private IntPtr GetPropertyValue ( IntPtr controlPtr, string propertyName)
{
// Get the C# control that maps to the C++ control
- Dali.CustomView view;
+ Dali.View view;
BaseHandle baseHandle = new BaseHandle (controlPtr, false);
if ( _controlMap.TryGetValue ( refObjectPtr, out view) )
{
-
// call the get property function
System.Object val = view.GetType ().GetProperty (propertyName).GetAccessors () [0].Invoke (view, null);
private void SetPropertyValue ( IntPtr controlPtr, string propertyName, IntPtr propertyValuePtr)
{
// Get the C# control that maps to the C++ control
- Dali.CustomView view;
+ Dali.View view;
//Console.WriteLine ("SetPropertyValue refObjectPtr = {0:X}", controlPtr);