Explorar o código

Adapted inspectables to new styling logic

marco.bellan %!s(int64=9) %!d(string=hai) anos
pai
achega
52f7046bb3

+ 1 - 1
Source/MBansheeEditor/Windows/Inspector/InspectableArray.cs

@@ -318,7 +318,7 @@ namespace BansheeEditor
 
 
                 string entryPath = arrayParent.Path + "[" + SeqIndex + "]";
                 string entryPath = arrayParent.Path + "[" + SeqIndex + "]";
                 field = CreateInspectable(arrayParent.Inspector, SeqIndex + ".", entryPath, 0, Depth + 1,
                 field = CreateInspectable(arrayParent.Inspector, SeqIndex + ".", entryPath, 0, Depth + 1,
-                    new InspectableFieldLayout(layout), property);
+                    new InspectableFieldLayout(layout), property, new InspectableFieldStyleInfo());
 
 
                 return field.GetTitleLayout();
                 return field.GetTitleLayout();
             }
             }

+ 2 - 2
Source/MBansheeEditor/Windows/Inspector/InspectableDictionary.cs

@@ -377,7 +377,7 @@ namespace BansheeEditor
 
 
                 string entryPath = dictParent.Path + "Key[" + RowIdx + "]";
                 string entryPath = dictParent.Path + "Key[" + RowIdx + "]";
                 fieldKey = CreateInspectable(dictParent.Inspector, "Key", entryPath, 0, Depth + 1,
                 fieldKey = CreateInspectable(dictParent.Inspector, "Key", entryPath, 0, Depth + 1,
-                    new InspectableFieldLayout(layout), property);
+                    new InspectableFieldLayout(layout), property, new InspectableFieldStyleInfo());
 
 
                 return fieldKey.GetTitleLayout();
                 return fieldKey.GetTitleLayout();
             }
             }
@@ -390,7 +390,7 @@ namespace BansheeEditor
 
 
                 string entryPath = dictParent.Path + "Value[" + RowIdx + "]";
                 string entryPath = dictParent.Path + "Value[" + RowIdx + "]";
                 fieldValue = CreateInspectable(dictParent.Inspector, "Value", entryPath, 0, Depth + 1,
                 fieldValue = CreateInspectable(dictParent.Inspector, "Value", entryPath, 0, Depth + 1,
-                    new InspectableFieldLayout(layout), property);
+                    new InspectableFieldLayout(layout), property, new InspectableFieldStyleInfo());
             }
             }
 
 
             /// <inheritdoc/>
             /// <inheritdoc/>

+ 7 - 11
Source/MBansheeEditor/Windows/Inspector/InspectableField.cs

