Browse Source

Dictionary GUI fixed and working
Various fixed to GUI skin inspector

BearishSun 10 years ago
parent
commit
119c07552d

+ 49 - 22
MBansheeEditor/GUI/GUIDictionaryField.cs

@@ -107,18 +107,21 @@ namespace BansheeEditor
                 GUITexture inspectorContentBg = new GUITexture(null, bgPanelStyle);
                 GUITexture inspectorContentBg = new GUITexture(null, bgPanelStyle);
                 backgroundPanel.AddElement(inspectorContentBg);
                 backgroundPanel.AddElement(inspectorContentBg);
 
 
-                editRow = new T();
-                editRow.BuildGUI(this, guiContentLayout, numRows, depth);
-                editRow.Enabled = false;
-
+                // Hidden dependency: BuildGUI must be called after all elements are 
+                // in the dictionary so we do it in two steps
                 for (int i = 0; i < numRows; i++)
                 for (int i = 0; i < numRows; i++)
                 {
                 {
                     GUIDictionaryFieldRow newRow = new T();
                     GUIDictionaryFieldRow newRow = new T();
-                    newRow.BuildGUI(this, guiContentLayout, i, depth);
-
                     rows.Add(i, newRow);
                     rows.Add(i, newRow);
                 }
                 }
 
 
+                editRow = new T();
+                editRow.BuildGUI(this, guiContentLayout, numRows, depth + 1);
+                editRow.Enabled = false;
+
+                for (int i = 0; i < numRows; i++)
+                    rows[i].BuildGUI(this, guiContentLayout, i, depth + 1);
+
                 ToggleFoldout(isExpanded);
                 ToggleFoldout(isExpanded);
             }
             }
         }
         }
@@ -143,13 +146,13 @@ namespace BansheeEditor
             for (int i = 0; i < rows.Count; i++)
             for (int i = 0; i < rows.Count; i++)
             {
             {
                 if (rows[i].Refresh())
                 if (rows[i].Refresh())
-                    rows[i].BuildGUI(this, guiContentLayout, i, depth);
+                    rows[i].BuildGUI(this, guiContentLayout, i, depth + 1);
             }
             }
 
 
             if (editRow != null && editRow.Enabled)
             if (editRow != null && editRow.Enabled)
             {
             {
                 if (editRow.Refresh())
                 if (editRow.Refresh())
-                    editRow.BuildGUI(this, guiContentLayout, rows.Count, depth);
+                    editRow.BuildGUI(this, guiContentLayout, rows.Count, depth + 1);
             }
             }
 
 
             return anythingModified;
             return anythingModified;
@@ -276,6 +279,14 @@ namespace BansheeEditor
         /// <param name="value">Value to assign to the element. Caller must ensure it is of valid type.</param>
         /// <param name="value">Value to assign to the element. Caller must ensure it is of valid type.</param>
         protected internal abstract void SetValue(object key, object value);
         protected internal abstract void SetValue(object key, object value);
 
 
+        /// <summary>
+        /// Updates both key and value of an existing entry.
+        /// </summary>
+        /// <param name="oldKey">Original key of the entry.</param>
+        /// <param name="newKey">New key of the entry.</param>
+        /// <param name="value">New value of the entry.</param>
+        protected internal abstract void EditEntry(object oldKey, object newKey, object value);
+
         /// <summary>
         /// <summary>
         /// Adds a new entry to the dictionary.
         /// Adds a new entry to the dictionary.
         /// </summary>
         /// </summary>
@@ -335,8 +346,8 @@ namespace BansheeEditor
             {
             {
                 DialogBox.Open(
                 DialogBox.Open(
                     new LocEdString("Edit in progress."),
                     new LocEdString("Edit in progress."),
-                    new LocEdString("You are editing the entry with key \"" + editKey + "\". You cannot add a row " + 
-                        "before applying or discarding those changes. Do you wish to apply those changes first?"),
+                    new LocEdString("You are editing the entry with key \"" + editKey + "\". You cannot add a row " +
+                                    "before applying or discarding those changes. Do you wish to apply those changes first?"),
                     DialogBox.Type.YesNoCancel,
                     DialogBox.Type.YesNoCancel,
                     x =>
                     x =>
                     {
                     {
@@ -354,7 +365,12 @@ namespace BansheeEditor
                     });
                     });
             }
             }
             else
             else
