FB-09: size default HUD widgets by title, not a fixed uniform cell
Adds minColSpanForLabel as a character-count proxy for how many grid columns a metric's title needs, reworks HudWidgetLayout.defaultFor into a left-to-right row-packing layout using it, enforces the same minimum as a floor on manual resize, and splits _HudMetricValue's FittedBox so the title renders at a fixed reference size while only the value shrinks/grows to fill the remaining space. Confirms a real, documented interaction with FB-08's _reflowRow: its even column split has no awareness of a member's title-driven minimum and can push one below it. Left unfixed per this ticket's own Out-of-scope section -- _reflowRow's algorithm is FB-08's, not this ticket's, to change. Test count 426 -> 434, all green. flutter analyze unchanged (same 4 pre-existing, unrelated info-level issues).
This commit is contained in:
@@ -89,6 +89,42 @@ void main() {
|
||||
expect(layout.clampedToGrid().rowSpan, layout.rowSpan);
|
||||
}
|
||||
});
|
||||
|
||||
test('every metric\'s colSpan is at least its own title-driven minimum', () {
|
||||
for (final metric in HudMetric.values) {
|
||||
final layout = HudWidgetLayout.defaultFor(metric);
|
||||
expect(
|
||||
layout.colSpan,
|
||||
greaterThanOrEqualTo(minColSpanForLabel(metric.label)),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('no row\'s members ever sum past hudGridColumns (the packing '
|
||||
'algorithm\'s own invariant)', () {
|
||||
final layouts = HudMetric.values.map(HudWidgetLayout.defaultFor).toList();
|
||||
final byRow = <int, int>{};
|
||||
for (final layout in layouts) {
|
||||
byRow[layout.row] = (byRow[layout.row] ?? 0) + layout.colSpan;
|
||||
}
|
||||
for (final sum in byRow.values) {
|
||||
expect(sum, lessThanOrEqualTo(hudGridColumns));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
group('minColSpanForLabel', () {
|
||||
test('a label under 10 characters fits one column', () {
|
||||
expect(minColSpanForLabel(HudMetric.speed.label), 1);
|
||||
});
|
||||
|
||||
test('a label under 15 characters needs two', () {
|
||||
expect(minColSpanForLabel(HudMetric.elapsedTime.label), 2);
|
||||
});
|
||||
|
||||
test('a label of 15 or more characters needs three', () {
|
||||
expect(minColSpanForLabel(HudMetric.pointsCaptured.label), 3);
|
||||
});
|
||||
});
|
||||
|
||||
group('clampedToGrid', () {
|
||||
|
||||
Reference in New Issue
Block a user