Skip to content

fix(ui): scale auto-icons by min(w,h) to prevent overflow in narrow panels#10376

Open
RafaelHGOliveira wants to merge 3 commits intoCard-Forge:masterfrom
RafaelHGOliveira:pr/flabel-icon-min-dim
Open

fix(ui): scale auto-icons by min(w,h) to prevent overflow in narrow panels#10376
RafaelHGOliveira wants to merge 3 commits intoCard-Forge:masterfrom
RafaelHGOliveira:pr/flabel-icon-min-dim

Conversation

@RafaelHGOliveira
Copy link
Copy Markdown

@RafaelHGOliveira RafaelHGOliveira commented Apr 12, 2026

Problem

`FLabel.resetIcon()` scaled non-background icons only by the panel's height, so icons overflowed horizontally when a panel became narrow without becoming short. This is visible when resizing the match window or in layouts with multiple narrow player fields side by side.

Fix

Use `Math.min(getHeight(), getWidth())` as the scaling basis so icons always fit within the smaller dimension.

```java
// Before
final int h = (int) (getHeight() * iconScaleFactor);

// After
final int basis = Math.min(getHeight(), getWidth());
final int h = (int) (basis * iconScaleFactor);
```

Also: PlayerDetailsPanel improvements

  • `baseFontSize` tracking — the font auto-sizing loop was starting from a hardcoded `14` even when a subclass configured a different size. Now uses the field.
  • Parameterized constructors — `DetailLabel` and `DetailLabelNumeric` accept `fontSize` and `iconScaleFactor`, enabling per-label config without changing existing defaults.
  • Mana labels — `DetailLabelMana` now uses 16pt font and 0.70 scale factor for better visibility.

Notes

This is not a perfect solution — icons may still appear small in very narrow panels — but it is already a noticeable improvement for 4-player Commander layouts where each player field is roughly one quarter of the screen width.

Screenshot

icon scaling in narrow panels

…t/icon config

FLabel.resetIcon() previously scaled only by panel height, causing icons to
overflow horizontally in narrow panels (e.g. resized match windows). Change
the basis to min(width, height) so icons always fit within the available area.

Also improve PlayerDetailsPanel:
- Track baseFontSize per label so the font auto-sizing loop starts from the
  configured size, not a hardcoded 14
- Add parameterized constructors to allow per-label font and icon scale config
- Use 16pt font and 0.70 scale for mana symbols for better visibility
@MostCromulent
Copy link
Copy Markdown
Contributor

MostCromulent commented Apr 12, 2026

This is not a perfect solution — icons may still appear small in very narrow panels — but it is already a noticeable improvement for 4-player Commander layouts where each player field is roughly one quarter of the screen width.

I thought of a potential fix for root cause of this scaling issue:

When resizing a player field window it currently resizes both the battlefield itself and the player details panel on left hand side, I assume based on some proportional logic.

Instead, set a minimum width for the player details panel which ensures labels are always a visible font size. Once rescaling causes the panel to hit that minimum, further window resizing only affects the battlefield area while leaving the details panel at the fixed minimum.

…text length

Address review feedback from @MostCromulent: instead of relying only on
min(w,h) for icon scaling, set a minimum width for the avatar and player
details panels via MigLayout constraints. When the window is resized
narrow, the details panel stops shrinking at 60px and the battlefield
area absorbs the remaining width change.

Additionally, PlayerDetailsPanel labels now dynamically reduce their
icon scale factor as text grows (e.g. multi-digit life totals). Each
extra character beyond 1 reduces the icon by ~15%, leaving room for
the text to render without overlap.
@RafaelHGOliveira
Copy link
Copy Markdown
Author

RafaelHGOliveira commented Apr 14, 2026

@MostCromulent I applied your suggestion in the PR:

VField.java — avatar and details panels now use MigLayout constraints w 60px:10%:10% (min 60px, preferred and max at 10%), and the scroller (battlefield) uses w 0:85%, growx so it absorbs remaining space. Once the window is narrow enough that 10% would drop below 60px, the panels hold steady and the battlefield keeps shrinking.

Honest note: at normal window sizes I didn't notice a big visual difference from the original min(w,h) approach — the benefit is mostly a safety floor for extreme narrow layouts (4-player Commander on a small window), where the details panel would otherwise degrade below legibility. Left it applied regardless since it's a cleaner root-cause fix.

Also added: dynamic icon scaling for multi-digit text. Multi-digit life totals (e.g. 120) or high radiation counters still needed to coexist with the icon in the same cell. I added getEffectiveIconScaleFactor() as a protected hook in FLabel that subclasses can override, and PlayerDetailsPanel.DetailLabel reduces the icon scale by ~15% per character beyond the first. Single-digit values keep the original icon size; larger numbers get progressive room without any cell resizing.

Let me know if the approach looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants