|
|
@ -35,7 +35,7 @@ import com.github.weisj.darklaf.util.PropertyKey; |
|
|
|
import com.github.weisj.darklaf.util.PropertyUtil; |
|
|
|
import com.github.weisj.darklaf.util.PropertyUtil; |
|
|
|
|
|
|
|
|
|
|
|
/** @author Jannis Weis */ |
|
|
|
/** @author Jannis Weis */ |
|
|
|
public class DarkScrollPaneUI extends BasicScrollPaneUI { |
|
|
|
public class DarkScrollPaneUI extends BasicScrollPaneUI implements PropertyChangeListener { |
|
|
|
|
|
|
|
|
|
|
|
private final MouseWheelListener verticalMouseWheelListener = e -> { |
|
|
|
private final MouseWheelListener verticalMouseWheelListener = e -> { |
|
|
|
if (!scrollpane.isWheelScrollingEnabled() || e.getModifiersEx() == 0 || !horizontalScrollBarEnabled()) { |
|
|
|
if (!scrollpane.isWheelScrollingEnabled() || e.getModifiersEx() == 0 || !horizontalScrollBarEnabled()) { |
|
|
@ -68,6 +68,11 @@ public class DarkScrollPaneUI extends BasicScrollPaneUI { |
|
|
|
scrollpane.getComponentOrientation().isLeftToRight()); |
|
|
|
scrollpane.getComponentOrientation().isLeftToRight()); |
|
|
|
scrollbar.setValueIsAdjusting(false); |
|
|
|
scrollbar.setValueIsAdjusting(false); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
private final PropertyChangeListener scrollbarPropertyChangeListener = e -> { |
|
|
|
|
|
|
|
if (PropertyKey.UI.equals(e.getPropertyName())) { |
|
|
|
|
|
|
|
updateScrollBarBackground(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
private ViewPropertyChangeListener viewPropertyChangeListener; |
|
|
|
private ViewPropertyChangeListener viewPropertyChangeListener; |
|
|
|
private ScrollPaneLayout oldLayout; |
|
|
|
private ScrollPaneLayout oldLayout; |
|
|
|
|
|
|
|
|
|
|
@ -105,9 +110,11 @@ public class DarkScrollPaneUI extends BasicScrollPaneUI { |
|
|
|
protected void installListeners(final JScrollPane c) { |
|
|
|
protected void installListeners(final JScrollPane c) { |
|
|
|
super.installListeners(c); |
|
|
|
super.installListeners(c); |
|
|
|
getViewPropertyChangeListener().install(); |
|
|
|
getViewPropertyChangeListener().install(); |
|
|
|
scrollpane.addPropertyChangeListener(getPropertyChangeListener()); |
|
|
|
scrollpane.addPropertyChangeListener(this); |
|
|
|
scrollpane.getVerticalScrollBar().addMouseWheelListener(verticalMouseWheelListener); |
|
|
|
scrollpane.getVerticalScrollBar().addMouseWheelListener(verticalMouseWheelListener); |
|
|
|
|
|
|
|
scrollpane.getVerticalScrollBar().addPropertyChangeListener(scrollbarPropertyChangeListener); |
|
|
|
scrollpane.getHorizontalScrollBar().addMouseWheelListener(horizontalMouseWheelListener); |
|
|
|
scrollpane.getHorizontalScrollBar().addMouseWheelListener(horizontalMouseWheelListener); |
|
|
|
|
|
|
|
scrollpane.getHorizontalScrollBar().addPropertyChangeListener(scrollbarPropertyChangeListener); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected ViewPropertyChangeListener getViewPropertyChangeListener() { |
|
|
|
protected ViewPropertyChangeListener getViewPropertyChangeListener() { |
|
|
@ -125,11 +132,8 @@ public class DarkScrollPaneUI extends BasicScrollPaneUI { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected PropertyChangeListener getPropertyChangeListener() { |
|
|
|
@Override |
|
|
|
return this::scrollPanePropertyChange; |
|
|
|
public void propertyChange(final PropertyChangeEvent e) { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected void scrollPanePropertyChange(final PropertyChangeEvent e) { |
|
|
|
|
|
|
|
if (e.getSource() == scrollpane) { |
|
|
|
if (e.getSource() == scrollpane) { |
|
|
|
String propertyName = e.getPropertyName(); |
|
|
|
String propertyName = e.getPropertyName(); |
|
|
|
if ("verticalScrollBar".equals(propertyName)) { |
|
|
|
if ("verticalScrollBar".equals(propertyName)) { |
|
|
@ -137,9 +141,11 @@ public class DarkScrollPaneUI extends BasicScrollPaneUI { |
|
|
|
Object newVal = e.getNewValue(); |
|
|
|
Object newVal = e.getNewValue(); |
|
|
|
if (old instanceof JScrollBar) { |
|
|
|
if (old instanceof JScrollBar) { |
|
|
|
((JScrollBar) old).removeMouseWheelListener(verticalMouseWheelListener); |
|
|
|
((JScrollBar) old).removeMouseWheelListener(verticalMouseWheelListener); |
|
|
|
|
|
|
|
((JScrollBar) old).removePropertyChangeListener(scrollbarPropertyChangeListener); |
|
|
|
} |
|
|
|
} |
|
|
|
if (newVal instanceof JScrollBar) { |
|
|
|
if (newVal instanceof JScrollBar) { |
|
|
|
((JScrollBar) newVal).addMouseWheelListener(verticalMouseWheelListener); |
|
|
|
((JScrollBar) newVal).addMouseWheelListener(verticalMouseWheelListener); |
|
|
|
|
|
|
|
((JScrollBar) newVal).addPropertyChangeListener(scrollbarPropertyChangeListener); |
|
|
|
PropertyUtil.installBackground((Component) newVal, getViewBackground()); |
|
|
|
PropertyUtil.installBackground((Component) newVal, getViewBackground()); |
|
|
|
} |
|
|
|
} |
|
|
|
} else if ("horizontalScrollBar".equals(propertyName)) { |
|
|
|
} else if ("horizontalScrollBar".equals(propertyName)) { |
|
|
@ -147,9 +153,11 @@ public class DarkScrollPaneUI extends BasicScrollPaneUI { |
|
|
|
Object newVal = e.getNewValue(); |
|
|
|
Object newVal = e.getNewValue(); |
|
|
|
if (old instanceof JScrollBar) { |
|
|
|
if (old instanceof JScrollBar) { |
|
|
|
((JScrollBar) old).removeMouseWheelListener(horizontalMouseWheelListener); |
|
|
|
((JScrollBar) old).removeMouseWheelListener(horizontalMouseWheelListener); |
|
|
|
|
|
|
|
((JScrollBar) old).removePropertyChangeListener(scrollbarPropertyChangeListener); |
|
|
|
} |
|
|
|
} |
|
|
|
if (newVal instanceof JScrollBar) { |
|
|
|
if (newVal instanceof JScrollBar) { |
|
|
|
((JScrollBar) newVal).addMouseWheelListener(horizontalMouseWheelListener); |
|
|
|
((JScrollBar) newVal).addMouseWheelListener(horizontalMouseWheelListener); |
|
|
|
|
|
|
|
((JScrollBar) newVal).addPropertyChangeListener(scrollbarPropertyChangeListener); |
|
|
|
PropertyUtil.installBackground((Component) newVal, getViewBackground()); |
|
|
|
PropertyUtil.installBackground((Component) newVal, getViewBackground()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -223,9 +231,11 @@ public class DarkScrollPaneUI extends BasicScrollPaneUI { |
|
|
|
protected void uninstallListeners(final JComponent c) { |
|
|
|
protected void uninstallListeners(final JComponent c) { |
|
|
|
super.uninstallListeners(c); |
|
|
|
super.uninstallListeners(c); |
|
|
|
getViewPropertyChangeListener().uninstall(); |
|
|
|
getViewPropertyChangeListener().uninstall(); |
|
|
|
scrollpane.addPropertyChangeListener(getPropertyChangeListener()); |
|
|
|
scrollpane.removePropertyChangeListener(this); |
|
|
|
scrollpane.getVerticalScrollBar().removeMouseWheelListener(verticalMouseWheelListener); |
|
|
|
scrollpane.getVerticalScrollBar().removeMouseWheelListener(verticalMouseWheelListener); |
|
|
|
|
|
|
|
scrollpane.getVerticalScrollBar().removePropertyChangeListener(scrollbarPropertyChangeListener); |
|
|
|
scrollpane.getHorizontalScrollBar().removeMouseWheelListener(horizontalMouseWheelListener); |
|
|
|
scrollpane.getHorizontalScrollBar().removeMouseWheelListener(horizontalMouseWheelListener); |
|
|
|
|
|
|
|
scrollpane.getHorizontalScrollBar().removePropertyChangeListener(scrollbarPropertyChangeListener); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|