From 6d67ae6d85dd4c50ec8cf1833d03808cc0ddd946 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Fri, 2 Jul 2010 17:44:32 +0400 Subject: [PATCH] scrollbar ui cleanup --- .../util/ui/ButtonlessScrollBarUI.java | 59 ++++--------------- .../editor/impl/EditorMarkupModelImpl.java | 4 -- 2 files changed, 12 insertions(+), 51 deletions(-) diff --git a/platform/platform-api/src/com/intellij/util/ui/ButtonlessScrollBarUI.java b/platform/platform-api/src/com/intellij/util/ui/ButtonlessScrollBarUI.java index dd7fe2549751..556cbbaf494b 100644 --- a/platform/platform-api/src/com/intellij/util/ui/ButtonlessScrollBarUI.java +++ b/platform/platform-api/src/com/intellij/util/ui/ButtonlessScrollBarUI.java @@ -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; } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java index 8a01072af9bc..9cb0ae34f7e2 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorMarkupModelImpl.java @@ -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();