diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/Bridge.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/Bridge.kt index 89b18c1c3..7af0739f9 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/Bridge.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/Bridge.kt @@ -1,5 +1,3 @@ -@file:Suppress("UnstableApiUsage") - package org.jetbrains.jewel.bridge import com.intellij.ide.ui.LafManagerListener diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/BridgeIconMapper.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/BridgeIconMapper.kt index 0c3c245a5..9c85bef76 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/BridgeIconMapper.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/BridgeIconMapper.kt @@ -26,6 +26,7 @@ internal object BridgeIconMapper : IconMapper { return originalPath } + // TODO #116 replace with public API access once it's made available (IJP 233?) val clazz = Class.forName("com.intellij.ui.icons.CachedImageIconKt") val patchIconPath = clazz.getMethod("patchIconPath", String::class.java, ClassLoader::class.java) patchIconPath.isAccessible = true diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/BridgeUtils.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/BridgeUtils.kt index dea3644c5..08da43b78 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/BridgeUtils.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/BridgeUtils.kt @@ -144,6 +144,15 @@ suspend fun retrieveTextStyle( val JBValue.dp get() = unscaled.dp +internal operator fun TextUnit.minus(delta: Float) = plus(-delta) + +internal operator fun TextUnit.plus(delta: Float) = + when { + isSp -> TextUnit(value + delta, type) + isEm -> TextUnit(value + delta, type) + else -> this + } + fun retrieveStatefulIcon( iconPath: String, svgLoader: SvgLoader, diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/IntUiBridge.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/IntUiBridge.kt index 5ffe23d04..ff5e37ed4 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/IntUiBridge.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/IntUiBridge.kt @@ -85,6 +85,7 @@ import org.jetbrains.jewel.themes.intui.standalone.styling.IntUiTextAreaStyle import org.jetbrains.jewel.themes.intui.standalone.styling.IntUiTextFieldColors import org.jetbrains.jewel.themes.intui.standalone.styling.IntUiTextFieldMetrics import org.jetbrains.jewel.themes.intui.standalone.styling.IntUiTextFieldStyle +import org.jetbrains.skiko.DependsOnJBR import javax.swing.UIManager import kotlin.time.Duration.Companion.milliseconds @@ -93,6 +94,7 @@ private val logger = Logger.getInstance("JewelIntUiBridge") internal val uiDefaults get() = UIManager.getDefaults() +@OptIn(DependsOnJBR::class) internal suspend fun createBridgeIntUiDefinition(): IntUiThemeDefinition { val textStyle = retrieveTextStyle("Label.font", "Label.foreground") return createBridgeIntUiDefinition(textStyle) @@ -113,6 +115,7 @@ internal fun createBridgeIntUiDefinition(textStyle: TextStyle): IntUiThemeDefini ) } +@OptIn(DependsOnJBR::class) internal suspend fun createSwingIntUiComponentStyling( theme: IntUiThemeDefinition, svgLoader: SvgLoader, diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/UiThemeExtensions.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/UiThemeExtensions.kt index 44f60c996..61c0f4dc2 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/UiThemeExtensions.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/UiThemeExtensions.kt @@ -14,14 +14,17 @@ private val classUITheme internal fun currentUiThemeOrNull() = (LafManager.getInstance().currentLookAndFeel as? UIThemeBasedLookAndFeelInfo)?.theme +// TODO #116 replace with public API access once it's made available (IJP 233?) internal val UITheme.icons: Map get() = readMapField(classUITheme.getDeclaredField("icons")) .filterKeys { it != "ColorPalette" } +// TODO #116 replace with public API access once it's made available (IJP 233?) internal val UITheme.iconColorPalette: Map get() = readMapField>(classUITheme.getDeclaredField("icons")) .get("ColorPalette").orEmpty() +// TODO #116 replace with public API access once it's made available (IJP 233?) internal val UITheme.selectedIconColorPalette: Map get() = readMapField(classUITheme.getDeclaredField("iconColorsOnSelection"))