Skip to content

Commit 223c99e

Browse files
authored
Merge pull request #100 from mallowigi/fixes
✨feat: add scaling, antialiasing and inset fix for tabs and icons
2 parents 5eb6c87 + 03d521f commit 223c99e

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

src/main/java/krasa/editorGroups/actions/GroupLinksCountAction.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import com.intellij.openapi.actionSystem.ActionUpdateThread
44
import com.intellij.openapi.actionSystem.AnActionEvent
55
import com.intellij.openapi.project.DumbAwareAction
66
import com.intellij.ui.JBColor
7+
import com.intellij.ui.scale.JBUIScale
78
import com.intellij.util.ui.UIUtil
89
import com.intellij.util.ui.UIUtil.drawCenteredString
910
import krasa.editorGroups.EditorGroupManager
@@ -23,6 +24,7 @@ class GroupLinksCountAction : DumbAwareAction() {
2324
val count = currentGroup.size(project)
2425

2526
e.presentation.icon = CompositeIcon(count)
27+
e.presentation.text = count.toString()
2628
}
2729

2830
internal class CompositeIcon(private val counter: Int) : Icon {
@@ -32,13 +34,15 @@ class GroupLinksCountAction : DumbAwareAction() {
3234
override fun paintIcon(c: Component?, g: Graphics, x: Int, y: Int) {
3335
val counterText = counter.toString()
3436
val g2d = g as Graphics2D
37+
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)
38+
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON)
3539
val fontSize = if (counter < 100) FONT_SIZE else SMALL_FONT_SIZE
3640

3741
g2d.color = backgroundColor
3842
g2d.fillOval(x, y, ICON_SIZE, ICON_SIZE)
3943

4044
g2d.color = UIUtil.getPanelBackground()
41-
g2d.font = g2d.font.deriveFont(fontSize)
45+
g2d.font = g2d.font.deriveFont(fontSize.toFloat())
4246
drawCenteredString(
4347
g2d,
4448
Rectangle(x, y, ICON_SIZE, ICON_SIZE),
@@ -52,8 +56,8 @@ class GroupLinksCountAction : DumbAwareAction() {
5256
}
5357

5458
companion object {
55-
private const val FONT_SIZE = 10.0f
56-
private const val SMALL_FONT_SIZE = 8.0f
57-
private const val ICON_SIZE = 16
59+
private val FONT_SIZE = JBUIScale.scale(10)
60+
private val SMALL_FONT_SIZE = JBUIScale.scale(8)
61+
private val ICON_SIZE = JBUIScale.scale(16)
5862
}
5963
}

src/main/java/krasa/editorGroups/tabs2/impl/rounded/RoundedTabPainter.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package krasa.editorGroups.tabs2.impl.rounded
22

33
import com.intellij.ui.ColorUtil
4+
import com.intellij.util.ui.JBInsets
45
import krasa.editorGroups.tabs2.EditorGroupsTabsPosition
56
import krasa.editorGroups.tabs2.impl.painter.EditorGroupsTabPainter
67
import krasa.editorGroups.tabs2.impl.themes.EditorGroupDefaultTabTheme
@@ -105,6 +106,9 @@ internal open class RoundedTabPainter : EditorGroupsTabPainter {
105106
hovered: Boolean
106107
) {
107108
val arc = theme.roundTabArc.toFloat()
109+
// Remove insets from rect
110+
JBInsets.removeFrom(rect, JBInsets.create(1, 1))
111+
108112
val shape = RoundRectangle2D.Float(
109113
rect.x.toFloat(),
110114
rect.y.toFloat(),

0 commit comments

Comments
 (0)