Explorar o código

WIP multi-resource library background

BearishSun %!s(int64=9) %!d(string=hai) anos
pai
achega
f893a76e04

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

@@ -427,6 +427,10 @@ namespace BansheeEngine
 		static const WString InspectorContentBgTex;
 		static const WString InspectorContentBgTex;
 		static const WString InspectorContentBgAlternateTex;
 		static const WString InspectorContentBgAlternateTex;
 
 
+		static const WString LibraryEntryFirstBgTex;
+		static const WString LibraryEntryBgTex;
+		static const WString LibraryEntryLastBgTex;
+
 		static const WString ShaderDockOverlayFile;
 		static const WString ShaderDockOverlayFile;
 		static const WString ShaderSceneGridFile;
 		static const WString ShaderSceneGridFile;
 		static const WString ShaderPickingCullNoneFile;
 		static const WString ShaderPickingCullNoneFile;

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

@@ -254,6 +254,10 @@ namespace BansheeEngine
 	const WString BuiltinEditorResources::InspectorContentBgTex = L"InspectorContentBg.png";
 	const WString BuiltinEditorResources::InspectorContentBgTex = L"InspectorContentBg.png";
 	const WString BuiltinEditorResources::InspectorContentBgAlternateTex = L"InspectorContentBgAlternate.png";
 	const WString BuiltinEditorResources::InspectorContentBgAlternateTex = L"InspectorContentBgAlternate.png";
 
 
+	const WString BuiltinEditorResources::LibraryEntryFirstBgTex = L"LibraryEntryFirstBg.png";
+	const WString BuiltinEditorResources::LibraryEntryBgTex = L"LibraryEntryBg.png";
+	const WString BuiltinEditorResources::LibraryEntryLastBgTex = L"LibraryEntryLastBg.png";
+
 	/************************************************************************/
 	/************************************************************************/
 	/* 									SHADERS                      		*/
 	/* 									SHADERS                      		*/
 	/************************************************************************/
 	/************************************************************************/
@@ -1884,6 +1888,36 @@ namespace BansheeEngine
 
 
 		skin->setStyle("InspectorContentBgAlternate", inspectorContentBgAlternate);
 		skin->setStyle("InspectorContentBgAlternate", inspectorContentBgAlternate);
 
 
+		// Background for multi-element resource entries in the library window
+		GUIElementStyle libraryEntryFirstBg;
+		libraryEntryFirstBg.normal.texture = getGUITexture(LibraryEntryFirstBgTex);
+		libraryEntryFirstBg.minHeight = 7;
+		libraryEntryFirstBg.minWidth = 4;
+		libraryEntryFirstBg.border.top = 5;
+		libraryEntryFirstBg.border.bottom = 2;
+		libraryEntryFirstBg.border.left = 2;
+
+		skin->setStyle("LibraryEntryFirstBg", libraryEntryFirstBg);
+
+		GUIElementStyle libraryEntryBg;
+		libraryEntryBg.normal.texture = getGUITexture(LibraryEntryBgTex);
+		libraryEntryBg.minHeight = 7;
+		libraryEntryBg.minWidth = 4;
+		libraryEntryBg.border.top = 5;
+		libraryEntryBg.border.bottom = 2;
+
+		skin->setStyle("LibraryEntryBg", libraryEntryBg);
+
+		GUIElementStyle libraryEntryLastBg;
+		libraryEntryLastBg.normal.texture = getGUITexture(LibraryEntryLastBgTex);
+		libraryEntryLastBg.minHeight = 7;
+		libraryEntryFirstBg.minWidth = 4;
+		libraryEntryLastBg.border.top = 5;
+		libraryEntryLastBg.border.bottom = 2;
+		libraryEntryLastBg.border.right = 2;
+
+		skin->setStyle("LibraryEntryLastBg", libraryEntryLastBg);
+
 		return skin;
 		return skin;
 	}
 	}
 
 

+ 42 - 39
Source/MBansheeEditor/EditorStyles.cs

