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

Enabling double-click for OpenGL and DX9 windows

Marko Pintera 10 лет назад
Родитель
Сommit
76a447c91e

+ 4 - 1
BansheeD3D9RenderSystem/Source/BsD3D9RenderWindow.cpp

@@ -201,9 +201,12 @@ namespace BansheeEngine
 				}
 			}
 
+			UINT classStyle = 0;
+			if (mDesc.enableDoubleClick)
+				classStyle |= CS_DBLCLKS;
 
 			// Register the window class
-			WNDCLASS wc = { 0, Win32Platform::_win32WndProc, 0, 0, hInst,
+			WNDCLASS wc = { classStyle, Win32Platform::_win32WndProc, 0, 0, hInst,
 				LoadIcon(0, IDI_APPLICATION), LoadCursor(NULL, IDC_ARROW),
 				(HBRUSH)GetStockObject(BLACK_BRUSH), 0, "D3D9Wnd" };
 			RegisterClass(&wc);

+ 5 - 1
BansheeGLRenderSystem/Source/BsWin32Window.cpp

@@ -254,8 +254,12 @@ namespace BansheeEngine
 				}
 			}
 
+			UINT classStyle = CS_OWNDC;
+			if (mDesc.enableDoubleClick)
+				classStyle |= CS_DBLCLKS;
+
 			// register class and create window
-			WNDCLASS wc = { CS_OWNDC, Win32Platform::_win32WndProc, 0, 0, hInst,
+			WNDCLASS wc = { classStyle, Win32Platform::_win32WndProc, 0, 0, hInst,
 				LoadIcon(NULL, IDI_APPLICATION), LoadCursor(NULL, IDC_ARROW),
 				(HBRUSH)GetStockObject(BLACK_BRUSH), NULL, "GLWindow" };
 			RegisterClass(&wc);

+ 24 - 7
MBansheeEditor/ProjectWindow.cs

@@ -381,8 +381,17 @@ namespace BansheeEditor
             GUITexture icon = new GUITexture(iconTexture, GUIImageScaleMode.ScaleToFit,
                 true, GUIOption.FixedHeight(tileSize), GUIOption.FixedWidth(tileSize));
 
-            GUILabel label = new GUILabel(entry.Name, EditorStyles.MultiLineLabel,
-                GUIOption.FixedWidth(tileSize), GUIOption.FlexibleHeight(0, MAX_LABEL_HEIGHT));
+            GUILabel label = null;
+
+            if (grid)
+            {
+                label = new GUILabel(entry.Name, EditorStyles.MultiLineLabel,
+                    GUIOption.FixedWidth(tileSize), GUIOption.FlexibleHeight(0, MAX_LABEL_HEIGHT));
+            }
+            else
+            {
+                label = new GUILabel(entry.Name);   
+            }
 
             entryLayout.AddElement(icon);
             entryLayout.AddElement(label);
@@ -445,6 +454,8 @@ namespace BansheeEditor
 
         private void OnEntryDoubleClicked(string path)
         {
+            Debug.Log("DOUBLE CLICK " + path);
+
             LibraryEntry entry = ProjectLibrary.GetEntry(path);
             if (entry != null && entry.Type == LibraryEntryType.Directory)
             {
@@ -543,10 +554,10 @@ namespace BansheeEditor
 
             GUIToggleGroup group = new GUIToggleGroup();
 
-            GUIToggle list16 = new GUIToggle("16", group);
-            GUIToggle grid32 = new GUIToggle("32", group);
-            GUIToggle grid48 = new GUIToggle("32", group);
-            GUIToggle grid64 = new GUIToggle("64", group);
+            GUIToggle list16 = new GUIToggle("16", group, EditorStyles.Button, GUIOption.FixedWidth(30));
+            GUIToggle grid32 = new GUIToggle("32", group, EditorStyles.Button, GUIOption.FixedWidth(30));
+            GUIToggle grid48 = new GUIToggle("48", group, EditorStyles.Button, GUIOption.FixedWidth(30));
+            GUIToggle grid64 = new GUIToggle("64", group, EditorStyles.Button, GUIOption.FixedWidth(30));
 
             ProjectViewType activeType = parent.ViewType;
             switch (activeType)
@@ -589,11 +600,17 @@ namespace BansheeEditor
                     ChangeViewType(ProjectViewType.Grid64);
             };
 
-            GUILayoutX contentLayout = GUI.AddLayoutX();
+            GUILayoutY vertLayout = GUI.AddLayoutY();
+
+            vertLayout.AddFlexibleSpace();
+            GUILayoutX contentLayout = vertLayout.AddLayoutX();
+            contentLayout.AddFlexibleSpace();
             contentLayout.AddElement(list16);
             contentLayout.AddElement(grid32);
             contentLayout.AddElement(grid48);
             contentLayout.AddElement(grid64);
+            contentLayout.AddFlexibleSpace();
+            vertLayout.AddFlexibleSpace();
         }
 
         private void ChangeViewType(ProjectViewType viewType)

+ 5 - 1
TODO.txt

@@ -25,11 +25,15 @@ GUIResourceField doesn't distinguish between tex2d, tex3d and texcube.
 ----------------------------------------------------------------------
 Project window
 
-Opening drop down when it doesn't fit vertically opens it at the wrong position
 Crash when opening and closing the context menu many times, trying to delete a GUILayout that has already been deleted
  - This might happen when parent layout or panel goes out of scope. It will get destroyed but it will not mark any of its children as destroyed
  - And I can't just call Destroy in finalizer since it accesses its children which might have been finalized already
  - When a window is closed(editor, modal or drop down, do I call destroy on its child layout?)
+ - SOLUTION: My only option to deal with this might be to store child elements ScriptObject references in C++. If I do that make sure
+   to properly unregister elements when they're removed manually from the parent, and if they go out of scope (i.e. child goes out of scope
+   before the parent)
+ - In general, do I want GUI elements to go out of scope when not being referenced? Probably doesn't matter much, and even if I add C++ handles
+   that doesn't solve my issue as elements will go out of scope during assembly refresh
 
 Other:
  - Double click doesn't seem to work