mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-149395 Add ability to use background of the scroll pane from the viewport's view
This commit is contained in:
@@ -110,8 +110,9 @@ abstract class AbstractScrollBarUI extends ScrollBarUI {
|
||||
@Override
|
||||
public void installUI(JComponent c) {
|
||||
myScrollBar = (JScrollBar)c;
|
||||
myScrollBar.setBackground(new JBColor(new ColorProducer(c, 0xF5F5F5, 0x3C3F41)));
|
||||
myScrollBar.setForeground(new JBColor(new ColorProducer(c, 0xE6E6E6, 0x3C3F41)));
|
||||
boolean auto = Registry.is("ide.scroll.background.auto");
|
||||
myScrollBar.setBackground(auto ? null : new JBColor(new ColorProducer(c, 0xF5F5F5, 0x3C3F41)));
|
||||
myScrollBar.setForeground(auto ? null : new JBColor(new ColorProducer(c, 0xE6E6E6, 0x3C3F41)));
|
||||
myScrollBar.setFocusable(false);
|
||||
myScrollBar.addMouseListener(myListener);
|
||||
myScrollBar.addMouseMotionListener(myListener);
|
||||
|
||||
@@ -35,6 +35,7 @@ import javax.swing.border.Border;
|
||||
import javax.swing.border.LineBorder;
|
||||
import javax.swing.plaf.ScrollBarUI;
|
||||
import javax.swing.plaf.ScrollPaneUI;
|
||||
import javax.swing.plaf.UIResource;
|
||||
import javax.swing.plaf.basic.BasicScrollBarUI;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
@@ -65,6 +66,7 @@ public class JBScrollPane extends JScrollPane {
|
||||
|
||||
private int myViewportBorderWidth = -1;
|
||||
private boolean myHasOverlayScrollbars;
|
||||
private volatile boolean myBackgroundRequested; // avoid cyclic references
|
||||
|
||||
public JBScrollPane(int viewportWidth) {
|
||||
init(false);
|
||||
@@ -91,6 +93,26 @@ public class JBScrollPane extends JScrollPane {
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getBackground() {
|
||||
Color color = super.getBackground();
|
||||
if (!myBackgroundRequested && EventQueue.isDispatchThread() && Registry.is("ide.scroll.background.auto")) {
|
||||
if (!isBackgroundSet() || color instanceof UIResource) {
|
||||
Component child = getViewport();
|
||||
if (child != null) {
|
||||
try {
|
||||
myBackgroundRequested = true;
|
||||
return child.getBackground();
|
||||
}
|
||||
finally {
|
||||
myBackgroundRequested = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
public static JScrollPane findScrollPane(Component c) {
|
||||
if (c == null) return null;
|
||||
|
||||
|
||||
@@ -94,6 +94,7 @@ public class JBViewport extends JViewport implements ZoomableViewport {
|
||||
|
||||
private Dimension myTempViewSize;
|
||||
private boolean mySaveTempViewSize;
|
||||
private volatile boolean myBackgroundRequested; // avoid cyclic references
|
||||
|
||||
public JBViewport() {
|
||||
addContainerListener(new ContainerListener() {
|
||||
@@ -117,6 +118,26 @@ public class JBViewport extends JViewport implements ZoomableViewport {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getBackground() {
|
||||
Color color = super.getBackground();
|
||||
if (!myBackgroundRequested && EventQueue.isDispatchThread() && Registry.is("ide.scroll.background.auto")) {
|
||||
if (!isBackgroundSet() || color instanceof UIResource) {
|
||||
Component child = getView();
|
||||
if (child != null) {
|
||||
try {
|
||||
myBackgroundRequested = true;
|
||||
return child.getBackground();
|
||||
}
|
||||
finally {
|
||||
myBackgroundRequested = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LayoutManager createLayoutManager() {
|
||||
return ourLayoutManager;
|
||||
|
||||
@@ -109,6 +109,7 @@ ide.tree.deferred.icon.invalidates.cache=true
|
||||
ide.splitter.mouseZone=6
|
||||
ide.smart.horizontal.scrolling=true
|
||||
ide.scroll.new.layout=true
|
||||
ide.scroll.background.auto=false
|
||||
ide.scroll.bar.expand.animation=false
|
||||
ide.scroll.track.border.paint=false
|
||||
ide.scroll.thumb.border.rounded=false
|
||||
|
||||
Reference in New Issue
Block a user