diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoComponent.java b/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoComponent.java index d253696a4e49..b60291cdb614 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoComponent.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoComponent.java @@ -185,7 +185,8 @@ public final class ParameterInfoComponent extends JPanel { ? ColorUtil.blendColorsInRgb(BACKGROUND, FOREGROUND, disabledSignatureAlpha(isDarkTheme)) : JBColor.namedColor("ParameterInfo.disabledForeground", new JBColor(0xA8A8A8, 0x777777)); HIGHLIGHTED_BACKGROUND = mySimpleDesignMode - ? ColorUtil.blendColorsInRgb(BACKGROUND, JBColor.GREEN, selectedSignatureAlpha(isDarkTheme)) + ? ColorUtil.blendColorsInRgb(BACKGROUND, getSelectedOverloadBackgroundBlendBase(), + selectedSignatureAlpha(isDarkTheme)) : JBColor.namedColor("ParameterInfo.currentOverloadBackground", BORDER_COLOR); HIGHLIGHTED_COLOR = mySimpleDesignMode ? FOREGROUND diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoControlPresentationUtil.kt b/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoControlPresentationUtil.kt index 082be63dfa47..f23b8d923548 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoControlPresentationUtil.kt +++ b/platform/lang-impl/src/com/intellij/codeInsight/hint/ParameterInfoControlPresentationUtil.kt @@ -16,17 +16,31 @@ import com.intellij.ui.ColorUtil import com.intellij.ui.JBColor import com.intellij.ui.scale.JBUIScale import com.intellij.util.applyIf -import com.intellij.util.ui.UIUtil import java.awt.Color +import javax.swing.UIManager internal fun disabledSignatureAlpha(isDarkTheme: Boolean) = - if (isDarkTheme) 0.5 else 0.75 + namedAlphaWithDefaults("ParameterInfo.mismatchedOverloadOpacity", if (isDarkTheme) 0.5 else 0.75) internal fun selectedSignatureAlpha(isDarkTheme: Boolean) = - if (isDarkTheme) 0.05 else 0.15 + namedAlphaWithDefaults("ParameterInfo.matchedOverloadBackgroundOpacity", if (isDarkTheme) 0.05 else 0.15) +internal fun mismatchedParameterAlpha(isDarkTheme: Boolean) = + namedAlphaWithDefaults("ParameterInfo.mismatchedParameterBackgroundOpacity", if (isDarkTheme) 0.05 else 0.2) + +internal fun defaultParameterAlpha(isDarkTheme: Boolean) = + namedAlphaWithDefaults("ParameterInfo.defaultValueOpacity", if (isDarkTheme) 0.5 else 0.75) + +internal fun deselectedParameterAlpha(isDarkTheme: Boolean) = + namedAlphaWithDefaults("ParameterInfo.notCurrentParameterOpacity", if (isDarkTheme) 0.6 else 0.9) + +internal val selectedOverloadBackgroundBlendBase = JBColor.namedColor("ParameterInfo.matchedOverloadBackgroundBase", JBColor.GREEN) +private val mismatchedParameterColor = JBColor.namedColor("ParameterInfo.mismatchedParameterBackgroundBase", JBColor.RED) private val isUnitTestMode = ApplicationManager.getApplication().isUnitTestMode +private fun namedAlphaWithDefaults(name: String, default: Double) = + (UIManager.get(name) as? Int)?.let { it / 100.0 }?.coerceIn(0.0, 1.0) ?: default + @NlsSafe internal fun renderSignaturePresentationToHtml( editor: Editor, @@ -38,10 +52,10 @@ internal fun renderSignaturePresentationToHtml( ): String { val backgroundColor = context.defaultParameterColor ?: JBColor.WHITE val isDarkTheme = ColorUtil.isDark(backgroundColor) - val deselectedParamAlpha = if (isDarkTheme) 0.6 else 0.9 - val defaultParamAlpha = if (isDarkTheme) 0.5 else 0.75 + val deselectedParamAlpha = deselectedParameterAlpha(isDarkTheme) + val defaultParamAlpha = defaultParameterAlpha(isDarkTheme) val disabledSignatureAlpha = disabledSignatureAlpha(isDarkTheme) - val mismatchedParameterAlpha = if (isDarkTheme) 0.05 else 0.2 + val mismatchedParameterAlpha = mismatchedParameterAlpha(isDarkTheme) val textAttributes = TextAttributes().apply { foregroundColor = EditorColorsManager.getInstance().getGlobalScheme().let { it.getAttributes(HighlighterColors.TEXT).foregroundColor @@ -50,7 +64,7 @@ internal fun renderSignaturePresentationToHtml( } val currentParameter = currentParameterIndex - val mismatchedParameterBgColor = "#${ColorUtil.toHex(ColorUtil.blendColorsInRgb(backgroundColor, JBColor.RED, mismatchedParameterAlpha))}" + val mismatchedParameterBgColor = "#${ColorUtil.toHex(ColorUtil.blendColorsInRgb(backgroundColor, mismatchedParameterColor, mismatchedParameterAlpha))}" val backgroundColorHex = "#${ColorUtil.toHex(backgroundColor)}" val separatorStr = "$separator" val parameters = parametersPresentation @@ -75,7 +89,8 @@ internal fun renderSignaturePresentationToHtml( } else if (!isUnitTestMode) { "$it" - } else it + } + else it } } diff --git a/platform/platform-resources/src/themes/metadata/IntelliJPlatform.themeMetadata.json b/platform/platform-resources/src/themes/metadata/IntelliJPlatform.themeMetadata.json index 94bb405bb35c..c6decb8bf7da 100644 --- a/platform/platform-resources/src/themes/metadata/IntelliJPlatform.themeMetadata.json +++ b/platform/platform-resources/src/themes/metadata/IntelliJPlatform.themeMetadata.json @@ -1251,6 +1251,34 @@ "key": "ParameterInfo.currentOverloadBackground", "description": "Selection background" }, + { + "key": "ParameterInfo.matchedOverloadBackgroundBase", + "description": "Matched overload background blend base. Default is green. Should match with ParameterInfo.mismatchedParameterBackgroundBase, which by default is red. The color is blended onto ParameterInfo.background using ParameterInfo.matchedOverloadBackgroundOpacity." + }, + { + "key": "ParameterInfo.matchedOverloadBackgroundOpacity", + "description": "Matched overload opacity percentage in range 0 - 100. It is used to control how much should ParameterInfo.currentOverloadBackgroundBase color blend with the ParameterInfo.background color." + }, + { + "key": "ParameterInfo.mismatchedParameterBackgroundBase", + "description": "Mismatched parameter background blend base. Default is red. Should match with ParameterInfo.matchedOverloadBackgroundBase, which by default is green. The color is blended onto ParameterInfo.background using ParameterInfo.mismatchedParameterBackgroundOpacity." + }, + { + "key": "ParameterInfo.mismatchedParameterBackgroundOpacity", + "description": "Mismatched parameter background opacity percentage in range 0 - 100. It is used to control how much should ParameterInfo.mismatchedParameterBackgroundBase color blend with the ParameterInfo.background color." + }, + { + "key": "ParameterInfo.mismatchedOverloadOpacity", + "description": "Opacity percentage in range 0 - 100. It is used to control how opaque should non-matching signature be." + }, + { + "key": "ParameterInfo.defaultValueOpacity", + "description": "Opacity percentage in range 0 - 100. It is used to control how opaque should parameter default values be." + }, + { + "key": "ParameterInfo.notCurrentParameterOpacity", + "description": "Opacity percentage in range 0 - 100. It is used to control how opaque should a not current parameter be. A current parameter is that under the cursor and it has 100% opacity." + }, { "key": "ParameterInfo.currentParameterForeground" },