From 03d521ff12c4747af43c75ae0807d33aa46ab003 Mon Sep 17 00:00:00 2001 From: Elior Date: Sun, 5 Oct 2025 21:09:32 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8feat:=20add=20scaling,=20antialiasing?= =?UTF-8?q?=20and=20inset=20fix=20for=20tabs=20and=20icons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../editorGroups/actions/GroupLinksCountAction.kt | 12 ++++++++---- .../tabs2/impl/rounded/RoundedTabPainter.kt | 4 ++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/krasa/editorGroups/actions/GroupLinksCountAction.kt b/src/main/java/krasa/editorGroups/actions/GroupLinksCountAction.kt index 39b204e..ff7fd54 100644 --- a/src/main/java/krasa/editorGroups/actions/GroupLinksCountAction.kt +++ b/src/main/java/krasa/editorGroups/actions/GroupLinksCountAction.kt @@ -4,6 +4,7 @@ import com.intellij.openapi.actionSystem.ActionUpdateThread import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.DumbAwareAction import com.intellij.ui.JBColor +import com.intellij.ui.scale.JBUIScale import com.intellij.util.ui.UIUtil import com.intellij.util.ui.UIUtil.drawCenteredString import krasa.editorGroups.EditorGroupManager @@ -23,6 +24,7 @@ class GroupLinksCountAction : DumbAwareAction() { val count = currentGroup.size(project) e.presentation.icon = CompositeIcon(count) + e.presentation.text = count.toString() } internal class CompositeIcon(private val counter: Int) : Icon { @@ -32,13 +34,15 @@ class GroupLinksCountAction : DumbAwareAction() { override fun paintIcon(c: Component?, g: Graphics, x: Int, y: Int) { val counterText = counter.toString() val g2d = g as Graphics2D + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON) + g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON) val fontSize = if (counter < 100) FONT_SIZE else SMALL_FONT_SIZE g2d.color = backgroundColor g2d.fillOval(x, y, ICON_SIZE, ICON_SIZE) g2d.color = UIUtil.getPanelBackground() - g2d.font = g2d.font.deriveFont(fontSize) + g2d.font = g2d.font.deriveFont(fontSize.toFloat()) drawCenteredString( g2d, Rectangle(x, y, ICON_SIZE, ICON_SIZE), @@ -52,8 +56,8 @@ class GroupLinksCountAction : DumbAwareAction() { } companion object { - private const val FONT_SIZE = 10.0f - private const val SMALL_FONT_SIZE = 8.0f - private const val ICON_SIZE = 16 + private val FONT_SIZE = JBUIScale.scale(10) + private val SMALL_FONT_SIZE = JBUIScale.scale(8) + private val ICON_SIZE = JBUIScale.scale(16) } } \ No newline at end of file diff --git a/src/main/java/krasa/editorGroups/tabs2/impl/rounded/RoundedTabPainter.kt b/src/main/java/krasa/editorGroups/tabs2/impl/rounded/RoundedTabPainter.kt index c35369c..5657fbe 100644 --- a/src/main/java/krasa/editorGroups/tabs2/impl/rounded/RoundedTabPainter.kt +++ b/src/main/java/krasa/editorGroups/tabs2/impl/rounded/RoundedTabPainter.kt @@ -1,6 +1,7 @@ package krasa.editorGroups.tabs2.impl.rounded import com.intellij.ui.ColorUtil +import com.intellij.util.ui.JBInsets import krasa.editorGroups.tabs2.EditorGroupsTabsPosition import krasa.editorGroups.tabs2.impl.painter.EditorGroupsTabPainter import krasa.editorGroups.tabs2.impl.themes.EditorGroupDefaultTabTheme @@ -105,6 +106,9 @@ internal open class RoundedTabPainter : EditorGroupsTabPainter { hovered: Boolean ) { val arc = theme.roundTabArc.toFloat() + // Remove insets from rect + JBInsets.removeFrom(rect, JBInsets.create(1, 1)) + val shape = RoundRectangle2D.Float( rect.x.toFloat(), rect.y.toFloat(),