mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix scrollbars in darcula
This commit is contained in:
@@ -80,12 +80,12 @@ public class JBScrollPane extends JScrollPane {
|
||||
|
||||
@Override
|
||||
public JScrollBar createVerticalScrollBar() {
|
||||
return new MyScrollBar(JScrollBar.VERTICAL);
|
||||
return new MyScrollBar(Adjustable.VERTICAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JScrollBar createHorizontalScrollBar() {
|
||||
return new MyScrollBar(JScrollBar.HORIZONTAL);
|
||||
return new MyScrollBar(Adjustable.HORIZONTAL);
|
||||
}
|
||||
|
||||
public boolean isHaveBorder() {
|
||||
@@ -115,11 +115,6 @@ public class JBScrollPane extends JScrollPane {
|
||||
public boolean canBePreprocessed(MouseEvent e) {
|
||||
return JBScrollPane.canBePreprocessed(e, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return super.getPreferredSize(); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -152,10 +147,10 @@ public class JBScrollPane extends JScrollPane {
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
g.setColor(ButtonlessScrollBarUI.TRACK_BACKGROUND);
|
||||
g.setColor(ButtonlessScrollBarUI.getTrackBackground());
|
||||
g.fillRect(0, 0, getWidth(), getHeight());
|
||||
|
||||
g.setColor(ButtonlessScrollBarUI.TRACK_BORDER);
|
||||
g.setColor(ButtonlessScrollBarUI.getTrackBorderColor());
|
||||
|
||||
int x2 = getWidth() - 1;
|
||||
int y2 = getHeight() - 1;
|
||||
|
||||
@@ -26,13 +26,19 @@ import java.awt.event.*;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class ButtonlessScrollBarUI extends BasicScrollBarUI {
|
||||
public static final Color GRADIENT_LIGHT = Gray._251;
|
||||
public static final Color GRADIENT_DARK = Gray._215;
|
||||
public static final Color GRADIENT_THUMB_BORDER = Gray._201;
|
||||
public static final Color TRACK_BACKGROUND = LightColors.SLIGHTLY_GRAY;
|
||||
public static final Color TRACK_BORDER = Gray._230;
|
||||
private static final Color GRADIENT_LIGHT = Gray._251;
|
||||
private static final Color GRADIENT_DARK = Gray._215;
|
||||
private static final Color GRADIENT_THUMB_BORDER = Gray._201;
|
||||
private static final Color TRACK_BACKGROUND = LightColors.SLIGHTLY_GRAY;
|
||||
private static final Color TRACK_BORDER = Gray._230;
|
||||
private static final Color GRADIENT_LIGHT_DARK_VARIANT = GRADIENT_LIGHT.darker().darker();
|
||||
private static final Color GRADIENT_DARK_DARK_VARIANT = GRADIENT_DARK.darker().darker();
|
||||
private static final Color GRADIENT_THUMB_BORDER_DARK_VARIANT = GRADIENT_THUMB_BORDER.darker().darker();
|
||||
private static final Color TRACK_BACKGROUND_DARK_VARIANT = TRACK_BACKGROUND.darker().darker();
|
||||
private static final Color TRACK_BORDER_DARK_VARIANT = TRACK_BORDER.darker().darker();
|
||||
|
||||
private static final BasicStroke BORDER_STROKE = new BasicStroke();
|
||||
|
||||
@@ -91,6 +97,26 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
|
||||
};
|
||||
}
|
||||
|
||||
public static Color getGradientLightColor() {
|
||||
return UIUtil.isUnderDarcula() ? GRADIENT_LIGHT_DARK_VARIANT : GRADIENT_LIGHT;
|
||||
}
|
||||
|
||||
public static Color getGradientDarkColor() {
|
||||
return UIUtil.isUnderDarcula() ? GRADIENT_DARK_DARK_VARIANT : GRADIENT_DARK;
|
||||
}
|
||||
|
||||
public static Color getGradientThumbBorderColor() {
|
||||
return UIUtil.isUnderDarcula() ? GRADIENT_THUMB_BORDER_DARK_VARIANT : GRADIENT_THUMB_BORDER;
|
||||
}
|
||||
|
||||
public static Color getTrackBackground() {
|
||||
return UIUtil.isUnderDarcula() ? TRACK_BACKGROUND_DARK_VARIANT : TRACK_BACKGROUND;
|
||||
}
|
||||
|
||||
public static Color getTrackBorderColor() {
|
||||
return UIUtil.isUnderDarcula() ? TRACK_BORDER_DARK_VARIANT : TRACK_BORDER;
|
||||
}
|
||||
|
||||
public int getDecrButtonHeight() {
|
||||
return decrButton.getHeight();
|
||||
}
|
||||
@@ -156,11 +182,10 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
|
||||
|
||||
@Override
|
||||
protected void paintTrack(Graphics g, JComponent c, Rectangle bounds) {
|
||||
final boolean dark = UIUtil.isUnderDarcula();
|
||||
g.setColor(dark ? TRACK_BACKGROUND.darker().darker(): TRACK_BACKGROUND);
|
||||
g.setColor(getTrackBackground());
|
||||
g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
|
||||
|
||||
g.setColor(dark ? TRACK_BORDER.darker().darker() : TRACK_BORDER);
|
||||
g.setColor(getTrackBorderColor());
|
||||
if (isVertical()) {
|
||||
g.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height);
|
||||
}
|
||||
@@ -207,7 +232,6 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
|
||||
}
|
||||
|
||||
private void paintMaxiThumb(Graphics2D g, Rectangle thumbBounds) {
|
||||
final boolean dark = UIUtil.isUnderDarcula();
|
||||
final boolean vertical = isVertical();
|
||||
int hGap = vertical ? 2 : 1;
|
||||
int vGap = vertical ? 1 : 2;
|
||||
@@ -224,8 +248,8 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
|
||||
}
|
||||
|
||||
final GradientPaint paint;
|
||||
final Color start = adjustColor(dark ? GRADIENT_LIGHT.darker().darker() : GRADIENT_LIGHT);
|
||||
final Color end = adjustColor(dark ? GRADIENT_DARK.darker().darker() : GRADIENT_DARK);
|
||||
final Color start = adjustColor(getGradientLightColor());
|
||||
final Color end = adjustColor(getGradientDarkColor());
|
||||
|
||||
if (vertical) {
|
||||
paint = new GradientPaint(1, 0, start, w + 1, 0, end);
|
||||
@@ -239,7 +263,7 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
|
||||
|
||||
final Stroke stroke = g.getStroke();
|
||||
g.setStroke(BORDER_STROKE);
|
||||
g.setColor(dark ? GRADIENT_THUMB_BORDER.darker().darker() : GRADIENT_THUMB_BORDER);
|
||||
g.setColor(getGradientThumbBorderColor());
|
||||
g.drawRoundRect(hGap, vGap, w, h, 3, 3);
|
||||
g.setStroke(stroke);
|
||||
}
|
||||
|
||||
@@ -6312,7 +6312,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
int width = bounds.width;
|
||||
int height = bounds.height;
|
||||
|
||||
g.setColor(ButtonlessScrollBarUI.TRACK_BACKGROUND);
|
||||
g.setColor(ButtonlessScrollBarUI.getTrackBackground());
|
||||
g.fillRect(0, 0, width, height);
|
||||
|
||||
int shortner = 0;
|
||||
@@ -6323,7 +6323,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
g.setColor(myGutterComponent.getBackground());
|
||||
g.fillRect(0, 0, width - shortner, height);
|
||||
|
||||
g.setColor(ButtonlessScrollBarUI.TRACK_BORDER);
|
||||
g.setColor(ButtonlessScrollBarUI.getTrackBorderColor());
|
||||
g.drawLine(width - 1 - shortner, 0, width - 1 - shortner, height);
|
||||
g.drawLine(0, 0, width - 1, 0);
|
||||
}
|
||||
|
||||
+8
-6
@@ -54,6 +54,7 @@ import com.intellij.util.ui.ButtonlessScrollBarUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.ScrollBarUI;
|
||||
@@ -182,6 +183,7 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private RangeHighlighter getNearestRangeHighlighter(final MouseEvent e, final int width) {
|
||||
List<RangeHighlighter> highlighters = new ArrayList<RangeHighlighter>();
|
||||
getNearestHighlighters(this, e, width, highlighters);
|
||||
@@ -250,6 +252,7 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
myEditor.getVerticalScrollBar().setPersistentUI(ButtonlessScrollBarUI.createNormal());
|
||||
}
|
||||
}
|
||||
@Nullable
|
||||
private MyErrorPanel getErrorPanel() {
|
||||
ScrollBarUI ui = myEditor.getVerticalScrollBar().getUI();
|
||||
return ui instanceof MyErrorPanel ? (MyErrorPanel)ui : null;
|
||||
@@ -336,10 +339,10 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
|
||||
final Rectangle bounds = getBounds();
|
||||
|
||||
g.setColor(ButtonlessScrollBarUI.TRACK_BACKGROUND);
|
||||
g.setColor(ButtonlessScrollBarUI.getTrackBackground());
|
||||
g.fillRect(0, 0, bounds.width, bounds.height);
|
||||
|
||||
g.setColor(ButtonlessScrollBarUI.TRACK_BORDER);
|
||||
g.setColor(ButtonlessScrollBarUI.getTrackBorderColor());
|
||||
g.drawLine(0, 0, 0, bounds.height);
|
||||
|
||||
try {
|
||||
@@ -424,8 +427,7 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
((ApplicationImpl)ApplicationManager.getApplication()).editorPaintStart();
|
||||
|
||||
try {
|
||||
ProperTextRange intersection = myDirtyYPositions.intersection(docRange);
|
||||
myDirtyYPositions = intersection;
|
||||
myDirtyYPositions = myDirtyYPositions.intersection(docRange);
|
||||
if (myDirtyYPositions == null) myDirtyYPositions = docRange;
|
||||
repaint(imageGraphics, componentBounds.width, ERROR_ICON_WIDTH - 1, myDirtyYPositions);
|
||||
myDirtyYPositions = null;
|
||||
@@ -439,10 +441,10 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
}
|
||||
|
||||
private void paintTrackBasement(Graphics g, Rectangle bounds) {
|
||||
g.setColor(TRACK_BACKGROUND);
|
||||
g.setColor(ButtonlessScrollBarUI.getTrackBackground());
|
||||
g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height + 1);
|
||||
|
||||
g.setColor(TRACK_BORDER);
|
||||
g.setColor(ButtonlessScrollBarUI.getTrackBorderColor());
|
||||
int border = isMirrored() ? bounds.x + bounds.width - 1 : bounds.x;
|
||||
g.drawLine(border, bounds.y, border, bounds.y + bounds.height + 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user