diff --git a/int-ui/int-ui-decorated-window/src/main/kotlin/org/jetbrains/jewel/intui/window/IntUiTheme.kt b/int-ui/int-ui-decorated-window/src/main/kotlin/org/jetbrains/jewel/intui/window/IntUiTheme.kt index 5047969f8d..e9f7533588 100644 --- a/int-ui/int-ui-decorated-window/src/main/kotlin/org/jetbrains/jewel/intui/window/IntUiTheme.kt +++ b/int-ui/int-ui-decorated-window/src/main/kotlin/org/jetbrains/jewel/intui/window/IntUiTheme.kt @@ -1,10 +1,7 @@ package org.jetbrains.jewel.intui.window import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import org.jetbrains.jewel.SvgLoader import org.jetbrains.jewel.intui.core.IntUiThemeDefinition -import org.jetbrains.jewel.intui.standalone.rememberSvgLoader import org.jetbrains.jewel.intui.window.styling.IntUiDecoratedWindowStyle import org.jetbrains.jewel.intui.window.styling.IntUiTitleBarStyle import org.jetbrains.jewel.window.styling.DecoratedWindowStyle @@ -12,16 +9,6 @@ import org.jetbrains.jewel.window.styling.LocalDecoratedWindowStyle import org.jetbrains.jewel.window.styling.LocalTitleBarStyle import org.jetbrains.jewel.window.styling.TitleBarStyle -@Composable -fun IntUiThemeDefinition.titleBarStyle(svgLoader: SvgLoader, lightHeaderInLight: Boolean = false): TitleBarStyle = - if (isDark) { - IntUiTitleBarStyle.dark(svgLoader) - } else if (lightHeaderInLight) { - IntUiTitleBarStyle.lightWithLightHeader(svgLoader) - } else { - IntUiTitleBarStyle.light(svgLoader) - } - @Composable fun IntUiThemeDefinition.decoratedWindowStyle(): DecoratedWindowStyle = if (isDark) { @@ -31,11 +18,15 @@ fun IntUiThemeDefinition.decoratedWindowStyle(): DecoratedWindowStyle = } @Composable -fun IntUiThemeDefinition.withDecoratedWindow(lightHeaderInLight: Boolean = false): IntUiThemeDefinition { - val svgLoader by rememberSvgLoader(!lightHeaderInLight) - +fun IntUiThemeDefinition.withDecoratedWindow( + titleBarStyle: TitleBarStyle = if (isDark) { + IntUiTitleBarStyle.dark() + } else { + IntUiTitleBarStyle.light() + }, +): IntUiThemeDefinition { return withExtensions( LocalDecoratedWindowStyle provides decoratedWindowStyle(), - LocalTitleBarStyle provides titleBarStyle(svgLoader, lightHeaderInLight), + LocalTitleBarStyle provides titleBarStyle, ) } diff --git a/int-ui/int-ui-decorated-window/src/main/kotlin/org/jetbrains/jewel/intui/window/styling/IntUiTitleBarStyling.kt b/int-ui/int-ui-decorated-window/src/main/kotlin/org/jetbrains/jewel/intui/window/styling/IntUiTitleBarStyling.kt index 62502856f2..7ef35123cd 100644 --- a/int-ui/int-ui-decorated-window/src/main/kotlin/org/jetbrains/jewel/intui/window/styling/IntUiTitleBarStyling.kt +++ b/int-ui/int-ui-decorated-window/src/main/kotlin/org/jetbrains/jewel/intui/window/styling/IntUiTitleBarStyling.kt @@ -14,6 +14,7 @@ import org.jetbrains.jewel.LocalIconData import org.jetbrains.jewel.SvgLoader import org.jetbrains.jewel.intui.core.theme.IntUiDarkTheme import org.jetbrains.jewel.intui.core.theme.IntUiLightTheme +import org.jetbrains.jewel.intui.standalone.rememberSvgLoader import org.jetbrains.jewel.intui.standalone.styling.IntUiIconButtonColors import org.jetbrains.jewel.intui.standalone.styling.IntUiIconButtonMetrics import org.jetbrains.jewel.intui.standalone.styling.IntUiIconButtonStyle @@ -109,7 +110,7 @@ class IntUiTitleBarStyle( @Composable fun light( - svgLoader: SvgLoader, + svgLoader: SvgLoader = rememberSvgLoader(false).value, colors: IntUiTitleBarColors = IntUiTitleBarColors.light(), metrics: IntUiTitleBarMetrics = IntUiTitleBarMetrics(), icons: IntUiTitleBarIcons = intUiTitleBarIcons(svgLoader), @@ -117,7 +118,7 @@ class IntUiTitleBarStyle( @Composable fun lightWithLightHeader( - svgLoader: SvgLoader, + svgLoader: SvgLoader = rememberSvgLoader(false).value, colors: IntUiTitleBarColors = IntUiTitleBarColors.lightWithLightHeader(), metrics: IntUiTitleBarMetrics = IntUiTitleBarMetrics(), icons: IntUiTitleBarIcons = intUiTitleBarIcons(svgLoader), @@ -125,7 +126,7 @@ class IntUiTitleBarStyle( @Composable fun dark( - svgLoader: SvgLoader, + svgLoader: SvgLoader = rememberSvgLoader(true).value, colors: IntUiTitleBarColors = IntUiTitleBarColors.dark(), metrics: IntUiTitleBarMetrics = IntUiTitleBarMetrics(), icons: IntUiTitleBarIcons = intUiTitleBarIcons(svgLoader), diff --git a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/Main.kt b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/Main.kt index 50b214b8e6..10ebb4f7a4 100644 --- a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/Main.kt +++ b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/Main.kt @@ -42,6 +42,7 @@ import org.jetbrains.jewel.Tooltip import org.jetbrains.jewel.VerticalScrollbar import org.jetbrains.jewel.intui.standalone.IntUiTheme import org.jetbrains.jewel.intui.standalone.rememberSvgLoader +import org.jetbrains.jewel.intui.window.styling.IntUiTitleBarStyle import org.jetbrains.jewel.intui.window.withDecoratedWindow import org.jetbrains.jewel.samples.standalone.components.Borders import org.jetbrains.jewel.samples.standalone.components.Buttons @@ -67,9 +68,6 @@ import java.net.URI fun main() { val icon = svgResource("icons/jewel-logo.svg") application { - // 0 for light - // 1 for light with light header - // 2 for dark var intTheme by remember { mutableStateOf(IntUiThemes.Light) } var swingCompat by remember { mutableStateOf(false) } @@ -79,10 +77,19 @@ fun main() { Color(0xFFF5D4C1) } else { Color(0xFF654B40) - } + }, ) - IntUiTheme(theme.withDecoratedWindow(intTheme.isLightHeader()), swingCompat) { + IntUiTheme( + theme.withDecoratedWindow( + titleBarStyle = when (intTheme) { + IntUiThemes.Light -> IntUiTitleBarStyle.light() + IntUiThemes.LightWithLightHeader -> IntUiTitleBarStyle.lightWithLightHeader() + IntUiThemes.Dark -> IntUiTitleBarStyle.dark() + }, + ), + swingCompat, + ) { val resourceLoader = LocalResourceLoader.current val svgLoader by rememberSvgLoader()