Browse Source

Renamed top-level 'UI-element' menu item to 'UI-layout' to be consistent with documentation. Removed option to expand/collapse hierarchy item by double-clicking because on certain condition it may accidentally trigger a drag-drop operation when the list view's panel scrolled due to the result of the expand/collapse. Anyway, we already have more than one way to expand/collapse hierarchy item.

Wei Tjong Yao 12 years ago
parent
commit
4c305a17a3

+ 4 - 4
Bin/Data/Scripts/Editor/AttributeEditor.as

@@ -142,7 +142,7 @@ UIElement@ CreateBoolAttributeEditor(ListView@ list, Array<Serializable@>@ seria
 
     CheckBox@ attrEdit = CheckBox();
     parent.AddChild(attrEdit);
-    attrEdit.style = "";    // Auto style
+    attrEdit.style = AUTO_STYLE;
     attrEdit.vars["Index"] = index;
     attrEdit.vars["SubIndex"] = subIndex;
     SetAttributeEditorID(attrEdit, serializables);
@@ -189,7 +189,7 @@ UIElement@ CreateIntAttributeEditor(ListView@ list, Array<Serializable@>@ serial
     {
         DropDownList@ attrEdit = DropDownList();
         parent.AddChild(attrEdit);
-        attrEdit.style = "";    // Auto style
+        attrEdit.style = AUTO_STYLE;
         attrEdit.SetFixedHeight(ATTR_HEIGHT - 2);
         attrEdit.resizePopup = true;
         attrEdit.placeholderText = STRIKED_OUT;
@@ -237,7 +237,7 @@ UIElement@ CreateResourceRefAttributeEditor(ListView@ list, Array<Serializable@>
 
     Button@ pickButton = Button();
     container.AddChild(pickButton);
-    pickButton.style = "";    // Auto style
+    pickButton.style = AUTO_STYLE;
     pickButton.SetFixedSize(36, ATTR_HEIGHT - 2);
     pickButton.vars["Index"] = index;
     pickButton.vars["SubIndex"] = subIndex;
@@ -252,7 +252,7 @@ UIElement@ CreateResourceRefAttributeEditor(ListView@ list, Array<Serializable@>
 
     Button@ openButton = Button();
     container.AddChild(openButton);
-    openButton.style = "";    // Auto style
+    openButton.style = AUTO_STYLE;
     openButton.SetFixedSize(36, ATTR_HEIGHT - 2);
     openButton.vars["Index"] = index;
     openButton.vars["SubIndex"] = subIndex;

+ 2 - 2
Bin/Data/Scripts/Editor/EditorNodeWindow.as

@@ -281,7 +281,7 @@ void UpdateAttributeInspector(bool fullUpdate = true)
             titleText.text = (sameType ? elementType : "Mixed type") + " [ID " + STRIKED_OUT + " : " + editUIElements.length + "x]";
             SetStyleListSelection(SetEditable(styleList, sameStyle), sameStyle ? appliedStyle : STRIKED_OUT);
             if (!sameType)
-                elementType = "";   // No icon
+                elementType.Clear();   // No icon
         }
         IconizeUIElement(titleText, elementType);
 
@@ -701,7 +701,7 @@ void HandleStyleItemSelected(StringHash eventType, VariantMap& eventData)
         return;
     String newStyle = text.text;
     if (newStyle == "auto")
-        newStyle = "";
+        newStyle.Clear();
 
     // Group for storing undo actions
     EditActionGroup group;

+ 0 - 7
Bin/Data/Scripts/Editor/EditorSceneWindow.as

@@ -66,7 +66,6 @@ void CreateHierarchyWindow()
     SubscribeToEvent(hierarchyWindow.GetChild("ExpandButton", true), "Released", "ExpandCollapseHierarchy");
     SubscribeToEvent(hierarchyWindow.GetChild("CollapseButton", true), "Released", "ExpandCollapseHierarchy");
     SubscribeToEvent(hierarchyList, "SelectionChanged", "HandleHierarchyListSelectionChange");
-    SubscribeToEvent(hierarchyList, "ItemDoubleClicked", "HandleHierarchyListItemDoubleClick");
     SubscribeToEvent("DragDropTest", "HandleDragDropTest");
     SubscribeToEvent("DragDropFinish", "HandleDragDropFinish");
     SubscribeToEvent(editorScene, "NodeAdded", "HandleNodeAdded");
@@ -691,12 +690,6 @@ void HandleHierarchyListSelectionChange()
     UpdateAttributeInspector();
 }
 
-void HandleHierarchyListItemDoubleClick(StringHash eventType, VariantMap& eventData)
-{
-    uint index = eventData["Selection"].GetUInt();
-    hierarchyList.ToggleExpand(index);
-}
-
 void HandleDragDropTest(StringHash eventType, VariantMap& eventData)
 {
     UIElement@ source = eventData["Source"].GetUIElement();

+ 20 - 19
Bin/Data/Scripts/Editor/EditorUI.as

@@ -11,6 +11,7 @@ const ShortStringHash MENU_TYPE("Menu");
 const ShortStringHash TEXT_TYPE("Text");
 const ShortStringHash CURSOR_TYPE("Cursor");
 
+const String AUTO_STYLE("");    // Empty string means auto style, i.e. applying style according to UI-element's type automatically
 const String TEMP_SCENE_NAME("_tempscene_.xml");
 const ShortStringHash CALLBACK_VAR("Callback");
 const ShortStringHash INDENT_MODIFIED_BY_ICON_VAR("IconIndented");
@@ -234,14 +235,14 @@ void CreateMenuBar()
     }
 
     {
-        Menu@ menu = CreateMenu("UI-element");
+        Menu@ menu = CreateMenu("UI-layout");
         Window@ popup = menu.popup;
-        popup.AddChild(CreateMenuItem("Open UI-element...", @PickFile, 'O', QUAL_ALT));
-        popup.AddChild(CreateMenuItem("Save UI-element", @SaveUIElementWithExistingName, 'S', QUAL_ALT));
-        popup.AddChild(CreateMenuItem("Save UI-element as...", @PickFile));
+        popup.AddChild(CreateMenuItem("Open UI-layout...", @PickFile, 'O', QUAL_ALT));
+        popup.AddChild(CreateMenuItem("Save UI-layout", @SaveUILayoutWithExistingName, 'S', QUAL_ALT));
+        popup.AddChild(CreateMenuItem("Save UI-layout as...", @PickFile));
         CreateChildDivider(popup);
-        popup.AddChild(CreateMenuItem("Close UI-element", @CloseUIElement, 'C', QUAL_ALT));
-        popup.AddChild(CreateMenuItem("Close all UI-elements", @CloseAllUIElements));
+        popup.AddChild(CreateMenuItem("Close UI-layout", @CloseUILayout, 'C', QUAL_ALT));
+        popup.AddChild(CreateMenuItem("Close all UI-layouts", @CloseAllUILayouts));
         CreateChildDivider(popup);
         popup.AddChild(CreateMenuItem("Load child element...", @PickFile));
         popup.AddChild(CreateMenuItem("Save child element as...", @PickFile));
@@ -345,12 +346,12 @@ bool PickFile()
         SubscribeToEvent(uiFileSelector, "FileSelected", "HandleResourcePath");
     }
     // UI-element
-    else if (action == "Open UI-element...")
+    else if (action == "Open UI-layout...")
     {
-        CreateFileSelector("Open UI-element", "Open", "Cancel", uiElementPath, uiElementFilters, uiElementFilter);
-        SubscribeToEvent(uiFileSelector, "FileSelected", "HandleOpenUIElementFile");
+        CreateFileSelector("Open UI-layout", "Open", "Cancel", uiElementPath, uiElementFilters, uiElementFilter);
+        SubscribeToEvent(uiFileSelector, "FileSelected", "HandleOpenUILayoutFile");
     }
-    else if (action == "Save UI-element as..." || action == "Save UI-element")
+    else if (action == "Save UI-layout as..." || action == "Save UI-layout")
     {
         if (editUIElement !is null)
         {
@@ -358,9 +359,9 @@ bool PickFile()
             if (element is null)
                 return false;
 
-            CreateFileSelector("Save UI-element as", "Save", "Cancel", uiElementPath, uiElementFilters, uiElementFilter);
+            CreateFileSelector("Save UI-layout as", "Save", "Cancel", uiElementPath, uiElementFilters, uiElementFilter);
             uiFileSelector.fileName = GetFileNameAndExtension(element.GetVar(FILENAME_VAR).GetString());
-            SubscribeToEvent(uiFileSelector, "FileSelected", "HandleSaveUIElementFile");
+            SubscribeToEvent(uiFileSelector, "FileSelected", "HandleSaveUILayoutFile");
         }
     }
     else if (action == "Load child element...")
@@ -465,7 +466,7 @@ Menu@ CreateMenuItem(const String&in title, MENU_CALLBACK@ callback = null, int
 {
     Menu@ menu = Menu(title);
     menu.defaultStyle = uiStyle;
-    menu.style = "";    // Auto style
+    menu.style = AUTO_STYLE;
     menu.SetLayout(LM_HORIZONTAL, 0, IntRect(8, 2, 8, 2));
     if (accelKey > 0)
         menu.SetAccelerator(accelKey, accelQual);
@@ -495,7 +496,7 @@ Menu@ CreateIconizedMenuItem(const String&in title, MENU_CALLBACK@ callback = nu
 {
     Menu@ menu = Menu(title);
     menu.defaultStyle = uiStyle;
-    menu.style = "";    // Auto style
+    menu.style = AUTO_STYLE;
     menu.SetLayout(LM_VERTICAL, 0, IntRect(8, 2, 8, 2));
     if (accelKey > 0)
         menu.SetAccelerator(accelKey, accelQual);
@@ -532,7 +533,7 @@ Window@ CreatePopup(Menu@ baseMenu)
 {
     Window@ popup = Window();
     popup.defaultStyle = uiStyle;
-    popup.style = "";    // Auto style
+    popup.style = AUTO_STYLE;
     popup.SetLayout(LM_VERTICAL, 1, IntRect(2, 6, 2, 6));
     baseMenu.popup = popup;
     baseMenu.popupOffset = IntVector2(0, baseMenu.height);
@@ -796,16 +797,16 @@ void HandleResourcePath(StringHash eventType, VariantMap& eventData)
     SetResourcePath(ExtractFileName(eventData), false);
 }
 
-void HandleOpenUIElementFile(StringHash eventType, VariantMap& eventData)
+void HandleOpenUILayoutFile(StringHash eventType, VariantMap& eventData)
 {
     CloseFileSelector(uiElementFilter, uiElementPath);
-    OpenUIElement(ExtractFileName(eventData));
+    OpenUILayout(ExtractFileName(eventData));
 }
 
-void HandleSaveUIElementFile(StringHash eventType, VariantMap& eventData)
+void HandleSaveUILayoutFile(StringHash eventType, VariantMap& eventData)
 {
     CloseFileSelector(uiElementFilter, uiElementPath);
-    SaveUIElement(ExtractFileName(eventData));
+    SaveUILayout(ExtractFileName(eventData));
 }
 
 void HandleLoadChildUIElementFile(StringHash eventType, VariantMap& eventData)

+ 8 - 8
Bin/Data/Scripts/Editor/EditorUIElement.as

@@ -64,7 +64,7 @@ bool NewUIElement(const String&in typeName)
             CenterDialog(element);
         }
         // Apply the auto style
-        element.style = "";
+        element.style = AUTO_STYLE;
         // Do not allow UI subsystem to reorder children while editing the element in the editor
         element.sortChildren = false;
 
@@ -88,7 +88,7 @@ void ResetSortChildren(UIElement@ element)
         ResetSortChildren(element.children[i]);
 }
 
-void OpenUIElement(const String&in fileName)
+void OpenUILayout(const String&in fileName)
 {
     if (fileName.empty)
         return;
@@ -144,7 +144,7 @@ void OpenUIElement(const String&in fileName)
     suppressUIElementChanges = false;
 }
 
-bool CloseUIElement()
+bool CloseUILayout()
 {
     ui.cursor.shape = CS_BUSY;
 
@@ -167,7 +167,7 @@ bool CloseUIElement()
     return true;
 }
 
-bool CloseAllUIElements()
+bool CloseAllUILayouts()
 {
     ui.cursor.shape = CS_BUSY;
 
@@ -187,7 +187,7 @@ bool CloseAllUIElements()
     return true;
 }
 
-bool SaveUIElement(const String&in fileName)
+bool SaveUILayout(const String&in fileName)
 {
     if (fileName.empty)
         return false;
@@ -219,7 +219,7 @@ bool SaveUIElement(const String&in fileName)
     return success;
 }
 
-bool SaveUIElementWithExistingName()
+bool SaveUILayoutWithExistingName()
 {
     ui.cursor.shape = CS_BUSY;
 
@@ -231,7 +231,7 @@ bool SaveUIElementWithExistingName()
     if (fileName.empty)
         return PickFile();  // No name yet, so pick one
     else
-        return SaveUIElement(fileName);
+        return SaveUILayout(fileName);
 }
 
 void LoadChildUIElement(const String&in fileName)
@@ -390,7 +390,7 @@ UIElement@ GetTopLevelUIElement(UIElement@ element)
 void SetUIElementModified(UIElement@ element, bool flag = true)
 {
     element = GetTopLevelUIElement(element);
-    if (element.GetVar(MODIFIED_VAR).GetBool() != flag)
+    if (element !is null && element.GetVar(MODIFIED_VAR).GetBool() != flag)
     {
         element.vars[MODIFIED_VAR] = flag;
         UpdateHierarchyItemText(GetListIndex(element), element.visible, GetUIElementTitle(element));