mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-148164 move TRACK key to JBScrollBar to share between UIs
This commit is contained in:
@@ -15,27 +15,34 @@
|
||||
*/
|
||||
package com.intellij.ui.components;
|
||||
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.util.ui.ButtonlessScrollBarUI;
|
||||
import com.intellij.util.ui.RegionPainter;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.intellij.lang.annotations.JdkConstants;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.JScrollBar;
|
||||
import java.awt.Adjustable;
|
||||
|
||||
public class JBScrollBar extends JScrollBar {
|
||||
/**
|
||||
* This key defines a region painter, which is used by the custom ScrollBarUI
|
||||
* to draw additional paintings (i.e. error stripes) on the scrollbar's track.
|
||||
*
|
||||
* @see UIUtil#putClientProperty
|
||||
*/
|
||||
public static final Key<RegionPainter<Object>> TRACK = Key.create("JB_SCROLL_BAR_TRACK");
|
||||
|
||||
public class JBScrollBar extends JScrollBar{
|
||||
public JBScrollBar() {
|
||||
init();
|
||||
this(Adjustable.VERTICAL);
|
||||
}
|
||||
|
||||
public JBScrollBar(@JdkConstants.AdjustableOrientation int orientation) {
|
||||
super(orientation);
|
||||
init();
|
||||
this(orientation, 0, 10, 0, 100);
|
||||
}
|
||||
|
||||
public JBScrollBar(@JdkConstants.AdjustableOrientation int orientation, int value, int extent, int min, int max) {
|
||||
super(orientation, value, extent, min, max);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
putClientProperty("JScrollBar.fastWheelScrolling", Boolean.TRUE); // fast scrolling for JDK 6
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.LightColors;
|
||||
import com.intellij.ui.components.JBScrollBar;
|
||||
import com.intellij.ui.components.JBScrollPane;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.NotNullProducer;
|
||||
@@ -44,15 +45,6 @@ import java.lang.reflect.Method;
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class ButtonlessScrollBarUI extends BasicScrollBarUI {
|
||||
/**
|
||||
* This key is used in the {@link ButtonlessScrollBarUI}
|
||||
* to paint error stripes over the scrollbar track.
|
||||
*
|
||||
* @see RegionPainter
|
||||
* @see UIUtil#putClientProperty
|
||||
*/
|
||||
public static final Key<RegionPainter<Object>> EXTRA_TRACK = Key.create("BUTTONLESS_SCROLL_BAR_UI_EXTRA_TRACK");
|
||||
|
||||
/**
|
||||
* This key is used in the {@link ButtonlessScrollBarUI}
|
||||
* to paint the scrollbar maxi thumb.
|
||||
@@ -645,7 +637,7 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
|
||||
if (alwaysShowTrack() || myMouseOverScrollbarExpandLevel > 0) {
|
||||
doPaintTrack(g, c, trackBounds);
|
||||
}
|
||||
RegionPainter<Object> painter = UIUtil.getClientProperty(c, EXTRA_TRACK);
|
||||
RegionPainter<Object> painter = UIUtil.getClientProperty(c, JBScrollBar.TRACK);
|
||||
if (painter != null) {
|
||||
painter.paint((Graphics2D)g, trackBounds.x, trackBounds.y, trackBounds.width, trackBounds.height, null);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.intellij.openapi.actionSystem.ShortcutSet;
|
||||
import com.intellij.openapi.keymap.KeymapManager;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.util.ui.ButtonlessScrollBarUI;
|
||||
import com.intellij.ui.components.JBScrollBar;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.RegionPainter;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -62,7 +62,7 @@ public abstract class Updater<Painter extends ErrorStripePainter> implements Dis
|
||||
myScrollBar.addMouseListener(myMouseAdapter);
|
||||
myScrollBar.addMouseMotionListener(myMouseAdapter);
|
||||
myQueue = new MergingUpdateQueue("ErrorStripeUpdater", 100, true, myScrollBar, this);
|
||||
UIUtil.putClientProperty(myScrollBar, ButtonlessScrollBarUI.EXTRA_TRACK, new RegionPainter<Object>() {
|
||||
UIUtil.putClientProperty(myScrollBar, JBScrollBar.TRACK, new RegionPainter<Object>() {
|
||||
@Override
|
||||
public void paint(Graphics2D g, int x, int y, int width, int height, Object object) {
|
||||
DaemonCodeAnalyzerSettings settings = DaemonCodeAnalyzerSettings.getInstance();
|
||||
@@ -83,7 +83,7 @@ public abstract class Updater<Painter extends ErrorStripePainter> implements Dis
|
||||
public void dispose() {
|
||||
myScrollBar.removeMouseListener(myMouseAdapter);
|
||||
myScrollBar.removeMouseMotionListener(myMouseAdapter);
|
||||
UIUtil.putClientProperty(myScrollBar, ButtonlessScrollBarUI.EXTRA_TRACK, null);
|
||||
UIUtil.putClientProperty(myScrollBar, JBScrollBar.TRACK, null);
|
||||
}
|
||||
|
||||
private int findErrorStripeIndex(Painter painter, int x, int y) {
|
||||
|
||||
Reference in New Issue
Block a user