mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ui: better "disabled foreground" default on GTK+
This commit is contained in:
@@ -243,7 +243,7 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
|
||||
@Override
|
||||
public void run() {
|
||||
fixGtkPopupStyle();
|
||||
patchOptionPaneIcons(UIManager.getLookAndFeelDefaults());
|
||||
patchGtkDefaults(UIManager.getLookAndFeelDefaults());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -535,7 +535,7 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
|
||||
|
||||
patchLafFonts(uiDefaults);
|
||||
|
||||
patchOptionPaneIcons(uiDefaults);
|
||||
patchGtkDefaults(uiDefaults);
|
||||
|
||||
fixSeparatorColor(uiDefaults);
|
||||
|
||||
@@ -695,13 +695,12 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
|
||||
}
|
||||
}
|
||||
|
||||
private static void patchOptionPaneIcons(UIDefaults defaults) {
|
||||
private static void patchGtkDefaults(UIDefaults defaults) {
|
||||
if (!UIUtil.isUnderGTKLookAndFeel()) return;
|
||||
|
||||
Map<String, Icon> map = ContainerUtil.newHashMap(
|
||||
Arrays.asList("OptionPane.errorIcon", "OptionPane.informationIcon", "OptionPane.warningIcon", "OptionPane.questionIcon"),
|
||||
Arrays.asList(AllIcons.General.ErrorDialog, AllIcons.General.InformationDialog, AllIcons.General.WarningDialog, AllIcons.General.QuestionDialog));
|
||||
|
||||
// GTK+ L&F keeps icons hidden in style
|
||||
SynthStyle style = SynthLookAndFeel.getStyle(new JOptionPane(""), Region.DESKTOP_ICON);
|
||||
for (String key : map.keySet()) {
|
||||
@@ -710,6 +709,12 @@ public final class LafManagerImpl extends LafManager implements ApplicationCompo
|
||||
Object icon = style == null ? null : style.get(null, key);
|
||||
defaults.put(key, icon instanceof Icon ? icon : map.get(key));
|
||||
}
|
||||
|
||||
Color fg = defaults.getColor("Label.foreground");
|
||||
Color bg = defaults.getColor("Label.background");
|
||||
if (fg != null && bg != null) {
|
||||
defaults.put("Label.disabledForeground", UIUtil.mix(fg, bg, 0.5));
|
||||
}
|
||||
}
|
||||
|
||||
private void patchLafFonts(UIDefaults uiDefaults) {
|
||||
|
||||
@@ -1248,6 +1248,7 @@ public class UIUtil {
|
||||
|
||||
public static Color shade(final Color c, final double factor, final double alphaFactor) {
|
||||
assert factor >= 0 : factor;
|
||||
//noinspection UseJBColor
|
||||
return new Color(
|
||||
Math.min((int)Math.round(c.getRed() * factor), 255),
|
||||
Math.min((int)Math.round(c.getGreen() * factor), 255),
|
||||
@@ -1259,6 +1260,7 @@ public class UIUtil {
|
||||
public static Color mix(final Color c1, final Color c2, final double factor) {
|
||||
assert 0 <= factor && factor <= 1.0 : factor;
|
||||
final double backFactor = 1.0 - factor;
|
||||
//noinspection UseJBColor
|
||||
return new Color(
|
||||
Math.min((int)Math.round(c1.getRed() * backFactor + c2.getRed() * factor), 255),
|
||||
Math.min((int)Math.round(c1.getGreen() * backFactor + c2.getGreen() * factor), 255),
|
||||
|
||||
Reference in New Issue
Block a user