fix(style): stop the hover registry from churning on idle rows
Review of block B found Query allocating an entry for every element it was
asked about, hovered or not. The cycle: Query creates the entry, the next
BeginFrame steps it to zero, evicts it, and the next Query creates it again.
With fifteen tabs that is fifteen allocations plus fifteen dictionary inserts
and removes per frame, permanently, with the mouse nowhere near the window.
That is exactly the property master spec 7.5 asks for and the one this block
claimed to improve, so it ate the two string allocations 31fa410 had just
saved. An unhovered element with no entry now returns zero without creating
one.
The footprint self-test only ever queried with hovered: true, which is why it
could not see this. It now runs an idle phase as well.
Four smaller items from the same review:
Advance skipped clearing the hover flags when deltaTime was zero, so such a
frame carried the previous frame's state forward.
Metrics reads GlobalScaleSafe now. The unsafe variant throws while the
interface manager is still coming up, and block F pulls Metrics into more call
sites.
Badge.CalcSize returned a full-size box for a count of zero while Draw drew
nothing, so a caller that reserves and then draws left a badge-shaped hole on
every tab without unread messages -- the normal case.
IconButton caches its glyph strings; ToIconString allocates on every call and
keeps no cache of its own. And the widget gallery clamps its own row width,
since asserting on a zero-width button in the window that demonstrates the
clamp would be a poor look.
This commit is contained in:
@@ -55,8 +55,14 @@ internal sealed class WidgetGalleryWindow : Window
|
||||
ImGui.TextUnformatted("Row");
|
||||
ImGui.Checkbox("active##row", ref _rowActive);
|
||||
|
||||
var width = ImGui.GetContentRegionAvail().X;
|
||||
var height = Metrics.SidebarRowHeight;
|
||||
// Clamped: this window demonstrates the guard, it should not be the one
|
||||
// that asserts when dragged narrow.
|
||||
var rowSize = HellionChat.Util.WidgetGeometry.IconButton(
|
||||
ImGui.GetContentRegionAvail().X,
|
||||
Metrics.SidebarRowHeight
|
||||
);
|
||||
var width = rowSize.X;
|
||||
var height = rowSize.Y;
|
||||
|
||||
for (var i = 0; i < 3; i++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user