@@ -1,39 +1,42 @@
-//********************************** 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>
-    /// Contains various editor specific GUI style names. You may use these to customize look and feel of various GUI 
-    /// elements.
-    /// </summary>
-    public static class EditorStyles
-    {
-        public const string Blank = "Blank";
-        public const string Label = "Label";
-        public const string LabelCentered = "LabelCentered";
-        public const string TitleLabel = "TitleLabel";
-        public const string MultiLineLabel = "MultiLineLabel";
-        public const string MultiLineLabelCentered = "MultiLineLabelCentered";
-        public const string Button = "Button";
-        public const string ButtonLeft = "ButtonLeft";
-        public const string ButtonRight = "ButtonRight";
-        public const string Toggle = "Toggle";
-        public const string InputBox = "InputBox";
-        public const string Foldout = "Foldout";
-        public const string ColorSliderHorz = "ColorSliderHorz";
-        public const string ColorSliderVert = "ColorSliderVert";
-        public const string ColorSlider2DHandle = "ColorSlider2DHandle";
-        public const string SelectionArea = "SelectionArea";
-        public const string SelectableLabel = "SelectableLabel";
-        public const string ScrollAreaBg = "ScrollAreaBg";
-        public const string InspectorTitleBg = "InspectorTitleBg";
-        public const string InspectorContentBg = "InspectorContentBg";
-        public const string InspectorContentBgAlternate = "InspectorContentBgAlternate";
-    }
-}
+//********************************** 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>
+    /// Contains various editor specific GUI style names. You may use these to customize look and feel of various GUI 
+    /// elements.
+    /// </summary>
+    public static class EditorStyles
+    {
+        public const string Blank = "Blank";
+        public const string Label = "Label";
+        public const string LabelCentered = "LabelCentered";
+        public const string TitleLabel = "TitleLabel";
+        public const string MultiLineLabel = "MultiLineLabel";
+        public const string MultiLineLabelCentered = "MultiLineLabelCentered";
+        public const string Button = "Button";
+        public const string ButtonLeft = "ButtonLeft";
+        public const string ButtonRight = "ButtonRight";
+        public const string Toggle = "Toggle";
+        public const string InputBox = "InputBox";
+        public const string Foldout = "Foldout";
+        public const string ColorSliderHorz = "ColorSliderHorz";
+        public const string ColorSliderVert = "ColorSliderVert";
+        public const string ColorSlider2DHandle = "ColorSlider2DHandle";
+        public const string SelectionArea = "SelectionArea";
+        public const string SelectableLabel = "SelectableLabel";
+        public const string ScrollAreaBg = "ScrollAreaBg";
+        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";
+    }
+}

+ 67 - 11
Source/MBansheeEditor/Library/LibraryGUIContent.cs

@@ -21,6 +21,7 @@ namespace BansheeEditor
         private GUILayout main;
         private GUILayout main;
         private GUIPanel overlay;
         private GUIPanel overlay;
         private GUIPanel underlay;
         private GUIPanel underlay;
+        private GUIPanel deepUnderlay;
         private GUIPanel renameOverlay;
         private GUIPanel renameOverlay;
 
 
         private LibraryWindow window;
         private LibraryWindow window;
@@ -30,6 +31,7 @@ namespace BansheeEditor
 
 
         private int elementsPerRow;
         private int elementsPerRow;
         private int labelWidth;
         private int labelWidth;
+        private int elementWidth;
 
 
         private List<LibraryGUIEntry> entries = new List<LibraryGUIEntry>();
         private List<LibraryGUIEntry> entries = new List<LibraryGUIEntry>();
         private Dictionary<string, LibraryGUIEntry> entryLookup = new Dictionary<string, LibraryGUIEntry>();
         private Dictionary<string, LibraryGUIEntry> entryLookup = new Dictionary<string, LibraryGUIEntry>();
@@ -43,13 +45,21 @@ namespace BansheeEditor
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Number of elements per row. Only relvant for grid layouts.
+        /// Number of elements per row. Only relevant for grid layouts.
         /// </summary>
         /// </summary>
         public int ElementsPerRow
         public int ElementsPerRow
         {
         {
             get { return elementsPerRow; }
             get { return elementsPerRow; }
         }
         }
 
 
+        /// <summary>
+        /// Width of a single element in a row, including any margins. Only relevant for grid layouts.
+        /// </summary>
+        public int ElementWidth
+        {
+            get { return elementWidth; }
+        }
+
         /// <summary>
         /// <summary>
         /// Determines is the content display in a grid (true) or list (false) layout.
         /// Determines is the content display in a grid (true) or list (false) layout.
         /// </summary>
         /// </summary>
@@ -90,6 +100,15 @@ namespace BansheeEditor
             get { return underlay; }
             get { return underlay; }
         }
         }
 
 
+        /// <summary>
+        /// Returns a GUI panel that can be used for displaying elements underneath the resource tiles. Displays under
+        /// <see cref="Underlay"/>.
+        /// </summary>
+        public GUIPanel DeepUnderlay
+        {
+            get { return deepUnderlay; }
+        }
+
         /// <summary>
         /// <summary>
         /// Returns a GUI panel that can be used for displaying elements above the resource tiles.
         /// Returns a GUI panel that can be used for displaying elements above the resource tiles.
         /// </summary>
         /// </summary>
@@ -135,16 +154,17 @@ namespace BansheeEditor
 
 
             GUIPanel contentPanel = mainPanel.AddPanel(1);
             GUIPanel contentPanel = mainPanel.AddPanel(1);
             overlay = mainPanel.AddPanel(0);
             overlay = mainPanel.AddPanel(0);
