diff --git a/platform/platform-impl/src/com/intellij/ide/ProjectWindowCustomizerService.kt b/platform/platform-impl/src/com/intellij/ide/ProjectWindowCustomizerService.kt index 4ca43995c142..07d6501ced9f 100644 --- a/platform/platform-impl/src/com/intellij/ide/ProjectWindowCustomizerService.kt +++ b/platform/platform-impl/src/com/intellij/ide/ProjectWindowCustomizerService.kt @@ -347,7 +347,7 @@ class ProjectWindowCustomizerService : Disposable { g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY) val color = getGradientProjectColor(project) - val length = Registry.intValue("ide.colorful.toolbar.gradient.length", 300) + val length = Registry.intValue("ide.colorful.toolbar.gradient.radius", 300) val projectComboBtn = ComponentUtil.findComponentsOfType(parent, ToolbarComboButton::class.java).find { ClientProperty.get(it, CustomComponentAction.ACTION_KEY) is ProjectToolbarWidgetAction } @@ -356,13 +356,18 @@ class ProjectWindowCustomizerService : Disposable { SwingUtilities.convertPoint(it.parent, it.x, it.y, parent).x.toFloat() + it.margin.left.toFloat() + projectIconWidth / 2 } ?: 150f - val mainToolbarXPosition = ComponentUtil.findComponentsOfType(parent, MainToolbar::class.java).firstOrNull()?.location?.x ?: 0 + + val mainToolbarXPosition = (ComponentUtil.findComponentsOfType(parent, MainToolbar::class.java).firstOrNull())?.let { + SwingUtilities.convertPoint(it.parent, it.location, parent) + }?.x ?: 0 + val saturation = Registry.doubleValue("ide.colorful.toolbar.gradient.saturation", 0.85).coerceIn(0.0, 1.0) + val blendedColor = ColorUtil.blendColorsInRgb(parent.background, color, saturation) val leftBound = (offset - length).coerceAtLeast(mainToolbarXPosition.toFloat() / 2) - g.paint = GradientPaint(leftBound, 0f, parent.background, offset, 0f, color) + g.paint = GradientPaint(leftBound, 0f, parent.background, offset, 0f, blendedColor) g.fillRect(0, 0, offset.toInt(), height) val rightBound = offset + length - g.paint = GradientPaint(offset, 0f, color, rightBound, 0f, parent.background) + g.paint = GradientPaint(offset, 0f, blendedColor, rightBound, 0f, parent.background) g.fillRect(offset.toInt(), 0, length, height) return true diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index 8bf7eda70c1c..4295034e60ac 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -2382,10 +2382,12 @@ ide.log.coroutine.pce.description=Log PCEs occurring in coroutines. \ ide.colorful.toolbar=true ide.colorful.toolbar.description=Enables gradient painting in main toolbar -ide.colorful.toolbar.gradient.length=600 +ide.colorful.toolbar.gradient.radius=300 ide.colorful.toolbar.gradient.type=[Just Icon|Linear Gradient and Icon|Circular Gradient and Icon*|Dropdown Background and Icon|Just Dropdown] ide.colorful.toolbar.gradient.type.description=Defines types of main toolbar decorations -ide.colorful.toolbar.gradient.length.description=Length of the gradient in Main Toolbar +ide.colorful.toolbar.gradient.radius.description=Radius of the gradient in Main Toolbar +ide.colorful.toolbar.gradient.saturation=0.85 +ide.colorful.toolbar.gradient.saturation.description=Saturation of the gradient color in Main Toolbar ide.colorful.toolbar.force=true ide.colorful.toolbar.force.description=Show 'Colorful toolbar' even if there is one project open (works only if the feature is enabled). \ Reopen project or restart IDE to apply the setting diff --git a/platform/util/src/com/intellij/openapi/util/registry/Registry.java b/platform/util/src/com/intellij/openapi/util/registry/Registry.java index aef3b13f3d07..7a2d0c3e9f7f 100644 --- a/platform/util/src/com/intellij/openapi/util/registry/Registry.java +++ b/platform/util/src/com/intellij/openapi/util/registry/Registry.java @@ -96,6 +96,20 @@ public final class Registry { isLoaded = false; } + public static double doubleValue(@NonNls @NotNull String key, double defaultValue) { + if (!LoadingState.COMPONENTS_LOADED.isOccurred()) { + LoadingState.COMPONENTS_REGISTERED.checkOccurred(); + return defaultValue; + } + + try { + return getInstance().doGet(key).asDouble(); + } + catch (MissingResourceException ignore) { + return defaultValue; + } + } + public static double doubleValue(@NonNls @NotNull String key) throws MissingResourceException { return get(key).asDouble(); }