Skip to content

Commit 78f2ad7

Browse files
committedFeb 10, 2017
Update view after changes
The view wasn't being redrawn for all the operations which require it
1 parent 21e7781 commit 78f2ad7

File tree

5 files changed

+39
-8
lines changed

5 files changed

+39
-8
lines changed
 

‎src/com/modsim/gui/GUI.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -254,15 +254,15 @@ private void createViewport() {
254254
*/
255255
public void zoomInToView()
256256
{
257-
view.zoom(view.getWidth()/2, view.getHeight()/2, 1.0);
257+
view.zoom(view.getWidth()/2, view.getHeight()/2, -2.0);
258258
}
259259

260260
/*
261261
* Accessible method for zooming out of view
262262
*/
263263
public void zoomOutToView()
264264
{
265-
view.zoom(view.getWidth()/2, view.getHeight()/2, -1.0);
265+
view.zoom(view.getWidth()/2, view.getHeight()/2, 2.0);
266266
}
267267

268268
public void resetView()

‎src/com/modsim/gui/view/ContextMenu.java

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public ContextMenu() {
4040
public void actionPerformed(ActionEvent arg0) {
4141
if (port != null && port.link != null) {
4242
port.link.delete();
43+
//redraw
44+
Main.ui.view.flagStaticRedraw();
4345
}
4446
}
4547
});

‎src/com/modsim/gui/view/View.java

+2
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ else if (zoom > maxZoom) {
314314
camX -= newScreenPt.x - x;
315315
camY -= newScreenPt.y - y;
316316
calcXForm();
317+
//redraw
318+
flagStaticRedraw();
317319
}
318320

319321
/***

‎src/com/modsim/operations/Ops.java

+31-6
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,19 @@ public static void fileNew() {
161161
/// Action implementations
162162

163163
// Undo stack
164-
undo = new DesignAction(event -> {Main.ui.view.cancelTool(); Main.opStack.undo();},
165-
"Undo", "Undo the previous operation", ctrlZ);
166-
redo = new DesignAction(event -> {if (!Main.ui.view.hasTool()) Main.opStack.redo();},
167-
"Redo", "Repeat an undone operation", ctrlY);
164+
undo = new DesignAction(event -> {
165+
Main.ui.view.cancelTool();
166+
Main.opStack.undo();
167+
//redraw
168+
Main.ui.view.flagStaticRedraw();
169+
}, "Undo", "Undo the previous operation", ctrlZ);
170+
redo = new DesignAction(event -> {
171+
if (!Main.ui.view.hasTool()) {
172+
Main.opStack.redo();
173+
}
174+
//redraw
175+
Main.ui.view.flagStaticRedraw();
176+
}, "Redo", "Repeat an undone operation", ctrlY);
168177

169178
// Copy/paste
170179
copy = new DesignAction(event -> Main.clipboard.copy(Main.selection), "Copy",
@@ -181,7 +190,11 @@ public static void fileNew() {
181190
}, "Paste", "Paste into the design from the application clipboard", ctrlV);
182191

183192
// Deletion
184-
delete = new DesignAction(event -> Main.selection.deleteAll(), "Delete", "Deletes the selection", del);
193+
delete = new DesignAction(event -> {
194+
Main.selection.deleteAll();
195+
//redraw
196+
Main.ui.view.flagStaticRedraw();
197+
}, "Delete", "Deletes the selection", del);
185198

186199
// Rotation
187200
rotateCW = new DesignAction(event -> doRotate(BaseModule.rotationDir.ROT_CW),
@@ -205,6 +218,8 @@ public static void fileNew() {
205218
}
206219
}
207220
Main.opStack.endCompoundOp();
221+
//redraw
222+
Main.ui.view.flagStaticRedraw();
208223
}, "Add/Edit label", null, ctrlL);
209224

210225
// Label sizing
@@ -219,6 +234,8 @@ public static void fileNew() {
219234
}
220235
}
221236
Main.opStack.endCompoundOp();
237+
//redraw
238+
Main.ui.view.flagStaticRedraw();
222239
}, "Big");
223240
labelSmall = new DesignAction(event -> {
224241
Main.opStack.beginCompoundOp();
@@ -231,6 +248,8 @@ public static void fileNew() {
231248
}
232249
}
233250
Main.opStack.endCompoundOp();
251+
//redraw
252+
Main.ui.view.flagStaticRedraw();
234253
}, "Small (default)");
235254

236255
// Simulator controls
@@ -251,7 +270,11 @@ public static void fileNew() {
251270
resetView = new DesignAction(event -> Main.ui.resetView(), "Reset View");
252271

253272
// View controls
254-
toggleAA = new DesignAction(event -> Main.ui.view.useAA = !Main.ui.view.useAA,
273+
toggleAA = new DesignAction(event -> {
274+
Main.ui.view.useAA = !Main.ui.view.useAA;
275+
//redraw
276+
Main.ui.view.flagStaticRedraw();
277+
},
255278
"Toggle anti-aliasing", "Toggles anti-aliased rendering in the viewport: " +
256279
"disabling AA may improve performance on older machines.");
257280

@@ -279,6 +302,8 @@ private static void doRotate(BaseModule.rotationDir dir){
279302
}
280303
}
281304
Main.opStack.endCompoundOp();
305+
//redraw
306+
Main.ui.view.flagStaticRedraw();
282307
}
283308

284309
/**

‎src/com/modsim/util/Selection.java

+2
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ public void deleteAll() {
9595
}
9696
clear();
9797
Main.opStack.endCompoundOp();
98+
//redraw
99+
Main.ui.view.flagStaticRedraw();
98100
}
99101

100102
public boolean isEmpty() {

0 commit comments

Comments
 (0)
Please sign in to comment.