mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
LLM-3705 Refactor RoundedLineBorder implementation
Moved RoundedLineBorder to a new file and renamed it to RoundedLineBorderWithBackground. Let's use this rounded border for In-Editor generation popup GitOrigin-RevId: b4365f7cefe24eca1e77d83c1f329e069788b226
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e36ee7c180
commit
c161c34677
+38
@@ -0,0 +1,38 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.ui.dsl.builder.components
|
||||
|
||||
import com.intellij.util.ui.JBUI
|
||||
import java.awt.*
|
||||
import javax.swing.border.LineBorder
|
||||
|
||||
class RoundedLineBorderWithBackground(
|
||||
color: Color,
|
||||
private val bgColor: Color,
|
||||
private val arcSize: Int = JBUI.scale(10),
|
||||
thickness: Int = JBUI.scale(1),
|
||||
) : LineBorder(color, thickness) {
|
||||
|
||||
override fun paintBorder(c: Component, g: Graphics, x: Int, y: Int, width: Int, height: Int) {
|
||||
val g2 = g as Graphics2D
|
||||
|
||||
val oldAntialiasing = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING)
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)
|
||||
val oldColor = g2.color
|
||||
|
||||
g2.color = bgColor
|
||||
g2.fillRoundRect(x + thickness - 1, y + thickness - 1,
|
||||
width - thickness - thickness + 1,
|
||||
height - thickness - thickness + 1,
|
||||
arcSize, arcSize)
|
||||
|
||||
g2.color = lineColor
|
||||
for (i in 0 until thickness) {
|
||||
g2.drawRoundRect(x + i, y + i, width - i - i - 1, height - i - i - 1, arcSize, arcSize)
|
||||
}
|
||||
|
||||
g2.color = oldColor
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAntialiasing)
|
||||
}
|
||||
|
||||
override fun getBorderInsets(c: Component, insets: Insets) = JBUI.emptyInsets()
|
||||
}
|
||||
+1
-36
@@ -12,50 +12,15 @@ import com.intellij.ui.dsl.builder.Cell
|
||||
import com.intellij.ui.dsl.builder.Row
|
||||
import com.intellij.ui.dsl.builder.bindText
|
||||
import com.intellij.ui.dsl.gridLayout.UnscaledGaps
|
||||
import com.intellij.util.ui.JBUI
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.annotations.Nls
|
||||
import java.awt.*
|
||||
import javax.swing.JPanel
|
||||
import javax.swing.border.LineBorder
|
||||
|
||||
@ApiStatus.Experimental
|
||||
enum class ValidationType {
|
||||
ERROR, WARNING
|
||||
}
|
||||
|
||||
private class RoundedLineBorder(color: Color,
|
||||
private val bgColor: Color,
|
||||
private val arcSize: Int = JBUI.scale(10),
|
||||
thickness: Int = JBUI.scale(1)) : LineBorder(color, thickness) {
|
||||
|
||||
override fun paintBorder(c: Component, g: Graphics, x: Int, y: Int, width: Int, height: Int) {
|
||||
val g2 = g as Graphics2D
|
||||
|
||||
val oldAntialiasing = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING)
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)
|
||||
val oldColor = g2.color
|
||||
|
||||
g2.color = bgColor
|
||||
g2.fillRoundRect(x + thickness - 1, y + thickness - 1,
|
||||
width - thickness - thickness + 1,
|
||||
height - thickness - thickness + 1,
|
||||
arcSize, arcSize)
|
||||
|
||||
g2.color = lineColor
|
||||
for (i in 0 until thickness) {
|
||||
g2.drawRoundRect(x + i, y + i, width - i - i - 1, height - i - i - 1, arcSize, arcSize)
|
||||
}
|
||||
|
||||
g2.color = oldColor
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAntialiasing)
|
||||
}
|
||||
|
||||
override fun getBorderInsets(c: Component, insets: Insets): Insets {
|
||||
return Insets(0, 0, 0, 0)
|
||||
}
|
||||
}
|
||||
|
||||
fun Row.validationTooltip(@Nls message: String,
|
||||
firstActionLink: ActionLink? = null,
|
||||
secondActionLink: ActionLink? = null,
|
||||
@@ -141,5 +106,5 @@ fun Row.validationTooltip(
|
||||
}
|
||||
})
|
||||
.customize(UnscaledGaps(top = 4, bottom = 4))
|
||||
.applyToComponent { border = RoundedLineBorder(borderColor, backgroundColor) }
|
||||
.applyToComponent { border = RoundedLineBorderWithBackground(borderColor, backgroundColor) }
|
||||
}
|
||||
Reference in New Issue
Block a user