mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
IJPL-186869 ui: better 'Branch' icon colors in Project Widget/Welcome Screen
GitOrigin-RevId: 702c1f0d1b592412bb5a5d0239d233b1861fcd24
This commit is contained in:
committed by
intellij-monorepo-bot
parent
fa73966ef4
commit
fae51d3f52
@@ -441,10 +441,12 @@ f:com.intellij.util.IconUtil
|
||||
- sf:brighter(javax.swing.Icon,I):javax.swing.Icon
|
||||
- sf:colorize(java.awt.Graphics2D,javax.swing.Icon,java.awt.Color):javax.swing.Icon
|
||||
- sf:colorize(java.awt.Graphics2D,javax.swing.Icon,java.awt.Color,Z):javax.swing.Icon
|
||||
- sf:colorize(java.awt.Graphics2D,javax.swing.Icon,java.awt.Color,Z,Z):javax.swing.Icon
|
||||
- sf:colorize(javax.swing.Icon,java.awt.Color):javax.swing.Icon
|
||||
- sf:colorize(javax.swing.Icon,java.awt.Color,Z):javax.swing.Icon
|
||||
- bs:colorize$default(java.awt.Graphics2D,javax.swing.Icon,java.awt.Color,Z,I,java.lang.Object):javax.swing.Icon
|
||||
- bs:colorize$default(javax.swing.Icon,java.awt.Color,Z,I,java.lang.Object):javax.swing.Icon
|
||||
- sf:colorize(javax.swing.Icon,java.awt.Color,Z,Z):javax.swing.Icon
|
||||
- bs:colorize$default(java.awt.Graphics2D,javax.swing.Icon,java.awt.Color,Z,Z,I,java.lang.Object):javax.swing.Icon
|
||||
- bs:colorize$default(javax.swing.Icon,java.awt.Color,Z,Z,I,java.lang.Object):javax.swing.Icon
|
||||
- sf:computeBaseFileIcon(com.intellij.openapi.vfs.VirtualFile):javax.swing.Icon
|
||||
- sf:computeFileIcon(com.intellij.openapi.vfs.VirtualFile,I,com.intellij.openapi.project.Project):javax.swing.Icon
|
||||
- sf:copy(javax.swing.Icon,java.awt.Component):javax.swing.Icon
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.intellij.ui.scale.ScaleType
|
||||
import com.intellij.ui.svg.paintIconWithSelection
|
||||
import com.intellij.util.IconUtil.ICON_FLAG_IGNORE_MASK
|
||||
import com.intellij.util.IconUtil.computeFileIcon
|
||||
import com.intellij.util.IconUtil.scale
|
||||
import com.intellij.util.ui.*
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.annotations.ApiStatus.Internal
|
||||
@@ -439,18 +440,23 @@ object IconUtil {
|
||||
return scaleByIcon(icon = icon, ancestor = ancestor, defaultIcon = defaultIcon) { it.iconWidth }
|
||||
}
|
||||
|
||||
/**
|
||||
* @param keepGray if false - the saturation is fully taken from [color]
|
||||
* @param keepBrightness if false - the brightness is fully taken from [color].
|
||||
* If left true - 'gray color + gray icon' will produce a nearly black resulting icon.
|
||||
*/
|
||||
@JvmOverloads
|
||||
@JvmStatic
|
||||
fun colorize(source: Icon, color: Color, keepGray: Boolean = false): Icon {
|
||||
fun colorize(source: Icon, color: Color, keepGray: Boolean = false, keepBrightness: Boolean = true): Icon {
|
||||
return filterIcon(icon = source, filterSupplier = object : RgbImageFilterSupplier {
|
||||
override fun getFilter() = ColorFilter(color = color, keepGray = keepGray)
|
||||
override fun getFilter() = ColorFilter(color = color, keepGray = keepGray, keepBrightness = keepBrightness)
|
||||
})
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
@JvmStatic
|
||||
fun colorize(g: Graphics2D?, source: Icon, color: Color, keepGray: Boolean = false): Icon {
|
||||
return filterIcon(g = g, source = source, filter = ColorFilter(color = color, keepGray = keepGray))
|
||||
fun colorize(g: Graphics2D?, source: Icon, color: Color, keepGray: Boolean = false, keepBrightness: Boolean = true): Icon {
|
||||
return filterIcon(g = g, source = source, filter = ColorFilter(color = color, keepGray = keepGray, keepBrightness = keepBrightness))
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@@ -650,7 +656,7 @@ class CropIcon internal constructor(val sourceIcon: Icon, val crop: Rectangle) :
|
||||
}
|
||||
|
||||
@Internal
|
||||
class ColorFilter(val color: Color, val keepGray: Boolean) : RGBImageFilter() {
|
||||
class ColorFilter(val color: Color, val keepGray: Boolean, val keepBrightness: Boolean) : RGBImageFilter() {
|
||||
private val base = Color.RGBtoHSB(color.red, color.green, color.blue, null)
|
||||
|
||||
override fun filterRGB(x: Int, y: Int, rgba: Int): Int {
|
||||
@@ -659,7 +665,9 @@ class ColorFilter(val color: Color, val keepGray: Boolean) : RGBImageFilter() {
|
||||
val b = rgba and 0xff
|
||||
val hsb = FloatArray(3)
|
||||
Color.RGBtoHSB(r, g, b, hsb)
|
||||
val rgb = Color.HSBtoRGB(base[0], base[1] * if (keepGray) hsb[1] else 1.0f, base[2] * hsb[2])
|
||||
val rgb = Color.HSBtoRGB(base[0],
|
||||
base[1] * if (keepGray) hsb[1] else 1.0f,
|
||||
base[2] * if (keepBrightness) hsb[2] else 1.0f)
|
||||
return rgba and -0x1000000 or (rgb and 0xffffff)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,7 +356,7 @@ private class ProjectWidgetRenderer : ListCellRenderer<PopupFactoryImpl.ActionIt
|
||||
label(it)
|
||||
.customize(rowGaps)
|
||||
.applyToComponent {
|
||||
icon = AllIcons.Vcs.Branch
|
||||
icon = IconUtil.colorize(AllIcons.Vcs.Branch, UIUtil.getLabelInfoForeground(), keepGray = false, keepBrightness = false)
|
||||
font = JBFont.smallOrNewUiMedium()
|
||||
foreground = UIUtil.getLabelInfoForeground()
|
||||
}.component
|
||||
|
||||
@@ -397,7 +397,7 @@ class RecentProjectFilteringTree(
|
||||
}
|
||||
private val projectBranchNameLabel = ComponentPanelBuilder.createNonWrappingCommentComponent("").apply {
|
||||
foreground = NamedColorUtil.getInactiveTextColor()
|
||||
icon = AllIcons.Vcs.Branch
|
||||
icon = IconUtil.colorize(AllIcons.Vcs.Branch, UIUtil.getInactiveTextColor(), keepGray = false, keepBrightness = false)
|
||||
}
|
||||
private val projectIconLabel = JLabel()
|
||||
private val projectActions = ActionsButton().apply {
|
||||
|
||||
Reference in New Issue
Block a user