Skip to content

Commit

Permalink
Merge pull request #4755 from kwvanderlinde/bugfix/4525-templates-not…
Browse files Browse the repository at this point in the history
…-updating-as-grid-size-changes

Update template rendering when the Adjust Grid tool is used
  • Loading branch information
cwisniew authored Apr 16, 2024
2 parents 8424030 + b4634bd commit e351151
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@
import net.rptools.maptool.client.swing.SwingUtil;
import net.rptools.maptool.client.tool.DefaultTool;
import net.rptools.maptool.client.ui.zone.renderer.ZoneRenderer;
import net.rptools.maptool.events.MapToolEventBus;
import net.rptools.maptool.model.CellPoint;
import net.rptools.maptool.model.Grid;
import net.rptools.maptool.model.Zone;
import net.rptools.maptool.model.ZonePoint;
import net.rptools.maptool.model.zones.GridChanged;

/** */
public class GridTool extends DefaultTool {
Expand Down Expand Up @@ -75,7 +77,8 @@ public GridTool() {
controlPanel = new AbeillePanel(new AdjustGridControlPanelView().getRootComponent());

gridSizeSpinner = (JSpinner) controlPanel.getComponent("gridSize");
gridSizeSpinner.setModel(new SpinnerNumberModel());
gridSizeSpinner.setModel(
new SpinnerNumberModel(100, Grid.MIN_GRID_SIZE, Grid.MAX_GRID_SIZE, 1));
gridSizeSpinner.addChangeListener(new UpdateGridListener());

gridOffsetXTextField = (JTextField) controlPanel.getComponent("offsetX");
Expand Down Expand Up @@ -175,6 +178,8 @@ private void copyControlPanelToGrid() {
grid.setOffset(getInt(gridOffsetXTextField, 0), getInt(gridOffsetYTextField, 0));
zone.setGridColor(colorWell.getColor().getRGB());
grid.setSize(Math.max((Integer) gridSizeSpinner.getValue(), Grid.MIN_GRID_SIZE));

new MapToolEventBus().getMainEventBus().post(new GridChanged(zone));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3557,6 +3557,9 @@ private void onGridChanged(GridChanged event) {
if (event.zone() != this.zone) {
return;
}

// A change in grid can change the size of templates.
flushDrawableRenderer();
repaintDebouncer.dispatch();
}

Expand Down

0 comments on commit e351151

Please sign in to comment.