mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-68995 Can't see the mouse in the editor when the background color is black on a Mac
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 913 B |
@@ -68,6 +68,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.openapi.wm.IdeGlassPane;
|
||||
import com.intellij.ui.ColorUtil;
|
||||
import com.intellij.ui.GuiUtils;
|
||||
import com.intellij.ui.LightweightHint;
|
||||
import com.intellij.ui.components.JBScrollBar;
|
||||
@@ -81,6 +82,7 @@ import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import com.intellij.util.ui.ButtonlessScrollBarUI;
|
||||
import com.intellij.util.ui.MacUIUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.update.UiNotifyConnector;
|
||||
import gnu.trove.TIntArrayList;
|
||||
@@ -3533,7 +3535,8 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
return;
|
||||
}
|
||||
}
|
||||
myEditorComponent.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
|
||||
myEditorComponent.setCursor(SystemInfo.isMac && ColorUtil.isDark(getBackgroundColor()) ?
|
||||
MacUIUtil.INVERTED_TEXT_CURSOR : Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,4 +98,15 @@ public class ColorUtil {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether color is dark or not based on perceptional luminosity
|
||||
* http://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color
|
||||
* @param c color to check
|
||||
* @return dark or not
|
||||
*/
|
||||
public static boolean isDark(@NotNull final Color c) {
|
||||
// based on perceptional luminosity, see
|
||||
return (1 - (0.299 * c.getRed() + 0.587 * c.getGreen() + 0.114 * c.getBlue()) / 255) >= 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ public class MacUIUtil {
|
||||
|
||||
public static final boolean USE_QUARTZ = "true".equals(System.getProperty("apple.awt.graphics.UseQuartz"));
|
||||
public static final String MAC_FILL_BORDER = "MAC_FILL_BORDER";
|
||||
public static final Cursor INVERTED_TEXT_CURSOR = createInvertedTextCursor();
|
||||
|
||||
private MacUIUtil() {
|
||||
}
|
||||
@@ -250,4 +251,10 @@ public class MacUIUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Cursor createInvertedTextCursor() {
|
||||
final Toolkit toolkit = Toolkit.getDefaultToolkit();
|
||||
Image cursorImage = toolkit.createImage(MacUIUtil.class.getClassLoader().getResource("/mac/text.gif"));
|
||||
return toolkit.createCustomCursor(cursorImage, new Point(0, 0), "InvertedTextCursor");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user