@@ -134,7 +134,7 @@ namespace BansheeEditor
         /// <returns>Inspectable field implementation that can be used for displaying the GUI for a serializable property
         /// <returns>Inspectable field implementation that can be used for displaying the GUI for a serializable property
         ///          of the provided type.</returns>
         ///          of the provided type.</returns>
         public static InspectableField CreateInspectable(Inspector parent, string title, string path, int layoutIndex, 
         public static InspectableField CreateInspectable(Inspector parent, string title, string path, int layoutIndex, 
-            int depth, InspectableFieldLayout layout, SerializableProperty property, InspectableFieldStyle[] style = null)
+            int depth, InspectableFieldLayout layout, SerializableProperty property, InspectableFieldStyleInfo style)
         {
         {
             InspectableField field = null;
             InspectableField field = null;
 
 
@@ -145,30 +145,26 @@ namespace BansheeEditor
             }
             }
             else
             else
             {
             {
-                InspectableFieldRangeStyle rangeInfo = null;
-
-                if (style != null)
-                    rangeInfo = InspectableFieldStyle.FindStyle<InspectableFieldRangeStyle>(style);
                 switch (property.Type)
                 switch (property.Type)
                 {
                 {
                     case SerializableProperty.FieldType.Int:
                     case SerializableProperty.FieldType.Int:
-                        if (rangeInfo == null)
+                        if (style.RangeStyle == null)
                         {
                         {
-                            field = new InspectableInt(parent, title, path, depth, layout, property);
+                            field = new InspectableInt(parent, title, path, depth, layout, property, style);
                         }
                         }
                         else
                         else
                         {
                         {
-                            field = new InspectableRangedInt(parent, title, path, depth, layout, property, rangeInfo);
+                            field = new InspectableRangedInt(parent, title, path, depth, layout, property, style);
                         }
                         }
                         break;
                         break;
                     case SerializableProperty.FieldType.Float:
                     case SerializableProperty.FieldType.Float:
-                        if (rangeInfo == null)
+                        if (style.RangeStyle == null)
                         {
                         {
-                            field = new InspectableFloat(parent, title, path, depth, layout, property);
+                            field = new InspectableFloat(parent, title, path, depth, layout, property, style);
                         }
                         }
                         else
                         else
                         {
                         {
-                            field = new InspectableRangedFloat(parent, title, path, depth, layout, property, rangeInfo);
+                            field = new InspectableRangedFloat(parent, title, path, depth, layout, property, style);
                         }
                         }
                         break;
                         break;
                     case SerializableProperty.FieldType.Bool:
                     case SerializableProperty.FieldType.Bool:

+ 6 - 2
Source/MBansheeEditor/Windows/Inspector/InspectableFloat.cs

@@ -15,6 +15,7 @@ namespace BansheeEditor
     {
     {
         private GUIFloatField guiFloatField;
         private GUIFloatField guiFloatField;
         private InspectableState state;
         private InspectableState state;
+        private InspectableFieldStyleInfo style;
 
 
         /// <summary>
         /// <summary>
         /// Creates a new inspectable float GUI for the specified property.
         /// Creates a new inspectable float GUI for the specified property.
@@ -26,11 +27,12 @@ namespace BansheeEditor
         ///                     contain other fields, in which case you should increase this value by one.</param>
         ///                     contain other fields, in which case you should increase this value by one.</param>
         /// <param name="layout">Parent layout that all the field elements will be added to.</param>
         /// <param name="layout">Parent layout that all the field elements will be added to.</param>
         /// <param name="property">Serializable property referencing the array whose contents to display.</param>
         /// <param name="property">Serializable property referencing the array whose contents to display.</param>
+        /// <param name="style">Contains information about the field style</param>
         public InspectableFloat(Inspector parent, string title, string path, int depth, InspectableFieldLayout layout, 
         public InspectableFloat(Inspector parent, string title, string path, int depth, InspectableFieldLayout layout, 
-            SerializableProperty property)
+            SerializableProperty property, InspectableFieldStyleInfo style)
             : base(parent, title, path, SerializableProperty.FieldType.Float, depth, layout, property)
             : base(parent, title, path, SerializableProperty.FieldType.Float, depth, layout, property)
         {
         {
-
+            this.style = style;
         }
         }
 
 
         /// <inheritoc/>
         /// <inheritoc/>
@@ -39,6 +41,8 @@ namespace BansheeEditor
             if (property != null)
             if (property != null)
             {
             {
                 guiFloatField = new GUIFloatField(new GUIContent(title));
                 guiFloatField = new GUIFloatField(new GUIContent(title));
+                if (style.StepStyle != null && style.StepStyle.Step != 0)
+                    guiFloatField.Step = style.StepStyle.Step;
                 guiFloatField.OnChanged += OnFieldValueChanged;
                 guiFloatField.OnChanged += OnFieldValueChanged;
                 guiFloatField.OnConfirmed += OnFieldValueConfirm;
                 guiFloatField.OnConfirmed += OnFieldValueConfirm;
                 guiFloatField.OnFocusLost += OnFieldValueConfirm;
                 guiFloatField.OnFocusLost += OnFieldValueConfirm;

+ 8 - 2
Source/MBansheeEditor/Windows/Inspector/InspectableInt.cs

@@ -1,5 +1,6 @@
 //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
 //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
 //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+
 using BansheeEngine;
 using BansheeEngine;
 
 
 namespace BansheeEditor
 namespace BansheeEditor
@@ -15,6 +16,7 @@ namespace BansheeEditor
     {
     {
         private GUIIntField guiIntField;
         private GUIIntField guiIntField;
         private InspectableState state;
         private InspectableState state;
+        private InspectableFieldStyleInfo style;
 
 
         /// <summary>
         /// <summary>
         /// Creates a new inspectable integer GUI for the specified property.
         /// Creates a new inspectable integer GUI for the specified property.
@@ -26,11 +28,12 @@ namespace BansheeEditor
         ///                     contain other fields, in which case you should increase this value by one.</param>
         ///                     contain other fields, in which case you should increase this value by one.</param>
         /// <param name="layout">Parent layout that all the field elements will be added to.</param>
         /// <param name="layout">Parent layout that all the field elements will be added to.</param>
         /// <param name="property">Serializable property referencing the array whose contents to display.</param>
         /// <param name="property">Serializable property referencing the array whose contents to display.</param>
+        /// <param name="style">Contains information about the field style</param>
         public InspectableInt(Inspector parent, string title, string path, int depth, InspectableFieldLayout layout, 
         public InspectableInt(Inspector parent, string title, string path, int depth, InspectableFieldLayout layout, 
-            SerializableProperty property)
+            SerializableProperty property, InspectableFieldStyleInfo style)
             : base(parent, title, path, SerializableProperty.FieldType.Int, depth, layout, property)
             : base(parent, title, path, SerializableProperty.FieldType.Int, depth, layout, property)
         {
         {
-
+            this.style = style;
         }
         }
 
 
         /// <inheritdoc/>
         /// <inheritdoc/>
@@ -39,6 +42,9 @@ namespace BansheeEditor
             if (property != null)
             if (property != null)
             {
             {
                 guiIntField = new GUIIntField(new GUIContent(title));
                 guiIntField = new GUIIntField(new GUIContent(title));
+                if (style.StepStyle != null && style.StepStyle.Step != 0)
+                    guiIntField.Step = (int)style.StepStyle.Step;
+                guiIntField.Step = (int)style.StepStyle.Step;
                 guiIntField.OnChanged += OnFieldValueChanged;
                 guiIntField.OnChanged += OnFieldValueChanged;
                 guiIntField.OnConfirmed += OnFieldValueConfirm;
                 guiIntField.OnConfirmed += OnFieldValueConfirm;
                 guiIntField.OnFocusLost += OnFieldValueConfirm;
                 guiIntField.OnFocusLost += OnFieldValueConfirm;

+ 1 - 1
Source/MBansheeEditor/Windows/Inspector/InspectableList.cs

@@ -291,7 +291,7 @@ namespace BansheeEditor
 
 
                 string entryPath = listParent.Path + "[" + SeqIndex + "]";
                 string entryPath = listParent.Path + "[" + SeqIndex + "]";
                 field = CreateInspectable(listParent.Inspector, SeqIndex + ".", entryPath, 0, Depth + 1,
                 field = CreateInspectable(listParent.Inspector, SeqIndex + ".", entryPath, 0, Depth + 1,
-                    new InspectableFieldLayout(layout), property);
+                    new InspectableFieldLayout(layout), property, new InspectableFieldStyleInfo());
 
 
                 return field.GetTitleLayout();
                 return field.GetTitleLayout();
             }
             }

+ 4 - 4
Source/MBansheeEditor/Windows/Inspector/InspectableRangedField.cs

@@ -17,7 +17,7 @@ namespace BansheeEditor
     /// </summary>
     /// </summary>
     public abstract class InspectableRangedField : InspectableField
     public abstract class InspectableRangedField : InspectableField
     {
     {
-        protected InspectableFieldRangeStyle rangeStyle;
+        protected InspectableFieldStyleInfo style;
         /// <summary>
         /// <summary>
         /// Creates a new inspectable field GUI for the specified property.
         /// Creates a new inspectable field GUI for the specified property.
         /// </summary>
         /// </summary>
@@ -29,11 +29,11 @@ namespace BansheeEditor
         ///                     contain other fields, in which case you should increase this value by one.</param>
         ///                     contain other fields, in which case you should increase this value by one.</param>
         /// <param name="layout">Parent layout that all the field elements will be added to.</param>
         /// <param name="layout">Parent layout that all the field elements will be added to.</param>
         /// <param name="property">Serializable property referencing the array whose contents to display.</param>
         /// <param name="property">Serializable property referencing the array whose contents to display.</param>
-        /// <param name="rangeStyle">Information about the range of the field</param>
+        /// <param name="style">Contains information about the field style</param>
         public InspectableRangedField(Inspector parent, string title, string path, SerializableProperty.FieldType type,
         public InspectableRangedField(Inspector parent, string title, string path, SerializableProperty.FieldType type,
-            int depth, InspectableFieldLayout layout, SerializableProperty property, InspectableFieldRangeStyle rangeStyle) : base(parent, title, path, type, depth, layout, property)
+            int depth, InspectableFieldLayout layout, SerializableProperty property, InspectableFieldStyleInfo style) : base(parent, title, path, type, depth, layout, property)
         {
         {
-            this.rangeStyle = rangeStyle;
+            this.style = style;
         }
         }
     }
     }
 
 

+ 6 - 6
Source/MBansheeEditor/Windows/Inspector/InspectableRangedFloat.cs

@@ -26,10 +26,10 @@ namespace BansheeEditor
         ///                     contain other fields, in which case you should increase this value by one.</param>
         ///                     contain other fields, in which case you should increase this value by one.</param>
         /// <param name="layout">Parent layout that all the field elements will be added to.</param>
         /// <param name="layout">Parent layout that all the field elements will be added to.</param>
         /// <param name="property">Serializable property referencing the array whose contents to display.</param>
         /// <param name="property">Serializable property referencing the array whose contents to display.</param>
-        /// <param name="rangeStyle">Information about the range of the field</param>
+        /// <param name="style">Contains information about the field style</param>
         public InspectableRangedFloat(Inspector parent, string title, string path, int depth, InspectableFieldLayout layout,
         public InspectableRangedFloat(Inspector parent, string title, string path, int depth, InspectableFieldLayout layout,
-            SerializableProperty property, InspectableFieldRangeStyle rangeStyle)
-            : base(parent, title, path, SerializableProperty.FieldType.Float, depth, layout, property, rangeStyle)
+            SerializableProperty property, InspectableFieldStyleInfo style)
+            : base(parent, title, path, SerializableProperty.FieldType.Float, depth, layout, property, style)
         {
         {
 
 
         }
         }
@@ -39,9 +39,9 @@ namespace BansheeEditor
         {
         {
             if (property != null)
             if (property != null)
             {
             {
-                guiFloatField = new GUISliderField(rangeStyle.Min, rangeStyle.Max, new GUIContent(title));
-                if (rangeStyle.Step != 0)
-                    guiFloatField.Step = rangeStyle.Step;
+                guiFloatField = new GUISliderField(style.RangeStyle.Min, style.RangeStyle.Max, new GUIContent(title));
+                if (style.StepStyle != null && style.StepStyle.Step != 0)
+                    guiFloatField.Step = style.StepStyle.Step;
                 guiFloatField.OnChanged += OnFieldValueChanged;
                 guiFloatField.OnChanged += OnFieldValueChanged;
                 guiFloatField.OnFocusLost += OnFieldValueConfirm;
                 guiFloatField.OnFocusLost += OnFieldValueConfirm;
 
 

+ 6 - 6
Source/MBansheeEditor/Windows/Inspector/InspectableRangedInt.cs

@@ -26,10 +26,10 @@ namespace BansheeEditor
         ///                     contain other fields, in which case you should increase this value by one.</param>
         ///                     contain other fields, in which case you should increase this value by one.</param>
         /// <param name="layout">Parent layout that all the field elements will be added to.</param>
         /// <param name="layout">Parent layout that all the field elements will be added to.</param>
         /// <param name="property">Serializable property referencing the array whose contents to display.</param>
         /// <param name="property">Serializable property referencing the array whose contents to display.</param>
-        /// <param name="rangeStyle">Information about the range of the field</param>
+        /// <param name="style">Information about the range of the field</param>
         public InspectableRangedInt(Inspector parent, string title, string path, int depth, InspectableFieldLayout layout,
         public InspectableRangedInt(Inspector parent, string title, string path, int depth, InspectableFieldLayout layout,
-            SerializableProperty property, InspectableFieldRangeStyle rangeStyle)
-            : base(parent, title, path, SerializableProperty.FieldType.Float, depth, layout, property, rangeStyle)
+            SerializableProperty property, InspectableFieldStyleInfo style)
+            : base(parent, title, path, SerializableProperty.FieldType.Float, depth, layout, property, style)
         {
         {
 
 
         }
         }
@@ -39,9 +39,9 @@ namespace BansheeEditor
         {
         {
             if (property != null)
             if (property != null)
             {
             {
-                guiIntField = new GUISliderField(rangeStyle.Min, rangeStyle.Max, new GUIContent(title));
-                if (rangeStyle.Step != 0)
-                    guiIntField.Step = rangeStyle.Step;
+                guiIntField = new GUISliderField(style.RangeStyle.Min, style.RangeStyle.Max, new GUIContent(title));
+                if (style.StepStyle != null && style.StepStyle.Step != 0)
+                    guiIntField.Step = style.StepStyle.Step;
                 guiIntField.OnChanged += OnFieldValueChanged;
                 guiIntField.OnChanged += OnFieldValueChanged;
                 guiIntField.OnFocusLost += OnFieldValueConfirm;
                 guiIntField.OnFocusLost += OnFieldValueConfirm;