Browse Source

Context menus with multiple sub-menus no longer have incorrect focus bounds
Added "Create Folder" entry to Library menu

BearishSun 10 years ago
parent
commit
32709ace83

+ 2 - 4
BansheeEngine/Source/BsGUIDropDownMenu.cpp

@@ -145,12 +145,11 @@ namespace BansheeEngine
 	void GUIDropDownMenu::notifySubMenuOpened(DropDownSubMenu* subMenu)
 	{
 		Vector<Rect2I> bounds;
-
 		while(subMenu != nullptr)
 		{
 			bounds.push_back(subMenu->getVisibleBounds());
 
-			subMenu = subMenu->mSubMenu;
+			subMenu = subMenu->mParent;
 		}
 
 		mBackHitBox->setBounds(bounds);
@@ -164,12 +163,11 @@ namespace BansheeEngine
 	void GUIDropDownMenu::notifySubMenuClosed(DropDownSubMenu* subMenu)
 	{
 		Vector<Rect2I> bounds;
-
 		while(subMenu != nullptr)
 		{
 			bounds.push_back(subMenu->getVisibleBounds());
 
-			subMenu = subMenu->mSubMenu;
+			subMenu = subMenu->mParent;
 		}
 
 		mBackHitBox->setBounds(bounds);

+ 1 - 1
BansheeEngine/Source/BsGUIMenu.cpp

@@ -114,7 +114,7 @@ namespace BansheeEngine
 				else
 				{
 					existingItem = bs_alloc<GUIMenuItem>();
-					existingItem = new (existingItem)GUIMenuItem(curSubMenu, pathElem, nullptr, priority, mNextIdx++, ShortcutKey::NONE);
+					existingItem = new (existingItem) GUIMenuItem(curSubMenu, pathElem, nullptr, priority, mNextIdx++, ShortcutKey::NONE);
 				}
 
 				curSubMenu->addChild(existingItem);

+ 14 - 0
MBansheeEditor/Library/LibraryMenu.cs

@@ -18,6 +18,7 @@ namespace BansheeEditor
         {
             ContextMenu entryContextMenu = new ContextMenu();
             entryContextMenu.AddItem("Create", null);
+            entryContextMenu.AddItem("Create/Folder", CreateFolder);
             entryContextMenu.AddItem("Create/Material", CreateEmptyMaterial);
             entryContextMenu.AddItem("Create/Shader", CreateEmptyShader);
             entryContextMenu.AddItem("Create/C# script", CreateEmptyCSScript);
@@ -56,6 +57,19 @@ namespace BansheeEditor
             return EditorWindow.GetWindow<LibraryWindow>() != null;
         }
 
+        /// <summary>
+        /// Creates a new material with the default shader in the currently selected project library folder.
+        /// </summary>
+        [MenuItem("Resources/Create/Folder", 9051, false, "IsLibraryWindowActive")]
+        internal static void CreateFolder()
+        {
+            LibraryWindow win = EditorWindow.GetWindow<LibraryWindow>();
+            if (win == null)
+                return;
+
+            LibraryUtility.CreateFolder(win.SelectedFolder);
+        }
+
         /// <summary>
         /// Creates a new material with the default shader in the currently selected project library folder.
         /// </summary>

+ 12 - 0
MBansheeEditor/Library/LibraryUtility.cs

@@ -9,6 +9,18 @@ namespace BansheeEditor
     /// </summary>
     public static class LibraryUtility
     {
+        /// <summary>
+        /// Creates a new folder with in the specified folder.
+        /// </summary>
+        /// <param name="folder">Folder relative to project library to create the new foldeer in.</param>
+        public static void CreateFolder(string folder)
+        {
+            string path = Path.Combine(folder, "New Folder");
+            path = GetUniquePath(path);
+
+            ProjectLibrary.CreateFolder(path);
+        }
+
         /// <summary>
         /// Creates a new material with the default shader in the specified folder.
         /// </summary>

+ 2 - 0
MBansheeEditor/Library/LibraryWindow.cs

@@ -1058,6 +1058,8 @@ namespace BansheeEditor
         /// </summary>
         internal void RenameSelection()
         {
+            Debug.Log("Rename " + selectionPaths.Count);
+
             if (selectionPaths.Count == 0)
                 return;