Changeset 5443 in josm for trunk/src/org


Ignore:
Timestamp:
2012-08-14T10:07:01+02:00 (12 years ago)
Author:
akks
Message:

see #7888: Ctrl-Drag moves the node/way under cursor; fix dragging after rotation; minor refactoring of SelectAction

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

    r5435 r5443  
    436436                virtualManager.activateVirtualNodeNearPoint(e.getPoint());
    437437            }
    438             selectPrims(cycleManager.cycleSetup(nearestPrimitive, e.getPoint()), false, false);
     438            OsmPrimitive toSelect = cycleManager.cycleSetup(nearestPrimitive, e.getPoint());
     439            selectPrims(mv.asColl(toSelect), false, false);
    439440            useLastMoveCommandIfPossible();
    440441            break;
     
    661662        // So don't add them in the first place to make handling easier
    662663        Collection<OsmPrimitive> selection = getCurrentDataSet().getSelectedNodesAndWays();
     664        if (selection.isEmpty()) { // if nothing was selected to drag, just select nearest node/way to the cursor
     665            OsmPrimitive nearestPrimitive = mv.getNearestNodeOrWay(mv.getPoint(startEN), OsmPrimitive.isSelectablePredicate, true);
     666            getCurrentDataSet().setSelected(nearestPrimitive);
     667        }
     668       
    663669        Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(selection);
    664670        // for these transformations, having only one node makes no sense - quit silently
     
    690696            }
    691697            getCurrentDataSet().endUpdate();
    692         } else if (mode == Mode.rotate) {
     698            return true;
     699        }
     700
     701        startEN = currentEN; // drag can continue after scaling/rotation
     702
     703        if (mode == Mode.rotate) {
    693704            getCurrentDataSet().beginUpdate();
    694705            if (c instanceof RotateCommand && affectedNodes.equals(((RotateCommand) c).getTransformedNodes())) {
     
    885896         * @param nearest primitive found by simple method
    886897         * @param p point where user clicked
    887          * @return single-element collection with OsmPrimitive to be selected
     898         * @return OsmPrimitive to be selected
    888899         */
    889         private Collection<OsmPrimitive> cycleSetup(OsmPrimitive nearest, Point p) {
     900        private OsmPrimitive cycleSetup(OsmPrimitive nearest, Point p) {
    890901            OsmPrimitive osm = null;
    891902
     
    938949                }
    939950            }
    940 
    941             return MapView.asColl(osm);
     951            return osm;
    942952        }
    943953
Note: See TracChangeset for help on using the changeset viewer.