Explorar o código

Project window better label and selection display

Marko Pintera %!s(int64=10) %!d(string=hai) anos
pai
achega
08adb83157

+ 6 - 6
BansheeCore/BansheeCore.vcxproj

@@ -151,7 +151,7 @@
     <Link>
     <Link>
       <SubSystem>NotSet</SubSystem>
       <SubSystem>NotSet</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>BansheeUtility.lib;nvtt.lib;IPHLPAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>BansheeUtility.lib;nvtt.lib;IPHLPAPI.lib;Rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <AdditionalLibraryDirectories>../lib/x86/$(Configuration);../Dependencies/lib/x86/Debug</AdditionalLibraryDirectories>
       <AdditionalLibraryDirectories>../lib/x86/$(Configuration);../Dependencies/lib/x86/Debug</AdditionalLibraryDirectories>
       <ImportLibrary>..\lib\x86\$(Configuration)\$(TargetName).lib</ImportLibrary>
       <ImportLibrary>..\lib\x86\$(Configuration)\$(TargetName).lib</ImportLibrary>
     </Link>
     </Link>
@@ -170,7 +170,7 @@
     <Link>
     <Link>
       <SubSystem>NotSet</SubSystem>
       <SubSystem>NotSet</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>BansheeUtility.lib;nvtt.lib;IPHLPAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>BansheeUtility.lib;nvtt.lib;IPHLPAPI.lib;Rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <AdditionalLibraryDirectories>../lib/$(Platform)/$(Configuration);../Dependencies/lib/x64/Debug</AdditionalLibraryDirectories>
       <AdditionalLibraryDirectories>../lib/$(Platform)/$(Configuration);../Dependencies/lib/x64/Debug</AdditionalLibraryDirectories>
       <ImportLibrary>..\lib\$(Platform)\$(Configuration)\$(TargetName).lib</ImportLibrary>
       <ImportLibrary>..\lib\$(Platform)\$(Configuration)\$(TargetName).lib</ImportLibrary>
     </Link>
     </Link>
@@ -195,7 +195,7 @@
       <GenerateDebugInformation>false</GenerateDebugInformation>
       <GenerateDebugInformation>false</GenerateDebugInformation>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
       <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>BansheeUtility.lib;nvtt.lib;IPHLPAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>BansheeUtility.lib;nvtt.lib;IPHLPAPI.lib;Rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <AdditionalLibraryDirectories>../lib/x86/$(Configuration);../Dependencies/lib/x86/Release</AdditionalLibraryDirectories>
       <AdditionalLibraryDirectories>../lib/x86/$(Configuration);../Dependencies/lib/x86/Release</AdditionalLibraryDirectories>
       <ImportLibrary>..\lib\x86\$(Configuration)\$(TargetName).lib</ImportLibrary>
       <ImportLibrary>..\lib\x86\$(Configuration)\$(TargetName).lib</ImportLibrary>
     </Link>
     </Link>
@@ -221,7 +221,7 @@
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
       <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>BansheeUtility.lib;nvtt.lib;IPHLPAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>BansheeUtility.lib;nvtt.lib;IPHLPAPI.lib;Rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <AdditionalLibraryDirectories>../lib/x86/$(Configuration);../Dependencies/lib/x86/DebugRelease</AdditionalLibraryDirectories>
       <AdditionalLibraryDirectories>../lib/x86/$(Configuration);../Dependencies/lib/x86/DebugRelease</AdditionalLibraryDirectories>
       <ImportLibrary>..\lib\x86\$(Configuration)\$(TargetName).lib</ImportLibrary>
       <ImportLibrary>..\lib\x86\$(Configuration)\$(TargetName).lib</ImportLibrary>
     </Link>
     </Link>
@@ -246,7 +246,7 @@
       <GenerateDebugInformation>false</GenerateDebugInformation>
       <GenerateDebugInformation>false</GenerateDebugInformation>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
       <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>BansheeUtility.lib;nvtt.lib;IPHLPAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>BansheeUtility.lib;nvtt.lib;IPHLPAPI.lib;Rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <AdditionalLibraryDirectories>../lib/$(Platform)/$(Configuration);../Dependencies/lib/x64/Release</AdditionalLibraryDirectories>
       <AdditionalLibraryDirectories>../lib/$(Platform)/$(Configuration);../Dependencies/lib/x64/Release</AdditionalLibraryDirectories>
       <ImportLibrary>..\lib\$(Platform)\$(Configuration)\$(TargetName).lib</ImportLibrary>
       <ImportLibrary>..\lib\$(Platform)\$(Configuration)\$(TargetName).lib</ImportLibrary>
     </Link>
     </Link>
