Browse Source

Added option in UI-element editor to show/hide the internal UI-elements, configurable in the editor's preferences window. Adjusted CheckBox UI-element to have fixed size by default.

Wei Tjong Yao 12 years ago
parent
commit
79b2fc726c

+ 16 - 7
Bin/Data/Scripts/Editor.as

@@ -25,7 +25,7 @@ void Start()
         // Unix-like platforms usually hide application configuration file
         configPath = ".Urho3D/Editor/";
     configFileName = fileSystem.userDocumentsDir + configPath + "Config.xml";
-    
+
     if (engine.headless)
     {
         ErrorDialog("Urho3D Editor", "Headless mode is not supported. The program will now exit.");
@@ -34,7 +34,7 @@ void Start()
     }
 
     SubscribeToEvent("Update", "HandleUpdate");
-    
+
     // Enable console commands from the editor script
     script.defaultScriptFile = scriptFile;
     // Enable automatic resource reloading
@@ -73,7 +73,7 @@ void ParseArguments()
             break;
         }
     }
-    
+
     if (!loaded)
         ResetScene();
 }
@@ -105,6 +105,7 @@ void LoadConfig()
     XMLElement objectElem = configElem.GetChild("object");
     XMLElement renderingElem = configElem.GetChild("rendering");
     XMLElement uiElem = configElem.GetChild("ui");
+    XMLElement hierarchyElem = configElem.GetChild("hierarchy");
     XMLElement inspectorElem = configElem.GetChild("attributeinspector");
 
     if (!cameraElem.isNull)
@@ -141,13 +142,18 @@ void LoadConfig()
         if (renderingElem.HasAttribute("dynamicinstancing")) renderer.dynamicInstancing = instancingSetting = renderingElem.GetBool("dynamicinstancing");
         if (renderingElem.HasAttribute("framelimiter")) engine.maxFps = renderingElem.GetBool("framelimiter") ? 200 : 0;
     }
-    
+
     if (!uiElem.isNull)
     {
         if (uiElem.HasAttribute("minopacity")) uiMinOpacity = uiElem.GetFloat("minopacity");
         if (uiElem.HasAttribute("maxopacity")) uiMaxOpacity = uiElem.GetFloat("maxopacity");
     }
 
+    if (!hierarchyElem.isNull)
+    {
+        if (hierarchyElem.HasAttribute("showinternaluielement")) showInternalUIElement = hierarchyElem.GetBool("showinternaluielement");
+    }
+
     if (!inspectorElem.isNull)
     {
         if (inspectorElem.HasAttribute("originalcolor")) normalTextColor = inspectorElem.GetColor("originalcolor");
@@ -167,6 +173,7 @@ void SaveConfig()
     XMLElement objectElem = configElem.CreateChild("object");
     XMLElement renderingElem = configElem.CreateChild("rendering");
     XMLElement uiElem = configElem.CreateChild("ui");
+    XMLElement hierarchyElem = configElem.CreateChild("hierarchy");
     XMLElement inspectorElem = configElem.CreateChild("attributeinspector");
 
     // The save config may be called on error exit so some of the objects below could still be null
@@ -199,15 +206,17 @@ void SaveConfig()
         renderingElem.SetInt("maxoccludertriangles", renderer.maxOccluderTriangles);
         renderingElem.SetBool("specularlighting", renderer.specularLighting);
     }
-    
+
     if (graphics !is null)
         renderingElem.SetBool("dynamicinstancing", graphics.sm3Support ? renderer.dynamicInstancing : instancingSetting);
-    
+
     renderingElem.SetBool("framelimiter", engine.maxFps > 0);
-    
+
     uiElem.SetFloat("minopacity", uiMinOpacity);
     uiElem.SetFloat("maxopacity", uiMaxOpacity);
 
+    hierarchyElem.SetBool("showinternaluielement", showInternalUIElement);
+
     inspectorElem.SetColor("originalcolor", normalTextColor);
     inspectorElem.SetColor("modifiedcolor", modifiedTextColor);
     inspectorElem.SetColor("noneditablecolor", nonEditableTextColor);

+ 0 - 1
Bin/Data/Scripts/Editor/AttributeEditor.as

