Ver código fonte

Library GUI multiresource bg working

BearishSun 9 anos atrás
pai
commit
d8b5b94f2a

+ 4 - 0
Source/BansheeEditor/Include/BsBuiltinEditorResources.h

@@ -431,6 +431,10 @@ namespace BansheeEngine
 		static const WString LibraryEntryBgTex;
 		static const WString LibraryEntryLastBgTex;
 
+		static const WString LibraryEntryVertFirstBgTex;
+		static const WString LibraryEntryVertBgTex;
+		static const WString LibraryEntryVertLastBgTex;
+
 		static const WString ShaderDockOverlayFile;
 		static const WString ShaderSceneGridFile;
 		static const WString ShaderPickingCullNoneFile;

+ 33 - 0
Source/BansheeEditor/Source/BsBuiltinEditorResources.cpp

@@ -258,6 +258,10 @@ namespace BansheeEngine
 	const WString BuiltinEditorResources::LibraryEntryBgTex = L"LibraryEntryBg.png";
 	const WString BuiltinEditorResources::LibraryEntryLastBgTex = L"LibraryEntryLastBg.png";
 
+	const WString BuiltinEditorResources::LibraryEntryVertFirstBgTex = L"LibraryEntryVertFirstBg.png";
+	const WString BuiltinEditorResources::LibraryEntryVertBgTex = L"LibraryEntryVertBg.png";
+	const WString BuiltinEditorResources::LibraryEntryVertLastBgTex = L"LibraryEntryVertLastBg.png";
+
 	/************************************************************************/
 	/* 									SHADERS                      		*/
 	/************************************************************************/
@@ -1918,6 +1922,35 @@ namespace BansheeEngine
 
 		skin->setStyle("LibraryEntryLastBg", libraryEntryLastBg);
 
+		GUIElementStyle libraryEntryVertFirstBg;
+		libraryEntryVertFirstBg.normal.texture = getGUITexture(LibraryEntryVertFirstBgTex);
+		libraryEntryVertFirstBg.minHeight = 5;
+		libraryEntryVertFirstBg.minWidth = 6;
+		libraryEntryVertFirstBg.border.top = 4;
+		libraryEntryVertFirstBg.border.left = 2;
+		libraryEntryVertFirstBg.border.right = 4;
+
+		skin->setStyle("LibraryEntryVertFirstBg", libraryEntryVertFirstBg);
+
+		GUIElementStyle libraryEntryVertBg;
+		libraryEntryVertBg.normal.texture = getGUITexture(LibraryEntryVertBgTex);
+		libraryEntryVertBg.minHeight = 4;
+		libraryEntryVertBg.minWidth = 6;
+		libraryEntryVertBg.border.left = 2;
+		libraryEntryVertBg.border.right = 4;
+
+		skin->setStyle("LibraryEntryVertBg", libraryEntryVertBg);
+
+		GUIElementStyle libraryEntryVertLastBg;
+		libraryEntryVertLastBg.normal.texture = getGUITexture(LibraryEntryVertLastBgTex);
+		libraryEntryVertLastBg.minHeight = 4;
+		libraryEntryVertLastBg.minWidth = 6;
+		libraryEntryVertLastBg.border.bottom = 2;
+		libraryEntryVertLastBg.border.left = 2;
+		libraryEntryVertLastBg.border.right = 4;
+
+		skin->setStyle("LibraryEntryVertLastBg", libraryEntryVertLastBg);
+
 		return skin;
 	}
 

+ 0 - 9
Source/MBansheeEditor/EditorStyles.cs

@@ -1,11 +1,5 @@
 //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
 //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
 namespace BansheeEditor
 {
     /// <summary>
@@ -35,8 +29,5 @@ namespace BansheeEditor
         public const string InspectorTitleBg = "InspectorTitleBg";
         public const string InspectorContentBg = "InspectorContentBg";
         public const string InspectorContentBgAlternate = "InspectorContentBgAlternate";
-        public const string LibraryEntryFirstBg = "LibraryEntryFirstBg";
-        public const string LibraryEntryBg = "LibraryEntryBg";
-        public const string LibraryEntryLastBg = "LibraryEntryLastBg";
     }
 }

+ 6 - 1
Source/MBansheeEditor/Library/LibraryGUIContent.cs

@@ -196,12 +196,17 @@ namespace BansheeEditor
                 gridLayout = false;
                 elementsPerRow = 1;
                 horzElementSpacing = 0;