+            {
+                if (!isExpanded)
+                    ToggleFoldout(true);
+
                 StartAdd();
                 StartAdd();
+            }
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -486,9 +502,11 @@ namespace BansheeEditor
         /// new pair in a temporary row before inserting them into the dictionary. Caller must ensure no edit operation is 
         /// new pair in a temporary row before inserting them into the dictionary. Caller must ensure no edit operation is 
         /// already in progress.
         /// already in progress.
         /// </summary>
         /// </summary>
-        /// <param name="key">Key of the row to clone.</param>
-        private void StartClone(object key)
+        /// <param name="rowIdx">Sequential row index of the entry to clone.</param>
+        private void StartClone(int rowIdx)
         {
         {
+            object key = GetKey(rowIdx);
+
             editKey = SerializableUtility.Clone(key);
             editKey = SerializableUtility.Clone(key);
             editValue = SerializableUtility.Clone(GetValue(key));
             editValue = SerializableUtility.Clone(GetValue(key));
             editOriginalKey = null;
             editOriginalKey = null;
@@ -510,7 +528,7 @@ namespace BansheeEditor
             if (!IsEditInProgress())
             if (!IsEditInProgress())
                 return true;
                 return true;
 
 
-            if (Contains(editKey))
+            if (Contains(editKey) && (editOriginalKey == null || !editOriginalKey.Equals(editKey)))
             {
             {
                 DialogBox.Open(
                 DialogBox.Open(
                     new LocEdString("Key already exists."),
                     new LocEdString("Key already exists."),
@@ -521,9 +539,6 @@ namespace BansheeEditor
             }
             }
             else
             else
             {
             {
-                if (editOriginalKey != null)
-                    RemoveEntry(editOriginalKey);
-
                 if (IsTemporaryRow(editRowIdx))
                 if (IsTemporaryRow(editRowIdx))
                 {
                 {
                     editRow.EditMode = false;
                     editRow.EditMode = false;
@@ -534,7 +549,11 @@ namespace BansheeEditor
                     rows[editRowIdx].EditMode = false;
                     rows[editRowIdx].EditMode = false;
                 }
                 }
 
 
-                AddEntry(editKey, editValue);
+                if (editOriginalKey != null) // Editing
+                    EditEntry(editOriginalKey, editKey, editValue);
+                else // Adding/Cloning
+                    AddEntry(editKey, editValue);
+
                 editKey = CreateKey();
                 editKey = CreateKey();
                 editValue = CreateValue();
                 editValue = CreateValue();
                 editOriginalKey = null;
                 editOriginalKey = null;
@@ -618,13 +637,12 @@ namespace BansheeEditor
             where RowType : GUIDictionaryFieldRow, new()
             where RowType : GUIDictionaryFieldRow, new()
         {
         {
             this.dictionary = dictionary;
             this.dictionary = dictionary;
+            UpdateKeys();
 
 
             if (dictionary != null)
             if (dictionary != null)
                 base.Update<RowType>(title, false, dictionary.Count, layout, depth);
                 base.Update<RowType>(title, false, dictionary.Count, layout, depth);
             else
             else
                 base.Update<RowType>(title, true, 0, layout, depth);
                 base.Update<RowType>(title, true, 0, layout, depth);
-
-            UpdateKeys();
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -674,6 +692,18 @@ namespace BansheeEditor
             return dictionary.ContainsKey((Key)key); ;
             return dictionary.ContainsKey((Key)key); ;
         }
         }
 
 
+        /// <inheritdoc/>
+        protected internal override void EditEntry(object oldKey, object newKey, object value)
+        {
+            dictionary.Remove((Key)oldKey);
+            dictionary[(Key)newKey] = (Value)value;
+
+            if (OnChanged != null)
+                OnChanged(dictionary);
+
+            UpdateKeys();
+        }
+
         /// <inheritdoc/>
         /// <inheritdoc/>
         protected internal override void AddEntry(object key, object value)
         protected internal override void AddEntry(object key, object value)
         {
         {
@@ -810,10 +840,7 @@ namespace BansheeEditor
                 rowLayout = parentLayout.AddLayoutY();
                 rowLayout = parentLayout.AddLayoutY();
 
 
             if (keyRowLayout == null)
             if (keyRowLayout == null)
-            {
                 keyRowLayout = rowLayout.AddLayoutX();
                 keyRowLayout = rowLayout.AddLayoutX();
-                rowLayout.AddSpace(7);
-            }
 
 
             if (keyLayout == null)
             if (keyLayout == null)
                 keyLayout = keyRowLayout.AddLayoutY();
                 keyLayout = keyRowLayout.AddLayoutY();

+ 10 - 0
MBansheeEditor/Inspector/InspectableDictionary.cs

@@ -174,6 +174,16 @@ namespace BansheeEditor
                 return dictionary.Contains(key); ;
                 return dictionary.Contains(key); ;
             }
             }
 
 
+            /// <inheritdoc/>
+            protected internal override void EditEntry(object oldKey, object newKey, object value)
+            {
+                IDictionary dictionary = property.GetValue<IDictionary>();
+                dictionary.Remove(oldKey);
+                dictionary.Add(newKey, value);
+
+                UpdateKeys();
+            }
+
             /// <inheritdoc/>
             /// <inheritdoc/>
             protected internal override void AddEntry(object key, object value)
             protected internal override void AddEntry(object key, object value)
             {
             {

+ 112 - 55
MBansheeEditor/Inspectors/GUISkinInspector.cs

@@ -100,7 +100,7 @@ namespace BansheeEditor
             protected override GUILayoutX CreateKeyGUI(GUILayoutY layout)
             protected override GUILayoutX CreateKeyGUI(GUILayoutY layout)
             {
             {
                 GUILayoutX titleLayout = layout.AddLayoutX();
                 GUILayoutX titleLayout = layout.AddLayoutX();
-                keyField = new GUITextField(new LocEdString("Style name"));
+                keyField = new GUITextField(new LocEdString("Name"));
                 titleLayout.AddElement(keyField);
                 titleLayout.AddElement(keyField);
 
 
                 keyField.OnChanged += SetKey;
                 keyField.OnChanged += SetKey;
@@ -112,7 +112,11 @@ namespace BansheeEditor
             protected override void CreateValueGUI(GUILayoutY layout)
             protected override void CreateValueGUI(GUILayoutY layout)
             {
             {
                 GUIElementStyle value = GetValue<GUIElementStyle>();
                 GUIElementStyle value = GetValue<GUIElementStyle>();
-                valueField = new GUIElementStyleGUI(value, layout);
+
+                if (valueField == null)
+                    valueField = new GUIElementStyleGUI();
+
+                valueField.BuildGUI(value, layout, depth);
             }
             }
 
 
             /// <inheritdoc/>
             /// <inheritdoc/>
@@ -130,6 +134,8 @@ namespace BansheeEditor
         /// </summary>
         /// </summary>
         private class GUIElementStyleGUI
         private class GUIElementStyleGUI
         {
         {
+            private const int IndentAmount = 5;
+
             private GUIResourceField fontField;
             private GUIResourceField fontField;
             private GUIIntField fontSizeField;
             private GUIIntField fontSizeField;
             private GUIEnumField horzAlignField;
             private GUIEnumField horzAlignField;
@@ -161,19 +167,58 @@ namespace BansheeEditor
             private GUIIntField maxHeightField;
             private GUIIntField maxHeightField;
 
 
             private GUIElementStyle style;
             private GUIElementStyle style;
+            private bool isExpanded;
 
 
             /// <summary>
             /// <summary>
             /// Creates a new GUI element style GUI.
             /// Creates a new GUI element style GUI.
             /// </summary>
             /// </summary>
+            public GUIElementStyleGUI()
+            {
+                normalGUI = new GUIElementStateStyleGUI();
+                hoverGUI = new GUIElementStateStyleGUI();
+                activeGUI = new GUIElementStateStyleGUI();
+                focusedGUI = new GUIElementStateStyleGUI();
+                normalOnGUI = new GUIElementStateStyleGUI();
+                hoverOnGUI = new GUIElementStateStyleGUI();
+                activeOnGUI = new GUIElementStateStyleGUI();
+                focusedOnGUI = new GUIElementStateStyleGUI();
+            }
+
+            /// <summary>
+            /// Builds GUI for the specified GUI element style.
+            /// </summary>
             /// <param name="style">Style to display in the GUI.</param>
             /// <param name="style">Style to display in the GUI.</param>
             /// <param name="layout">Layout to append the GUI elements to.</param>
             /// <param name="layout">Layout to append the GUI elements to.</param>
-            public GUIElementStyleGUI(GUIElementStyle style, GUILayout layout)
+            /// <param name="depth">Determines the depth at which the element is rendered.</param>
+            public void BuildGUI(GUIElementStyle style, GUILayout layout, int depth)
             {
             {
                 this.style = style;
                 this.style = style;
 
 
                 if (style == null)
                 if (style == null)
                     return;
                     return;
 
 
+                short backgroundDepth = (short)(Inspector.START_BACKGROUND_DEPTH - depth - 1);
+                string bgPanelStyle = depth % 2 == 0
+                    ? EditorStyles.InspectorContentBgAlternate
+                    : EditorStyles.InspectorContentBg;
+
+                GUIToggle foldout = new GUIToggle(new LocEdString("Style"), EditorStyles.Foldout);
+                GUITexture inspectorContentBg = new GUITexture(null, bgPanelStyle);
+
+                layout.AddElement(foldout);
+                GUIPanel panel = layout.AddPanel();
+                GUIPanel backgroundPanel = panel.AddPanel(backgroundDepth);
+                
+                backgroundPanel.AddElement(inspectorContentBg);
+
+                GUILayoutX guiIndentLayoutX = panel.AddLayoutX();
+                guiIndentLayoutX.AddSpace(IndentAmount);
+                GUILayoutY guiIndentLayoutY = guiIndentLayoutX.AddLayoutY();
+                guiIndentLayoutY.AddSpace(IndentAmount);
+                GUILayoutY contentLayout = guiIndentLayoutY.AddLayoutY();
+                guiIndentLayoutY.AddSpace(IndentAmount);
+                guiIndentLayoutX.AddSpace(IndentAmount);
+
                 fontField = new GUIResourceField(typeof (Font), new LocEdString("Font"));
                 fontField = new GUIResourceField(typeof (Font), new LocEdString("Font"));
                 fontSizeField = new GUIIntField(new LocEdString("Font size"));
                 fontSizeField = new GUIIntField(new LocEdString("Font size"));
                 horzAlignField = new GUIEnumField(typeof (TextHorzAlign), new LocEdString("Horizontal alignment"));
                 horzAlignField = new GUIEnumField(typeof (TextHorzAlign), new LocEdString("Horizontal alignment"));
@@ -181,25 +226,25 @@ namespace BansheeEditor
                 imagePositionField = new GUIEnumField(typeof(GUIImagePosition), new LocEdString("Image position"));
                 imagePositionField = new GUIEnumField(typeof(GUIImagePosition), new LocEdString("Image position"));
                 wordWrapField = new GUIToggleField(new LocEdString("Word wrap"));
                 wordWrapField = new GUIToggleField(new LocEdString("Word wrap"));
 
 
-                layout.AddElement(fontField);
-                layout.AddElement(fontSizeField);
-                layout.AddElement(horzAlignField);
-                layout.AddElement(vertAlignField);
-                layout.AddElement(imagePositionField);
-                layout.AddElement(wordWrapField);
-
-                normalGUI = new GUIElementStateStyleGUI(new LocEdString("Normal"), style.Normal, layout);
-                hoverGUI = new GUIElementStateStyleGUI(new LocEdString("Hover"), style.Hover, layout);
-                activeGUI = new GUIElementStateStyleGUI(new LocEdString("Active"), style.Active, layout);
-                focusedGUI = new GUIElementStateStyleGUI(new LocEdString("Focused"), style.Focused, layout);
-                normalOnGUI = new GUIElementStateStyleGUI(new LocEdString("NormalOn"), style.NormalOn, layout);
-                hoverOnGUI = new GUIElementStateStyleGUI(new LocEdString("HoverOn"), style.HoverOn, layout);
-                activeOnGUI = new GUIElementStateStyleGUI(new LocEdString("ActiveOn"), style.ActiveOn, layout);
-                focusedOnGUI = new GUIElementStateStyleGUI(new LocEdString("FocusedOn"), style.FocusedOn, layout);
-
-                borderGUI = new RectOffsetGUI(new LocEdString("Border"), style.Border, layout);
-                marginsGUI = new RectOffsetGUI(new LocEdString("Margins"), style.Margins, layout);
-                contentOffsetGUI = new RectOffsetGUI(new LocEdString("Content offset"), style.ContentOffset, layout);
+                contentLayout.AddElement(fontField);
+                contentLayout.AddElement(fontSizeField);
+                contentLayout.AddElement(horzAlignField);
+                contentLayout.AddElement(vertAlignField);
+                contentLayout.AddElement(imagePositionField);
+                contentLayout.AddElement(wordWrapField);
+
+                normalGUI.BuildGUI(new LocEdString("Normal"), style.Normal, contentLayout);
+                hoverGUI.BuildGUI(new LocEdString("Hover"), style.Hover, contentLayout);
+                activeGUI.BuildGUI(new LocEdString("Active"), style.Active, contentLayout);
+                focusedGUI.BuildGUI(new LocEdString("Focused"), style.Focused, contentLayout);
+                normalOnGUI.BuildGUI(new LocEdString("NormalOn"), style.NormalOn, contentLayout);
+                hoverOnGUI.BuildGUI(new LocEdString("HoverOn"), style.HoverOn, contentLayout);
+                activeOnGUI.BuildGUI(new LocEdString("ActiveOn"), style.ActiveOn, contentLayout);
+                focusedOnGUI.BuildGUI(new LocEdString("FocusedOn"), style.FocusedOn, contentLayout);
+
+                borderGUI = new RectOffsetGUI(new LocEdString("Border"), style.Border, contentLayout);
+                marginsGUI = new RectOffsetGUI(new LocEdString("Margins"), style.Margins, contentLayout);
+                contentOffsetGUI = new RectOffsetGUI(new LocEdString("Content offset"), style.ContentOffset, contentLayout);
 
 
                 fixedWidthField = new GUIToggleField(new LocEdString("Fixed width"));
                 fixedWidthField = new GUIToggleField(new LocEdString("Fixed width"));
                 widthField = new GUIIntField(new LocEdString("Width"));
                 widthField = new GUIIntField(new LocEdString("Width"));
@@ -211,15 +256,20 @@ namespace BansheeEditor
                 minHeightField = new GUIIntField(new LocEdString("Min. height"));
                 minHeightField = new GUIIntField(new LocEdString("Min. height"));
                 maxHeightField = new GUIIntField(new LocEdString("Max. height"));
                 maxHeightField = new GUIIntField(new LocEdString("Max. height"));
 
 
-                layout.AddElement(fixedWidthField);
-                layout.AddElement(widthField);
-                layout.AddElement(minWidthField);
-                layout.AddElement(maxWidthField);
+                contentLayout.AddElement(fixedWidthField);
+                contentLayout.AddElement(widthField);
+                contentLayout.AddElement(minWidthField);
+                contentLayout.AddElement(maxWidthField);
 
 
-                layout.AddElement(fixedHeightField);
-                layout.AddElement(heightField);
-                layout.AddElement(minHeightField);
-                layout.AddElement(maxHeightField);
+                contentLayout.AddElement(fixedHeightField);
+                contentLayout.AddElement(heightField);
+                contentLayout.AddElement(minHeightField);
+                contentLayout.AddElement(maxHeightField);
+
+                foldout.OnToggled += x =>
+                {
+                    panel.Active = x;
+                };
 
 
                 fontField.OnChanged += x => style.Font = (Font)x;
                 fontField.OnChanged += x => style.Font = (Font)x;
                 fontSizeField.OnChanged += x => style.FontSize = x;
                 fontSizeField.OnChanged += x => style.FontSize = x;
@@ -241,27 +291,18 @@ namespace BansheeEditor
                 marginsGUI.OnChanged += x => style.Margins = x;
                 marginsGUI.OnChanged += x => style.Margins = x;
                 contentOffsetGUI.OnChanged += x => style.ContentOffset = x;
                 contentOffsetGUI.OnChanged += x => style.ContentOffset = x;
 
 
-                fixedWidthField.OnChanged += x =>
-                {
-                    widthField.Active = x;
-                    minWidthField.Active = !x;
-                    maxWidthField.Active = !x;
-                };
-
+                fixedWidthField.OnChanged += x => { style.FixedWidth = x; };
                 widthField.OnChanged += x => style.Width = x;
                 widthField.OnChanged += x => style.Width = x;
                 minWidthField.OnChanged += x => style.MinWidth = x;
                 minWidthField.OnChanged += x => style.MinWidth = x;
                 maxWidthField.OnChanged += x => style.MaxWidth = x;
                 maxWidthField.OnChanged += x => style.MaxWidth = x;
 
 
-                fixedHeightField.OnChanged += x =>
-                {
-                    heightField.Active = x;
-                    minHeightField.Active = !x;
-                    maxHeightField.Active = !x;
-                };
-
+                fixedHeightField.OnChanged += x => { style.FixedHeight = x; };
                 heightField.OnChanged += x => style.Height = x;
                 heightField.OnChanged += x => style.Height = x;
                 minHeightField.OnChanged += x => style.MinHeight = x;
                 minHeightField.OnChanged += x => style.MinHeight = x;
                 maxHeightField.OnChanged += x => style.MaxHeight = x;
                 maxHeightField.OnChanged += x => style.MaxHeight = x;
+
+                foldout.Value = isExpanded;
+                panel.Active = isExpanded;
             }
             }
 
 
             /// <summary>
             /// <summary>
@@ -300,6 +341,14 @@ namespace BansheeEditor
                 heightField.Value = style.Height;
                 heightField.Value = style.Height;
                 minHeightField.Value = style.MinHeight;
                 minHeightField.Value = style.MinHeight;
                 maxHeightField.Value = style.MaxHeight;
                 maxHeightField.Value = style.MaxHeight;
+
+                widthField.Active = style.FixedWidth;
+                minWidthField.Active = !style.FixedWidth;
+                maxWidthField.Active = !style.FixedWidth;
+
+                heightField.Active = style.FixedHeight;
+                minHeightField.Active = !style.FixedHeight;
+                maxHeightField.Active = !style.FixedHeight;
             }
             }
 
 
             /// <summary>
             /// <summary>
@@ -307,9 +356,10 @@ namespace BansheeEditor
             /// </summary>
             /// </summary>
             public class GUIElementStateStyleGUI
             public class GUIElementStateStyleGUI
             {
             {
-                private GUIToggleField foldout;
+                private GUIToggle foldout;
                 private GUIResourceField textureField;
                 private GUIResourceField textureField;
                 private GUIColorField textColorField;
                 private GUIColorField textColorField;
+                private bool isExpanded;
 
 
                 /// <summary>
                 /// <summary>
                 /// Triggered when some value in the style state changes.
                 /// Triggered when some value in the style state changes.
@@ -319,19 +369,26 @@ namespace BansheeEditor
                 /// <summary>
                 /// <summary>
                 /// Creates a new GUI element state style GUI.
                 /// Creates a new GUI element state style GUI.
                 /// </summary>
                 /// </summary>
+                public GUIElementStateStyleGUI()
+                { }
+
+                /// <summary>
+                /// Builds the GUI for the specified state style.
+                /// </summary>
                 /// <param name="title">Text to display on the title bar.</param>
                 /// <param name="title">Text to display on the title bar.</param>
                 /// <param name="state">State object to display in the GUI.</param>
                 /// <param name="state">State object to display in the GUI.</param>
                 /// <param name="layout">Layout to append the GUI elements to.</param>
                 /// <param name="layout">Layout to append the GUI elements to.</param>
-                public GUIElementStateStyleGUI(LocString title, GUIElementStateStyle state, GUILayout layout)
+                public void BuildGUI(LocString title, GUIElementStateStyle state, GUILayout layout)
                 {
                 {
-                    foldout = new GUIToggleField(title, 100, EditorStyles.Foldout);
+                    foldout = new GUIToggle(title, EditorStyles.Foldout);
                     textureField = new GUIResourceField(typeof(SpriteTexture), new LocEdString("Texture"));
                     textureField = new GUIResourceField(typeof(SpriteTexture), new LocEdString("Texture"));
                     textColorField = new GUIColorField(new LocEdString("Text color"));
                     textColorField = new GUIColorField(new LocEdString("Text color"));
 
 
-                    foldout.OnChanged += x =>
+                    foldout.OnToggled += x =>
                     {
                     {
                         textureField.Active = x;
                         textureField.Active = x;
                         textColorField.Active = x;
                         textColorField.Active = x;
+                        isExpanded = x;
                     };
                     };
 
 
                     textureField.OnChanged += x =>
                     textureField.OnChanged += x =>
@@ -354,9 +411,9 @@ namespace BansheeEditor
                     layout.AddElement(textureField);
                     layout.AddElement(textureField);
                     layout.AddElement(textColorField);
                     layout.AddElement(textColorField);
 
 
-                    foldout.Value = false;
-                    textureField.Active = false;
-                    textColorField.Active = false;
+                    foldout.Value = isExpanded;
+                    textureField.Active = isExpanded;
+                    textColorField.Active = isExpanded;
                 }
                 }
 
 
                 /// <summary>
                 /// <summary>
@@ -400,10 +457,10 @@ namespace BansheeEditor
                     GUILayoutX rectTopRow = rectContentLayout.AddLayoutX();
                     GUILayoutX rectTopRow = rectContentLayout.AddLayoutX();
                     GUILayoutX rectBotRow = rectContentLayout.AddLayoutX();
                     GUILayoutX rectBotRow = rectContentLayout.AddLayoutX();
 
 
-                    offsetLeftField = new GUIIntField(new LocEdString("Left"));
-                    offsetRightField = new GUIIntField(new LocEdString("Right"));
-                    offsetTopField = new GUIIntField(new LocEdString("Top"));
-                    offsetBottomField = new GUIIntField(new LocEdString("Bottom"));
+                    offsetLeftField = new GUIIntField(new LocEdString("Left"), 40);
+                    offsetRightField = new GUIIntField(new LocEdString("Right"), 40);
+                    offsetTopField = new GUIIntField(new LocEdString("Top"), 40);
+                    offsetBottomField = new GUIIntField(new LocEdString("Bottom"), 40);
 
 
                     rectTopRow.AddElement(offsetLeftField);
                     rectTopRow.AddElement(offsetLeftField);
                     rectTopRow.AddElement(offsetRightField);
                     rectTopRow.AddElement(offsetRightField);