From 64d35815d8c97ff2dc63ec36df6f86549a71e416 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Tue, 26 May 2020 11:26:24 +0200 Subject: [PATCH 1/4] Made property row labels flexible --- com.unity.shadergraph/Editor/Resources/Styles/PropertyRow.uss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/com.unity.shadergraph/Editor/Resources/Styles/PropertyRow.uss b/com.unity.shadergraph/Editor/Resources/Styles/PropertyRow.uss index 775aa955fff..40f0cff21d9 100644 --- a/com.unity.shadergraph/Editor/Resources/Styles/PropertyRow.uss +++ b/com.unity.shadergraph/Editor/Resources/Styles/PropertyRow.uss @@ -19,6 +19,8 @@ PropertyRow > #container{ } PropertyRow > #container > #label { + flex-grow: 5; + min-width: 92px; width: 92px; font-size: 12px; margin-right: 4px; From 021e99dfec962d7649b94841df0f0f77f3e85a13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Tue, 26 May 2020 11:36:05 +0200 Subject: [PATCH 2/4] Fixed indent level of propertyRow --- .../Contexts/TargetPropertyGUIContext.cs | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/com.unity.shadergraph/Editor/Generation/Contexts/TargetPropertyGUIContext.cs b/com.unity.shadergraph/Editor/Generation/Contexts/TargetPropertyGUIContext.cs index 1f64879804c..08f8465ca9a 100644 --- a/com.unity.shadergraph/Editor/Generation/Contexts/TargetPropertyGUIContext.cs +++ b/com.unity.shadergraph/Editor/Generation/Contexts/TargetPropertyGUIContext.cs @@ -10,6 +10,8 @@ namespace UnityEditor.ShaderGraph [GenerationAPI] internal class TargetPropertyGUIContext : VisualElement { + const int kIndentWidthInPixel = 20; + public TargetPropertyGUIContext() { @@ -43,29 +45,23 @@ public void AddProperty(string label, int indentLevel, BaseField field, Ev notifyValueChanged.RegisterValueChangedCallback(evt); } - string labelText = ""; - for (var i = 0; i < indentLevel; i++) - { - labelText += " "; - } - labelText += label; - var propertyRow = new PropertyRow(new Label(labelText)); + var propertyRow = new PropertyRow(new Label(label)); + ApplyPadding(propertyRow, indentLevel); propertyRow.Add(field); this.hierarchy.Add(propertyRow); } public void AddLabel(string label, int indentLevel) { - string labelText = ""; - for (var i = 0; i < indentLevel; i++) - { - labelText += " "; - } - labelText += label; - - var propertyRow = new PropertyRow(new Label(labelText)); + var propertyRow = new PropertyRow(new Label(label)); + ApplyPadding(propertyRow, indentLevel); this.hierarchy.Add(propertyRow); } + + void ApplyPadding(VisualElement element, int indentLevel) + { + element.style.paddingLeft = indentLevel * kIndentWidthInPixel; + } } } From f3cf3d58263028c9493fa873f17e3e469a6aa46b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Tue, 26 May 2020 14:53:32 +0200 Subject: [PATCH 3/4] Added more control to indent level and clear foldout --- .../PropertyDrawers/GraphDataPropertyDrawer.cs | 1 + .../Generation/Contexts/TargetPropertyGUIContext.cs | 6 ++++-- .../Editor/Resources/Styles/InspectorView.uss | 11 ++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/GraphDataPropertyDrawer.cs b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/GraphDataPropertyDrawer.cs index 021c587f054..64eabe68e85 100644 --- a/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/GraphDataPropertyDrawer.cs +++ b/com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/GraphDataPropertyDrawer.cs @@ -96,6 +96,7 @@ void RegisterActionToUndo(string actionName) // Create foldout var foldout = new Foldout() { text = targetName, value = foldoutActive, name = "foldout" }; element.Add(foldout); + foldout.AddToClassList("MainFoldout"); foldout.RegisterValueChangedCallback(evt => { // Update foldout value and rebuild diff --git a/com.unity.shadergraph/Editor/Generation/Contexts/TargetPropertyGUIContext.cs b/com.unity.shadergraph/Editor/Generation/Contexts/TargetPropertyGUIContext.cs index 08f8465ca9a..120f0de6227 100644 --- a/com.unity.shadergraph/Editor/Generation/Contexts/TargetPropertyGUIContext.cs +++ b/com.unity.shadergraph/Editor/Generation/Contexts/TargetPropertyGUIContext.cs @@ -10,7 +10,9 @@ namespace UnityEditor.ShaderGraph [GenerationAPI] internal class TargetPropertyGUIContext : VisualElement { - const int kIndentWidthInPixel = 20; + const int kIndentWidthInPixel = 15; + + public int globalIndentLevel {get; set;} = 0; public TargetPropertyGUIContext() { @@ -61,7 +63,7 @@ public void AddLabel(string label, int indentLevel) void ApplyPadding(VisualElement element, int indentLevel) { - element.style.paddingLeft = indentLevel * kIndentWidthInPixel; + element.style.paddingLeft = (globalIndentLevel + indentLevel) * kIndentWidthInPixel; } } } diff --git a/com.unity.shadergraph/Editor/Resources/Styles/InspectorView.uss b/com.unity.shadergraph/Editor/Resources/Styles/InspectorView.uss index ccd6137f8c3..5aa67a04bce 100644 --- a/com.unity.shadergraph/Editor/Resources/Styles/InspectorView.uss +++ b/com.unity.shadergraph/Editor/Resources/Styles/InspectorView.uss @@ -1,8 +1,3 @@ -.unity-label { - padding: 5px 2px 2px; - margin: 2px 4px; -} - .InspectorView { position:absolute; justify-content: flex-start; @@ -65,3 +60,9 @@ font-size: 11px; color: #606060; } + +.MainFoldout { + background-color: #383838; + border-color: #1F1F1F; + border-top-width: 1px; +} \ No newline at end of file From 944c20a9e015268fc1416f6cae76b208ad91673c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Tue, 26 May 2020 19:42:48 +0200 Subject: [PATCH 4/4] Fix slight misalignment in fields --- .../Editor/Generation/Contexts/TargetPropertyGUIContext.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/com.unity.shadergraph/Editor/Generation/Contexts/TargetPropertyGUIContext.cs b/com.unity.shadergraph/Editor/Generation/Contexts/TargetPropertyGUIContext.cs index 120f0de6227..108d8f204aa 100644 --- a/com.unity.shadergraph/Editor/Generation/Contexts/TargetPropertyGUIContext.cs +++ b/com.unity.shadergraph/Editor/Generation/Contexts/TargetPropertyGUIContext.cs @@ -61,9 +61,9 @@ public void AddLabel(string label, int indentLevel) this.hierarchy.Add(propertyRow); } - void ApplyPadding(VisualElement element, int indentLevel) + void ApplyPadding(PropertyRow row, int indentLevel) { - element.style.paddingLeft = (globalIndentLevel + indentLevel) * kIndentWidthInPixel; + row.Q(className: "unity-label").style.marginLeft = (globalIndentLevel + indentLevel) * kIndentWidthInPixel; } } }