+                int elemWidth = bounds.width;
+                int elemHeight = tileSize;
+
+                main.AddSpace(TOP_MARGIN);
 
                 for (int i = 0; i < resourcesToDisplay.Count; i++)
                 {
                     ResourceToDisplay entry = resourcesToDisplay[i];
 
-                    LibraryGUIEntry guiEntry = new LibraryGUIEntry(this, main, entry.path, i, 0, 0, entry.type);
+                    LibraryGUIEntry guiEntry = new LibraryGUIEntry(this, main, entry.path, i, elemWidth, elemHeight, 
+                        entry.type);
                     entries.Add(guiEntry);
                     entryLookup[guiEntry.path] = guiEntry;
 

+ 63 - 23
Source/MBansheeEditor/Library/LibraryGUIEntry.cs

@@ -16,6 +16,14 @@ namespace BansheeEditor
         private static readonly Color CUT_COLOR = new Color(1.0f, 1.0f, 1.0f, 0.5f);
         private const int VERT_PADDING = 3;
         private const int BG_HORZ_PADDING = 2;
+        private const int BG_VERT_PADDING = 2;
+
+        private const string LibraryEntryFirstBg = "LibraryEntryFirstBg";
+        private const string LibraryEntryBg = "LibraryEntryBg";
+        private const string LibraryEntryLastBg = "LibraryEntryLastBg";
+        private const string LibraryEntryVertFirstBg = "LibraryEntryVertFirstBg";
+        private const string LibraryEntryVertBg = "LibraryEntryVertBg";
+        private const string LibraryEntryVertLastBg = "LibraryEntryVertLastBg";
 
         /// <summary>
         /// Possible visual states for the resource tile.
@@ -37,6 +45,7 @@ namespace BansheeEditor
         private UnderlayState underlayState;
         private GUITextBox renameTextBox;
 
+        private int width, height;
         private LibraryGUIEntryType type;
         private bool delayedSelect;
         private float delayedSelectTime;
@@ -84,30 +93,45 @@ namespace BansheeEditor
 
                 label = new GUILabel(name, EditorStyles.MultiLineLabelCentered,
                     GUIOption.FixedWidth(width), GUIOption.FixedHeight(labelHeight));
+
+                switch (type)
+                {
+                    case LibraryGUIEntryType.Single:
+                        break;
+                    case LibraryGUIEntryType.MultiFirst:
+                        groupUnderlay = new GUITexture(null, LibraryEntryFirstBg);
+                        break;
+                    case LibraryGUIEntryType.MultiElement:
+                        groupUnderlay = new GUITexture(null, LibraryEntryBg);
+                        break;
+                    case LibraryGUIEntryType.MultiLast:
+                        groupUnderlay = new GUITexture(null, LibraryEntryLastBg);
+                        break;
+                }
             }
             else
             {
-                label = new GUILabel(name);
+                label = new GUILabel(name, GUIOption.FixedWidth(width - owner.TileSize), GUIOption.FixedHeight(height));
+
+                switch (type)
+                {
+                    case LibraryGUIEntryType.Single:
+                        break;
+                    case LibraryGUIEntryType.MultiFirst:
+                        groupUnderlay = new GUITexture(null, LibraryEntryVertFirstBg);
+                        break;
+                    case LibraryGUIEntryType.MultiElement:
+                        groupUnderlay = new GUITexture(null, LibraryEntryVertBg);
+                        break;
+                    case LibraryGUIEntryType.MultiLast:
+                        groupUnderlay = new GUITexture(null, LibraryEntryVertLastBg);
+                        break;
+                }
             }
 
             entryLayout.AddElement(icon);
             entryLayout.AddElement(label);
 
-            switch (type)
-            {
-                case LibraryGUIEntryType.Single:
-                    break;
-                case LibraryGUIEntryType.MultiFirst:
-                    groupUnderlay = new GUITexture(null, EditorStyles.LibraryEntryFirstBg);
-                    break;
-                case LibraryGUIEntryType.MultiElement:
-                    groupUnderlay = new GUITexture(null, EditorStyles.LibraryEntryBg);
-                    break;
-                case LibraryGUIEntryType.MultiLast:
-                    groupUnderlay = new GUITexture(null, EditorStyles.LibraryEntryLastBg);
-                    break;
-            }
-
             if (groupUnderlay != null)
                 owner.DeepUnderlay.AddElement(groupUnderlay);
 
@@ -117,6 +141,8 @@ namespace BansheeEditor
             this.bounds = new Rect2I();
             this.underlay = null;
             this.type = type;
+            this.width = width;
+            this.height = height;
         }
 
         /// <summary>
@@ -129,12 +155,19 @@ namespace BansheeEditor
             bounds = iconBounds;
             Rect2I labelBounds = label.Bounds;
 
-            // TODO - Won't work for list
-
-            bounds.x = labelBounds.x;
-            bounds.y -= VERT_PADDING;
-            bounds.width = labelBounds.width;
-            bounds.height = (labelBounds.y + labelBounds.height + VERT_PADDING) - bounds.y;
+            if (owner.GridLayout)
+            {
+                bounds.x = labelBounds.x;
+                bounds.y -= VERT_PADDING;
+                bounds.width = labelBounds.width;
+                bounds.height = (labelBounds.y + labelBounds.height + VERT_PADDING) - bounds.y;
+            }
+            else
+            {
+                bounds.y -= VERT_PADDING;
+                bounds.width = width;
+                bounds.height += VERT_PADDING;
+            }
 
             string hoistedPath = path;
 
@@ -160,7 +193,14 @@ namespace BansheeEditor
                 }
                 else
                 {
-                    // TODO
+                    int offsetToNext = BG_VERT_PADDING + LibraryGUIContent.LIST_ENTRY_SPACING;
+                    if (type == LibraryGUIEntryType.MultiLast)
+                        offsetToNext = BG_VERT_PADDING * 2;
+
+                    Rect2I bgBounds = new Rect2I(bounds.x, bounds.y - BG_VERT_PADDING,
+                        bounds.width, bounds.height + offsetToNext);
+
+                    groupUnderlay.Bounds = bgBounds;
                 }
             }
         }