@@ -272,7 +272,7 @@
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
       <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>BansheeUtility.lib;nvtt.lib;IPHLPAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>BansheeUtility.lib;nvtt.lib;IPHLPAPI.lib;Rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <AdditionalLibraryDirectories>../lib/$(Platform)/$(Configuration);../Dependencies/lib/x64/DebugRelease</AdditionalLibraryDirectories>
       <AdditionalLibraryDirectories>../lib/$(Platform)/$(Configuration);../Dependencies/lib/x64/DebugRelease</AdditionalLibraryDirectories>
       <ImportLibrary>..\lib\$(Platform)\$(Configuration)\$(TargetName).lib</ImportLibrary>
       <ImportLibrary>..\lib\$(Platform)\$(Configuration)\$(TargetName).lib</ImportLibrary>
     </Link>
     </Link>

+ 2 - 2
BansheeCore/Source/BsResources.cpp

@@ -78,7 +78,7 @@ namespace BansheeEngine
 		bool foundUUID = getUUIDFromFilePath(filePath, uuid);
 		bool foundUUID = getUUIDFromFilePath(filePath, uuid);
 
 
 		if(!foundUUID)
 		if(!foundUUID)
-			uuid = UUIDGenerator::instance().generateRandom();
+			uuid = UUIDGenerator::generateRandom();
 
 
 		HResource outputResource;
 		HResource outputResource;
 		bool alreadyLoading = false;
 		bool alreadyLoading = false;
