Kaynağa Gözat

Refactor: Cleaner way of handling GUI panels in the Library window

BearishSun 6 yıl önce
ebeveyn
işleme
cb99cc5333

+ 10 - 11
Source/EditorManaged/Windows/Library/LibraryGUIContent.cs

@@ -166,10 +166,10 @@ namespace bs.Editor
             mainPanel = parent.Layout.AddPanel();
 
             GUIPanel contentPanel = mainPanel.AddPanel(1);
-            overlay = new GUIPanel(0);//mainPanel.AddPanel(0));mainPanel.AddPanel(0);
-            underlay = new GUIPanel(2);//mainPanel.AddPanel(2));mainPanel.AddPanel(2);
-            deepUnderlay = new GUIPanel(3);//ainPanel.AddPanel(3));mainPanel.AddPanel(3);
-            renameOverlay = new GUIPanel(-1);//mainPanel.AddPanel(-1));mainPanel.AddPanel(-1);
+            overlay = mainPanel.AddPanel(0);
+            underlay = mainPanel.AddPanel(2);
+            deepUnderlay = mainPanel.AddPanel(3);
+            renameOverlay = mainPanel.AddPanel(-1);
 
             main = contentPanel.AddLayoutY();
 
@@ -352,18 +352,17 @@ namespace bs.Editor
                 main.AddFlexibleSpace();
             }
 
+            // Fix bounds as that makes GUI updates faster
+            underlay.Bounds = main.Bounds;
+            overlay.Bounds = main.Bounds;
+            deepUnderlay.Bounds = main.Bounds;
+            renameOverlay.Bounds = main.Bounds;
+
             for (int i = 0; i < entries.Count; i++)
             {
                 LibraryGUIEntry guiEntry = entries[i];
                 guiEntry.Initialize();
             }
-
-            // Important to add panels after all elements on them have been initialized, as we avoid expensive layout
-            // updates time we request GUI element bounds after adding a new element
-            mainPanel.AddElement(overlay);
-            mainPanel.AddElement(underlay);
-            mainPanel.AddElement(deepUnderlay);
-            mainPanel.AddElement(renameOverlay);
         }
 
         /// <summary>

+ 1 - 1
Source/EditorManaged/Windows/Library/LibraryGUIEntry.cs

@@ -217,7 +217,7 @@ namespace bs.Editor
                     else if (lastInRow)
                         offsetToNext = owner.PaddingRight + spacing;
 
-                    Rect2I bgBounds = new Rect2I(bounds.x - offsetToPrevious, bounds.y, 
+                    Rect2I bgBounds = new Rect2I(bounds.x - offsetToPrevious, bounds.y,
                         bounds.width + offsetToNext + offsetToPrevious, bounds.height);
                     groupUnderlay.Bounds = bgBounds;
                 }

+ 0 - 1
Source/EditorManaged/Windows/Library/LibraryWindow.cs

@@ -202,7 +202,6 @@ namespace bs.Editor
 
             contentScrollArea = new GUIScrollArea(GUIOption.FlexibleWidth(), GUIOption.FlexibleHeight());
             contentLayout.AddElement(contentScrollArea);
-            contentLayout.AddFlexibleSpace();
 
             entryContextMenu = LibraryMenu.CreateContextMenu(this);
             content = new LibraryGUIContent(this, contentScrollArea);

+ 1 - 1
Source/bsf

@@ -1 +1 @@
-Subproject commit 950d7192557f8899dcd4972b17699a20f8335567
+Subproject commit 75adb123b31efa36efabc5e6006704d56cff59a2