Procházet zdrojové kódy

Added background to inspectable components
Updated component foldout style

BearishSun před 10 roky
rodič
revize
1dbc71c517

+ 2 - 0
BansheeEditor/Include/BsBuiltinEditorResources.h

@@ -388,7 +388,9 @@ namespace BansheeEngine
 
 
 		static const WString StatusBarBgTex;
 		static const WString StatusBarBgTex;
 		static const WString ScrollAreaBgTex;
 		static const WString ScrollAreaBgTex;
+
 		static const WString InspectorTitleBgTex;
 		static const WString InspectorTitleBgTex;
+		static const WString InspectorContentBgTex;
 
 
 		static const WString ShaderDockOverlayFile;
 		static const WString ShaderDockOverlayFile;
 		static const WString ShaderSceneGridFile;
 		static const WString ShaderSceneGridFile;

+ 21 - 4
BansheeEditor/Source/BsBuiltinEditorResources.cpp

@@ -266,7 +266,9 @@ namespace BansheeEngine
 
 
 	const WString BuiltinEditorResources::StatusBarBgTex = L"StatusBarBackground.png";
 	const WString BuiltinEditorResources::StatusBarBgTex = L"StatusBarBackground.png";
 	const WString BuiltinEditorResources::ScrollAreaBgTex = L"ScrollAreaBg.png";
 	const WString BuiltinEditorResources::ScrollAreaBgTex = L"ScrollAreaBg.png";
+
 	const WString BuiltinEditorResources::InspectorTitleBgTex = L"InspectorTitleBg.png";
 	const WString BuiltinEditorResources::InspectorTitleBgTex = L"InspectorTitleBg.png";
+	const WString BuiltinEditorResources::InspectorContentBgTex = L"InspectorContentBg.png";
 
 
 	/************************************************************************/
 	/************************************************************************/
 	/* 									SHADERS                      		*/
 	/* 									SHADERS                      		*/
@@ -1357,14 +1359,17 @@ namespace BansheeEngine
 		cmpFoldoutBtnStyle.activeOn.textColor = TextNormalColor;
 		cmpFoldoutBtnStyle.activeOn.textColor = TextNormalColor;
 		cmpFoldoutBtnStyle.fixedHeight = true;
 		cmpFoldoutBtnStyle.fixedHeight = true;
 		cmpFoldoutBtnStyle.fixedWidth = false;
 		cmpFoldoutBtnStyle.fixedWidth = false;
-		cmpFoldoutBtnStyle.height = 10;
-		cmpFoldoutBtnStyle.minWidth = 14;
+		cmpFoldoutBtnStyle.height = 21;
+		cmpFoldoutBtnStyle.minWidth = 17;
 		cmpFoldoutBtnStyle.font = font;
 		cmpFoldoutBtnStyle.font = font;
 		cmpFoldoutBtnStyle.fontSize = DefaultFontSize;
 		cmpFoldoutBtnStyle.fontSize = DefaultFontSize;
 		cmpFoldoutBtnStyle.textHorzAlign = THA_Left;
 		cmpFoldoutBtnStyle.textHorzAlign = THA_Left;
 		cmpFoldoutBtnStyle.textVertAlign = TVA_Center;
 		cmpFoldoutBtnStyle.textVertAlign = TVA_Center;
-		cmpFoldoutBtnStyle.contentOffset = RectOffset(13, 0, 0, 0);
-		cmpFoldoutBtnStyle.border.left = 10;
+		cmpFoldoutBtnStyle.contentOffset = RectOffset(16, 0, 0, 0);
+		cmpFoldoutBtnStyle.border.left = 15;
+		cmpFoldoutBtnStyle.border.right = 2;
+		cmpFoldoutBtnStyle.border.top = 2;
+		cmpFoldoutBtnStyle.border.bottom = 4;
 
 
 		skin->setStyle(GUIComponentFoldout::getFoldoutButtonStyleType(), cmpFoldoutBtnStyle);
 		skin->setStyle(GUIComponentFoldout::getFoldoutButtonStyleType(), cmpFoldoutBtnStyle);
 
 
