From 9a6f8669563f555d86ea4441b32d962d7ea0d346 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Mon, 29 Apr 2024 18:24:01 -0500 Subject: [PATCH 1/4] Move control transform to be under general group in layout. --- .../Dedicated/UIControlEditor.cs | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs b/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs index 27be8e538..282a3103b 100644 --- a/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs +++ b/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs @@ -458,12 +458,36 @@ namespace FlaxEditor.CustomEditors.Dedicated { if (layout.Children[i] is GroupElement group && group.Panel.HeaderText == "Transform") { - VerticalPanelElement mainHor = VerticalPanelWithoutMargin(group); - CreateTransformElements(mainHor, ValuesTypes); - group.ContainerControl.ChangeChildIndex(mainHor.Control, 0); + layout.Children.Remove(group); break; } } + + // Setup transform + if (Presenter is LayoutElementsContainer l) + { + var group = l.Group("Transform"); + VerticalPanelElement mainHor = VerticalPanelWithoutMargin(group); + CreateTransformElements(mainHor, ValuesTypes); + + ScriptMemberInfo scaleInfo = ValuesTypes[0].GetProperty("Scale"); + ItemInfo scaleItem = new ItemInfo(scaleInfo); + group.Property("Scale", scaleItem.GetValues(Values)); + + ScriptMemberInfo pivotInfo = ValuesTypes[0].GetProperty("Pivot"); + ItemInfo pivotItem = new ItemInfo(pivotInfo); + group.Property("Pivot", pivotItem.GetValues(Values)); + + ScriptMemberInfo shearInfo = ValuesTypes[0].GetProperty("Shear"); + ItemInfo shearItem = new ItemInfo(shearInfo); + group.Property("Shear", shearItem.GetValues(Values)); + + ScriptMemberInfo rotationInfo = ValuesTypes[0].GetProperty("Rotation"); + ItemInfo rotationItem = new ItemInfo(rotationInfo); + group.Property("Rotation", rotationItem.GetValues(Values)); + + Presenter.ContainerControl.ChangeChildIndex(group.Control, 1); + } } private void CreateTransformElements(LayoutElementsContainer main, ScriptType[] valueTypes) From 2e5ad8c48ae74847b84770c7225a162593d49688 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Mon, 29 Apr 2024 18:28:04 -0500 Subject: [PATCH 2/4] Always set control transform under general tab --- .../Dedicated/UIControlEditor.cs | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs b/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs index 282a3103b..9deb685a1 100644 --- a/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs +++ b/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs @@ -466,27 +466,35 @@ namespace FlaxEditor.CustomEditors.Dedicated // Setup transform if (Presenter is LayoutElementsContainer l) { - var group = l.Group("Transform"); - VerticalPanelElement mainHor = VerticalPanelWithoutMargin(group); + var transformGroup = l.Group("Transform"); + VerticalPanelElement mainHor = VerticalPanelWithoutMargin(transformGroup); CreateTransformElements(mainHor, ValuesTypes); ScriptMemberInfo scaleInfo = ValuesTypes[0].GetProperty("Scale"); ItemInfo scaleItem = new ItemInfo(scaleInfo); - group.Property("Scale", scaleItem.GetValues(Values)); + transformGroup.Property("Scale", scaleItem.GetValues(Values)); ScriptMemberInfo pivotInfo = ValuesTypes[0].GetProperty("Pivot"); ItemInfo pivotItem = new ItemInfo(pivotInfo); - group.Property("Pivot", pivotItem.GetValues(Values)); + transformGroup.Property("Pivot", pivotItem.GetValues(Values)); ScriptMemberInfo shearInfo = ValuesTypes[0].GetProperty("Shear"); ItemInfo shearItem = new ItemInfo(shearInfo); - group.Property("Shear", shearItem.GetValues(Values)); + transformGroup.Property("Shear", shearItem.GetValues(Values)); ScriptMemberInfo rotationInfo = ValuesTypes[0].GetProperty("Rotation"); ItemInfo rotationItem = new ItemInfo(rotationInfo); - group.Property("Rotation", rotationItem.GetValues(Values)); + transformGroup.Property("Rotation", rotationItem.GetValues(Values)); - Presenter.ContainerControl.ChangeChildIndex(group.Control, 1); + // Get position of general tab + for (int i = 0; i < l.Children.Count; i++) + { + if (l.Children[i] is GroupElement g && g.Panel.HeaderText == "General" && i + 1 <= l.Children.Count) + { + Presenter.ContainerControl.ChangeChildIndex(transformGroup.Control, i + 1); + break; + } + } } } From 1c1d2fd96f39806fef1a61cc1cf114c88f0bffff Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Mon, 29 Apr 2024 19:38:36 -0500 Subject: [PATCH 3/4] Fix still showing some control transform properties in wrong spot. --- Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs b/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs index 9deb685a1..5db974240 100644 --- a/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs +++ b/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs @@ -456,9 +456,10 @@ namespace FlaxEditor.CustomEditors.Dedicated for (int i = 0; i < layout.Children.Count; i++) { - if (layout.Children[i] is GroupElement group && group.Panel.HeaderText == "Transform") + if (layout.Children[i] is GroupElement group && group.Panel.HeaderText.Equals("Transform", StringComparison.Ordinal)) { layout.Children.Remove(group); + layout.ContainerControl.Children.Remove(group.Panel); break; } } @@ -489,7 +490,7 @@ namespace FlaxEditor.CustomEditors.Dedicated // Get position of general tab for (int i = 0; i < l.Children.Count; i++) { - if (l.Children[i] is GroupElement g && g.Panel.HeaderText == "General" && i + 1 <= l.Children.Count) + if (l.Children[i] is GroupElement g && g.Panel.HeaderText.Equals("General", StringComparison.Ordinal) && i + 1 <= l.Children.Count) { Presenter.ContainerControl.ChangeChildIndex(transformGroup.Control, i + 1); break; From d1db06a9bb8da631fdc5a589a684a2bc2aa0180b Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Mon, 29 Apr 2024 19:44:49 -0500 Subject: [PATCH 4/4] Change text alignment to far on some control transform properties --- Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs b/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs index 5db974240..d517d12fd 100644 --- a/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs +++ b/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs @@ -678,7 +678,7 @@ namespace FlaxEditor.CustomEditors.Dedicated { var grid = UniformGridTwoByOne(el); grid.CustomControl.SlotPadding = new Margin(5, 5, 1, 1); - var label = grid.Label(text); + var label = grid.Label(text, TextAlignment.Far); var editor = grid.Object(values); if (editor is FloatEditor floatEditor && floatEditor.Element is FloatValueElement floatEditorElement) {