Skip to content

Commit

Permalink
Improve outlines in bridge (#115)
Browse files Browse the repository at this point in the history
They were too thin — now that's better. Not 100% the same yet, but I
suspect it's mostly down to rounding.
  • Loading branch information
rock3r authored Sep 15, 2023
1 parent 0cdfaa1 commit c438a8e
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package org.jetbrains.jewel.bridge

import androidx.compose.runtime.Immutable
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.intellij.ide.ui.laf.darcula.DarculaUIUtil
import com.intellij.util.ui.UIUtil
import org.jetbrains.jewel.GlobalMetrics

@Immutable
Expand All @@ -28,8 +30,13 @@ internal class BridgeGlobalMetrics(

companion object {

fun readFromLaF() = BridgeGlobalMetrics(
outlineWidth = DarculaUIUtil.BW.dp,
)
fun readFromLaF(): BridgeGlobalMetrics {
// Copied from DarculaUIUtil.doPaint(java.awt.Graphics2D, int, int, float, float, boolean)
// except that scaling is all moved into the .dp operation below
val f = if (UIUtil.isRetina()) 0.5f else 1.0f
val lw = if (UIUtil.isUnderDefaultMacTheme()) f else DarculaUIUtil.LW.unscaled

return BridgeGlobalMetrics(outlineWidth = (DarculaUIUtil.BW.unscaled + lw).dp)
}
}
}

0 comments on commit c438a8e

Please sign in to comment.