IDEA-322073 Project gradient: left side of circular gradient is too long

GitOrigin-RevId: e97df210fbb53c2e74f33ff2610f07b1d7814ec7
This commit is contained in:
Vera Petrenkova
2023-11-01 16:08:15 +00:00
committed by intellij-monorepo-bot
parent 2650b3103b
commit 378f251ba2
3 changed files with 27 additions and 6 deletions
@@ -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
@@ -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
@@ -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();
}