Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Identify the Bug or Feature request
Fixes #3684. and fixes #755, #1157 some more.
Description of the Change
The main thing to change was to stop hardcoding a preferred size for the
PaintChooser
in the Choose Background / Chose Fog dialogs. This fixed the width of those dialogs, though the height of the dialogs suddenly became very large. The culprit there is the scrollableImagePanel
setting its preferred viewport size based on the number of rows it expects, which can be very many. I've solved this by taking a cue fromJList
:ImagePanel
now has a configurable "visible row count" that is used to determine the preferred viewport height separately from the preferred height.The Select Map Image dialog also had a hardcoded size that is now removed.
It became clear while working on this that both #755 and #1157 still existed, and I've included fixes for them as they are related. The problem was two discrepancies between
ImagePanel.getPreferredSize()
andImagePanel.paintComponent()
:paintComponent()
sometimes renders one fewer columns than it should. Fewer columns means more rows, which causes the render to go beyond whatgetPreferredSize()
was expecting vertically. SincegetPreferredSize()
is used in decide whether scrolling is need, this resulted in the apparenty issue of scrolling not being enabled when it should be.paintComponent()
incorrectly calculated its vertical step by omitting the caption padding. All other height calculations included it, in particulargetPreferredSize()
. This caused the rendered height to be far less than the preferred height when there are many rows of thumbnails. As a result, scrolling was allowed to go far beyond the end of the thumbnail list.The solution to both of these was to bring
getPreferredSize()
andpaintComponent()
more in line with each other in terms of layout. There are new methods for consistently calculating the real estate needed for a thumbnail (getItemWidth()
,getItemHeight()
), and a new method for calculating how many columns there should be (calculateItemsPerRow()
).paintComponent()
no longer does line wrapping, but instead calculates the current row and column using the above methods, making it consistent withgetPreferredSize()
.Possible Drawbacks
The sizing changes might not be optimized for different screen configurations.
Documentation Notes
N/A, bugfix
Release Notes
This change is