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 4 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. |
DragCell now exposes a per-cell minW (default SResizingUtil.W_MIN); SResizingUtil.resizeX consults t.getMinW() instead of the global constant so user drag is locked at each cell's own minimum. VField.populate sets parentCell.setMinW(240) and uses fixed pixel widths for avatar (90), phase indicator (22) and details panel (90), letting the scroller absorb extra horizontal space via growx. The phase indicator strip is wide enough to render its icons cleanly. PlayerDetailsPanel.DetailLabel scales the icon down progressively when text grows past one digit (0.55x / 0.40x / 0.30x) so multi-digit counters share the cell with the icon without truncation. setSmoothW intentionally does NOT clamp to minW: clamping there breaks SRearrangingUtil.fillGap, which relies on exact tiled coordinates and throws "Gap was not filled" when starting a match with stale dynamic cells. The drag-time check is enough for the user-facing case.
|
@MostCromulent you're right — didn't test on a window that narrow, sorry. The Pushed a different approach: per-cell Caveat: I do not clamp inside Also tuned the icon-scaling: 2 digits → 0.55x, 3 → 0.40x, 4+ → 0.30x. The previous |
|
Tested again - seems to work fine and I think the fixed width panel is a solid improvement. 👍 Will leave code review to the pros from here. |


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