Skip to content

Commit

Permalink
Update view after changes
Browse files Browse the repository at this point in the history
The view wasn't being redrawn for all the operations which require it
  • Loading branch information
AliShug committed Feb 10, 2017
1 parent 21e7781 commit 78f2ad7
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/com/modsim/gui/GUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,15 @@ private void createViewport() {
*/
public void zoomInToView()
{
view.zoom(view.getWidth()/2, view.getHeight()/2, 1.0);
view.zoom(view.getWidth()/2, view.getHeight()/2, -2.0);
}

/*
* Accessible method for zooming out of view
*/
public void zoomOutToView()
{
view.zoom(view.getWidth()/2, view.getHeight()/2, -1.0);
view.zoom(view.getWidth()/2, view.getHeight()/2, 2.0);
}

public void resetView()
Expand Down
2 changes: 2 additions & 0 deletions src/com/modsim/gui/view/ContextMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public ContextMenu() {
public void actionPerformed(ActionEvent arg0) {
if (port != null && port.link != null) {
port.link.delete();
//redraw
Main.ui.view.flagStaticRedraw();
}
}
});
Expand Down
2 changes: 2 additions & 0 deletions src/com/modsim/gui/view/View.java
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ else if (zoom > maxZoom) {
camX -= newScreenPt.x - x;
camY -= newScreenPt.y - y;
calcXForm();
//redraw
flagStaticRedraw();
}

/***
Expand Down
37 changes: 31 additions & 6 deletions src/com/modsim/operations/Ops.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,19 @@ public static void fileNew() {
/// Action implementations

// Undo stack
undo = new DesignAction(event -> {Main.ui.view.cancelTool(); Main.opStack.undo();},
"Undo", "Undo the previous operation", ctrlZ);
redo = new DesignAction(event -> {if (!Main.ui.view.hasTool()) Main.opStack.redo();},
"Redo", "Repeat an undone operation", ctrlY);
undo = new DesignAction(event -> {
Main.ui.view.cancelTool();
Main.opStack.undo();
//redraw
Main.ui.view.flagStaticRedraw();
}, "Undo", "Undo the previous operation", ctrlZ);
redo = new DesignAction(event -> {
if (!Main.ui.view.hasTool()) {
Main.opStack.redo();
}
//redraw
Main.ui.view.flagStaticRedraw();
}, "Redo", "Repeat an undone operation", ctrlY);

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

// Deletion
delete = new DesignAction(event -> Main.selection.deleteAll(), "Delete", "Deletes the selection", del);
delete = new DesignAction(event -> {
Main.selection.deleteAll();
//redraw
Main.ui.view.flagStaticRedraw();
}, "Delete", "Deletes the selection", del);

// Rotation
rotateCW = new DesignAction(event -> doRotate(BaseModule.rotationDir.ROT_CW),
Expand All @@ -205,6 +218,8 @@ public static void fileNew() {
}
}
Main.opStack.endCompoundOp();
//redraw
Main.ui.view.flagStaticRedraw();
}, "Add/Edit label", null, ctrlL);

// Label sizing
Expand All @@ -219,6 +234,8 @@ public static void fileNew() {
}
}
Main.opStack.endCompoundOp();
//redraw
Main.ui.view.flagStaticRedraw();
}, "Big");
labelSmall = new DesignAction(event -> {
Main.opStack.beginCompoundOp();
Expand All @@ -231,6 +248,8 @@ public static void fileNew() {
}
}
Main.opStack.endCompoundOp();
//redraw
Main.ui.view.flagStaticRedraw();
}, "Small (default)");

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

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

Expand Down Expand Up @@ -279,6 +302,8 @@ private static void doRotate(BaseModule.rotationDir dir){
}
}
Main.opStack.endCompoundOp();
//redraw
Main.ui.view.flagStaticRedraw();
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/com/modsim/util/Selection.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ public void deleteAll() {
}
clear();
Main.opStack.endCompoundOp();
//redraw
Main.ui.view.flagStaticRedraw();
}

public boolean isEmpty() {
Expand Down

0 comments on commit 78f2ad7

Please sign in to comment.