Ticket #2054: Dont Do stuff on hidden layers.patch

File Dont Do stuff on hidden layers.patch, 4.3 KB (added by xeen, 16 years ago)

This disables the following when the layer is not active: Any clicks when in select, delete, extrude mode and also disables Edit -> Delete (none of those visually, they just don't work). It doesn't disable drawing though because I use that very often when adding additional stuff via WMS in an already good mapped area to net get distracted.

  • src/org/openstreetmap/josm/actions/DeleteAction.java

     
    2424    }
    2525
    2626    public void actionPerformed(ActionEvent e) {
     27        if(!Main.map.mapView.isVisibleDrawableLayer())
     28            return;
    2729        new org.openstreetmap.josm.actions.mapmode.DeleteAction(Main.map)
    2830                .doActionPerformed(e);
    2931    }
  • src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java

     
    9595    @Override public void mouseClicked(MouseEvent e) {
    9696        if (e.getButton() != MouseEvent.BUTTON1)
    9797            return;
    98         if(!Main.map.mapView.isDrawableLayer())
     98        if(!Main.map.mapView.isVisibleDrawableLayer())
    9999            return;
    100100        boolean ctrl = (e.getModifiers() & ActionEvent.CTRL_MASK) != 0;
    101101        boolean shift = (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0;
  • src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java

     
    125125     * mouse (which will become selected).
    126126     */
    127127    @Override public void mouseDragged(MouseEvent e) {
     128        if(!Main.map.mapView.isVisibleDrawableLayer())
     129            return;
    128130        if (mode == Mode.select) return;
    129131
    130132        // do not count anything as a move if it lasts less than 100 milliseconds.
     
    192194    /**
    193195     */
    194196    @Override public void mousePressed(MouseEvent e) {
     197        if(!Main.map.mapView.isVisibleDrawableLayer())
     198            return;
    195199        if (!(Boolean)this.getValue("active")) return;
    196200        if (e.getButton() != MouseEvent.BUTTON1)
    197201            return;
     
    219223     * Restore the old mouse cursor.
    220224     */
    221225    @Override public void mouseReleased(MouseEvent e) {
     226        if(!Main.map.mapView.isVisibleDrawableLayer())
     227            return;
    222228        restoreCursor();
    223229        if (selectedSegment == null) return;
    224230        if (mousePos.distance(initialMousePos) > 10) {
  • src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

     
    144144     * mouse (which will become selected).
    145145     */
    146146    @Override public void mouseDragged(MouseEvent e) {
     147        if(!Main.map.mapView.isVisibleDrawableLayer())
     148            return;
     149       
    147150        cancelDrawMode = true;
    148151        if (mode == Mode.select) return;
    149152
     
    282285     * cursor to movement.
    283286     */
    284287    @Override public void mousePressed(MouseEvent e) {
     288        if(!Main.map.mapView.isVisibleDrawableLayer())
     289            return;
     290       
    285291        cancelDrawMode = false;
    286292        if (! (Boolean)this.getValue("active")) return;
    287293        if (e.getButton() != MouseEvent.BUTTON1)
     
    331337     * Restore the old mouse cursor.
    332338     */
    333339    @Override public void mouseReleased(MouseEvent e) {
     340        if(!Main.map.mapView.isVisibleDrawableLayer())
     341            return;
     342       
    334343        if (mode == Mode.select) {
    335344            selectionManager.unregister(Main.map.mapView);
    336345
  • src/org/openstreetmap/josm/gui/MapView.java

     
    189189    {
    190190        return activeLayer != null && activeLayer instanceof OsmDataLayer;
    191191    }
     192   
     193    public Boolean isVisibleDrawableLayer() {
     194        return isDrawableLayer() && activeLayer.visible;
     195    }
     196   
    192197
    193198    /**
    194199     * Remove the layer from the mapview. If the layer was in the list before,