toolstroke: show the tool's effect as a preview when mouse is down
git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@645 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
parent
d0a6bb2303
commit
52794b9c25
7 changed files with 108 additions and 32 deletions
|
@ -934,6 +934,7 @@ public class MainWindow extends JFrame
|
|||
}
|
||||
else {
|
||||
this.toolStroke = currentTool.beginStroke(engine, x, y);
|
||||
previewTool();
|
||||
}
|
||||
|
||||
this.lastX = x;
|
||||
|
@ -943,6 +944,8 @@ public class MainWindow extends JFrame
|
|||
private void onToolUp(MouseEvent ev)
|
||||
{
|
||||
if (toolStroke != null) {
|
||||
drawingArea.setToolPreview(null);
|
||||
|
||||
CityLocation loc = toolStroke.getLocation();
|
||||
ToolResult tr = toolStroke.apply();
|
||||
showToolResult(loc, tr);
|
||||
|
@ -952,6 +955,20 @@ public class MainWindow extends JFrame
|
|||
onToolHover(ev);
|
||||
}
|
||||
|
||||
void previewTool()
|
||||
{
|
||||
assert this.toolStroke != null;
|
||||
assert this.currentTool != null;
|
||||
|
||||
drawingArea.setToolCursor(
|
||||
toolStroke.getBounds(),
|
||||
currentTool
|
||||
);
|
||||
drawingArea.setToolPreview(
|
||||
toolStroke.getPreview()
|
||||
);
|
||||
}
|
||||
|
||||
private void onToolDrag(MouseEvent ev)
|
||||
{
|
||||
if (currentTool == null)
|
||||
|
@ -966,10 +983,7 @@ public class MainWindow extends JFrame
|
|||
|
||||
if (toolStroke != null) {
|
||||
toolStroke.dragTo(x, y);
|
||||
drawingArea.setToolCursor(
|
||||
toolStroke.getBounds(),
|
||||
currentTool
|
||||
);
|
||||
previewTool();
|
||||
}
|
||||
else if (currentTool == MicropolisTool.QUERY) {
|
||||
doQueryTool(x, y);
|
||||
|
|
Reference in a new issue