Browse Source

Stretch metadata row details across the full row width

The details content was pinned left and the text blob capped at 800px,
leaving dead space to the right of embedded-source text and the
flags/typed sub-grids. Let all three detail shapes stretch and give the
last sub-grid column the leftover width so the details area fills its
host row.

Assisted-by: Claude:claude-fable-5:Claude Code
pull/3945/head
Siegfried Pammer 2 months ago committed by Siegfried Pammer
parent
commit
917b0a4bcb
  1. 24
      ILSpy.Tests/Metadata/MetadataRowDetailsTests.cs
  2. 9
      ILSpy/Metadata/MetadataRowDetails.cs

24
ILSpy.Tests/Metadata/MetadataRowDetailsTests.cs

@ -23,6 +23,7 @@ using System.Threading.Tasks; @@ -23,6 +23,7 @@ using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Headless.NUnit;
using Avalonia.Layout;
using Avalonia.VisualTree;
using AwesomeAssertions;
@ -147,6 +148,29 @@ public class MetadataRowDetailsTests @@ -147,6 +148,29 @@ public class MetadataRowDetailsTests
.OnlyContain(e => !tab.IsRowDetailsVisible!(e));
}
[AvaloniaTest]
public void Details_Content_Stretches_Across_The_Full_Row_Width()
{
// The details area spans the host row, and its content fills it: a capped or
// left-pinned control would leave dead space to the right of the blob text or
// sub-grid columns.
var text = MetadataRowDetails.BuildTextBlob("blob text");
text.HorizontalAlignment.Should().Be(HorizontalAlignment.Stretch);
text.MaxWidth.Should().Be(double.PositiveInfinity, "the text blob must not cap its width");
var flagsGrid = (DataGrid)MetadataRowDetails.BuildFlagsGrid(new List<BitEntry> { new(true, "<0001> bit") });
flagsGrid.HorizontalAlignment.Should().Be(HorizontalAlignment.Stretch);
flagsGrid.Columns[^1].Width.UnitType.Should().Be(DataGridLengthUnitType.Star,
"the meaning column takes the leftover width");
var detailsGrid = (DataGrid)MetadataRowDetails.BuildDetailsGrid(
new List<BitEntry> { new(true, "<0001> bit") },
("Value", nameof(BitEntry.Value)), ("Meaning", nameof(BitEntry.Meaning)));
detailsGrid.HorizontalAlignment.Should().Be(HorizontalAlignment.Stretch);
detailsGrid.Columns[^1].Width.UnitType.Should().Be(DataGridLengthUnitType.Star,
"the last column takes the leftover width");
}
[AvaloniaTest]
public async Task Double_Tap_Inside_The_Details_Area_Does_Not_Resolve_To_An_Activatable_Row()
{

9
ILSpy/Metadata/MetadataRowDetails.cs

@ -24,7 +24,6 @@ using Avalonia; @@ -24,7 +24,6 @@ using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Templates;
using Avalonia.Data;
using Avalonia.Layout;
using Avalonia.Media;
using ICSharpCode.ILSpy.ViewModels;
@ -105,6 +104,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -105,6 +104,7 @@ namespace ICSharpCode.ILSpy.Metadata
grid.Columns.Add(new DataGridTextColumn {
Binding = new Binding(nameof(BitEntry.Meaning)),
IsReadOnly = true,
Width = new DataGridLength(1, DataGridLengthUnitType.Star),
});
return grid;
}
@ -117,9 +117,7 @@ namespace ICSharpCode.ILSpy.Metadata @@ -117,9 +117,7 @@ namespace ICSharpCode.ILSpy.Metadata
Text = text,
IsReadOnly = true,
TextWrapping = TextWrapping.Wrap,
MaxWidth = 800,
MaxHeight = 400,
HorizontalAlignment = HorizontalAlignment.Left,
};
}
@ -143,6 +141,10 @@ namespace ICSharpCode.ILSpy.Metadata @@ -143,6 +141,10 @@ namespace ICSharpCode.ILSpy.Metadata
IsReadOnly = true,
});
}
// The last column absorbs the leftover width so the sub-grid fills the host row
// instead of ending in dead space after its auto-sized columns.
if (grid.Columns.Count > 0)
grid.Columns[^1].Width = new DataGridLength(1, DataGridLengthUnitType.Star);
return grid;
}
@ -154,7 +156,6 @@ namespace ICSharpCode.ILSpy.Metadata @@ -154,7 +156,6 @@ namespace ICSharpCode.ILSpy.Metadata
CanUserReorderColumns = false,
CanUserSortColumns = false,
SelectionMode = DataGridSelectionMode.Single,
HorizontalAlignment = HorizontalAlignment.Left,
};
}
}

Loading…
Cancel
Save