@@ -1692,6 +1697,18 @@ namespace BansheeEngine
 
 
 		skin->setStyle("InspectorTitleBg", inspectorTitleBg);
 		skin->setStyle("InspectorTitleBg", inspectorTitleBg);
 
 
+		// Inspector content background
+		GUIElementStyle inspectorContentBg;
+		inspectorContentBg.normal.texture = getGUITexture(InspectorContentBgTex);
+		inspectorContentBg.minWidth = 4;
+		inspectorContentBg.minHeight = 6;
+		inspectorContentBg.border.left = 2;
+		inspectorContentBg.border.right = 2;
+		inspectorContentBg.border.top = 2;
+		inspectorContentBg.border.bottom = 4;
+
+		skin->setStyle("InspectorContentBg", inspectorContentBg);
+
 		return skin;
 		return skin;
 	}
 	}
 
 

+ 2 - 0
MBansheeEditor/EditorStyles.cs

@@ -17,6 +17,7 @@ namespace BansheeEditor
         public const string ButtonRight = "ButtonRight";
         public const string ButtonRight = "ButtonRight";
         public const string Toggle = "Toggle";
         public const string Toggle = "Toggle";
         public const string InputBox = "InputBox";
         public const string InputBox = "InputBox";
+        public const string Foldout = "ComponentFoldoutButton";
         public const string ColorSliderHorz = "ColorSliderHorz";
         public const string ColorSliderHorz = "ColorSliderHorz";
         public const string ColorSliderVert = "ColorSliderVert";
         public const string ColorSliderVert = "ColorSliderVert";
         public const string ColorSlider2DHandle = "ColorSlider2DHandle";
         public const string ColorSlider2DHandle = "ColorSlider2DHandle";
@@ -24,5 +25,6 @@ namespace BansheeEditor
         public const string SelectableLabel = "SelectableLabel";
         public const string SelectableLabel = "SelectableLabel";
         public const string ScrollAreaBg = "ScrollAreaBg";
         public const string ScrollAreaBg = "ScrollAreaBg";
         public const string InspectorTitleBg = "InspectorTitleBg";
         public const string InspectorTitleBg = "InspectorTitleBg";
+        public const string InspectorContentBg = "InspectorContentBg";
     }
     }
 }
 }

+ 25 - 0
MBansheeEditor/Inspector/GenericInspector.cs

