diff --git a/CHANGELOG.md b/CHANGELOG.md index ba32d5c..6145b09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), ### Changed +- Reduce the vertical gap between object rows by at least half (#292). + - Point new installs and documentation links to Ambiguous-Interactive/DxVisualizer. Update site bookmarks to ; the old Pages site does not redirect. Existing Git installs keep working (#151). diff --git a/Editor/DataVisualizer/DataVisualizer.cs b/Editor/DataVisualizer/DataVisualizer.cs index 72b5fda..6cbad22 100644 --- a/Editor/DataVisualizer/DataVisualizer.cs +++ b/Editor/DataVisualizer/DataVisualizer.cs @@ -85,11 +85,10 @@ overwrite the saved preferred size. private const int AsyncLoadPriorityBatchSize = 100; /* - Uniform row height for the virtualized object ListView. Measured live: the .object-item - box renders at ~40px; the slot is forced to this height and centers the box, so the extra - 6px becomes a 3px gap above and below each row. + Keep the fixed-height object ListView slots close to the card height to reduce + empty vertical space. Card padding and controls keep their existing dimensions. */ - private const float ObjectRowFixedHeight = 46f; + private const float ObjectRowFixedHeight = 40f; internal static DataVisualizer Instance; diff --git a/Tests/Editor/ObjectRowLayoutTests.cs b/Tests/Editor/ObjectRowLayoutTests.cs new file mode 100644 index 0000000..2463ce3 --- /dev/null +++ b/Tests/Editor/ObjectRowLayoutTests.cs @@ -0,0 +1,74 @@ +namespace WallstopStudios.DataVisualizer.Tests.Editor +{ + using System.Collections; + using System.Reflection; + using NUnit.Framework; + using UnityEditor; + using UnityEngine; + using UnityEngine.TestTools; + using UnityEngine.UIElements; + using WallstopStudios.DataVisualizer.Editor.Styles; + using DataVisualizerWindow = WallstopStudios.DataVisualizer.Editor.DataVisualizer; + + public sealed class ObjectRowLayoutTests + { + [UnityTest] + public IEnumerator ShouldKeepCompactRowsAndControlsInsideEveryShippedTheme() + { + using TestCleanupScope cleanup = new(); + FieldInfo instanceField = typeof(DataVisualizerWindow).GetField("Instance", BindingFlags.Static | BindingFlags.NonPublic); + object previousInstance = instanceField.GetValue(null); + cleanup.Defer(() => instanceField.SetValue(null, previousInstance)); + DataVisualizerWindow owner = ScriptableObject.CreateInstance(); + cleanup.Defer(() => Object.DestroyImmediate(owner)); + MethodInfo makeRow = typeof(DataVisualizerWindow).GetMethod("MakeObjectRow", BindingFlags.Instance | BindingFlags.NonPublic); + LayoutTestWindow window = ScriptableObject.CreateInstance(); + cleanup.Defer(window.Close); + window.position = new Rect(100, 100, 700, 200); + VisualElement root = window.rootVisualElement; + root.AddToClassList("dataviz-root"); + const string folder = "Packages/com.wallstop-studios.data-visualizer/Editor/DataVisualizer/Styles/"; + root.styleSheets.Add(AssetDatabase.LoadAssetAtPath(folder + "DataVisualizerStyles.uss")); + VisualElement first = (VisualElement)makeRow.Invoke(owner, null); + VisualElement second = (VisualElement)makeRow.Invoke(owner, null); + first.Q