mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-06 06:21:16 +07:00
IDEA-301307 Toolbar customization: Added action icon looks disabled in Light theme
GitOrigin-RevId: 8e70059ec3eda8705737954ee9ca87914edebc8b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7eba801525
commit
8909ecc23b
+10
-2
@@ -5,6 +5,8 @@ import com.intellij.openapi.actionSystem.ActionButtonComponent
|
||||
import com.intellij.openapi.actionSystem.impl.IdeaActionButtonLook
|
||||
import com.intellij.openapi.util.IconLoader
|
||||
import com.intellij.openapi.util.ScalableIcon
|
||||
import com.intellij.ui.ColorUtil
|
||||
import com.intellij.ui.JBColor
|
||||
import com.intellij.util.ui.JBUI
|
||||
import com.intellij.util.ui.JBValue
|
||||
import java.awt.Color
|
||||
@@ -18,6 +20,9 @@ private val iconSize: Int
|
||||
get() = JBUI.scale(20)
|
||||
|
||||
class HeaderToolbarButtonLook : IdeaActionButtonLook() {
|
||||
|
||||
private val headerColor = JBColor.namedColor("MainToolbar.background")
|
||||
|
||||
override fun getStateBackground(component: JComponent, state: Int): Color = when (state) {
|
||||
ActionButtonComponent.NORMAL -> component.background
|
||||
ActionButtonComponent.PUSHED -> UIManager.getColor("MainToolbar.Icon.pressedBackground")
|
||||
@@ -30,15 +35,18 @@ class HeaderToolbarButtonLook : IdeaActionButtonLook() {
|
||||
override fun getButtonArc(): JBValue = JBValue.Float(0f)
|
||||
|
||||
override fun paintIcon(g: Graphics?, actionButton: ActionButtonComponent?, icon: Icon) {
|
||||
val scaledIcon = scaleIcon(icon, iconSize)
|
||||
val scaledIcon = scaleIcon(adjustColor(icon), iconSize)
|
||||
super.paintIcon(g, actionButton, scaledIcon)
|
||||
}
|
||||
|
||||
override fun paintIcon(g: Graphics?, actionButton: ActionButtonComponent?, icon: Icon, x: Int, y: Int) {
|
||||
val scaledIcon = scaleIcon(icon, iconSize)
|
||||
val scaledIcon = scaleIcon(adjustColor(icon), iconSize)
|
||||
super.paintIcon(g, actionButton, scaledIcon, x, y)
|
||||
}
|
||||
|
||||
private fun adjustColor(icon: Icon) =
|
||||
if (ColorUtil.isDark(headerColor)) IconLoader.getDarkIcon(icon, true) else icon
|
||||
|
||||
private fun scaleIcon(icon: Icon, size: Int) : Icon {
|
||||
if (icon is ScalableIcon && icon.iconWidth != size) {
|
||||
return IconLoader.loadCustomVersionOrScale(icon, size.toFloat());
|
||||
|
||||
Reference in New Issue
Block a user