@@ -9,9 +9,34 @@ namespace BansheeEditor
 {
 {
     internal sealed class GenericInspector : Inspector
     internal sealed class GenericInspector : Inspector
     {
     {
+        private GUIPanel RootGUI;
         private bool isInitialized;
         private bool isInitialized;
         private List<InspectableField> inspectableFields = new List<InspectableField>();
         private List<InspectableField> inspectableFields = new List<InspectableField>();
 
 
+        internal override void Initialize(InspectorWindow parentWindow, GUIPanel gui, object instance)
+        {
+            RootGUI = gui;
+
+            GUILayout contentLayoutX = gui.AddLayoutX();
+            contentLayoutX.AddSpace(5);
+            GUILayout contentLayoutY = contentLayoutX.AddLayoutY();
+            contentLayoutY.AddSpace(5);
+            GUIPanel contentPanel = contentLayoutY.AddPanel();
+            contentLayoutY.AddSpace(5);
+            contentLayoutX.AddSpace(5);
+
+            GUIPanel backgroundPanel = gui.AddPanel(1);
+            GUITexture inspectorContentBg = new GUITexture(null, EditorStyles.InspectorContentBg);
+            backgroundPanel.AddElement(inspectorContentBg);
+
+            base.Initialize(parentWindow, contentPanel, instance);
+        }
+
+        internal override void SetVisible(bool visible)
+        {
+            RootGUI.Visible = visible;
+        }
+
         private void Initialize()
         private void Initialize()
         {
         {
             if (referencedObject != null)
             if (referencedObject != null)

+ 3 - 3
MBansheeEditor/Inspector/Inspector.cs

@@ -14,15 +14,15 @@ namespace BansheeEditor
 
 
         private InspectorWindow parentWindow;
         private InspectorWindow parentWindow;
 
 
-        internal void Initialize(InspectorWindow parentWindow, GUIPanel gui, object instance)
+        internal virtual void Initialize(InspectorWindow parentWindow, GUIPanel gui, object instance)
         {
         {
             GUI = gui;
             GUI = gui;
-            layout = gui.AddLayoutY();
+            layout = GUI.AddLayoutY();
             referencedObject = instance;
             referencedObject = instance;
             this.parentWindow = parentWindow;
             this.parentWindow = parentWindow;
         }
         }
 
 
-        internal void SetVisible(bool visible)
+        internal virtual void SetVisible(bool visible)
         {
         {
             GUI.Visible = visible;
             GUI.Visible = visible;
         }
         }

+ 4 - 9
MBansheeEditor/Inspector/InspectorWindow.cs

@@ -18,7 +18,7 @@ namespace BansheeEditor
 
 
         private class InspectorComponent
         private class InspectorComponent
         {
         {
-            public GUIComponentFoldout foldout;
+            public GUIToggle foldout;
             public GUIButton removeBtn;
             public GUIButton removeBtn;
             public GUIPanel panel;
             public GUIPanel panel;
             public Inspector inspector;
             public Inspector inspector;
@@ -124,22 +124,17 @@ namespace BansheeEditor
                 InspectorComponent data = new InspectorComponent();
                 InspectorComponent data = new InspectorComponent();
                 data.instanceId = allComponents[i].InstanceId;
                 data.instanceId = allComponents[i].InstanceId;
 
 
-                data.foldout = new GUIComponentFoldout(allComponents[i].GetType().Name);
+                data.foldout = new GUIToggle(allComponents[i].GetType().Name, EditorStyles.Foldout);
                 data.removeBtn = new GUIButton(new GUIContent(EditorBuiltin.XBtnIcon), GUIOption.FixedWidth(30));
                 data.removeBtn = new GUIButton(new GUIContent(EditorBuiltin.XBtnIcon), GUIOption.FixedWidth(30));
 
 
                 GUILayoutX titleLayout = inspectorLayout.AddLayoutX();
                 GUILayoutX titleLayout = inspectorLayout.AddLayoutX();
                 titleLayout.AddElement(data.foldout);
                 titleLayout.AddElement(data.foldout);
                 titleLayout.AddElement(data.removeBtn);
                 titleLayout.AddElement(data.removeBtn);
 
 
-                GUILayoutX contentLayout = inspectorLayout.AddLayoutX();
-                contentLayout.AddSpace(5);
-                data.panel = contentLayout.AddPanel();
-                contentLayout.AddSpace(5);
-
+                data.panel = inspectorLayout.AddPanel();
                 data.inspector = InspectorUtility.GetInspector(allComponents[i].GetType());
                 data.inspector = InspectorUtility.GetInspector(allComponents[i].GetType());
                 data.inspector.Initialize(this, data.panel, allComponents[i]);
                 data.inspector.Initialize(this, data.panel, allComponents[i]);
-
-                data.foldout.SetExpanded(true);
+                data.foldout.Value = true;
 
 
                 Type curComponentType = allComponents[i].GetType();
                 Type curComponentType = allComponents[i].GetType();
                 data.foldout.OnToggled += (bool expanded) => OnComponentFoldoutToggled(data, expanded);
                 data.foldout.OnToggled += (bool expanded) => OnComponentFoldoutToggled(data, expanded);