mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
1. Propagate antialiasing settings to more Swing components
2. Use default aa contrast value or system value for non-mac platforms
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.ide.ui;
|
||||
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import sun.swing.SwingUtilities2;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -24,29 +25,31 @@ public enum AntialiasingType {
|
||||
GREYSCALE,
|
||||
OFF;
|
||||
|
||||
private static final SwingUtilities2.AATextInfo aaEnabled =
|
||||
new SwingUtilities2.AATextInfo(RenderingHints.VALUE_TEXT_ANTIALIAS_ON, 140);
|
||||
|
||||
private static final SwingUtilities2.AATextInfo lcdEnabled =
|
||||
new SwingUtilities2.AATextInfo(RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB, 140);
|
||||
|
||||
private static final SwingUtilities2.AATextInfo aaDisabled = null;
|
||||
|
||||
private static SwingUtilities2.AATextInfo getLCDEnabledTextInfo () {
|
||||
return new SwingUtilities2.AATextInfo(RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB, UIUtil.getLcdContrastValue());
|
||||
}
|
||||
|
||||
private static SwingUtilities2.AATextInfo getAAEnabledTextInfo () {
|
||||
return new SwingUtilities2.AATextInfo(RenderingHints.VALUE_TEXT_ANTIALIAS_ON, UIUtil.getLcdContrastValue());
|
||||
}
|
||||
|
||||
public static Object getAAHintForSwingComponent() {
|
||||
UISettings uiSettings = UISettings.getInstance();
|
||||
|
||||
if (uiSettings == null) return aaEnabled;
|
||||
if (uiSettings == null) return getAAEnabledTextInfo();
|
||||
|
||||
switch (uiSettings.IDE_AA_TYPE) {
|
||||
case SUBPIXEL:
|
||||
return lcdEnabled;
|
||||
return getLCDEnabledTextInfo();
|
||||
case GREYSCALE:
|
||||
return aaEnabled;
|
||||
return getAAEnabledTextInfo();
|
||||
case OFF:
|
||||
return aaDisabled;
|
||||
}
|
||||
|
||||
return aaEnabled;
|
||||
return getAAEnabledTextInfo();
|
||||
}
|
||||
|
||||
public Object getRenderingHintValue () {
|
||||
|
||||
@@ -281,6 +281,9 @@ public class UISettings extends SimpleModificationTracker implements PersistentS
|
||||
*/
|
||||
public static void setupAntialiasing(final Graphics g) {
|
||||
|
||||
Graphics2D g2d = (Graphics2D)g;
|
||||
g2d.setRenderingHint(RenderingHints.KEY_TEXT_LCD_CONTRAST, UIUtil.getLcdContrastValue());
|
||||
|
||||
Application application = ApplicationManager.getApplication();
|
||||
if (application == null) {
|
||||
// We cannot use services while Aplication has not been loaded yet
|
||||
@@ -289,7 +292,6 @@ public class UISettings extends SimpleModificationTracker implements PersistentS
|
||||
return;
|
||||
}
|
||||
|
||||
Graphics2D g2d = (Graphics2D)g;
|
||||
UISettings uiSettings = getInstance();
|
||||
|
||||
if (uiSettings != null) {
|
||||
|
||||
@@ -468,7 +468,7 @@ public class LookupCellRenderer implements ListCellRenderer {
|
||||
|
||||
@Override
|
||||
protected void applyAdditionalHints(@NotNull Graphics2D g) {
|
||||
GraphicsUtil.setupAntialiasing(g);
|
||||
super.applyAdditionalHints(g);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,9 +15,11 @@
|
||||
*/
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.ide.ui.AntialiasingType;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import sun.swing.SwingUtilities2;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -33,6 +35,7 @@ public class ExpandedItemListCellRendererWrapper implements ListCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
list.putClientProperty(SwingUtilities2.AA_TEXT_PROPERTY_KEY, AntialiasingType.getAAHintForSwingComponent());
|
||||
Component result = myWrappee.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
if (!myHandler.getExpandedItems().contains(index)) return result;
|
||||
Rectangle bounds = result.getBounds();
|
||||
|
||||
@@ -733,7 +733,6 @@ public class SimpleColoredComponent extends JComponent implements Accessible, Co
|
||||
|
||||
final List<Object[]> searchMatches = new ArrayList<Object[]>();
|
||||
|
||||
UISettings.setupAntialiasing(g);
|
||||
applyAdditionalHints(g);
|
||||
final Font ownFont = getFont();
|
||||
if (ownFont != null) {
|
||||
@@ -915,6 +914,7 @@ public class SimpleColoredComponent extends JComponent implements Accessible, Co
|
||||
}
|
||||
|
||||
protected void applyAdditionalHints(@NotNull Graphics2D g) {
|
||||
UISettings.setupAntialiasing(g);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.ui.components.editors;
|
||||
|
||||
import com.intellij.ide.ui.AntialiasingType;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.ui.popup.JBPopupAdapter;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
@@ -31,6 +32,7 @@ import com.intellij.util.Function;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import sun.swing.SwingUtilities2;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.TableModelEvent;
|
||||
@@ -78,6 +80,7 @@ public class JBComboBoxTableCellEditorComponent extends JBLabel {
|
||||
} else {
|
||||
label.setIcon(getEmptyIcon());
|
||||
}
|
||||
label.putClientProperty(SwingUtilities2.AA_TEXT_PROPERTY_KEY, AntialiasingType.getAAHintForSwingComponent());
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
@@ -149,11 +149,6 @@ public class TabLabel extends JPanel {
|
||||
g.setClip(oldClip);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyAdditionalHints(@NotNull Graphics2D g) {
|
||||
UISettings.setupAntialiasing(g);
|
||||
}
|
||||
};
|
||||
label.setOpaque(false);
|
||||
label.setBorder(null);
|
||||
|
||||
@@ -175,6 +175,11 @@ public class AppearanceConfigurable extends BaseConfigurable implements Searchab
|
||||
|
||||
if (!myComponent.myAntialiasingInIDE.getSelectedItem().equals(settings.IDE_AA_TYPE)) {
|
||||
settings.IDE_AA_TYPE = (AntialiasingType)myComponent.myAntialiasingInIDE.getSelectedItem();
|
||||
for (Window w : Window.getWindows()) {
|
||||
for (JComponent c : UIUtil.uiTraverser(w).filter(JComponent.class)) {
|
||||
c.putClientProperty(SwingUtilities2.AA_TEXT_PROPERTY_KEY, AntialiasingType.getAAHintForSwingComponent());
|
||||
}
|
||||
}
|
||||
shouldUpdateUI = true;
|
||||
}
|
||||
|
||||
@@ -523,8 +528,10 @@ public class AppearanceConfigurable extends BaseConfigurable implements Searchab
|
||||
}
|
||||
|
||||
private static class AAListCellRenderer extends ListCellRendererWrapper<AntialiasingType> {
|
||||
private static final SwingUtilities2.AATextInfo SUBPIXEL_HINT = new SwingUtilities2.AATextInfo(RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB, 140);
|
||||
private static final SwingUtilities2.AATextInfo GREYSCALE_HINT = new SwingUtilities2.AATextInfo(RenderingHints.VALUE_TEXT_ANTIALIAS_ON, 140);
|
||||
private static final SwingUtilities2.AATextInfo SUBPIXEL_HINT = new SwingUtilities2.AATextInfo(
|
||||
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB, UIUtil.getLcdContrastValue());
|
||||
private static final SwingUtilities2.AATextInfo GREYSCALE_HINT = new SwingUtilities2.AATextInfo(
|
||||
RenderingHints.VALUE_TEXT_ANTIALIAS_ON, UIUtil.getLcdContrastValue());
|
||||
|
||||
@Override
|
||||
public void customize(JList list, AntialiasingType value, int index, boolean selected, boolean hasFocus) {
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.openapi.ui.impl;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.ide.IdeEventQueue;
|
||||
import com.intellij.ide.impl.TypeSafeDataProviderAdapter;
|
||||
import com.intellij.ide.ui.AntialiasingType;
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.Application;
|
||||
@@ -57,6 +58,7 @@ import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import sun.swing.SwingUtilities2;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -955,12 +957,15 @@ public class DialogWrapperPeerImpl extends DialogWrapperPeer implements FocusTra
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowOpened(WindowEvent e) {
|
||||
public void windowOpened(final WindowEvent e) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myOpened = true;
|
||||
final DialogWrapper activeWrapper = getActiveWrapper();
|
||||
for (JComponent c : UIUtil.uiTraverser(e.getWindow()).filter(JComponent.class)) {
|
||||
c.putClientProperty(SwingUtilities2.AA_TEXT_PROPERTY_KEY, AntialiasingType.getAAHintForSwingComponent());
|
||||
}
|
||||
if (activeWrapper == null) {
|
||||
myFocusedCallback.setRejected();
|
||||
myTypeAheadDone.setRejected();
|
||||
|
||||
@@ -3077,13 +3077,24 @@ public class UIUtil {
|
||||
|
||||
// Evaluate the value depending on our current theme
|
||||
if (lcdContrastValue == 0) {
|
||||
lcdContrastValue = UIUtil.isUnderDarcula() ? 100 : 250;
|
||||
if (SystemInfo.isMacIntel64) {
|
||||
lcdContrastValue = UIUtil.isUnderDarcula() ? 100 : 250;
|
||||
} else {
|
||||
Map map = (Map)Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints");
|
||||
|
||||
if (map == null) {
|
||||
lcdContrastValue = 140;
|
||||
} else {
|
||||
lcdContrastValue = ((Integer)map.get(RenderingHints.KEY_TEXT_LCD_CONTRAST));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lcdContrastValue < 100 || lcdContrastValue > 250) {
|
||||
// the default value
|
||||
lcdContrastValue = 140;
|
||||
}
|
||||
|
||||
return lcdContrastValue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user