Skip to content

Commit

Permalink
Support window border on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
devkanro committed Oct 12, 2023
1 parent c323889 commit 9f2c0f0
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ import javax.swing.JFrame
Stroke.Alignment.Inside,
style.metrics.borderWidth,
style.colors.borderFor(decoratedWindowState).value,
RectangleShape
RectangleShape,
).padding(style.metrics.borderWidth)
} else {
Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
Expand Down Expand Up @@ -49,8 +47,6 @@ import org.jetbrains.jewel.window.styling.TitleBarStyle
import org.jetbrains.jewel.window.utils.DesktopPlatform
import org.jetbrains.jewel.window.utils.macos.MacUtil
import java.awt.Window
import java.awt.event.WindowAdapter
import java.awt.event.WindowEvent
import kotlin.math.max

internal const val TITLE_BAR_COMPONENT_LAYOUT_ID_PREFIX = "__TITLE_BAR_"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ interface DecoratedWindowMetrics {

val LocalDecoratedWindowStyle = staticCompositionLocalOf<DecoratedWindowStyle> {
error("No DecoratedWindowStyle provided")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ fun IntUiThemeDefinition.withDecoratedWindow(lightHeaderInLight: Boolean = false

return withExtensions(
LocalDecoratedWindowStyle provides decoratedWindowStyle(),
LocalTitleBarStyle provides titleBarStyle(svgLoader, lightHeaderInLight)
LocalTitleBarStyle provides titleBarStyle(svgLoader, lightHeaderInLight),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.compose.runtime.Stable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import org.jetbrains.jewel.SvgLoader
import org.jetbrains.jewel.window.styling.DecoratedWindowColors
import org.jetbrains.jewel.window.styling.DecoratedWindowMetrics
import org.jetbrains.jewel.window.styling.DecoratedWindowStyle
Expand Down Expand Up @@ -48,7 +47,7 @@ import org.jetbrains.jewel.window.styling.DecoratedWindowStyle
inactiveBorderColor: Color = borderColor,
) = IntUiDecoratedWindowColors(
borderColor,
inactiveBorderColor
inactiveBorderColor,
)

@Composable fun dark(
Expand All @@ -57,11 +56,11 @@ import org.jetbrains.jewel.window.styling.DecoratedWindowStyle
inactiveBorderColor: Color = borderColor,
) = IntUiDecoratedWindowColors(
borderColor,
inactiveBorderColor
inactiveBorderColor,
)
}
}

@Stable data class IntUiDecoratedWindowMetrics(
override val borderWidth: Dp
override val borderWidth: Dp,
) : DecoratedWindowMetrics
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ fun main() {
val svgLoader by rememberSvgLoader()

DecoratedWindow(
onCloseRequest = { exitApplication() },
title = "Jewel component catalog",
icon = icon,
) {
onCloseRequest = { exitApplication() },
title = "Jewel component catalog",
icon = icon,
) {
val windowBackground = if (isDark) {
IntUiTheme.colorPalette.grey(1)
} else {
Expand Down

0 comments on commit 9f2c0f0

Please sign in to comment.