fix(ui): scale auto-icons by min(w,h) to prevent overflow in narrow panels#10376
fix(ui): scale auto-icons by min(w,h) to prevent overflow in narrow panels#10376RafaelHGOliveira wants to merge 3 commits intoCard-Forge:masterfrom
Conversation
…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
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.
|
@MostCromulent I applied your suggestion in the PR:
Honest note: at normal window sizes I didn't notice a big visual difference from the original Also added: dynamic icon scaling for multi-digit text. Multi-digit life totals (e.g. Let me know if the approach looks good. |
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
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