- Timestamp:
- 2016-11-01T11:17:36+01:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/layer/LayerVisibilityAction.java
r11055 r11206 61 61 this.model = model; 62 62 popup = new JPopupMenu(); 63 // prevent popup close on mouse wheel move 64 popup.addMouseWheelListener(MouseWheelEvent::consume); 63 65 64 66 // just to add a border … … 82 84 83 85 private void addSlider(JPanel content, FilterSlider<?> slider) { 84 content.add(new JLabel(slider.getIcon()), GBC.std().span(1, 2).insets(0, 0, 5, 0)); 85 content.add(new JLabel(slider.getLabel()), GBC.eol()); 86 content.add(slider, GBC.eop()); 86 // wrap to a common content pane to allow for mouse wheel listener on label. 87 JPanel container = new JPanel(new GridBagLayout()); 88 container.add(new JLabel(slider.getIcon()), GBC.std().span(1, 2).insets(0, 0, 5, 0)); 89 container.add(new JLabel(slider.getLabel()), GBC.eol()); 90 container.add(slider, GBC.eol()); 91 content.add(container, GBC.eop()); 92 93 container.addMouseWheelListener(slider::mouseWheelMoved); 87 94 sliders.add(slider); 88 95 } … … 177 184 178 185 addChangeListener(e -> onStateChanged()); 179 addMouseWheelListener(this::mouseWheelMoved);180 186 } 181 187 … … 193 199 194 200 protected void mouseWheelMoved(MouseWheelEvent e) { 201 e.consume(); 202 if (!isEnabled()) { 203 // ignore mouse wheel in disabled state. 204 return; 205 } 195 206 double rotation = e.getPreciseWheelRotation(); 196 207 double destinationValue = getValue() + rotation * SLIDER_WHEEL_INCREMENT; … … 201 212 } 202 213 setValue(Utils.clamp((int) destinationValue, getMinimum(), getMaximum())); 203 e.consume();204 214 } 205 215 … … 271 281 272 282 @Override 283 protected void mouseWheelMoved(MouseWheelEvent e) { 284 if (!isEnabled() && !filterLayers(model.getSelectedLayers()).isEmpty() && e.getPreciseWheelRotation() > 0) { 285 // make layer visible and set the value. 286 // this allows users to use the mouse wheel to make the layer visible if it was hidden previously. 287 e.consume(); 288 setVisibleFlag(true); 289 setRealValue(0.05); 290 } else { 291 super.mouseWheelMoved(e); 292 } 293 } 294 295 @Override 273 296 protected void applyValueToLayer(Layer layer) { 274 297 layer.setOpacity(getRealValue());
Note:
See TracChangeset
for help on using the changeset viewer.