diff --git a/platform/platform-impl/src/com/intellij/ide/ui/UITheme.java b/platform/platform-impl/src/com/intellij/ide/ui/UITheme.java index 7e4451d1e985..38d62f79bc94 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/UITheme.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/UITheme.java @@ -63,6 +63,7 @@ public class UITheme { private Map icons; private IconPathPatcher patcher; private Map background; + private Map emptyFrameBackground; private Map colors; private ClassLoader providerClassLoader = getClass().getClassLoader(); private String editorSchemeName; @@ -323,6 +324,10 @@ public class UITheme { return background; } + public Map getEmptyFrameBackground() { + return emptyFrameBackground; + } + public void applyProperties(UIDefaults defaults) { if (ui == null) return; @@ -600,10 +605,7 @@ public class UITheme { } } - // - //json deserialization methods - // - + // @SuppressWarnings("unused") private void setName(String name) { this.name = name; @@ -638,6 +640,10 @@ public class UITheme { this.background = background; } + public void setEmptyFrameBackground(Map emptyFrameBackground) { + this.emptyFrameBackground = emptyFrameBackground; + } + public Map getColors() { return colors; } @@ -645,4 +651,5 @@ public class UITheme { public void setColors(Map colors) { this.colors = colors; } + // } \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/UIThemeBasedLookAndFeelInfo.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/UIThemeBasedLookAndFeelInfo.java index d7d0639de51c..3bb69004973c 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/UIThemeBasedLookAndFeelInfo.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/UIThemeBasedLookAndFeelInfo.java @@ -99,10 +99,14 @@ public class UIThemeBasedLookAndFeelInfo extends UIManager.LookAndFeelInfo { } private void installBackgroundImage() { + installBackgroundImage(myTheme.getBackground(), IdeBackgroundUtil.EDITOR_PROP); + installBackgroundImage(myTheme.getEmptyFrameBackground(), IdeBackgroundUtil.FRAME_PROP); + } + + private void installBackgroundImage(Map backgroundProps, String bgImageProperty) { try { - Map background = myTheme.getBackground(); - if (background != null) { - Object path = background.get("image"); + if (backgroundProps != null) { + Object path = backgroundProps.get("image"); if (path instanceof String) { File tmpImage = FileUtil.createTempFile("ijBackgroundImage", path.toString().substring(((String)path).lastIndexOf(".")), true); URL resource = myTheme.getResource((String)path); @@ -114,16 +118,16 @@ public class UIThemeBasedLookAndFeelInfo extends UIManager.LookAndFeelInfo { } String image = tmpImage.getPath(); - Object transparency = background.get("transparency"); + Object transparency = backgroundProps.get("transparency"); String alpha = String.valueOf(transparency instanceof Integer ? (int)transparency : 15); - String fill = parseEnumValue(background.get("fill"), IdeBackgroundUtil.Fill.SCALE); - String anchor = parseEnumValue(background.get("anchor"), IdeBackgroundUtil.Anchor.CENTER); + String fill = parseEnumValue(backgroundProps.get("fill"), IdeBackgroundUtil.Fill.SCALE); + String anchor = parseEnumValue(backgroundProps.get("anchor"), IdeBackgroundUtil.Anchor.CENTER); String spec = StringUtil.join(new String[]{image, alpha, fill, anchor}, ","); - String currentSpec = PropertiesComponent.getInstance().getValue(IdeBackgroundUtil.EDITOR_PROP); - PropertiesComponent.getInstance().setValue("old." + IdeBackgroundUtil.EDITOR_PROP, currentSpec); + String currentSpec = PropertiesComponent.getInstance().getValue(bgImageProperty); + PropertiesComponent.getInstance().setValue("old." + bgImageProperty, currentSpec); - PropertiesComponent.getInstance().setValue(IdeBackgroundUtil.EDITOR_PROP, spec); + PropertiesComponent.getInstance().setValue(bgImageProperty, spec); IdeBackgroundUtil.repaintAllWindows(); } else { @@ -156,15 +160,20 @@ public class UIThemeBasedLookAndFeelInfo extends UIManager.LookAndFeelInfo { } SVGLoader.setColorPatcherProvider(null); + unsetBackgroundProperties(IdeBackgroundUtil.EDITOR_PROP); + unsetBackgroundProperties(IdeBackgroundUtil.FRAME_PROP); + } + + private void unsetBackgroundProperties(String backgroundPropertyKey) { PropertiesComponent propertyManager = PropertiesComponent.getInstance(); - String value = propertyManager.getValue("old." + IdeBackgroundUtil.EDITOR_PROP); - propertyManager.unsetValue("old." + IdeBackgroundUtil.EDITOR_PROP); + String value = propertyManager.getValue("old." + backgroundPropertyKey); + propertyManager.unsetValue("old." + backgroundPropertyKey); if (value == null) { if (myTheme.getBackground() != null) { - propertyManager.unsetValue(IdeBackgroundUtil.EDITOR_PROP); + propertyManager.unsetValue(backgroundPropertyKey); } } else { - propertyManager.setValue(IdeBackgroundUtil.EDITOR_PROP, value); + propertyManager.setValue(backgroundPropertyKey, value); } } } diff --git a/plugins/devkit/devkit-core/resources/schemes/theme.schema.json b/plugins/devkit/devkit-core/resources/schemes/theme.schema.json index 024e03ef91d9..08c7d51580ef 100644 --- a/plugins/devkit/devkit-core/resources/schemes/theme.schema.json +++ b/plugins/devkit/devkit-core/resources/schemes/theme.schema.json @@ -1,5 +1,5 @@ { - "version": "0.3", + "version": "0.4", "definitions": { "color": { "type": "string", @@ -10,6 +10,71 @@ "#123abc", "#123abc80" ] }, + "background": { + "type": "object", + "required": [ + "image" + ], + "title": "Background image", + "description": "Background image for entire window", + "properties": { + "image": { + "type": "string", + "title": "Path to the background image", + "description": "Path to the background image starting with '/'", + "default": "", + "examples": [ + "/background.jpg" + ] + }, + "transparency": { + "type": "integer", + "title": "Transparency for background image.", + "description": "An integer from 0 to 100.", + "default": 10, + "minimum": 0, + "maximum": 100, + "examples": [ + 10 + ] + }, + "fill": { + "type": "string", + "title": "Background image filling options", + "default": "scale", + "description": "Background image filling options. One of the following values: plain, scale, tile", + "enum": [ + "plain", + "scale", + "tile" + ], + "examples": [ + "scale" + ] + }, + "anchor": { + "type": "string", + "title": "Background image anchor", + "default": "center", + "description": "Background image anchor. One of the following values: top_left, top_center, top_right, middle_left, center, middle_right, bottom_left, bottom_center, bottom_right", + "enum": [ + "top_left", + "top_center", + "top_right", + "middle_left", + "center", + "middle_right", + "bottom_left", + "bottom_center", + "bottom_right" + ], + "examples": [ + "center" + ] + } + } + + }, "ColorPaletteBase": { "type": "object", "properties": { @@ -222,68 +287,10 @@ "type": "object" }, "background": { - "type": "object", - "required": [ - "image" - ], - "title": "Background image", - "description": "Background image for entire window", - "properties": { - "image": { - "type": "string", - "title": "Path to the background image", - "description": "Path to the background image starting with '/'", - "default": "", - "examples": [ - "/background.jpg" - ] - }, - "transparency": { - "type": "integer", - "title": "Transparency for background image.", - "description": "An integer from 0 to 100.", - "default": 10, - "minimum": 0, - "maximum": 100, - "examples": [ - 10 - ] - }, - "fill": { - "type": "string", - "title": "Background image filling options", - "default": "scale", - "description": "Background image filling options. One of the following values: plain, scale, tile", - "enum": [ - "plain", - "scale", - "tile" - ], - "examples": [ - "scale" - ] - }, - "anchor": { - "type": "string", - "title": "Background image anchor", - "default": "center", - "description": "Background image anchor. One of the following values: top_left, top_center, top_right, middle_left, center, middle_right, bottom_left, bottom_center, bottom_right", - "enum": [ - "top_left", - "top_center", - "top_right", - "middle_left", - "center", - "middle_right", - "bottom_left", - "bottom_center", - "bottom_right" - ], - "examples": [ - "center" - ] - } - } + "$ref": "#/definitions/background" + }, + "emptyFrameBackground": { + "$ref": "#/definitions/background" }, "icons": { "type": "object", diff --git a/plugins/devkit/devkit-core/src/themes/ApplyThemeAction.java b/plugins/devkit/devkit-core/src/themes/ApplyThemeAction.java index dbafc9f9f283..64419847e378 100644 --- a/plugins/devkit/devkit-core/src/themes/ApplyThemeAction.java +++ b/plugins/devkit/devkit-core/src/themes/ApplyThemeAction.java @@ -77,13 +77,9 @@ public class ApplyThemeAction extends DumbAwareAction { if (pathToScheme != null) { editorScheme = findThemeFile(json, project, pathToScheme); } - Map background = theme.getBackground(); - if (background != null) { - VirtualFile pathToBg = findThemeFile(json, project, background.get("image").toString()); - if (pathToBg != null) { - background.put("image", pathToBg.getPath()); - } - } + + patchBackgroundImagePath(json, project, theme.getBackground()); + patchBackgroundImagePath(json, project, theme.getEmptyFrameBackground()); LafManager.getInstance().setCurrentLookAndFeel(new TempUIThemeBasedLookAndFeelInfo(theme, editorScheme)); IconLoader.clearCache(); @@ -94,6 +90,15 @@ public class ApplyThemeAction extends DumbAwareAction { return false; } + private static void patchBackgroundImagePath(@NotNull VirtualFile json, Project project, Map background) { + if (background != null) { + VirtualFile pathToBg = findThemeFile(json, project, background.get("image").toString()); + if (pathToBg != null) { + background.put("image", pathToBg.getPath()); + } + } + } + @Nullable private static VirtualFile findThemeFile(@NotNull VirtualFile json, Project project, String pathToFile) { Module module = ModuleUtilCore.findModuleForFile(json, project);