hold the header's width against a changing status caption

The panel is sized to its card, so anything that changes the card's width drags
the panel with it. The status caption changes as a building works -- "producing"
is shorter than "missing input", which is shorter than "output full" -- and the
panel twitched every time it did. On a Smelter it also changed height, because a
narrower card wraps its item chips differently.

The pill now reserves room for the widest caption it can ever show, so the
header keeps one width whatever the state is. The captions were spelled out in
the switch that chose them, which left no way to ask for the set; they come from
one function now, and the set is what the reservation is built from.

Ship cards do the same with the behaviour names (REQ-UI-SHIP-BEHAVIOR), which
change just as often while a ship fights.

Miner card, sampled every tick for 900 ticks across two different-length
captions: one distinct width, one distinct height. The reservation is what does
it -- the same run without it sits at 138px, with it at 155px, the width of the
longest caption.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JcReq7hVk4KUPhTDKWAG7K
This commit is contained in:
2026-08-07 22:07:49 +02:00
parent 7d0f3e6daf
commit a6152b9998
7 changed files with 105 additions and 15 deletions

View File

@@ -33,3 +33,16 @@ QString getBehaviorLabel(BehaviorKind kind)
}
return QString();
}
QStringList getAllBehaviorLabels()
{
QStringList labels;
for (BehaviorKind kind : { BehaviorKind::Retreat, BehaviorKind::Attack,
BehaviorKind::SalvageScrap, BehaviorKind::Repair,
BehaviorKind::Rally, BehaviorKind::Standby,
BehaviorKind::Advance })
{
labels << getBehaviorLabel(kind);
}
return labels;
}