@@ -145,7 +145,6 @@ UIElement@ CreateBoolAttributeEditor(ListView@ list, Array<Serializable@>@ seria
     CheckBox@ attrEdit = CheckBox();
     parent.AddChild(attrEdit);
     attrEdit.style = uiStyle;
-    attrEdit.SetFixedSize(16, 16);
     attrEdit.vars["Index"] = index;
     attrEdit.vars["SubIndex"] = subIndex;
     SetAttributeEditorID(attrEdit, serializables);

+ 17 - 7
Bin/Data/Scripts/Editor/EditorPreferences.as

@@ -17,7 +17,7 @@ void CreateEditorPreferencesDialog()
 {
     if (preferencesDialog !is null)
         return;
-    
+
     preferencesDialog = ui.LoadLayout(cache.GetResource("XMLFile", "UI/EditorPreferencesDialog.xml"));
     ui.root.AddChild(preferencesDialog);
     preferencesDialog.opacity = uiMaxOpacity;
@@ -44,29 +44,33 @@ void UpdateEditorPreferencesDialog()
 
     LineEdit@ uiMinOpacityEdit = preferencesDialog.GetChild("UIMinOpacity", true);
     uiMinOpacityEdit.text = String(uiMinOpacity);
-    
+
     LineEdit@ uiMaxOpacityEdit = preferencesDialog.GetChild("UIMaxOpacity", true);
     uiMaxOpacityEdit.text = String(uiMaxOpacity);
-    
+
+    CheckBox@ showInternalUIElementToggle = preferencesDialog.GetChild("ShowInternalUIElement", true);
+    showInternalUIElementToggle.checked = showInternalUIElement;
+
     CheckBox@ showNonEditableAttributeToggle = preferencesDialog.GetChild("ShowNonEditableAttribute", true);
     showNonEditableAttributeToggle.checked = showNonEditableAttribute;
-    
+
     originalAttributeTextColorEditR.text = String(normalTextColor.r);
     originalAttributeTextColorEditG.text = String(normalTextColor.g);
     originalAttributeTextColorEditB.text = String(normalTextColor.b);
-    
+
     modifiedAttributeTextColorEditR.text = String(modifiedTextColor.r);
     modifiedAttributeTextColorEditG.text = String(modifiedTextColor.g);
     modifiedAttributeTextColorEditB.text = String(modifiedTextColor.b);
-    
+
     nonEditableAttributeTextColorEditR.text = String(nonEditableTextColor.r);
     nonEditableAttributeTextColorEditG.text = String(nonEditableTextColor.g);
     nonEditableAttributeTextColorEditB.text = String(nonEditableTextColor.b);
-    
+
     if (!subscribedToEditorPreferences)
     {
         SubscribeToEvent(uiMinOpacityEdit, "TextFinished", "EditUIMinOpacity");
         SubscribeToEvent(uiMaxOpacityEdit, "TextFinished", "EditUIMaxOpacity");
+        SubscribeToEvent(showInternalUIElementToggle, "Toggled", "ToggleShowInternalUIElement");
         SubscribeToEvent(showNonEditableAttributeToggle, "Toggled", "ToggleShowNonEditableAttribute");
         SubscribeToEvent(originalAttributeTextColorEditR, "TextFinished", "EditOriginalAttributeTextColor");
         SubscribeToEvent(originalAttributeTextColorEditG, "TextFinished", "EditOriginalAttributeTextColor");
@@ -113,6 +117,12 @@ void EditUIMaxOpacity(StringHash eventType, VariantMap& eventData)
     UnfadeUI();
 }
 
+void ToggleShowInternalUIElement(StringHash eventType, VariantMap& eventData)
+{
+    showInternalUIElement = cast<CheckBox>(eventData["Element"].GetUIElement()).checked;
+    UpdateHierarchyItem(editorUIElement, true);
+}
+
 void ToggleShowNonEditableAttribute(StringHash eventType, VariantMap& eventData)
 {
     showNonEditableAttribute = cast<CheckBox>(eventData["Element"].GetUIElement()).checked;

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

@@ -20,6 +20,7 @@ ListView@ hierarchyList;
 // UIElement does not have unique ID, so use a running number to generate a new ID each time an item is inserted into hierarchy list
 const uint UI_ELEMENT_BASE_ID = 1;
 uint uiElementNextID = UI_ELEMENT_BASE_ID;
+bool showInternalUIElement = false;
 
 Variant GetUIElementID(UIElement@ element)
 {
@@ -236,7 +237,8 @@ uint UpdateHierarchyItem(uint itemIndex, Serializable@ serializable, UIElement@
             for (uint i = 0; i < element.numChildren; ++i)
             {
                 UIElement@ childElement = element.children[i];
-                itemIndex = UpdateHierarchyItem(itemIndex, childElement, text);
+                if (showInternalUIElement || !childElement.internal)
+                    itemIndex = UpdateHierarchyItem(itemIndex, childElement, text);
             }
 
             break;
@@ -788,7 +790,7 @@ bool TestDragDrop(UIElement@ source, UIElement@ target, int& itemType)
     if (sourceNode !is null && targetNode !is null)
     {
         itemType = ITEM_NODE;
-        
+
         if (sourceNode.parent is targetNode)
             return false;
         if (targetNode.parent is sourceNode)
@@ -797,7 +799,7 @@ bool TestDragDrop(UIElement@ source, UIElement@ target, int& itemType)
     else if (sourceElement !is null && targetElement !is null)
     {
         itemType = ITEM_UI_ELEMENT;
-        
+
         if (sourceElement.parent is targetElement)
             return false;
         if (targetElement.parent is sourceElement)
@@ -933,7 +935,8 @@ void HandleUIElementAdded(StringHash eventType, VariantMap& eventData)
         return;
 
     UIElement@ element = eventData["Element"].GetUIElement();
-    UpdateHierarchyItem(element);
+    if (showInternalUIElement || !element.internal)
+        UpdateHierarchyItem(element);
 }
 
 void HandleUIElementRemoved(StringHash eventType, VariantMap& eventData)

+ 2 - 1
Bin/Data/UI/DefaultStyle.xml

@@ -9,7 +9,8 @@
         <attribute name="Label Offset" value="-1 1" />
     </element>
     <element type="CheckBox">
-        <attribute name="Size" value="16 16" />
+        <attribute name="Min Size" value="16 16" />
+        <attribute name="Max Size" value="16 16" />
         <attribute name="Texture" value="Texture2D;Textures/UI.png" />
         <attribute name="Image Rect" value="64 0 80 16" />
         <attribute name="Border" value="4 4 4 4" />

+ 24 - 6
Bin/Data/UI/EditorPreferencesDialog.xml

@@ -2,16 +2,16 @@
     <attribute name="Name" value="EditorPrefsDialog" />
     <attribute name="Min Size" value="400 0" />
     <attribute name="Max Size" value="400 2147483647" />
-    <attribute name="Is Movable" value="true" />
     <attribute name="Layout Mode" value="Vertical" />
     <attribute name="Layout Spacing" value="4" />
     <attribute name="Layout Border" value="6 6 6 6" />
+    <attribute name="Is Movable" value="true" />
     <element>
         <attribute name="Min Size" value="0 16" />
         <attribute name="Max Size" value="2147483647 16" />
         <attribute name="Layout Mode" value="Horizontal" />
         <element type="Text">
-            <attribute name="Text" value="Editor Preferences" />
+            <attribute name="Text" value="Editor preferences" />
         </element>
         <element type="Button" style="CloseButton">
             <attribute name="Name" value="CloseButton" />
@@ -22,7 +22,7 @@
         <attribute name="Min Size" value="0 17" />
         <attribute name="Max Size" value="2147483647 17" />
         <element type="Text">
-            <attribute name="Text" value="User Interface" />
+            <attribute name="Text" value="User interface" />
         </element>
     </element>
     <element>
@@ -58,7 +58,27 @@
         <attribute name="Min Size" value="0 17" />
         <attribute name="Max Size" value="2147483647 17" />
         <element type="Text">
-            <attribute name="Text" value="Attribute Inspector" />
+            <attribute name="Text" value="Hierarchy" />
+        </element>
+    </element>
+    <element>
+        <attribute name="Min Size" value="0 17" />
+        <attribute name="Max Size" value="2147483647 17" />
+        <attribute name="Layout Mode" value="Horizontal" />
+        <attribute name="Layout Border" value="20 0 0 0" />
+        <element type="Text">
+            <attribute name="Text" value="Show internal UI-elements" />
+        </element>
+        <element type="CheckBox">
+            <attribute name="Name" value="ShowInternalUIElement" />
+        </element>
+    </element>
+    <element type="BorderImage" style="EditorDivider" />
+    <element>
+        <attribute name="Min Size" value="0 17" />
+        <attribute name="Max Size" value="2147483647 17" />
+        <element type="Text">
+            <attribute name="Text" value="Attribute inspector" />
         </element>
     </element>
     <element>
@@ -71,8 +91,6 @@
         </element>
         <element type="CheckBox">
             <attribute name="Name" value="ShowNonEditableAttribute" />
-            <attribute name="Min Size" value="16 16" />
-            <attribute name="Max Size" value="16 16" />
         </element>
     </element>
     <element>

+ 0 - 16
Bin/Data/UI/EditorSettingsDialog.xml

@@ -99,8 +99,6 @@
         </element>
         <element type="CheckBox">
             <attribute name="Name" value="MoveSnapToggle" />
-            <attribute name="Min Size" value="16 16" />
-            <attribute name="Max Size" value="16 16" />
         </element>
         <element type="Text">
             <attribute name="Min Size" value="34 0" />
@@ -123,8 +121,6 @@
         </element>
         <element type="CheckBox">
             <attribute name="Name" value="RotateSnapToggle" />
-            <attribute name="Min Size" value="16 16" />
-            <attribute name="Max Size" value="16 16" />
         </element>
         <element type="Text">
             <attribute name="Min Size" value="34 0" />
@@ -147,8 +143,6 @@
         </element>
         <element type="CheckBox">
             <attribute name="Name" value="ScaleSnapToggle" />
-            <attribute name="Min Size" value="16 16" />
-            <attribute name="Max Size" value="16 16" />
         </element>
         <element type="Text">
             <attribute name="Min Size" value="34 0" />
@@ -207,8 +201,6 @@
         <attribute name="Layout Spacing" value="8" />
         <element type="CheckBox">
             <attribute name="Name" value="LocalIDToggle" />
-            <attribute name="Min Size" value="16 16" />
-            <attribute name="Max Size" value="16 16" />
         </element>
         <element type="Text">
             <attribute name="Text" value="Use local entity IDs on import" />
@@ -221,8 +213,6 @@
         <attribute name="Layout Spacing" value="8" />
         <element type="CheckBox">
             <attribute name="Name" value="ApplyMaterialListToggle" />
-            <attribute name="Min Size" value="16 16" />
-            <attribute name="Max Size" value="16 16" />
         </element>
         <element type="Text">
             <attribute name="Text" value="Apply material list when model set" />
@@ -402,8 +392,6 @@
         <attribute name="Layout Spacing" value="8" />
         <element type="CheckBox">
             <attribute name="Name" value="SpecularLightingToggle" />
-            <attribute name="Min Size" value="16 16" />
-            <attribute name="Max Size" value="16 16" />
         </element>
         <element type="Text">
             <attribute name="Text" value="Specular lighting" />
@@ -416,8 +404,6 @@
         <attribute name="Layout Spacing" value="8" />
         <element type="CheckBox">
             <attribute name="Name" value="DynamicInstancingToggle" />
-            <attribute name="Min Size" value="16 16" />
-            <attribute name="Max Size" value="16 16" />
         </element>
         <element type="Text">
             <attribute name="Text" value="Dynamic instancing" />
@@ -430,8 +416,6 @@
         <attribute name="Layout Spacing" value="8" />
         <element type="CheckBox">
             <attribute name="Name" value="FrameLimiterToggle" />
-            <attribute name="Min Size" value="16 16" />
-            <attribute name="Max Size" value="16 16" />
         </element>
         <element type="Text">
             <attribute name="Text" value="Frame limiter" />

+ 1 - 1
Engine/UI/UIElement.cpp

@@ -1618,7 +1618,7 @@ bool UIElement::FilterImplicitAttributes(XMLElement& dest) const
     }
 
     // Remove positioning and sizing attributes when they are under the influence of layout mode
-    if (layoutMode_ != LM_FREE && minSize_ != maxSize_)
+    if (layoutMode_ != LM_FREE && !IsFixedWidth() && !IsFixedHeight())
     {
         if (!RemoveChildXML(dest, "Min Size"))
             return false;