@@ -311,7 +311,7 @@ namespace BansheeEngine
 
 
 	HResource Resources::_createResourceHandle(const ResourcePtr& obj)
 	HResource Resources::_createResourceHandle(const ResourcePtr& obj)
 	{
 	{
-		String uuid = UUIDGenerator::instance().generateRandom();
+		String uuid = UUIDGenerator::generateRandom();
 		HResource newHandle(obj, uuid);
 		HResource newHandle(obj, uuid);
 
 
 		{
 		{

+ 37 - 31
MBansheeEditor/ProjectWindow.cs

@@ -14,7 +14,7 @@ namespace BansheeEditor
     {
     {
         private class ContentInfo
         private class ContentInfo
         {
         {
-            public ContentInfo(ProjectWindow window, ProjectViewType viewType)
+            public ContentInfo(ProjectWindow window, ProjectViewType viewType, int numEntries)
             {
             {
                 GUIPanel parentPanel = window.scrollAreaPanel;
                 GUIPanel parentPanel = window.scrollAreaPanel;
 
 
@@ -28,6 +28,7 @@ namespace BansheeEditor
                 {
                 {
                     tileSize = 16;
                     tileSize = 16;
                     gridLayout = false;
                     gridLayout = false;
+                    elementsPerRow = 1;
                 }
                 }
                 else
                 else
                 {
                 {
@@ -45,6 +46,24 @@ namespace BansheeEditor
                     }
                     }
 
 
                     gridLayout = true;
                     gridLayout = true;
+
+                    Rect2I scrollBounds = window.contentScrollArea.Bounds;
+                    int availableWidth = scrollBounds.width;
+
+                    int elemSize = tileSize + GRID_ENTRY_SPACING;
+                    elementsPerRow = (availableWidth - GRID_ENTRY_SPACING * 2) / elemSize;
+                    int numRows = MathEx.CeilToInt(numEntries / (float)elementsPerRow);
+                    int neededHeight = numRows * (elemSize);
+
+                    bool requiresScrollbar = neededHeight > scrollBounds.height;
+                    if (requiresScrollbar)
+                    {
+                        availableWidth -= window.contentScrollArea.ScrollBarWidth;
+                        elementsPerRow = (availableWidth - GRID_ENTRY_SPACING * 2) / elemSize;
+                    }
+
+                    labelWidth = availableWidth / elementsPerRow;
+                    labelWidth -= (elementsPerRow + 1)*MIN_HORZ_SPACING;
                 }
                 }
 
 
                 this.window = window;
                 this.window = window;
@@ -57,6 +76,9 @@ namespace BansheeEditor
             public ProjectWindow window;
             public ProjectWindow window;
             public int tileSize;
             public int tileSize;
             public bool gridLayout;
             public bool gridLayout;
+
+            public int elementsPerRow;
+            public int labelWidth;
         }
         }
 
 
         private class ElementEntry
         private class ElementEntry
@@ -95,10 +117,8 @@ namespace BansheeEditor
 
 
                 if (info.gridLayout)
                 if (info.gridLayout)
                 {
                 {
-                    int labelWidth = info.tileSize + LABEL_EXTRA_WIDTH;
-
                     label = new GUILabel(entry.Name, EditorStyles.MultiLineLabel,
                     label = new GUILabel(entry.Name, EditorStyles.MultiLineLabel,
-                        GUIOption.FixedWidth(labelWidth), GUIOption.FlexibleHeight(0, MAX_LABEL_HEIGHT));
+                        GUIOption.FixedWidth(info.labelWidth), GUIOption.FlexibleHeight(0, MAX_LABEL_HEIGHT));
                 }
                 }
                 else
                 else
                 {
                 {
@@ -121,7 +141,7 @@ namespace BansheeEditor
                 Rect2I labelBounds = label.Bounds;
                 Rect2I labelBounds = label.Bounds;
 
 
                 bounds.x = MathEx.Min(bounds.x, labelBounds.x);
                 bounds.x = MathEx.Min(bounds.x, labelBounds.x);
-                bounds.y = MathEx.Min(bounds.y, labelBounds.y);
+                bounds.y = MathEx.Min(bounds.y, labelBounds.y) - 5; // 5 - Just padding for better look
                 bounds.width = MathEx.Max(bounds.x + bounds.width,
                 bounds.width = MathEx.Max(bounds.x + bounds.width,
                     labelBounds.x + labelBounds.width) - bounds.x;
                     labelBounds.x + labelBounds.width) - bounds.x;
                 bounds.height = MathEx.Max(bounds.y + bounds.height,
                 bounds.height = MathEx.Max(bounds.y + bounds.height,
@@ -264,7 +284,7 @@ namespace BansheeEditor
         private const int GRID_ENTRY_SPACING = 15;
         private const int GRID_ENTRY_SPACING = 15;
         private const int LIST_ENTRY_SPACING = 7;
         private const int LIST_ENTRY_SPACING = 7;
         private const int MAX_LABEL_HEIGHT = 50;
         private const int MAX_LABEL_HEIGHT = 50;
-        private const int LABEL_EXTRA_WIDTH = 10;
+        private const int MIN_HORZ_SPACING = 5;
         private const int DRAG_SCROLL_HEIGHT = 20;
         private const int DRAG_SCROLL_HEIGHT = 20;
         private const int DRAG_SCROLL_AMOUNT_PER_SECOND = 100;
         private const int DRAG_SCROLL_AMOUNT_PER_SECOND = 100;
         private const int FOLDER_BUTTON_WIDTH = 20;
         private const int FOLDER_BUTTON_WIDTH = 20;
@@ -289,6 +309,7 @@ namespace BansheeEditor
         private string pingPath = "";
         private string pingPath = "";
         private string hoverHighlightPath = "";
         private string hoverHighlightPath = "";
 
 
+        private ContentInfo contentInfo;
         private GUIScrollArea contentScrollArea;
         private GUIScrollArea contentScrollArea;
         private GUIPanel scrollAreaPanel;
         private GUIPanel scrollAreaPanel;
         private GUILayoutX searchBarLayout;
         private GUILayoutX searchBarLayout;
@@ -301,7 +322,6 @@ namespace BansheeEditor
 
 
         private List<ElementEntry> entries = new List<ElementEntry>();
         private List<ElementEntry> entries = new List<ElementEntry>();
         private Dictionary<string, ElementEntry> entryLookup = new Dictionary<string, ElementEntry>();
         private Dictionary<string, ElementEntry> entryLookup = new Dictionary<string, ElementEntry>();
-        private int elementsPerRow;
 
 
         private int autoScrollAmount;
         private int autoScrollAmount;
 
 
@@ -630,16 +650,16 @@ namespace BansheeEditor
                             newPath = entries[selectionAnchorEnd - 1].path;
                             newPath = entries[selectionAnchorEnd - 1].path;
                         break;
                         break;
                     case MoveDirection.Up:
                     case MoveDirection.Up:
-                        if (selectionAnchorEnd - elementsPerRow > 0)
-                            newPath = entries[selectionAnchorEnd - elementsPerRow].path;
+                        if (selectionAnchorEnd - contentInfo.elementsPerRow > 0)
+                            newPath = entries[selectionAnchorEnd - contentInfo.elementsPerRow].path;
                         break;
                         break;
                     case MoveDirection.Right:
                     case MoveDirection.Right:
                         if (selectionAnchorEnd + 1 < entries.Count)
                         if (selectionAnchorEnd + 1 < entries.Count)
                             newPath = entries[selectionAnchorEnd + 1].path;
                             newPath = entries[selectionAnchorEnd + 1].path;
                         break;
                         break;
                     case MoveDirection.Down:
                     case MoveDirection.Down:
-                        if (selectionAnchorEnd + elementsPerRow > 0)
-                            newPath = entries[selectionAnchorEnd + elementsPerRow].path;
+                        if (selectionAnchorEnd + contentInfo.elementsPerRow > 0)
+                            newPath = entries[selectionAnchorEnd + contentInfo.elementsPerRow].path;
                         break;
                         break;
                 }
                 }
             }
             }
@@ -901,11 +921,8 @@ namespace BansheeEditor
             if (entriesToDisplay.Length == 0)
             if (entriesToDisplay.Length == 0)
                 return;
                 return;
 
 
-            ContentInfo contentInfo = new ContentInfo(this, viewType);
+            contentInfo = new ContentInfo(this, viewType, entriesToDisplay.Length);
 
 
-            Rect2I scrollBounds = contentScrollArea.Bounds;
-            int availableWidth = scrollBounds.width;
-            
             if (viewType == ProjectViewType.List16)
             if (viewType == ProjectViewType.List16)
             {
             {
                 for (int i = 0; i < entriesToDisplay.Length; i++)
                 for (int i = 0; i < entriesToDisplay.Length; i++)
@@ -919,7 +936,6 @@ namespace BansheeEditor
                 }
                 }
 
 
                 contentInfo.main.AddFlexibleSpace();
                 contentInfo.main.AddFlexibleSpace();
-                elementsPerRow = 1;
             }
             }
             else
             else
             {
             {
@@ -931,26 +947,16 @@ namespace BansheeEditor
                     case ProjectViewType.Grid32: tileSize = 32; break;
                     case ProjectViewType.Grid32: tileSize = 32; break;
                 }
                 }
 
 
+                contentInfo.main.AddSpace(GRID_ENTRY_SPACING / 2);
                 GUILayoutX rowLayout = contentInfo.main.AddLayoutX();
                 GUILayoutX rowLayout = contentInfo.main.AddLayoutX();
+                contentInfo.main.AddSpace(GRID_ENTRY_SPACING);
                 rowLayout.AddFlexibleSpace();
                 rowLayout.AddFlexibleSpace();
 
 
-                int elemSize = tileSize + GRID_ENTRY_SPACING;
-                elementsPerRow = (availableWidth - GRID_ENTRY_SPACING * 2) / elemSize;
-                int numRows = MathEx.CeilToInt(entriesToDisplay.Length / (float)elementsPerRow);
-                int neededHeight = numRows*(elemSize);
-
-                bool requiresScrollbar = neededHeight > scrollBounds.height;
-                if (requiresScrollbar)
-                {
-                    availableWidth -= contentScrollArea.ScrollBarWidth;
-                    elementsPerRow = (availableWidth - GRID_ENTRY_SPACING * 2) / elemSize;
-                }
-
                 int elemsInRow = 0;
                 int elemsInRow = 0;
 
 
                 for (int i = 0; i < entriesToDisplay.Length; i++)
                 for (int i = 0; i < entriesToDisplay.Length; i++)
                 {
                 {
-                    if (elemsInRow == elementsPerRow && elemsInRow > 0)
+                    if (elemsInRow == contentInfo.elementsPerRow && elemsInRow > 0)
                     {
                     {
                         rowLayout = contentInfo.main.AddLayoutX();
                         rowLayout = contentInfo.main.AddLayoutX();
                         contentInfo.main.AddSpace(GRID_ENTRY_SPACING);
                         contentInfo.main.AddSpace(GRID_ENTRY_SPACING);
@@ -968,10 +974,10 @@ namespace BansheeEditor
                     elemsInRow++;
                     elemsInRow++;
                 }
                 }
 
 
-                int extraElements = elementsPerRow - elemsInRow;
+                int extraElements = contentInfo.elementsPerRow - elemsInRow;
                 for (int i = 0; i < extraElements; i++)
                 for (int i = 0; i < extraElements; i++)
                 {
                 {
-                    rowLayout.AddSpace(tileSize);
+                    rowLayout.AddSpace(contentInfo.labelWidth);
                     rowLayout.AddFlexibleSpace();
                     rowLayout.AddFlexibleSpace();
                 }
                 }