From dc7e60442c6cfe4d79463295e1eab0ca0c5d4780 Mon Sep 17 00:00:00 2001 From: Sebastiano Poggi Date: Fri, 15 Sep 2023 17:30:27 +0200 Subject: [PATCH] Improve outlines in bridge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit They were too thin — now that's better. Not 100% the same yet, but I suspect it's mostly down to rounding. --- .../jetbrains/jewel/bridge/BridgeGlobalMetrics.kt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/BridgeGlobalMetrics.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/BridgeGlobalMetrics.kt index b5e5722d1..f4183eb44 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/BridgeGlobalMetrics.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/BridgeGlobalMetrics.kt @@ -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 @@ -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) + } } }