-            underlay = mainPanel.AddPanel(2);
+            underlay = mainPanel.AddPanel(2);
+            deepUnderlay = mainPanel.AddPanel(3);
             renameOverlay = mainPanel.AddPanel(-1);
             renameOverlay = mainPanel.AddPanel(-1);
 
 
             main = contentPanel.AddLayoutY();
             main = contentPanel.AddLayoutY();
 
 
-            List<string> resourcesToDisplay = new List<string>();
+            List<ResourceToDisplay> resourcesToDisplay = new List<ResourceToDisplay>();
             foreach (var entry in entriesToDisplay)
             foreach (var entry in entriesToDisplay)
             {
             {
                 if (entry.Type == LibraryEntryType.Directory)
                 if (entry.Type == LibraryEntryType.Directory)
-                    resourcesToDisplay.Add(entry.Path);
+                    resourcesToDisplay.Add(new ResourceToDisplay(entry.Path, LibraryGUIEntryType.Single));
                 else
                 else
                 {
                 {
                     FileEntry fileEntry = (FileEntry)entry;
                     FileEntry fileEntry = (FileEntry)entry;
@@ -152,10 +172,21 @@ namespace BansheeEditor
 
 
                     if (metas.Length > 0)
                     if (metas.Length > 0)
                     {
                     {
-                        resourcesToDisplay.Add(entry.Path);
-
-                        for (int i = 1; i < metas.Length; i++)
-                            resourcesToDisplay.Add(Path.Combine(entry.Path, metas[i].SubresourceName));
+                        if (metas.Length == 1)
+                            resourcesToDisplay.Add(new ResourceToDisplay(entry.Path, LibraryGUIEntryType.Single));
+                        else
+                        {
+                            resourcesToDisplay.Add(new ResourceToDisplay(entry.Path, LibraryGUIEntryType.MultiFirst));
+
+                            for (int i = 1; i < metas.Length - 1; i++)
+                            {
+                                string path = Path.Combine(entry.Path, metas[i].SubresourceName);
+                                resourcesToDisplay.Add(new ResourceToDisplay(path, LibraryGUIEntryType.MultiElement));
+                            }
+
+                            string lastPath = Path.Combine(entry.Path, metas[metas.Length - 1].SubresourceName);
+                            resourcesToDisplay.Add(new ResourceToDisplay(lastPath, LibraryGUIEntryType.MultiLast));
+                        }
                     }
                     }
                 }
                 }
             }
             }
@@ -201,16 +232,24 @@ namespace BansheeEditor
                 }
                 }
 
 
                 if (elementsPerRow > 0)
                 if (elementsPerRow > 0)
-                    labelWidth = (availableWidth - (elementsPerRow + 1) * MIN_HORZ_SPACING) / elementsPerRow;
+                {
+                    labelWidth = (availableWidth - (elementsPerRow + 1)*MIN_HORZ_SPACING)/elementsPerRow;
+                    elementWidth = availableWidth/elementsPerRow;
+                }
                 else
                 else
+                {
                     labelWidth = 0;
                     labelWidth = 0;
+                    elementWidth = 0;
+                }
             }
             }
 
 
             if (viewType == ProjectViewType.List16)
             if (viewType == ProjectViewType.List16)
             {
             {
                 for (int i = 0; i < resourcesToDisplay.Count; i++)
                 for (int i = 0; i < resourcesToDisplay.Count; i++)
                 {
                 {
-                    LibraryGUIEntry guiEntry = new LibraryGUIEntry(this, main, resourcesToDisplay[i], i, labelWidth);
+                    ResourceToDisplay entry = resourcesToDisplay[i];
+
+                    LibraryGUIEntry guiEntry = new LibraryGUIEntry(this, main, entry.path, i, labelWidth, entry.type);
                     entries.Add(guiEntry);
                     entries.Add(guiEntry);
                     entryLookup[guiEntry.path] = guiEntry;
                     entryLookup[guiEntry.path] = guiEntry;
 
 
@@ -240,7 +279,9 @@ namespace BansheeEditor
                         elemsInRow = 0;
                         elemsInRow = 0;
                     }
                     }
 
 
-                    LibraryGUIEntry guiEntry = new LibraryGUIEntry(this, rowLayout, resourcesToDisplay[i], i, labelWidth);
+                    ResourceToDisplay entry = resourcesToDisplay[i];
+
+                    LibraryGUIEntry guiEntry = new LibraryGUIEntry(this, rowLayout, entry.path, i, labelWidth, entry.type);
                     entries.Add(guiEntry);
                     entries.Add(guiEntry);
                     entryLookup[guiEntry.path] = guiEntry;
                     entryLookup[guiEntry.path] = guiEntry;
 
 
@@ -379,5 +420,20 @@ namespace BansheeEditor
         {
         {
             return entryLookup.TryGetValue(path, out entry);
             return entryLookup.TryGetValue(path, out entry);
         }
         }
+
+        /// <summary>
+        /// Helper structure containing information about a single entry to display in the library.
+        /// </summary>
+        private struct ResourceToDisplay
+        {
+            public ResourceToDisplay(string path, LibraryGUIEntryType type)
+            {
+                this.path = path;
+                this.type = type;
+            }
+
+            public string path;
+            public LibraryGUIEntryType type;
+        }
     }
     }
 }
 }

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

