Changeset 18554 in josm


Ignore:
Timestamp:
2022-09-08T17:32:45+02:00 (2 years ago)
Author:
taylor.smock
Message:

Fix #22309: Add option to merge by default when dragging nodes (patch by Woazboat)

This is currently an advanced preference only. It uses the ctrl key to manage
merging.

File:
1 edited

Legend:

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

    r18487 r18554  
    4343import org.openstreetmap.josm.data.osm.visitor.AllNodesVisitor;
    4444import org.openstreetmap.josm.data.osm.visitor.paint.WireframeMapRenderer;
     45import org.openstreetmap.josm.data.preferences.BooleanProperty;
     46import org.openstreetmap.josm.data.preferences.CachingProperty;
    4547import org.openstreetmap.josm.gui.ExtendedDialog;
    4648import org.openstreetmap.josm.gui.MainApplication;
     
    132134    }
    133135
     136    /** Whether nodes should be merged with other primitives by default when they are being dragged */
     137    private static final CachingProperty<Boolean> MERGE_BY_DEFAULT
     138            = new BooleanProperty("edit.move.merge-by-default", false).cached();
     139
    134140    private boolean lassoMode;
    135141    private boolean repeatedKeySwitchLassoOption;
     
    320326                // only consider merge if ctrl is pressed and there are nodes in
    321327                // the selection that could be merged
    322                 if (!platformMenuShortcutKeyMask || getLayerManager().getEditDataSet().getSelectedNodes().isEmpty()) {
     328                if (!isMergeRequested() || getLayerManager().getEditDataSet().getSelectedNodes().isEmpty()) {
    323329                    c = "move";
    324330                    break;
     
    497503            return;
    498504
     505        updateKeyModifiers(e);
     506
    499507        cancelDrawMode = true;
    500508        if (mode == Mode.SELECT) {
     
    520528            // If ctrl is pressed we are in merge mode. Look for a nearby node,
    521529            // highlight it and adjust the cursor accordingly.
    522             final boolean canMerge = platformMenuShortcutKeyMask && !getLayerManager().getEditDataSet().getSelectedNodes().isEmpty();
     530            final boolean canMerge = isMergeRequested() && !getLayerManager().getEditDataSet().getSelectedNodes().isEmpty();
    523531            final OsmPrimitive p = canMerge ? findNodeToMergeTo(e.getPoint()) : null;
    524532            boolean needsRepaint = removeHighlighting();
     
    892900            // if small number of elements were moved,
    893901            updateKeyModifiers(e);
    894             if (platformMenuShortcutKeyMask) mergePrims(e.getPoint());
     902            if (isMergeRequested()) mergePrims(e.getPoint());
    895903        }
    896904    }
     
    939947                .flatMap(n -> n.referrers(Way.class))
    940948                .anyMatch(Way::isDisabledAndHidden);
     949    }
     950
     951    /**
     952     * Check if dragged node should be merged when moving it over another primitive
     953     * @return true if merge is requested
     954     */
     955    private boolean isMergeRequested() {
     956        return MERGE_BY_DEFAULT.get() ^ platformMenuShortcutKeyMask;
    941957    }
    942958
Note: See TracChangeset for help on using the changeset viewer.