Skip to content

Commit

Permalink
Fix broken build, add comments tracking #116
Browse files Browse the repository at this point in the history
  • Loading branch information
rock3r committed Sep 19, 2023
1 parent 5a060a3 commit 3476af6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@file:Suppress("UnstableApiUsage")

package org.jetbrains.jewel.bridge

import com.intellij.ide.ui.LafManagerListener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <T : InteractiveComponentState> retrieveStatefulIcon(
iconPath: String,
svgLoader: SvgLoader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand All @@ -113,6 +115,7 @@ internal fun createBridgeIntUiDefinition(textStyle: TextStyle): IntUiThemeDefini
)
}

@OptIn(DependsOnJBR::class)
internal suspend fun createSwingIntUiComponentStyling(
theme: IntUiThemeDefinition,
svgLoader: SvgLoader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String>
get() = readMapField<String>(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<String, String>
get() = readMapField<Map<String, String>>(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<String, String>
get() = readMapField(classUITheme.getDeclaredField("iconColorsOnSelection"))

Expand Down

0 comments on commit 3476af6

Please sign in to comment.