mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-86322 Default font gets skewed when saving changes in IDE Settings --> Appearance
This commit is contained in:
@@ -30,7 +30,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Dictionary;
|
||||
@@ -318,7 +317,6 @@ public class AppearanceConfigurable extends BaseConfigurable implements Searchab
|
||||
private JLabel myFontNameLabel;
|
||||
private JPanel myTransparencyPanel;
|
||||
private JCheckBox myOverrideLAFFonts;
|
||||
private JLabel myIDEALafFont;
|
||||
|
||||
private JCheckBox myHideIconsInQuickNavigation;
|
||||
private JCheckBox myCbDisplayIconsInMenu;
|
||||
@@ -328,24 +326,15 @@ public class AppearanceConfigurable extends BaseConfigurable implements Searchab
|
||||
private JCheckBox myAllowMergeButtons;
|
||||
|
||||
public MyComponent() {
|
||||
ActionListener updater = new ActionListener() {
|
||||
myOverrideLAFFonts.addActionListener( new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
updateCombo();
|
||||
}
|
||||
};
|
||||
myLafComboBox.addActionListener(updater);
|
||||
myOverrideLAFFonts.addActionListener(updater);
|
||||
myIDEALafFont.setPreferredSize(new Dimension(myIDEALafFont.getPreferredSize().width, myOverrideLAFFonts.getPreferredSize().height));
|
||||
});
|
||||
}
|
||||
|
||||
public void updateCombo() {
|
||||
UIManager.LookAndFeelInfo selectedLAF = (UIManager.LookAndFeelInfo)myLafComboBox.getSelectedItem();
|
||||
//noinspection HardCodedStringLiteral
|
||||
boolean isIdeaLAFSelected = selectedLAF != null && selectedLAF.getName().startsWith("IDEA");
|
||||
|
||||
myIDEALafFont.setVisible(isIdeaLAFSelected);
|
||||
myOverrideLAFFonts.setVisible(!isIdeaLAFSelected);
|
||||
boolean enableChooser = isIdeaLAFSelected || myOverrideLAFFonts.isSelected();
|
||||
boolean enableChooser = myOverrideLAFFonts.isSelected();
|
||||
|
||||
myFontCombo.setEnabled(enableChooser);
|
||||
myFontSizeCombo.setEnabled(enableChooser);
|
||||
|
||||
@@ -134,7 +134,7 @@
|
||||
</hspacer>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="ce348" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="ce348" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
@@ -142,17 +142,9 @@
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="d0d45" class="javax.swing.JLabel" binding="myIDEALafFont">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/IdeBundle" key="label.override.laf.font"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="9a283" class="javax.swing.JCheckBox" binding="myOverrideLAFFonts">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/IdeBundle" key="checkbox.override.default.laf.fonts"/>
|
||||
|
||||
@@ -433,7 +433,7 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
|
||||
patchFileChooserStrings(uiDefaults);
|
||||
if (shouldPatchLAFFonts()) {
|
||||
storeOriginalFontDefaults(uiDefaults);
|
||||
initFontDefaults(uiDefaults);
|
||||
initFontDefaults(uiDefaults, myUiSettings.FONT_FACE, myUiSettings.FONT_SIZE);
|
||||
}
|
||||
else {
|
||||
restoreOriginalFontDefaults(uiDefaults);
|
||||
@@ -576,9 +576,8 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldPatchLAFFonts() {
|
||||
//noinspection HardCodedStringLiteral
|
||||
return getCurrentLookAndFeel().getName().startsWith("IDEA") || UISettings.getInstance().OVERRIDE_NONIDEA_LAF_FONTS;
|
||||
private static boolean shouldPatchLAFFonts() {
|
||||
return UISettings.getInstance().OVERRIDE_NONIDEA_LAF_FONTS;
|
||||
}
|
||||
|
||||
private static void updateUI(Window window){
|
||||
@@ -657,13 +656,11 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
|
||||
}
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
private void initFontDefaults(UIDefaults defaults) {
|
||||
private static void initFontDefaults(UIDefaults defaults, String fontFace, int fontSize) {
|
||||
defaults.put("Tree.ancestorInputMap", null);
|
||||
int uiFontSize = myUiSettings.FONT_SIZE;
|
||||
String uiFontFace = myUiSettings.FONT_FACE;
|
||||
FontUIResource uiFont = new FontUIResource(uiFontFace, Font.PLAIN, uiFontSize);
|
||||
FontUIResource textFont = new FontUIResource("Serif", Font.PLAIN, uiFontSize);
|
||||
FontUIResource monoFont = new FontUIResource("Monospaced", Font.PLAIN, uiFontSize);
|
||||
FontUIResource uiFont = new FontUIResource(fontFace, Font.PLAIN, fontSize);
|
||||
FontUIResource textFont = new FontUIResource("Serif", Font.PLAIN, fontSize);
|
||||
FontUIResource monoFont = new FontUIResource("Monospaced", Font.PLAIN, fontSize);
|
||||
|
||||
for (String fontResource : ourPatchableFontResources) {
|
||||
defaults.put(fontResource, uiFont);
|
||||
@@ -673,7 +670,6 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
|
||||
defaults.put("TextArea.font", monoFont);
|
||||
defaults.put("TextPane.font", textFont);
|
||||
defaults.put("EditorPane.font", textFont);
|
||||
defaults.put("TitledBorder.font", uiFont);
|
||||
}
|
||||
|
||||
|
||||
@@ -692,10 +688,11 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
|
||||
}
|
||||
|
||||
private static final class IdeaLaf extends MetalLookAndFeel{
|
||||
protected void initComponentDefaults(UIDefaults table) {
|
||||
super.initComponentDefaults(table);
|
||||
initInputMapDefaults(table);
|
||||
initIdeaDefaults(table);
|
||||
protected void initComponentDefaults(UIDefaults defaults) {
|
||||
super.initComponentDefaults(defaults);
|
||||
initInputMapDefaults(defaults);
|
||||
initIdeaDefaults(defaults);
|
||||
initFontDefaults(defaults, "Tahoma", 11);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
|
||||
Reference in New Issue
Block a user