Browse Source

Slider: Adjust track baseline behaviour.

pull/245/head
weisj 4 years ago
parent
commit
7762fb11d0
No known key found for this signature in database
GPG Key ID: 31124CB75461DA2A
  1. 20
      core/src/main/java/com/github/weisj/darklaf/ui/slider/DarkSliderUI.java
  2. 2
      core/src/main/resources/com/github/weisj/darklaf/icons/control/slider.svg
  3. 2
      core/src/main/resources/com/github/weisj/darklaf/icons/control/sliderDisabled.svg
  4. 2
      core/src/main/resources/com/github/weisj/darklaf/icons/control/sliderFocused.svg
  5. 2
      core/src/main/resources/com/github/weisj/darklaf/icons/control/volumeSlider.svg
  6. 2
      core/src/main/resources/com/github/weisj/darklaf/icons/control/volumeSliderDisabled.svg
  7. 2
      core/src/main/resources/com/github/weisj/darklaf/icons/control/volumeSliderFocused.svg

20
core/src/main/java/com/github/weisj/darklaf/ui/slider/DarkSliderUI.java

@ -40,6 +40,7 @@ import com.github.weisj.darklaf.util.PropertyKey;
import com.github.weisj.darklaf.util.PropertyUtil;
import com.github.weisj.darklaf.util.graphics.GraphicsContext;
import com.github.weisj.darklaf.util.graphics.GraphicsUtil;
import com.github.weisj.swingdsl.visualpadding.VisualPaddingProvider;
/** @author Jannis Weis */
public class DarkSliderUI extends BasicSliderUI {
@ -161,7 +162,21 @@ public class DarkSliderUI extends BasicSliderUI {
@Override
public int getBaseline(JComponent c, int width, int height) {
if (isHorizontal() && PropertyUtil.getBooleanProperty(c, KEY_USE_TRACK_AS_BASELINE)) {
return trackRect.y + trackRect.height / 2;
int thumbY = focusInsets.top + trackBuffer;
if (isPlainThumb()) {
Dimension thumbSize = getThumbSize();
return thumbY + thumbSize.height - focusBorderSize;
} else {
Icon icon = getThumbIcon();
int baseline = thumbY + icon.getIconHeight();
if (icon instanceof RotatableIcon) {
icon = ((RotatableIcon) icon).getIcon();
}
if (icon instanceof VisualPaddingProvider) {
baseline -= ((VisualPaddingProvider) icon).getVisualPaddings(slider).bottom;
}
return baseline;
}
} else {
return super.getBaseline(c, width, height);
}
@ -260,6 +275,7 @@ public class DarkSliderUI extends BasicSliderUI {
* @param direction the direction
*/
public void scrollByBlock(final int direction) {
// noinspection SynchronizeOnNonFinalField
synchronized (slider) {
int blockIncrement = (slider.getMaximum() - slider.getMinimum()) / 10;
if (blockIncrement == 0) {
@ -289,6 +305,7 @@ public class DarkSliderUI extends BasicSliderUI {
* @param direction the direction
*/
public void scrollByUnit(final int direction) {
// noinspection SynchronizeOnNonFinalField
synchronized (slider) {
int delta = ((direction > 0) ? POSITIVE_SCROLL : NEGATIVE_SCROLL);
@ -401,6 +418,7 @@ public class DarkSliderUI extends BasicSliderUI {
int bw = 2 * getFocusBorderSize();
return new Dimension(plainThumbRadius + bw, plainThumbRadius + bw);
}
// noinspection SuspiciousNameCombination
return isHorizontal() ? new Dimension(thumbSize.width, thumbSize.height)
: new Dimension(thumbSize.height, thumbSize.width);
}

2
core/src/main/resources/com/github/weisj/darklaf/icons/control/slider.svg

@ -1,4 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="23" viewBox="0 0 20 23">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="23" viewBox="0 0 20 23" visualPadding="2 2 2 2">
<defs id="colors">
<linearGradient id="Icons.Slider.activeFillColor">
<stop offset="0" stop-color="#43494A"/>

Before

Width:  |  Height:  |  Size: 796 B

After

Width:  |  Height:  |  Size: 820 B

2
core/src/main/resources/com/github/weisj/darklaf/icons/control/sliderDisabled.svg

@ -1,4 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="23" viewBox="0 0 20 22">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="23" viewBox="0 0 20 22" visualPadding="2 2 2 2">
<defs id="colors">
<linearGradient id="Icons.SliderDisabled.inactiveFillColor">
<stop offset="0" stop-color="#3C3F41"/>

Before

Width:  |  Height:  |  Size: 848 B

After

Width:  |  Height:  |  Size: 872 B

2
core/src/main/resources/com/github/weisj/darklaf/icons/control/sliderFocused.svg

@ -1,4 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="23" viewBox="0 0 20 23">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="23" viewBox="0 0 20 23" visualPadding="2 2 2 2">
<defs id="colors">
<linearGradient id="Icons.SliderFocused.activeFillColor">
<stop offset="0" stop-color="#43494A"/>

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

2
core/src/main/resources/com/github/weisj/darklaf/icons/control/volumeSlider.svg

@ -1,4 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="23" viewBox="0 0 20 23">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="23" viewBox="0 0 20 23" visualPadding="2 2 2 2">
<defs id="colors">
<linearGradient id="Icons.VolumeSlider.activeFillColor">
<stop offset="0" stop-color="#A0A0A0"/>

Before

Width:  |  Height:  |  Size: 820 B

After

Width:  |  Height:  |  Size: 844 B

2
core/src/main/resources/com/github/weisj/darklaf/icons/control/volumeSliderDisabled.svg

@ -1,4 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="23" viewBox="0 0 20 23">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="23" viewBox="0 0 20 23" visualPadding="2 2 2 2">
<defs id="colors">
<linearGradient id="Icons.VolumeSliderDisabled.inactiveFillColor">
<stop offset="0" stop-color="#3C3F41"/>

Before

Width:  |  Height:  |  Size: 872 B

After

Width:  |  Height:  |  Size: 896 B

2
core/src/main/resources/com/github/weisj/darklaf/icons/control/volumeSliderFocused.svg

@ -1,4 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="23" viewBox="0 0 20 23">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="23" viewBox="0 0 20 23" visualPadding="2 2 2 2">
<defs id="colors">
<linearGradient id="Icons.VolumeSliderFocused.activeFillColor">
<stop offset="0" stop-color="#A0A0A0"/>

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Loading…
Cancel
Save