diff --git a/decorated-window/api/decorated-window.api b/decorated-window/api/decorated-window.api index d84dece450..5264dffd10 100644 --- a/decorated-window/api/decorated-window.api +++ b/decorated-window/api/decorated-window.api @@ -49,6 +49,13 @@ public abstract interface class com/jetbrains/WindowMove { public abstract fun startMovingTogetherWithMouse (Ljava/awt/Window;I)V } +public final class org/jetbrains/jewel/window/ComposableSingletons$TitleBarKt { + public static final field INSTANCE Lorg/jetbrains/jewel/window/ComposableSingletons$TitleBarKt; + public static field lambda-1 Lkotlin/jvm/functions/Function2; + public fun ()V + public final fun getLambda-1$decorated_window ()Lkotlin/jvm/functions/Function2; +} + public final class org/jetbrains/jewel/window/DecoratedWindowKt { public static final fun DecoratedWindow (Lkotlin/jvm/functions/Function0;Landroidx/compose/ui/window/WindowState;ZLjava/lang/String;Landroidx/compose/ui/graphics/painter/Painter;ZZZZLkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lorg/jetbrains/jewel/window/styling/DecoratedWindowStyle;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;III)V } diff --git a/decorated-window/src/main/kotlin/org/jetbrains/jewel/window/TitleBar.Windows.kt b/decorated-window/src/main/kotlin/org/jetbrains/jewel/window/TitleBar.Windows.kt index e342f36bae..a25acea21b 100644 --- a/decorated-window/src/main/kotlin/org/jetbrains/jewel/window/TitleBar.Windows.kt +++ b/decorated-window/src/main/kotlin/org/jetbrains/jewel/window/TitleBar.Windows.kt @@ -1,6 +1,8 @@ package org.jetbrains.jewel.window import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier @@ -27,7 +29,7 @@ internal fun DecoratedWindowScope.TitleBarOnWindows( val titleBar = remember { JBR.getWindowDecorations().createCustomTitleBar() } TitleBarImpl( - modifier = modifier.customTitleBarMouseEventHandler(titleBar), + modifier = modifier, gradientStartColor = gradientStartColor, style = style, applyTitleBar = { height, _ -> @@ -36,6 +38,7 @@ internal fun DecoratedWindowScope.TitleBarOnWindows( JBR.getWindowDecorations().setCustomTitleBar(window, titleBar) PaddingValues(start = titleBar.leftInset.dp, end = titleBar.rightInset.dp) }, + backgroundContent = { Spacer(modifier = modifier.fillMaxSize().customTitleBarMouseEventHandler(titleBar)) }, content = content, ) } diff --git a/decorated-window/src/main/kotlin/org/jetbrains/jewel/window/TitleBar.kt b/decorated-window/src/main/kotlin/org/jetbrains/jewel/window/TitleBar.kt index 8a84e264cb..41b60c305d 100644 --- a/decorated-window/src/main/kotlin/org/jetbrains/jewel/window/TitleBar.kt +++ b/decorated-window/src/main/kotlin/org/jetbrains/jewel/window/TitleBar.kt @@ -1,8 +1,10 @@ package org.jetbrains.jewel.window import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.runtime.Composable @@ -77,6 +79,7 @@ internal fun DecoratedWindowScope.TitleBarImpl( gradientStartColor: Color = Color.Unspecified, style: TitleBarStyle = JewelTheme.defaultTitleBarStyle, applyTitleBar: (Dp, DecoratedWindowState) -> PaddingValues, + backgroundContent: @Composable () -> Unit = {}, content: @Composable TitleBarScope.(DecoratedWindowState) -> Unit, ) { val titleBarInfo = LocalTitleBarInfo.current @@ -102,19 +105,7 @@ internal fun DecoratedWindowScope.TitleBarImpl( } } - Layout( - content = { - CompositionLocalProvider( - LocalContentColor provides style.colors.content, - LocalIconButtonStyle provides style.iconButtonStyle, - LocalDefaultDropdownStyle provides style.dropdownStyle, - ) { - OverrideDarkMode(background.isDark()) { - val scope = TitleBarScopeImpl(titleBarInfo.title, titleBarInfo.icon) - scope.content(state) - } - } - }, + Box( modifier = modifier .background(backgroundBrush) @@ -122,9 +113,26 @@ internal fun DecoratedWindowScope.TitleBarImpl( .layoutId(TITLE_BAR_LAYOUT_ID) .height(style.metrics.height) .onSizeChanged { with(density) { applyTitleBar(it.height.toDp(), state) } } - .fillMaxWidth(), - measurePolicy = rememberTitleBarMeasurePolicy(window, state, applyTitleBar), - ) + .fillMaxWidth() + ) { + backgroundContent() + Layout( + content = { + CompositionLocalProvider( + LocalContentColor provides style.colors.content, + LocalIconButtonStyle provides style.iconButtonStyle, + LocalDefaultDropdownStyle provides style.dropdownStyle, + ) { + OverrideDarkMode(background.isDark()) { + val scope = TitleBarScopeImpl(titleBarInfo.title, titleBarInfo.icon) + scope.content(state) + } + } + }, + modifier = modifier.fillMaxSize(), + measurePolicy = rememberTitleBarMeasurePolicy(window, state, applyTitleBar), + ) + } Spacer(Modifier.layoutId(TITLE_BAR_BORDER_LAYOUT_ID).height(1.dp).fillMaxWidth().background(style.colors.border)) }