/* Copyright (C) 2005-2011 Fabio Riccardi */

package com.lightcrafts.ui.browser.ctrls;

import static com.lightcrafts.ui.browser.ctrls.Locale.LOCALE;
import com.lightcrafts.ui.browser.view.AbstractImageBrowser;

import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.util.prefs.Preferences;

public class SizeSlider extends Box {

    // The slider position is globally sticky.
    private final static Preferences Prefs =
        Preferences.userRoot().node("/com/lightcrafts/ui/browser/ctrls");
    private final static String SizeKey = "SizeSlider";

//    private final static Icon SmallIcon =
//        ButtonFactory.getIconByName("thumbshrink", 12);
//    private final static Icon BigIcon =
//        ButtonFactory.getIconByName("thumbgrow", 12);

    private final static int MinSize = 80;
    private final static int MaxSize = 320;
    private final static int DefaultSize = 144;

//    private JLabel small;
    private JSlider slider;
//    private JLabel big;

    public SizeSlider(final AbstractImageBrowser browser) {
        super(BoxLayout.X_AXIS);
//        small = new JLabel(SmallIcon);
//        big = new JLabel(BigIcon);
        slider = new JSlider(MinSize, MaxSize);
//        add(small);
        // add(new JLabel("Thumbnails"));
        add(slider);
//        add(big);

        // Don't let the slider stretch in wide layout environments.
        setMaximumSize(new Dimension(150, 150));
        setPreferredSize(new Dimension(150, 0));

        int size = Prefs.getInt(SizeKey, DefaultSize);
        slider.setValue(size);
        slider.setToolTipText(LOCALE.get("SizeToolTip"));
        slider.addChangeListener(
            new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    int size = slider.getValue();
                    boolean isAdjusting = slider.getValueIsAdjusting();
                    browser.setCharacteristicSize(size, isAdjusting);
                    if (! isAdjusting) {
                        Prefs.putInt(SizeKey, size);
                    }
                }
            }
        );
        slider.setFocusable(false);
    }

    public int getValue() {
        return slider.getValue();
    }
}

@@ -37,16 +37,64 @@
 cardi */
+%0A/* Copyright (C) 2017-     Masahiro Kitagawa */
 %0A%0Apackag
@@ -370,24 +370,105 @@
 java.awt.*;%0A
+import java.awt.event.MouseWheelEvent;%0Aimport java.awt.event.MouseWheelListener;%0A
 import java.
@@ -1876,24 +1876,50 @@
 istener() %7B%0A
+                @Override%0A
             
@@ -2347,24 +2347,385 @@
 ble(false);%0A
+        slider.addMouseWheelListener(%0A                new MouseWheelListener() %7B%0A                    @Override%0A                    public void mouseWheelMoved(MouseWheelEvent e) %7B%0A                        slider.setValue(slider.getValue()%0A                                + (e.getWheelRotation() %3C 0 ? 1 : -1));%0A                    %7D%0A                %7D%0A        );%0A
     %7D%0A%0A    p

Enable mouse wheel on SizeSlider