Skip to content

Commit

Permalink
Allow configuring the ComposePanel via JewelComposePanel APIs (#673)
Browse files Browse the repository at this point in the history
This way one can do things like setting up manual disposing, etc. The
change is binary-compatible as the default config is an empty block.
  • Loading branch information
rock3r authored Nov 6, 2024
1 parent c3416e6 commit 25e5fdb
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 26 deletions.
12 changes: 8 additions & 4 deletions ide-laf-bridge/api/ide-laf-bridge.api
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,14 @@ 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 JewelComposeNoThemePanel (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;)Ljavax/swing/JComponent;
public static synthetic fun JewelComposeNoThemePanel$default (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Ljavax/swing/JComponent;
public static final fun JewelComposePanel (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;)Ljavax/swing/JComponent;
public static synthetic fun JewelComposePanel$default (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Ljavax/swing/JComponent;
public static final fun JewelToolWindowComposePanel (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;)Ljavax/swing/JComponent;
public static synthetic fun JewelToolWindowComposePanel$default (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Ljavax/swing/JComponent;
public static final fun JewelToolWindowNoThemeComposePanel (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;)Ljavax/swing/JComponent;
public static synthetic fun JewelToolWindowNoThemeComposePanel$default (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Ljavax/swing/JComponent;
public static final fun getLocalComponent ()Landroidx/compose/runtime/ProvidableCompositionLocal;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,41 @@ import org.jetbrains.jewel.foundation.ExperimentalJewelApi
import org.jetbrains.jewel.foundation.InternalJewelApi

@Suppress("ktlint:standard:function-naming", "FunctionName") // Swing to Compose bridge API
public fun JewelComposePanel(content: @Composable () -> Unit): JComponent = createJewelComposePanel { jewelPanel ->
setContent {
SwingBridgeTheme {
CompositionLocalProvider(LocalComponent provides this@createJewelComposePanel) {
ComponentDataProviderBridge(jewelPanel, content = content)
public fun JewelComposePanel(config: ComposePanel.() -> Unit = {}, content: @Composable () -> Unit): JComponent =
createJewelComposePanel { jewelPanel ->
config()
setContent {
SwingBridgeTheme {
CompositionLocalProvider(LocalComponent provides this@createJewelComposePanel) {
ComponentDataProviderBridge(jewelPanel, content = content)
}
}
}
}
}

@InternalJewelApi
@Suppress("ktlint:standard:function-naming", "FunctionName") // Swing to Compose bridge API
public fun JewelToolWindowComposePanel(content: @Composable () -> Unit): JComponent =
createJewelComposePanel { jewelPanel ->
setContent {
Compose17IJSizeBugWorkaround {
SwingBridgeTheme {
CompositionLocalProvider(LocalComponent provides this@createJewelComposePanel) {
ComponentDataProviderBridge(jewelPanel, content = content)
}
public fun JewelToolWindowComposePanel(
config: ComposePanel.() -> Unit = {},
content: @Composable () -> Unit,
): JComponent = createJewelComposePanel { jewelPanel ->
config()
setContent {
Compose17IJSizeBugWorkaround {
SwingBridgeTheme {
CompositionLocalProvider(LocalComponent provides this@createJewelComposePanel) {
ComponentDataProviderBridge(jewelPanel, content = content)
}
}
}
}
}

@ExperimentalJewelApi
@Suppress("ktlint:standard:function-naming", "FunctionName") // Swing to Compose bridge API
public fun JewelComposeNoThemePanel(content: @Composable () -> Unit): JComponent =
public fun JewelComposeNoThemePanel(config: ComposePanel.() -> Unit = {}, content: @Composable () -> Unit): JComponent =
createJewelComposePanel { jewelPanel ->
config()
setContent {
CompositionLocalProvider(LocalComponent provides this@createJewelComposePanel) {
ComponentDataProviderBridge(jewelPanel, content = content)
Expand All @@ -60,16 +66,19 @@ public fun JewelComposeNoThemePanel(content: @Composable () -> Unit): JComponent

@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)
}
public fun JewelToolWindowNoThemeComposePanel(
config: ComposePanel.() -> Unit = {},
content: @Composable () -> Unit,
): JComponent = createJewelComposePanel { jewelPanel ->
config()
setContent {
Compose17IJSizeBugWorkaround {
CompositionLocalProvider(LocalComponent provides this@createJewelComposePanel) {
ComponentDataProviderBridge(jewelPanel, content = content)
}
}
}
}

private fun createJewelComposePanel(config: ComposePanel.(JewelComposePanel) -> Unit): JewelComposePanel {
val jewelPanel = JewelComposePanel()
Expand Down

0 comments on commit 25e5fdb

Please sign in to comment.