Просмотр исходного кода

Fixing ProjectWindow arrow movement and scroll to element

Marko Pintera 10 лет назад
Родитель
Сommit
d3c3d4972c
2 измененных файлов с 16 добавлено и 14 удалено
  1. 15 11
      MBansheeEditor/ProjectWindow.cs
  2. 1 3
      TODO.txt

+ 15 - 11
MBansheeEditor/ProjectWindow.cs

@@ -632,11 +632,11 @@ namespace BansheeEditor
                     {
                     {
                         case MoveDirection.Left:
                         case MoveDirection.Left:
                         case MoveDirection.Up:
                         case MoveDirection.Up:
-                            newPath = entries[0].path;
+                            newPath = entries[entries.Count - 1].path;
                             break;
                             break;
                         case MoveDirection.Right:
                         case MoveDirection.Right:
                         case MoveDirection.Down:
                         case MoveDirection.Down:
-                            newPath = entries[entries.Count - 1].path;
+                            newPath = entries[0].path;
                             break;
                             break;
                     }
                     }
                 }
                 }
@@ -646,11 +646,11 @@ namespace BansheeEditor
                 switch (dir)
                 switch (dir)
                 {
                 {
                     case MoveDirection.Left:
                     case MoveDirection.Left:
-                        if (selectionAnchorEnd - 1 > 0)
+                        if (selectionAnchorEnd - 1 >= 0)
                             newPath = entries[selectionAnchorEnd - 1].path;
                             newPath = entries[selectionAnchorEnd - 1].path;
                         break;
                         break;
                     case MoveDirection.Up:
                     case MoveDirection.Up:
-                        if (selectionAnchorEnd - contentInfo.elementsPerRow > 0)
+                        if (selectionAnchorEnd - contentInfo.elementsPerRow >= 0)
                             newPath = entries[selectionAnchorEnd - contentInfo.elementsPerRow].path;
                             newPath = entries[selectionAnchorEnd - contentInfo.elementsPerRow].path;
                         break;
                         break;
                     case MoveDirection.Right:
                     case MoveDirection.Right:
@@ -658,7 +658,7 @@ namespace BansheeEditor
                             newPath = entries[selectionAnchorEnd + 1].path;
                             newPath = entries[selectionAnchorEnd + 1].path;
                         break;
                         break;
                     case MoveDirection.Down:
                     case MoveDirection.Down:
-                        if (selectionAnchorEnd + contentInfo.elementsPerRow > 0)
+                        if (selectionAnchorEnd + contentInfo.elementsPerRow < entries.Count)
                             newPath = entries[selectionAnchorEnd + contentInfo.elementsPerRow].path;
                             newPath = entries[selectionAnchorEnd + contentInfo.elementsPerRow].path;
                         break;
                         break;
                 }
                 }
@@ -875,18 +875,22 @@ namespace BansheeEditor
                 return;
                 return;
 
 
             Rect2I entryBounds = entryGUI.Bounds;
             Rect2I entryBounds = entryGUI.Bounds;
+
             Rect2I contentBounds = contentScrollArea.Layout.Bounds;
             Rect2I contentBounds = contentScrollArea.Layout.Bounds;
-            entryBounds.x += contentBounds.x;
-            entryBounds.y += contentBounds.y;
+            Rect2I windowEntryBounds = entryBounds;
+            windowEntryBounds.x += contentBounds.x;
+            windowEntryBounds.y += contentBounds.y;
 
 
-            Rect2I scrollAreaBounds = scrollAreaPanel.Bounds;
-            bool requiresScroll = entryBounds.y < scrollAreaBounds.y ||
-                                  (entryBounds.y + entryBounds.height) > (scrollAreaBounds.y + scrollAreaBounds.height);
+            Rect2I scrollAreaBounds = contentScrollArea.Bounds;
+            bool requiresScroll = windowEntryBounds.y < scrollAreaBounds.y ||
+                                  (windowEntryBounds.y + windowEntryBounds.height) > (scrollAreaBounds.y + scrollAreaBounds.height);
 
 
             if (!requiresScroll)
             if (!requiresScroll)
                 return;
                 return;
 
 
-            float percent = (entryBounds.y - entryBounds.height * 0.5f - scrollAreaBounds.height * 0.5f) / contentBounds.height;
+            int scrollableSize = contentBounds.height - scrollAreaBounds.height;
+            float percent = (((entryBounds.y + entryBounds.height * 0.5f) - scrollAreaBounds.height * 0.5f) / (float)scrollableSize);
+
             percent = MathEx.Clamp01(percent);
             percent = MathEx.Clamp01(percent);
             contentScrollArea.VerticalScroll = percent;
             contentScrollArea.VerticalScroll = percent;
         }
         }

+ 1 - 3
TODO.txt

@@ -29,11 +29,9 @@ TODO - Might need to handle overwritting better when importing/moving
 
 
 Simple tasks:
 Simple tasks:
  - Hook up scene view drag and drop instantiation
  - Hook up scene view drag and drop instantiation
+ - Fix scroll to element
 
 
 Test:
 Test:
- - If labels are now wider and selection looks better
- - If arrow key navigation and multi-selection (using arrows or ctrl/shift) works
-  - And scroll to element
  - Test search
  - Test search
  - Test directory bar
  - Test directory bar
  - See how are elements and search results ordered (should be by name)
  - See how are elements and search results ordered (should be by name)