Ticket #3910: lassoOnS-5443.patch

File lassoOnS-5443.patch, 4.1 KB (added by akks, 14 years ago)

in this patch, repeated S switching is enabled by default, do we need checkbox in preferences?

Line 
1Index: src/org/openstreetmap/josm/actions/LassoModeAction.java
2===================================================================
3--- src/org/openstreetmap/josm/actions/LassoModeAction.java (revision 5443)
4+++ src/org/openstreetmap/josm/actions/LassoModeAction.java (working copy)
5@@ -31,4 +31,11 @@
6 Main.map.mapModeSelect.exitMode();
7 super.exitMode();
8 }
9+
10+ @Override
11+ public void reenterMode() {
12+ if (Main.map != null && Main.map.mapModeSelect.repeatedKeySwitchLassoOption) {
13+ Main.map.selectMapMode(Main.map.mapModeSelect);
14+ }
15+ }
16 }
17Index: src/org/openstreetmap/josm/actions/mapmode/MapMode.java
18===================================================================
19--- src/org/openstreetmap/josm/actions/mapmode/MapMode.java (revision 5443)
20+++ src/org/openstreetmap/josm/actions/mapmode/MapMode.java (working copy)
21@@ -57,6 +57,12 @@
22 putValue("active", false);
23 Main.map.mapView.resetCursor(this);
24 }
25+ /**
26+ * For optionlal overloading - called when action is repeated while mapmode
27+ * is already active
28+ */
29+ public void reenterMode() {
30+ }
31
32 protected void updateStatusLine() {
33 Main.map.statusLine.setHelpText(getModeHelpText());
34Index: src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
35===================================================================
36--- src/org/openstreetmap/josm/actions/mapmode/SelectAction.java (revision 5443)
37+++ src/org/openstreetmap/josm/actions/mapmode/SelectAction.java (working copy)
38@@ -100,6 +100,7 @@
39 }
40
41 private boolean lassoMode = false;
42+ public boolean repeatedKeySwitchLassoOption;
43
44 // Cache previous mouse event (needed when only the modifier keys are
45 // pressed but the mouse isn't moved)
46@@ -180,6 +181,7 @@
47 mv.addMouseMotionListener(this);
48 mv.setVirtualNodesEnabled(Main.pref.getInteger("mappaint.node.virtual-size", 8) != 0);
49 drawTargetHighlight = Main.pref.getBoolean("draw.target-highlight", true);
50+ repeatedKeySwitchLassoOption = Main.pref.getBoolean("mappaint.select.toggle-lasso-on-repeated-S", true);
51 cycleManager.init();
52 virtualManager.init();
53 // This is required to update the cursors when ctrl/shift/alt is pressed
54@@ -873,6 +875,13 @@
55 this.lassoMode = lassoMode;
56 }
57
58+ @Override
59+ public void reenterMode() {
60+ if (Main.map!=null && repeatedKeySwitchLassoOption) {
61+ Main.map.selectMapMode(Main.map.mapModeLassoSelect);
62+ }
63+ }
64+
65 CycleManager cycleManager = new CycleManager();
66 VirtualManager virtualManager = new VirtualManager();
67Index: src/org/openstreetmap/josm/gui/MapFrame.java
68===================================================================
69--- src/org/openstreetmap/josm/gui/MapFrame.java (revision 5443)
70+++ src/org/openstreetmap/josm/gui/MapFrame.java (working copy)
71@@ -112,6 +112,7 @@
72 public final SelectAction mapModeSelect;
73 private final MapMode mapModeDraw;
74 private final MapMode mapModeZoom;
75+ public final MapMode mapModeLassoSelect;
76
77 /**
78 * The panel list of all toggle dialog icons. To add new toggle dialog actions, use addToggleDialog
79@@ -159,7 +160,7 @@
80 // toolbar
81 toolBarActions.setFloatable(false);
82 addMapMode(new IconToggleButton(mapModeSelect = new SelectAction(this)));
83- addMapMode(new IconToggleButton(new LassoModeAction(), true));
84+ addMapMode(new IconToggleButton(mapModeLassoSelect = new LassoModeAction(), true)) ;
85 addMapMode(new IconToggleButton(mapModeDraw = new DrawAction(this)));
86 addMapMode(new IconToggleButton(mapModeZoom = new ZoomAction(this)));
87 addMapMode(new IconToggleButton(new DeleteAction(this), true));
88@@ -361,8 +362,10 @@
89 return false;
90
91 MapMode oldMapMode = this.mapMode;
92- if (newMapMode == oldMapMode)
93+ if (newMapMode == oldMapMode) {
94+ newMapMode.reenterMode();
95 return true;
96+ }
97 if (oldMapMode != null) {
98 oldMapMode.exitMode();
99 }