mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IJPL-199920 Parameter info popup: allow customizing parameter info popup signature and parameters colors and transparency.
(cherry picked from commit bb92cc6cb3b4eb5a73aef9dce61d9cdb35066823) IJ-CR-182404 GitOrigin-RevId: e23c9e0679dd021b0d5ad9148958203b2af34dfd
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5e937826db
commit
115fba8cd6
@@ -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
|
||||
|
||||
+23
-8
@@ -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 = "<span style=\"color:#${ColorUtil.toHex(textAttributes.foregroundColor)};\">$separator</span>"
|
||||
val parameters = parametersPresentation
|
||||
@@ -75,7 +89,8 @@ internal fun renderSignaturePresentationToHtml(
|
||||
}
|
||||
else if (!isUnitTestMode) {
|
||||
"<code>$it</code>"
|
||||
} else it
|
||||
}
|
||||
else it
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user