Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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),
Expand All @@ -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)
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(),
Expand Down
Loading