mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Remove old non-safe icon
GitOrigin-RevId: 6f02b7eeb7e2c8982921aa3a4037bae3df69aedf
This commit is contained in:
committed by
intellij-monorepo-bot
parent
31465da6e2
commit
faea4ac0f3
@@ -39,7 +39,8 @@ import com.intellij.ui.table.JBTable
|
||||
import com.intellij.util.ui.EditableModel
|
||||
import com.intellij.util.ui.JBInsets
|
||||
import com.intellij.util.ui.JBUI.Borders
|
||||
import com.intellij.util.ui.PaintIcon
|
||||
import com.intellij.util.ui.RegionPaintIcon
|
||||
import com.intellij.util.ui.RegionPainter
|
||||
import org.jetbrains.annotations.Nls
|
||||
import java.awt.*
|
||||
import javax.swing.*
|
||||
@@ -395,10 +396,19 @@ private class FileColorsTableModel(val manager: FileColorManagerImpl) : Abstract
|
||||
|
||||
// renderers
|
||||
|
||||
private class ColorPainter(val color: Color) : RegionPainter<Component?> {
|
||||
fun asIcon(): Icon = RegionPaintIcon(36, 12, this).withIconPreScaled(false)
|
||||
|
||||
override fun paint(g: Graphics2D, x: Int, y: Int, width: Int, height: Int, c: Component?) {
|
||||
g.color = color
|
||||
g.fillRect(x, y, width, height)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateColorRenderer(renderer: JLabel, selected: Boolean, background: Color?): JLabel {
|
||||
if (!selected) renderer.background = background
|
||||
renderer.horizontalTextPosition = SwingConstants.LEFT
|
||||
renderer.icon = background?.let { if (selected) PaintIcon(36, 12, it).withIconPreScaled(false) else null }
|
||||
renderer.icon = background?.let { if (selected) ColorPainter(it).asIcon() else null }
|
||||
return renderer
|
||||
}
|
||||
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.util.ui
|
||||
|
||||
import java.awt.Component
|
||||
import java.awt.Graphics
|
||||
import java.awt.Graphics2D
|
||||
import java.awt.Paint
|
||||
import javax.swing.border.Border
|
||||
import kotlin.math.ceil
|
||||
|
||||
open class PaintIcon(private val width: Int, private val height: Int, private val painter: RegionPainter<Component?>)
|
||||
: JBCachingScalableIcon<PaintIcon>() {
|
||||
|
||||
constructor(size: Int, painter: RegionPainter<Component?>) : this(size, size, painter)
|
||||
constructor(size: Int, paint: Paint) : this(size, size, paint)
|
||||
constructor(width: Int, height: Int, paint: Paint) : this(width, height, Painter(paint))
|
||||
constructor(icon: PaintIcon) : this(icon.width, icon.height, icon.painter) {
|
||||
isIconPreScaled = icon.isIconPreScaled
|
||||
border = icon.border
|
||||
}
|
||||
|
||||
var border: Border? = null
|
||||
|
||||
override fun copy() = PaintIcon(this)
|
||||
|
||||
override fun equals(other: Any?) = other === this
|
||||
override fun hashCode() = System.identityHashCode(this)
|
||||
|
||||
override fun getIconWidth() = ceil(scaleVal(width.toDouble())).toInt()
|
||||
override fun getIconHeight() = ceil(scaleVal(height.toDouble())).toInt()
|
||||
override fun paintIcon(component: Component, g: Graphics, x: Int, y: Int) {
|
||||
(g as? Graphics2D)?.let { painter.paint(it, x, y, iconWidth, iconHeight, component) }
|
||||
border?.paintBorder(component, g, x, y, iconWidth, iconHeight)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class Painter(private val paint: Paint) : RegionPainter<Component?> {
|
||||
override fun paint(g: Graphics2D, x: Int, y: Int, width: Int, height: Int, component: Component?) {
|
||||
g.paint = paint
|
||||
g.fillRect(x, y, width, height)
|
||||
}
|
||||
}
|
||||
+13
-6
@@ -1,22 +1,23 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.util.ui
|
||||
|
||||
import com.intellij.ui.scale.DerivedScaleType.PIX_SCALE
|
||||
import java.awt.Component
|
||||
import java.awt.Graphics
|
||||
import java.awt.Graphics2D
|
||||
import java.util.Objects
|
||||
import kotlin.math.ceil
|
||||
|
||||
class RegionIcon(
|
||||
class RegionPaintIcon(
|
||||
private val width: Int,
|
||||
private val height: Int,
|
||||
private val painter: RegionPainter<Component?>
|
||||
) : JBCachingScalableIcon<RegionIcon>() {
|
||||
) : JBCachingScalableIcon<RegionPaintIcon>() {
|
||||
|
||||
constructor(size: Int, painter: RegionPainter<Component?>) : this(size, size, painter)
|
||||
|
||||
override fun copy(): RegionIcon {
|
||||
val icon = RegionIcon(width, height, painter)
|
||||
override fun copy(): RegionPaintIcon {
|
||||
val icon = RegionPaintIcon(width, height, painter)
|
||||
icon.updateContextFrom(this)
|
||||
return icon
|
||||
}
|
||||
@@ -39,13 +40,19 @@ class RegionIcon(
|
||||
|
||||
override fun getIconHeight() = ceil(scaleVal(height.toDouble())).toInt()
|
||||
|
||||
private fun getPixWidth() = scaleVal(width.toDouble(), PIX_SCALE)
|
||||
|
||||
private fun getPixHeight() = scaleVal(height.toDouble(), PIX_SCALE)
|
||||
|
||||
override fun toString() = painter.toString()
|
||||
|
||||
override fun hashCode(): Int = Objects.hash(width, height, painter)
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other === this) return true
|
||||
val icon = other as? RegionIcon ?: return false
|
||||
return icon.width == width && icon.height == height && icon.painter == painter
|
||||
val icon = other as? RegionPaintIcon ?: return false
|
||||
return icon.getPixWidth() == getPixWidth() &&
|
||||
icon.getPixHeight() == getPixHeight() &&
|
||||
icon.painter == painter
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user