update devel/master branch to 0.2.32
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / devel-src / PropertyRangeManager.cs
index d3e51f5..7560286 100755 (executable)
-using System;
+#define DOT_NET_CORE
+
+using System;
 using System.Runtime.InteropServices;
 using System.Collections.Generic;
-
-#if true
+#if (DOT_NET_CORE)
 using System.Reflection;
 #endif
 
 namespace Tizen.NUI
 {
-  /// <summary>
-  /// Helper class for calculating what property indexes should be assigned to C# View (view) classes.
-  /// </summary>
-  public class PropertyRangeManager
+    /// <summary>
+    /// Helper class for calculating what property indexes should be assigned to C# View (view) classes.
+    /// </summary>
+    internal class PropertyRangeManager
   {
     private Dictionary<String, PropertyRange > _propertyRange;
 
-    /// <summary>
-    /// Initializes a new instance of the <see cref="Tizen.NUI.PropertyRangeManager"/> class.
-    /// </summary>
-    public PropertyRangeManager ()
-    {
-      _propertyRange = new Dictionary<String, PropertyRange > ();
-    }
+        /// <summary>
+        /// Initializes a new instance of the <see cref="Tizen.NUI.PropertyRangeManager"/> class.
+        /// </summary>
+        public PropertyRangeManager()
+        {
+            _propertyRange = new Dictionary<String, PropertyRange>();
+        }
 
-    /// <summary>
-    /// Only called if a View has scriptable properties
-    /// </summary>
-    private PropertyRange RegisterView( string viewName, System.Type viewType )
-    {
-      PropertyRange range;
+        /// <summary>
+        /// Only called if a View has scriptable properties
+        /// </summary>
+        private PropertyRange RegisterView(string viewName, System.Type viewType)
+        {
+            PropertyRange range;
 
-      if ( _propertyRange.TryGetValue (viewName, out range) )
-      {
-        // already registered
-        return range;
-      }
+            if (_propertyRange.TryGetValue(viewName, out range))
+            {
+                // already registered
+                return range;
+            }
 
-      // Find out the event and animatable start indexes for the type
-      range = new PropertyRange();
+            // Find out the event and animatable start indexes for the type
+            range = new PropertyRange();
 
-      GetPropertyStartRange( viewType, ref range);
+            GetPropertyStartRange(viewType, ref range);
 
-      // add it to our dictionary
-      _propertyRange.Add( viewName, range );
+            // add it to our dictionary
+            _propertyRange.Add(viewName, range);
 
-      return range;
+            return range;
 
-     }
+        }
 
-    /// <summary>
-    /// Gets the index of the property.
-    /// Each property has to have unique index for this view type
-    /// </summary>
-    /// <returns>The property index.</returns>
-    /// <param name="viewName">View name</param>
-    /// <param name="viewType">View type</param>
-    /// <param name="type">Type.</param>
-    public int GetPropertyIndex( string viewName, System.Type viewType, ScriptableProperty.ScriptableType type )
-    {
+        /// <summary>
+        /// Gets the index of the property.
+        /// Each property has to have unique index for this view type
+        /// </summary>
+        /// <returns>The property index.</returns>
+        /// <param name="viewName">View name</param>
+        /// <param name="viewType">View type</param>
+        /// <param name="type">Type.</param>
+        public int GetPropertyIndex(string viewName, System.Type viewType, ScriptableProperty.ScriptableType type)
+        {
 
-      PropertyRange range;
+            PropertyRange range;
 
-      if (!  _propertyRange.TryGetValue (viewName, out range) )
-      {
-         // view not found, register it now
-          range = RegisterView( viewName, viewType);
-      }
+            if (!_propertyRange.TryGetValue(viewName, out range))
+            {
+                // view not found, register it now
+                range = RegisterView(viewName, viewType);
+            }
 
-      int index =  range.GetNextFreePropertyIndex ( type );
+            int index = range.GetNextFreePropertyIndex(type);
 
-      // update the dictionary
-      _propertyRange[viewName]=range;
+            // update the dictionary
+            _propertyRange[viewName] = range;
 
-      return index;
+            return index;
 
-    }
+        }
 
-    ///<summary>
-    /// We calculate the start property indices, based on the type and it's class  heirachy, e.g. DateView (70,000)- > Spin (60,000) -> View (50,000)
-    /// </summary>
-    private void GetPropertyStartRange( System.Type viewType, ref PropertyRange range )
-    {
-      const int maxCountPerDerivation = 1000; // For child and animtable properties we use a gap of 1000 between each
-      // views property range in the heirachy
-
-      // custom views start there property index, at view_PROPERTY_END_INDEX
-      // we add 1000, just incase View class (our C# custom view base) starts using scriptable properties
-      int startEventPropertyIndex = (int)View.PropertyRange.CONTROL_PROPERTY_END_INDEX+maxCountPerDerivation;
-
-      // for animatable properties current range starts at ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX,
-      // we add 1000, just incase View class starts using animatable properties
-      int startAnimatablePropertyIndex = (int)Tizen.NUI.PropertyRanges.ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX +maxCountPerDerivation;\r
-\r
-#if true
-            while (viewType.GetTypeInfo().BaseType.Name != "CustomView")   // custom view is our C# view base class. we don't go any deeper.\r
-            {\r
-                // for every base class increase property start index\r
-                startEventPropertyIndex += (int)Tizen.NUI.PropertyRanges.DEFAULT_PROPERTY_MAX_COUNT_PER_DERIVATION; // DALi uses 10,000\r
-                startAnimatablePropertyIndex += maxCountPerDerivation;\r
-\r
-                Tizen.Log.Debug("NUI-APP", "getStartPropertyIndex =  " + viewType.Name + "current index " + startEventPropertyIndex);\r
-                viewType = viewType.GetTypeInfo().BaseType;\r
-            }\r
+        ///<summary>
+        /// We calculate the start property indices, based on the type and it's class  heirachy, e.g. DateView (70,000)- > Spin (60,000) -> View (50,000)
+        /// </summary>
+        private void GetPropertyStartRange(System.Type viewType, ref PropertyRange range)
+        {
+            const int maxCountPerDerivation = 1000; // For child and animtable properties we use a gap of 1000 between each
+                                                    // views property range in the heirachy
+
+            // custom views start there property index, at view_PROPERTY_END_INDEX
+            // we add 1000, just incase View class (our C# custom view base) starts using scriptable properties
+            int startEventPropertyIndex = (int)View.PropertyRange.CONTROL_PROPERTY_END_INDEX + maxCountPerDerivation;
+
+            // for animatable properties current range starts at ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX,
+            // we add 1000, just incase View class starts using animatable properties
+            int startAnimatablePropertyIndex = (int)Tizen.NUI.PropertyRanges.ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + maxCountPerDerivation;
+
+#if (DOT_NET_CORE)
+            while ( viewType.GetTypeInfo().BaseType.Name != "CustomView" )   // custom view is our C# view base class. we don't go any deeper.
 #else
-      //original
-      while ( viewType.BaseType.Name != "CustomView" )   // custom view is our C# view base class. we don't go any deeper.
-      {
-        // for every base class increase property start index
-        startEventPropertyIndex += (int)Tizen.NUI.PropertyRanges.DEFAULT_PROPERTY_MAX_COUNT_PER_DERIVATION; // DALi uses 10,000
-        startAnimatablePropertyIndex += maxCountPerDerivation;
-
-        ////Console.WriteLine ("getStartPropertyIndex =  " + viewType.Name +"current index " + startEventPropertyIndex);
-        viewType = viewType.BaseType;
-      }
+            while (viewType.BaseType.Name != "CustomView")   // custom view is our C# view base class. we don't go any deeper.
 #endif
-\r
+            {
+                // for every base class increase property start index
+                startEventPropertyIndex += (int)Tizen.NUI.PropertyRanges.DEFAULT_PROPERTY_MAX_COUNT_PER_DERIVATION; // DALi uses 10,000
+                startAnimatablePropertyIndex += maxCountPerDerivation;
+
+                //Console.WriteLine ("getStartPropertyIndex =  " + viewType.Name +"current index " + startEventPropertyIndex);
+#if (DOT_NET_CORE)
+                viewType = viewType.GetTypeInfo().BaseType;
+#else
+                viewType = viewType.BaseType;
+#endif
+            }
+
             range.startEventIndex = startEventPropertyIndex;
-      range.lastUsedEventIndex = startEventPropertyIndex;
+            range.lastUsedEventIndex = startEventPropertyIndex;
 
-      range.startAnimationIndex = startAnimatablePropertyIndex;
-      range.lastUsedAnimationIndex = startAnimatablePropertyIndex;
-
-    }
+            range.startAnimationIndex = startAnimatablePropertyIndex;
+            range.lastUsedAnimationIndex = startAnimatablePropertyIndex;
 
+        }
 
-    public struct PropertyRange
-    {
 
-      public int GetNextFreePropertyIndex( ScriptableProperty.ScriptableType type)
-      {
-        if ( type == ScriptableProperty.ScriptableType.Default )
-        {
-           lastUsedEventIndex++;
-           return lastUsedEventIndex;
-        }
-        else
+        public struct PropertyRange
         {
-          lastUsedAnimationIndex++;
-          return lastUsedAnimationIndex ;
-        }
-      }
 
+            public int GetNextFreePropertyIndex(ScriptableProperty.ScriptableType type)
+            {
+                if (type == ScriptableProperty.ScriptableType.Default)
+                {
+                    lastUsedEventIndex++;
+                    return lastUsedEventIndex;
+                }
+                else
+                {
+                    lastUsedAnimationIndex++;
+                    return lastUsedAnimationIndex;
+                }
+            }
 
-      public int startEventIndex;    /// start of the property range
-      public int lastUsedEventIndex;    /// last used of the property index
 
-      public int startAnimationIndex;  /// start of the property range
-      public int lastUsedAnimationIndex; /// last used of the property index
-    };
+            public int startEventIndex;    /// start of the property range
+            public int lastUsedEventIndex;    /// last used of the property index
 
+            public int startAnimationIndex;  /// start of the property range
+            public int lastUsedAnimationIndex; /// last used of the property index
+        };
 
 
-}
+
+    }
 }