Changeset 15660 in josm


Ignore:
Timestamp:
2020-01-07T23:57:15+01:00 (3 months ago)
Author:
simon04
Message:

fix #15946 - double click sliders to reset opacity/colorfulness/gamma/sharpness

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/layer/LayerVisibilityAction.java

    r15586 r15660  
    3434import javax.swing.JPopupMenu;
    3535import javax.swing.JSlider;
     36import javax.swing.SwingUtilities;
    3637import javax.swing.UIManager;
    3738import javax.swing.border.Border;
     
    6364     */
    6465    private static final int SLIDER_WHEEL_INCREMENT = 5;
     66    private static final double DEFAULT_OPACITY = 1;
     67    private static final double DEFAULT_GAMMA_VALUE = 0;
     68    private static final double DEFAULT_SHARPNESS_FACTOR = 1;
    6569    private static final double MAX_SHARPNESS_FACTOR = 2;
     70    private static final double DEFAULT_COLORFUL_FACTOR = 1;
    6671    private static final double MAX_COLORFUL_FACTOR = 2;
    6772    private final LayerListModel model;
     
    231236         * @param minValue The minimum value to map to the left side.
    232237         * @param maxValue The maximum value to map to the right side.
     238         * @param defaultValue The default value for resetting.
    233239         * @param layerClassFilter The type of layer influenced by this filter.
    234240         */
    235         AbstractFilterSlider(double minValue, double maxValue, Class<T> layerClassFilter) {
     241        AbstractFilterSlider(double minValue, double maxValue, double defaultValue, Class<T> layerClassFilter) {
    236242            super(new GridBagLayout());
    237243            this.minValue = minValue;
     
    251257
    252258            slider.addChangeListener(e -> onStateChanged());
     259            slider.addMouseListener(new MouseAdapter() {
     260                @Override
     261                public void mouseClicked(MouseEvent e) {
     262                    if (e != null && SwingUtilities.isLeftMouseButton(e) && e.getClickCount() > 1) {
     263                        setRealValue(defaultValue);
     264                    }
     265                }
     266            });
    253267
    254268            //final NumberFormat format = DecimalFormat.getInstance();
     
    352366         */
    353367        OpacitySlider() {
    354             super(0, 1, Layer.class);
     368            super(0, 1, DEFAULT_OPACITY, Layer.class);
    355369            setLabels("0%", "50%", "100%");
    356             slider.setToolTipText(tr("Adjust opacity of the layer."));
     370            slider.setToolTipText(tr("Adjust opacity of the layer.") + " " + tr("Double click to reset."));
    357371        }
    358372
     
    425439         */
    426440        GammaFilterSlider() {
    427             super(-1, 1, ImageryLayer.class);
     441            super(-1, 1, DEFAULT_GAMMA_VALUE, ImageryLayer.class);
    428442            setLabels("0", "1", "∞");
    429             slider.setToolTipText(tr("Adjust gamma value of the layer."));
     443            slider.setToolTipText(tr("Adjust gamma value of the layer.") + " " + tr("Double click to reset."));
    430444        }
    431445
     
    485499         */
    486500        SharpnessSlider() {
    487             super(0, MAX_SHARPNESS_FACTOR, ImageryLayer.class);
     501            super(0, MAX_SHARPNESS_FACTOR, DEFAULT_SHARPNESS_FACTOR, ImageryLayer.class);
    488502            setLabels(trc("image sharpness", "blurred"), trc("image sharpness", "normal"), trc("image sharpness", "sharp"));
    489             slider.setToolTipText(tr("Adjust sharpness/blur value of the layer."));
     503            slider.setToolTipText(tr("Adjust sharpness/blur value of the layer.") + " " + tr("Double click to reset."));
    490504        }
    491505
     
    523537         */
    524538        ColorfulnessSlider() {
    525             super(0, MAX_COLORFUL_FACTOR, ImageryLayer.class);
     539            super(0, MAX_COLORFUL_FACTOR, DEFAULT_COLORFUL_FACTOR, ImageryLayer.class);
    526540            setLabels(trc("image colorfulness", "less"), trc("image colorfulness", "normal"), trc("image colorfulness", "more"));
    527             slider.setToolTipText(tr("Adjust colorfulness of the layer."));
     541            slider.setToolTipText(tr("Adjust colorfulness of the layer.") + " " + tr("Double click to reset."));
    528542        }
    529543
Note: See TracChangeset for help on using the changeset viewer.