fix(jetbrains): use standard diagram toolbar icons

This commit is contained in:
kirillk
2026-08-27 14:18:00 -04:00
parent 0ee530d85a
commit 4801e43127
2 changed files with 6 additions and 10 deletions
@@ -11,7 +11,6 @@ import ai.kilocode.client.ui.toolbarButton
import com.intellij.icons.AllIcons
import com.intellij.ui.components.JBLayeredPane
import com.intellij.ui.components.JBScrollPane
import com.intellij.util.IconUtil
import com.intellij.util.concurrency.annotations.RequiresEdt
import com.intellij.util.ui.JBUI
import java.awt.Color
@@ -43,7 +42,7 @@ internal class DiagramViewer(palette: Palette) : JBLayeredPane() {
}
private val copy = SessionCopyButton(
tooltip = KiloBundle.message("diagram.copy"),
icon = big(AllIcons.Actions.Copy),
icon = AllIcons.Actions.Copy,
image = { canvas.image() },
) { null }
// Built by chaining rather than `apply`, so these lambdas cannot bind to Stack's own fit().
@@ -177,12 +176,8 @@ internal class DiagramViewer(palette: Palette) : JBLayeredPane() {
private companion object {
const val STEP = 1.25
const val SIZE = 2f
fun control(icon: Icon, key: String, handler: () -> Unit) =
toolbarButton(ToolbarButtonAction(big(icon), KiloBundle.message(key), handler))
/** Overlay icons are drawn over the diagram, so they are sized up to stay readable. */
fun big(icon: Icon): Icon = IconUtil.scale(icon, null, SIZE)
toolbarButton(ToolbarButtonAction(icon, KiloBundle.message(key), handler))
}
}
@@ -177,14 +177,15 @@ class DiagramViewerTest : BasePlatformTestCase() {
)
}
fun `test overlay icons are twice the platform size and size their buttons`() = edtWait {
fun `test overlay icons keep the standard platform action size`() = edtWait {
val viewer = viewer(400, 300)
val zoom = buttons(viewer).first()
assertEquals(AllIcons.General.ZoomIn.iconWidth * 2, zoom.icon.iconWidth)
assertTrue("the hit target grows with the icon", zoom.preferredSize.width > zoom.icon.iconWidth)
assertEquals(AllIcons.General.ZoomIn.iconWidth, zoom.icon.iconWidth)
assertEquals(AllIcons.General.ZoomIn.iconHeight, zoom.icon.iconHeight)
assertTrue("icon-only controls stay square", zoom.preferredSize.width == zoom.preferredSize.height)
assertTrue("the hit target is larger than the glyph", zoom.preferredSize.width > zoom.icon.iconWidth)
}
fun `test copy puts the whole diagram on the clipboard as a picture`() = edtWait {