|
|
@ -19,6 +19,7 @@ package com.bulenkov.darcula.ui; |
|
|
|
import com.bulenkov.iconloader.util.ColorUtil; |
|
|
|
import com.bulenkov.iconloader.util.ColorUtil; |
|
|
|
import com.bulenkov.iconloader.util.GraphicsConfig; |
|
|
|
import com.bulenkov.iconloader.util.GraphicsConfig; |
|
|
|
import com.bulenkov.iconloader.util.GraphicsUtil; |
|
|
|
import com.bulenkov.iconloader.util.GraphicsUtil; |
|
|
|
|
|
|
|
import com.intellij.util.ui.JBDimension; |
|
|
|
import com.intellij.util.ui.JBUI; |
|
|
|
import com.intellij.util.ui.JBUI; |
|
|
|
import org.jetbrains.annotations.NotNull; |
|
|
|
import org.jetbrains.annotations.NotNull; |
|
|
|
|
|
|
|
|
|
|
@ -58,7 +59,7 @@ public class DarculaSliderUI extends BasicSliderUI { |
|
|
|
int trackSize = JBUI.scale(6); |
|
|
|
int trackSize = JBUI.scale(6); |
|
|
|
final GraphicsConfig config = GraphicsUtil.setupAAPainting(g); |
|
|
|
final GraphicsConfig config = GraphicsUtil.setupAAPainting(g); |
|
|
|
final Color bg = getTrackBackground(); |
|
|
|
final Color bg = getTrackBackground(); |
|
|
|
final Color selection = slider.isEnabled() ? getSelectedTrackColor() : getDisabledTickColor(); |
|
|
|
final Color selection = getThumbColor(); |
|
|
|
if (slider.getOrientation() == JSlider.HORIZONTAL) { |
|
|
|
if (slider.getOrientation() == JSlider.HORIZONTAL) { |
|
|
|
int cy = (trackBounds.height / 2) - trackSize / 2; |
|
|
|
int cy = (trackBounds.height / 2) - trackSize / 2; |
|
|
|
int cw = trackBounds.width; |
|
|
|
int cw = trackBounds.width; |
|
|
@ -87,7 +88,7 @@ public class DarculaSliderUI extends BasicSliderUI { |
|
|
|
if (isPlainThumb()) { |
|
|
|
if (isPlainThumb()) { |
|
|
|
return new Dimension(JBUI.scale(20), JBUI.scale(20)); |
|
|
|
return new Dimension(JBUI.scale(20), JBUI.scale(20)); |
|
|
|
} |
|
|
|
} |
|
|
|
return super.getThumbSize(); |
|
|
|
return slider.getOrientation() == JSlider.HORIZONTAL ? new JBDimension(12, 20) : new JBDimension(20, 12); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@NotNull |
|
|
|
@NotNull |
|
|
@ -167,10 +168,9 @@ public class DarculaSliderUI extends BasicSliderUI { |
|
|
|
|
|
|
|
|
|
|
|
g.translate(knobBounds.x, knobBounds.y); |
|
|
|
g.translate(knobBounds.x, knobBounds.y); |
|
|
|
|
|
|
|
|
|
|
|
if ( slider.isEnabled() ) { |
|
|
|
if (slider.isEnabled()) { |
|
|
|
g.setColor(slider.getBackground()); |
|
|
|
g.setColor(slider.getBackground()); |
|
|
|
} |
|
|
|
} else { |
|
|
|
else { |
|
|
|
|
|
|
|
g.setColor(slider.getBackground().darker()); |
|
|
|
g.setColor(slider.getBackground().darker()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -178,76 +178,68 @@ public class DarculaSliderUI extends BasicSliderUI { |
|
|
|
if (isPlainThumb()) { |
|
|
|
if (isPlainThumb()) { |
|
|
|
double r = slider.getOrientation() == JSlider.HORIZONTAL ? h : w; |
|
|
|
double r = slider.getOrientation() == JSlider.HORIZONTAL ? h : w; |
|
|
|
final Ellipse2D.Double thumb = new Ellipse2D.Double(0, 0, r, r); |
|
|
|
final Ellipse2D.Double thumb = new Ellipse2D.Double(0, 0, r, r); |
|
|
|
final Ellipse2D.Double innerThumb = new Ellipse2D.Double(1, 1, r-2, r-2); |
|
|
|
final Ellipse2D.Double innerThumb = new Ellipse2D.Double(1, 1, r - 2, r - 2); |
|
|
|
g.setColor(ColorUtil.fromHex("555555")); |
|
|
|
g.setColor(getThumbBorderColor()); |
|
|
|
((Graphics2D) g).fill(thumb); |
|
|
|
((Graphics2D) g).fill(thumb); |
|
|
|
g.setColor(slider.isEnabled() ? getSelectedTrackColor() : getDisabledTickColor()); |
|
|
|
g.setColor(getThumbColor()); |
|
|
|
((Graphics2D) g).fill(innerThumb); |
|
|
|
((Graphics2D) g).fill(innerThumb); |
|
|
|
} |
|
|
|
} else if (slider.getOrientation() == JSlider.HORIZONTAL) { |
|
|
|
else if ( slider.getOrientation() == JSlider.HORIZONTAL ) { |
|
|
|
|
|
|
|
int cw = w / 2; |
|
|
|
int cw = w / 2; |
|
|
|
g.fillRect(1, 1, w-3, h-1-cw); |
|
|
|
g.setColor(getThumbBorderColor()); |
|
|
|
Polygon p = new Polygon(); |
|
|
|
Polygon p = new Polygon(); //border
|
|
|
|
p.addPoint(1, h-cw); |
|
|
|
p.addPoint(0, 0); |
|
|
|
p.addPoint(cw-1, h-1); |
|
|
|
p.addPoint(w - 1, 0); |
|
|
|
p.addPoint(w-2, h-1-cw); |
|
|
|
p.addPoint(w - 1, h - cw); |
|
|
|
|
|
|
|
p.addPoint(cw, h - 1); |
|
|
|
|
|
|
|
p.addPoint(0, h - cw); |
|
|
|
g.fillPolygon(p); |
|
|
|
g.fillPolygon(p); |
|
|
|
|
|
|
|
|
|
|
|
g.setColor(getHighlightColor()); |
|
|
|
g.setColor(getThumbColor()); |
|
|
|
g.drawLine(0, 0, w-2, 0); |
|
|
|
p = new Polygon(); |
|
|
|
g.drawLine(0, 1, 0, h-1-cw); |
|
|
|
p.addPoint(1, 1); |
|
|
|
g.drawLine(0, h-cw, cw-1, h-1); |
|
|
|
p.addPoint(w - 2, 1); |
|
|
|
|
|
|
|
p.addPoint(w - 2, h - cw - 1); |
|
|
|
g.setColor(Color.black); |
|
|
|
p.addPoint(cw, h - 2); |
|
|
|
g.drawLine(w-1, 0, w-1, h-2-cw); |
|
|
|
p.addPoint(1, h - cw - 1); |
|
|
|
g.drawLine(w-1, h-1-cw, w-1-cw, h-1); |
|
|
|
g.fillPolygon(p); |
|
|
|
|
|
|
|
} else { // vertical
|
|
|
|
g.setColor(getShadowColor()); |
|
|
|
|
|
|
|
g.drawLine(w-2, 1, w-2, h-2-cw); |
|
|
|
|
|
|
|
g.drawLine(w-2, h-1-cw, w-1-cw, h-2); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { // vertical
|
|
|
|
|
|
|
|
int cw = h / 2; |
|
|
|
int cw = h / 2; |
|
|
|
if(slider.getComponentOrientation().isLeftToRight()) { |
|
|
|
if (slider.getComponentOrientation().isLeftToRight()) { |
|
|
|
g.fillRect(1, 1, w-1-cw, h-3); |
|
|
|
g.setColor(getThumbBorderColor()); |
|
|
|
Polygon p = new Polygon(); |
|
|
|
Polygon p = new Polygon(); //border
|
|
|
|
p.addPoint(w-cw-1, 0); |
|
|
|
p.addPoint(0, 0); |
|
|
|
p.addPoint(w-1, cw); |
|
|
|
p.addPoint(w - cw, 0); |
|
|
|
p.addPoint(w-1-cw, h-2); |
|
|
|
p.addPoint(w - 1, h - cw); |
|
|
|
|
|
|
|
p.addPoint(w - cw, h - 1); |
|
|
|
|
|
|
|
p.addPoint(0, h - 1); |
|
|
|
g.fillPolygon(p); |
|
|
|
g.fillPolygon(p); |
|
|
|
|
|
|
|
|
|
|
|
g.setColor(getHighlightColor()); |
|
|
|
g.setColor(getThumbColor()); |
|
|
|
g.drawLine(0, 0, 0, h - 2); // left
|
|
|
|
p = new Polygon(); |
|
|
|
g.drawLine(1, 0, w-1-cw, 0); // top
|
|
|
|
p.addPoint(1, 1); |
|
|
|
g.drawLine(w-cw-1, 0, w-1, cw); // top slant
|
|
|
|
p.addPoint(w - cw, 1); |
|
|
|
|
|
|
|
p.addPoint(w - 2, h - cw); |
|
|
|
g.setColor(Color.black); |
|
|
|
p.addPoint(w - cw, h - 2); |
|
|
|
g.drawLine(0, h-1, w-2-cw, h-1); // bottom
|
|
|
|
p.addPoint(1, h - 2); |
|
|
|
g.drawLine(w-1-cw, h-1, w-1, h-1-cw); // bottom slant
|
|
|
|
g.fillPolygon(p); |
|
|
|
|
|
|
|
} else { |
|
|
|
g.setColor(getShadowColor()); |
|
|
|
g.setColor(getThumbBorderColor()); |
|
|
|
g.drawLine(1, h-2, w-2-cw, h-2 ); // bottom
|
|
|
|
Polygon p = new Polygon(); //border
|
|
|
|
g.drawLine(w-1-cw, h-2, w-2, h-cw-1 ); // bottom slant
|
|
|
|
p.addPoint(w - 1, 0); |
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
g.fillRect(5, 1, w-1-cw, h-3); |
|
|
|
|
|
|
|
Polygon p = new Polygon(); |
|
|
|
|
|
|
|
p.addPoint(cw, 0); |
|
|
|
p.addPoint(cw, 0); |
|
|
|
p.addPoint(0, cw); |
|
|
|
p.addPoint(0, h - cw); |
|
|
|
p.addPoint(cw, h-2); |
|
|
|
p.addPoint(cw, h - 1); |
|
|
|
|
|
|
|
p.addPoint(w - 1 , h - 1); |
|
|
|
g.fillPolygon(p); |
|
|
|
g.fillPolygon(p); |
|
|
|
|
|
|
|
|
|
|
|
g.setColor(getHighlightColor()); |
|
|
|
g.setColor(getThumbColor()); |
|
|
|
g.drawLine(cw-1, 0, w-2, 0); // top
|
|
|
|
p = new Polygon(); |
|
|
|
g.drawLine(0, cw, cw, 0); // top slant
|
|
|
|
p.addPoint(w - 2, 1); |
|
|
|
|
|
|
|
p.addPoint(cw + 1, 1); |
|
|
|
g.setColor(Color.black); |
|
|
|
p.addPoint(1, h - cw); |
|
|
|
g.drawLine(0, h-1-cw, cw, h-1 ); // bottom slant
|
|
|
|
p.addPoint(cw + 1, h - 2); |
|
|
|
g.drawLine(cw, h-1, w-1, h-1); // bottom
|
|
|
|
p.addPoint(w - 2, h - 2); |
|
|
|
|
|
|
|
g.fillPolygon(p); |
|
|
|
g.setColor(getShadowColor()); |
|
|
|
|
|
|
|
g.drawLine(cw, h-2, w-2, h-2 ); // bottom
|
|
|
|
|
|
|
|
g.drawLine(w-1, 1, w-1, h-2 ); // right
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -255,8 +247,18 @@ public class DarculaSliderUI extends BasicSliderUI { |
|
|
|
config.restore(); |
|
|
|
config.restore(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@NotNull |
|
|
|
|
|
|
|
protected Color getThumbColor() { |
|
|
|
|
|
|
|
return slider.isEnabled() ? getSelectedTrackColor() : getDisabledTickColor(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@NotNull |
|
|
|
|
|
|
|
protected Color getThumbBorderColor() { |
|
|
|
|
|
|
|
return slider.isEnabled() ? ColorUtil.fromHex("707070") : ColorUtil.fromHex("444444"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected boolean isPlainThumb() { |
|
|
|
protected boolean isPlainThumb() { |
|
|
|
Boolean paintThumbArrowShape = (Boolean)slider.getClientProperty("Slider.paintThumbArrowShape"); |
|
|
|
Boolean paintThumbArrowShape = (Boolean) slider.getClientProperty("Slider.paintThumbArrowShape"); |
|
|
|
return (!slider.getPaintTicks() && paintThumbArrowShape == null) || |
|
|
|
return (!slider.getPaintTicks() && paintThumbArrowShape == null) || |
|
|
|
paintThumbArrowShape == Boolean.FALSE; |
|
|
|
paintThumbArrowShape == Boolean.FALSE; |
|
|
|
} |
|
|
|
} |
|
|
|