From 0ebf4efc4f8214d8885b352dd259e4cc2002fc57 Mon Sep 17 00:00:00 2001 From: Lamberto Basti Date: Tue, 19 Sep 2023 17:21:46 +0200 Subject: [PATCH] Refine 'addComposeTab' to include closeable option Introduced 'isCloseable' parameter in 'addComposeTab' function to enable flexibility in controlling behavior of tabs. This option allows programmatically defining whether a tab can be closed or not. Default value set to false to maintain existing function calls. --- .../org/jetbrains/jewel/bridge/ComposePanel.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/ComposePanel.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/ComposePanel.kt index af0764830..72646a406 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/ComposePanel.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/ComposePanel.kt @@ -7,7 +7,13 @@ import com.intellij.openapi.wm.ToolWindow fun ToolWindow.addComposeTab( tabDisplayName: String, isLockable: Boolean = true, + isCloseable: Boolean = false, content: @Composable () -> Unit, -) = ComposePanel() - .apply { setContent(content) } - .also { contentManager.addContent(contentManager.factory.createContent(it, tabDisplayName, isLockable)) } +) { + System.setProperty("compose.swing.render.on.graphics", "true") + val composePanel = ComposePanel() + composePanel.setContent(content) + val tabContent = contentManager.factory.createContent(composePanel, tabDisplayName, isLockable) + tabContent.isCloseable = isCloseable + contentManager.addContent(tabContent) +}