mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
scrollbar ui cleanup
This commit is contained in:
@@ -29,23 +29,18 @@ import java.awt.event.AdjustmentEvent;
|
||||
import java.awt.event.AdjustmentListener;
|
||||
|
||||
public class ButtonlessScrollBarUI extends BasicScrollBarUI {
|
||||
|
||||
public static final Color GRADIENT_LIGHT = new SameColor(0xfb);
|
||||
public static final Color GRADIENT_DARK = new SameColor(0xd7);
|
||||
public static final Color GRADIENT_THUMB_BORDER = new SameColor(0xc9);
|
||||
public static final Color PLAIN_THUMB_FILL = new SameColor(0xe5);
|
||||
public static final Color PLAIN_THUMB_BORDER = new SameColor(0xd0);
|
||||
public static final Color TRACK_BACKGROUND = LightColors.SLIGHTLY_GRAY;
|
||||
public static final Color TRACK_BORDER = new SameColor(230);
|
||||
|
||||
private final boolean myIsMini;
|
||||
private final AdjustmentListener myAdjustmentListener;
|
||||
private final Animator myAnimator;
|
||||
|
||||
private int myAnimationColorShift = 0;
|
||||
|
||||
protected ButtonlessScrollBarUI(boolean isMini) {
|
||||
myIsMini = isMini;
|
||||
protected ButtonlessScrollBarUI() {
|
||||
myAdjustmentListener = new AdjustmentListener() {
|
||||
@Override
|
||||
public void adjustmentValueChanged(AdjustmentEvent e) {
|
||||
@@ -54,10 +49,16 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
|
||||
}
|
||||
};
|
||||
|
||||
myAnimator = new Animator("Adjustment fadeout", myIsMini ? 5 : 10, myIsMini ? 300 : 500, false, 1, 0) {
|
||||
final int delayFrames = 4;
|
||||
final int framesCount = 10 + delayFrames;
|
||||
myAnimator = new Animator("Adjustment fadeout", framesCount, framesCount * 50, false, 1, 0) {
|
||||
@Override
|
||||
public void paintNow(float frame, float totalFrames, float cycle) {
|
||||
myAnimationColorShift = (int)((totalFrames - frame) * 3);
|
||||
myAnimationColorShift = 40;
|
||||
if (frame > delayFrames) {
|
||||
myAnimationColorShift *= 1 - ((frame - delayFrames) / (totalFrames - delayFrames));
|
||||
}
|
||||
|
||||
if (scrollbar != null) {
|
||||
scrollbar.repaint();
|
||||
}
|
||||
@@ -66,20 +67,7 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
|
||||
}
|
||||
|
||||
public static BasicScrollBarUI createNormal() {
|
||||
return new ButtonlessScrollBarUI(false);
|
||||
}
|
||||
|
||||
public static BasicScrollBarUI createMini() {
|
||||
return new ButtonlessScrollBarUI(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void installUI(JComponent c) {
|
||||
if (myIsMini) {
|
||||
c.putClientProperty("JComponent.sizeVariant", "mini");
|
||||
}
|
||||
|
||||
super.installUI(c);
|
||||
return new ButtonlessScrollBarUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -116,7 +104,7 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
|
||||
}
|
||||
|
||||
protected int getThickness() {
|
||||
return myIsMini ? 10 : 13;
|
||||
return 13;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -142,14 +130,7 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
|
||||
}
|
||||
|
||||
g.translate(thumbBounds.x, thumbBounds.y);
|
||||
|
||||
if (myIsMini) {
|
||||
paintMiniThumb(g, thumbBounds);
|
||||
}
|
||||
else {
|
||||
paintMaxiThumb(g, thumbBounds);
|
||||
}
|
||||
|
||||
paintMaxiThumb(g, thumbBounds);
|
||||
g.translate(-thumbBounds.x, -thumbBounds.y);
|
||||
}
|
||||
|
||||
@@ -197,22 +178,6 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
|
||||
return new SameColor(c.getRed() - myAnimationColorShift);
|
||||
}
|
||||
|
||||
private void paintMiniThumb(Graphics g, Rectangle thumbBounds) {
|
||||
final boolean vertical = isVertical();
|
||||
final int hgap = vertical ? 2 : 1;
|
||||
final int vgap = vertical ? 1 : 2;
|
||||
|
||||
int w = thumbBounds.width - hgap * 2;
|
||||
int h = thumbBounds.height - vgap * 2;
|
||||
|
||||
g.setColor(adjustColor(PLAIN_THUMB_FILL));
|
||||
g.fillRect(hgap, vgap, w, h);
|
||||
|
||||
g.setColor(PLAIN_THUMB_BORDER);
|
||||
g.drawRect(hgap, vgap, w, h);
|
||||
}
|
||||
|
||||
|
||||
private boolean isVertical() {
|
||||
return scrollbar.getOrientation() == JScrollBar.VERTICAL;
|
||||
}
|
||||
|
||||
@@ -584,10 +584,6 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
private class MyErrorPanel extends ButtonlessScrollBarUI implements MouseMotionListener, MouseListener {
|
||||
private PopupHandler myHandler;
|
||||
|
||||
private MyErrorPanel() {
|
||||
super(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JButton createDecreaseButton(int orientation) {
|
||||
return new ErrorStripeButton();
|
||||
|
||||
Reference in New Issue
Block a user