@@ -33,6 +33,7 @@ namespace BansheeEditor
         public Rect2I bounds;
         public Rect2I bounds;
 
 
         private GUITexture underlay;
         private GUITexture underlay;
+        private GUITexture groupUnderlay;
         private LibraryGUIContent owner;
         private LibraryGUIContent owner;
         private UnderlayState underlayState;
         private UnderlayState underlayState;
         private GUITextBox renameTextBox;
         private GUITextBox renameTextBox;
@@ -57,7 +58,9 @@ namespace BansheeEditor
         /// <param name="path">Path to the project library entry to display data for.</param>
         /// <param name="path">Path to the project library entry to display data for.</param>
         /// <param name="index">Sequential index of the entry in the conent area.</param>
         /// <param name="index">Sequential index of the entry in the conent area.</param>
         /// <param name="labelWidth">Width of the GUI labels that display the elements.</param>
         /// <param name="labelWidth">Width of the GUI labels that display the elements.</param>
-        public LibraryGUIEntry(LibraryGUIContent owner, GUILayout parent, string path, int index, int labelWidth)
+        /// <param name="type">Type of the entry, which controls its style and/or behaviour.</param>
+        public LibraryGUIEntry(LibraryGUIContent owner, GUILayout parent, string path, int index, int labelWidth,
+            LibraryGUIEntryType type)
         {
         {
             GUILayout entryLayout;
             GUILayout entryLayout;
 
 
@@ -87,6 +90,24 @@ namespace BansheeEditor
             entryLayout.AddElement(icon);
             entryLayout.AddElement(icon);
             entryLayout.AddElement(label);
             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);
+
             this.owner = owner;
             this.owner = owner;
             this.index = index;
             this.index = index;
             this.path = path;
             this.path = path;
@@ -100,7 +121,8 @@ namespace BansheeEditor
         /// </summary>
         /// </summary>
         public void Initialize()
         public void Initialize()
         {
         {
-            bounds = icon.Bounds;
+            Rect2I iconBounds = icon.Bounds;
+            bounds = iconBounds;
             Rect2I labelBounds = label.Bounds;
             Rect2I labelBounds = label.Bounds;
 
 
             bounds.x = MathEx.Min(bounds.x, labelBounds.x - SELECTION_EXTRA_WIDTH);
             bounds.x = MathEx.Min(bounds.x, labelBounds.x - SELECTION_EXTRA_WIDTH);
@@ -119,6 +141,22 @@ namespace BansheeEditor
             overlayBtn.SetContextMenu(owner.Window.ContextMenu);
             overlayBtn.SetContextMenu(owner.Window.ContextMenu);
 
 
             owner.Overlay.AddElement(overlayBtn);
             owner.Overlay.AddElement(overlayBtn);
+
+            if (groupUnderlay != null)
+            {
+                if (owner.GridLayout)
+                {
+                    int centerX = iconBounds.x + iconBounds.width/2;
+                    int left = centerX - owner.ElementWidth/2;
+
+                    Rect2I bgBounds = new Rect2I(left, bounds.y, owner.ElementWidth, bounds.height);
+                    groupUnderlay.Bounds = bgBounds;
+                }
+                else
+                {
+                    // TODO
+                }
+            }
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -402,4 +440,27 @@ namespace BansheeEditor
             return null;
             return null;
         }
         }
     }
     }
+
+    /// <summary>
+    /// Type of <see cref="LibraryGUIEntry"/> that controls its look.
+    /// </summary>
+    internal enum LibraryGUIEntryType
+    {
+        /// <summary>
+        /// Represents a single resource.
+        /// </summary>
+        Single,
+        /// <summary>
+        /// Represents the first entry in a multi-resource group.
+        /// </summary>
+        MultiFirst,
+        /// <summary>
+        /// Represents one of the mid entries in a multi-resource group.
+        /// </summary>
+        MultiElement,
+        /// <summary>
+        /// Represents the last entry in a multi-resource group.
+        /// </summary>
+        MultiLast
+    }
 }
 }