From b74dcb29194acadb9103d4f66d628730aa068730 Mon Sep 17 00:00:00 2001 From: Sebastiano Poggi Date: Tue, 10 Sep 2024 00:06:19 +0200 Subject: [PATCH] Create NoTheme JewelComposePanel versions (#588) Useful for those cases where you want to have your own theme. --- ide-laf-bridge/api/ide-laf-bridge.api | 2 ++ .../jewel/bridge/JewelComposePanel.kt | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/ide-laf-bridge/api/ide-laf-bridge.api b/ide-laf-bridge/api/ide-laf-bridge.api index c1b87cc2d..322faea32 100644 --- a/ide-laf-bridge/api/ide-laf-bridge.api +++ b/ide-laf-bridge/api/ide-laf-bridge.api @@ -65,8 +65,10 @@ public final class org/jetbrains/jewel/bridge/JewelBridgeException$KeysNotFoundE } public final class org/jetbrains/jewel/bridge/JewelComposePanelKt { + public static final fun JewelComposeNoThemePanel (Lkotlin/jvm/functions/Function2;)Ljavax/swing/JComponent; public static final fun JewelComposePanel (Lkotlin/jvm/functions/Function2;)Ljavax/swing/JComponent; public static final fun JewelToolWindowComposePanel (Lkotlin/jvm/functions/Function2;)Ljavax/swing/JComponent; + public static final fun JewelToolWindowNoThemeComposePanel (Lkotlin/jvm/functions/Function2;)Ljavax/swing/JComponent; public static final fun getLocalComponent ()Landroidx/compose/runtime/ProvidableCompositionLocal; } diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/JewelComposePanel.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/JewelComposePanel.kt index c5694130a..b5d05c3c7 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/JewelComposePanel.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/JewelComposePanel.kt @@ -47,6 +47,30 @@ public fun JewelToolWindowComposePanel(content: @Composable () -> Unit): JCompon } } +@ExperimentalJewelApi +@Suppress("ktlint:standard:function-naming", "FunctionName") // Swing to Compose bridge API +public fun JewelComposeNoThemePanel(content: @Composable () -> Unit): JComponent = + createJewelComposePanel { jewelPanel -> + setContent { + CompositionLocalProvider(LocalComponent provides this@createJewelComposePanel) { + ComponentDataProviderBridge(jewelPanel, content = content) + } + } + } + +@ExperimentalJewelApi +@Suppress("ktlint:standard:function-naming", "FunctionName") // Swing to Compose bridge API +public fun JewelToolWindowNoThemeComposePanel(content: @Composable () -> Unit): JComponent = + createJewelComposePanel { jewelPanel -> + setContent { + Compose17IJSizeBugWorkaround { + CompositionLocalProvider(LocalComponent provides this@createJewelComposePanel) { + ComponentDataProviderBridge(jewelPanel, content = content) + } + } + } + } + private fun createJewelComposePanel(config: ComposePanel.(JewelComposePanel) -> Unit): JewelComposePanel { val jewelPanel = JewelComposePanel() jewelPanel.layout = BorderLayout()