From cbc8c731cf03c47878e6daa4009815fc9822c698 Mon Sep 17 00:00:00 2001 From: Kenneth VanderLinde Date: Fri, 12 Apr 2024 13:30:10 -0700 Subject: [PATCH] Flush drawable renderer on grid changes so templates are updated Also fire grid change events when the adjust grid tool is used. --- .../net/rptools/maptool/client/tool/gridtool/GridTool.java | 7 ++++++- .../maptool/client/ui/zone/renderer/ZoneRenderer.java | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/rptools/maptool/client/tool/gridtool/GridTool.java b/src/main/java/net/rptools/maptool/client/tool/gridtool/GridTool.java index aac0cfc007..13e0343f70 100644 --- a/src/main/java/net/rptools/maptool/client/tool/gridtool/GridTool.java +++ b/src/main/java/net/rptools/maptool/client/tool/gridtool/GridTool.java @@ -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 { @@ -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"); @@ -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 diff --git a/src/main/java/net/rptools/maptool/client/ui/zone/renderer/ZoneRenderer.java b/src/main/java/net/rptools/maptool/client/ui/zone/renderer/ZoneRenderer.java index 23f7e91ed4..99c060fba4 100644 --- a/src/main/java/net/rptools/maptool/client/ui/zone/renderer/ZoneRenderer.java +++ b/src/main/java/net/rptools/maptool/client/ui/zone/renderer/ZoneRenderer.java @@ -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(); }