Platform: OS X scrollbars (taking system preference into account IDEA-122633 - obsolete registry key removed)

This commit is contained in:
Anton Makeev
2014-03-24 11:39:37 +01:00
parent c68fd07d79
commit f8fc600e3f
3 changed files with 11 additions and 18 deletions
@@ -16,13 +16,11 @@
package com.intellij.util.ui;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.SystemInfo;
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.JBScrollPane;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
@@ -166,7 +164,7 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
};
myNSScrollerListener = new NSScrollerHelper.ScrollbarStyleListener() {
@Override
public void styleChanged(@NotNull NSScrollerHelper.Style newStyle) {
public void styleChanged() {
updateMacScrollbarStyle();
}
};
@@ -177,11 +175,7 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
}
private void updateMacScrollbarStyle() {
if (!SystemInfo.isMac) return;
NSScrollerHelper.Style style = UIUtil.isUnderNativeMacLookAndFeel() && !Registry.is("ui.no.mac.scrollbar")
? NSScrollerHelper.getScrollerStyle()
: null;
NSScrollerHelper.Style style = NSScrollerHelper.getScrollerStyle();
if (style != myMacScrollerStyle && scrollbar != null) {
myMacScrollerStyle = style;
@@ -193,7 +187,7 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
if (pane != null) pane.revalidate();
}
}
public boolean alwaysShowTrack() {
return !isMacOverlayScrollbar();
}
@@ -21,6 +21,7 @@ import com.intellij.ui.mac.foundation.ID;
import com.sun.jna.Callback;
import com.sun.jna.Pointer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.event.EventListenerList;
import java.util.EventListener;
@@ -31,11 +32,10 @@ class NSScrollerHelper {
private static final Callback CALLBACK = new Callback() {
@SuppressWarnings("UnusedDeclaration")
public void callback(ID self, Pointer selector, ID event) {
final Style style = getScrollerStyle();
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
fireStyleChanged(style);
fireStyleChanged();
}
});
}
@@ -75,9 +75,9 @@ class NSScrollerHelper {
}
}
@NotNull
@Nullable
public static Style getScrollerStyle() {
if (!SystemInfo.isMac) return Style.Legacy;
if (!SystemInfo.isMac) return null;
Foundation.NSAutoreleasePool pool = new Foundation.NSAutoreleasePool();
try {
@@ -101,16 +101,16 @@ class NSScrollerHelper {
ourListeners.remove(ScrollbarStyleListener.class, listener);
}
private static void fireStyleChanged(@NotNull Style style) {
private static void fireStyleChanged() {
Object[] listeners = ourListeners.getListenerList();
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == ScrollbarStyleListener.class) {
((ScrollbarStyleListener)listeners[i + 1]).styleChanged(style);
((ScrollbarStyleListener)listeners[i + 1]).styleChanged();
}
}
}
public interface ScrollbarStyleListener extends EventListener {
void styleChanged(@NotNull Style newStyle);
void styleChanged();
}
}
@@ -378,5 +378,4 @@ dsm.retina.darcula.legend.description=Experimental DSM legend component
ide.scratch.enabled=false
editor.injected.highlighting.enabled=true
editor.injected.highlighting.enabled.description=Disables injected fragments highlighting (requires project reopening)
ui.no.mac.scrollbar=false
editor.injected.highlighting.enabled.description=Disables injected fragments highlighting (requires project reopening)