Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://ambiguous-interactive.github.io/DxVisualizer/>; the old Pages
site does not redirect. Existing Git installs keep working (#151).

Expand Down
7 changes: 3 additions & 4 deletions Editor/DataVisualizer/DataVisualizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
74 changes: 74 additions & 0 deletions Tests/Editor/ObjectRowLayoutTests.cs
Original file line number Diff line number Diff line change
@@ -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<DataVisualizerWindow>();
cleanup.Defer(() => Object.DestroyImmediate(owner));
MethodInfo makeRow = typeof(DataVisualizerWindow).GetMethod("MakeObjectRow", BindingFlags.Instance | BindingFlags.NonPublic);
LayoutTestWindow window = ScriptableObject.CreateInstance<LayoutTestWindow>();
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<StyleSheet>(folder + "DataVisualizerStyles.uss"));
VisualElement first = (VisualElement)makeRow.Invoke(owner, null);
VisualElement second = (VisualElement)makeRow.Invoke(owner, null);
first.Q<Label>("object-item-label").text = "First object";
second.Q<Label>("object-item-label").text = "Second object";
root.Add(first);
root.Add(second);
DataVisualizerThemeSelection selection = new();
cleanup.Defer(() => selection.Apply(null, null));
window.ShowUtility();

string[] themes = { "Dx", "Classic", "Nord", "Dracula", "Compact", "Minimal" };
foreach (string name in themes)
{
DataVisualizerThemeSettings theme = AssetDatabase.LoadAssetAtPath<DataVisualizerThemeSettings>(folder + name + ".asset");
Assert.That(theme != null, name);
selection.Apply(root, theme);
yield return null;
EditorSurfaceCapture.SettleLayout(window);
VisualElement firstBox = first.Q("object-item-box");
VisualElement secondBox = second.Q("object-item-box");
float gap = secondBox.worldBound.yMin - firstBox.worldBound.yMax;
Assert.That(0 <= gap, name + " cards must not overlap");
if (name == "Dx")
{
Assert.LessOrEqual(gap, 5f, "halve the previous 10-point default gap");
}
Comment thread
wallstop marked this conversation as resolved.

foreach (VisualElement row in new[] { first, second })
{
VisualElement box = row.Q("object-item-box");
Assert.That(row.worldBound.yMin <= box.worldBound.yMin, name);
Assert.That(box.worldBound.yMax <= row.worldBound.yMax, name);
foreach (Button button in box.Query<Button>().ToList())
{
Assert.That(0 < button.worldBound.height, name);
Assert.That(box.worldBound.yMin <= button.worldBound.yMin, name);
Assert.That(button.worldBound.yMax <= box.worldBound.yMax, name);
}
}
}
}
}
}
2 changes: 2 additions & 0 deletions Tests/Editor/ObjectRowLayoutTests.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified docs/images/data-visualizer-layout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/data-visualizer-layout.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading