Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the new window decoration parameter experimental #1561

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,36 +83,14 @@ fun Dialog(
content = content
)

@Deprecated(
level = DeprecationLevel.WARNING,
message = "Replaced by an overload that takes a decoration argument",
replaceWith = ReplaceWith("DialogWindow(" +
"onCloseRequest," +
"state," +
"visible," +
"title," +
"icon," +
"if (undecorated) WindowDecoration.Undecorated() else WindowDecoration.SystemDefault," +
"transparent," +
"resizable," +
"enabled," +
"focusable," +
"alwaysOnTop," +
"onPreviewKeyEvent," +
"onKeyEvent," +
"content" +
")",
"androidx.compose.ui.window.WindowDecoration"
)
)
@Composable
fun DialogWindow(
onCloseRequest: () -> Unit,
state: DialogState = rememberDialogState(),
visible: Boolean = true,
title: String = "Untitled",
icon: Painter? = null,
undecorated: Boolean,
undecorated: Boolean = false,
transparent: Boolean = false,
resizable: Boolean = true,
enabled: Boolean = true,
Expand Down Expand Up @@ -197,36 +175,14 @@ fun DialogWindow(
* If you return false, the key event will be sent to this [onKeyEvent]'s parent.
* @param content content of the dialog
*/
@Deprecated(
level = DeprecationLevel.WARNING,
message = "Replaced by an overload that takes a decoration argument",
replaceWith = ReplaceWith("DialogWindow(" +
"onCloseRequest," +
"state," +
"visible," +
"title," +
"icon," +
"if (undecorated) WindowDecoration.Undecorated() else WindowDecoration.SystemDefault," +
"transparent," +
"resizable," +
"enabled," +
"focusable," +
"alwaysOnTop," +
"onPreviewKeyEvent," +
"onKeyEvent," +
"content" +
")",
"androidx.compose.ui.window.WindowDecoration"
)
)
@Composable
fun DialogWindow(
onCloseRequest: () -> Unit,
state: DialogState = rememberDialogState(),
visible: Boolean = true,
title: String = "Untitled",
icon: Painter? = null,
undecorated: Boolean,
undecorated: Boolean = false,
transparent: Boolean = false,
resizable: Boolean = true,
enabled: Boolean = true,
Expand Down Expand Up @@ -312,14 +268,15 @@ fun DialogWindow(
* If you return false, the key event will be sent to this [onKeyEvent]'s parent.
* @param content content of the dialog
*/
@ExperimentalComposeUiApi
@Composable
fun DialogWindow(
onCloseRequest: () -> Unit,
state: DialogState = rememberDialogState(),
visible: Boolean = true,
title: String = "Untitled",
icon: Painter? = null,
decoration: WindowDecoration = WindowDecoration.SystemDefault,
decoration: WindowDecoration,
transparent: Boolean = false,
resizable: Boolean = true,
enabled: Boolean = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ import javax.swing.JMenuBar
* will be visible;
* - native resources will not be released. They will be released only when [Window]
* will leave the composition.
* @param title Title in the titlebar of the window
* @param icon Icon in the titlebar of the window (for platforms which support this).
* On macOs individual windows can't have a separate icon. To change the icon in the Dock,
* @param title Title in the title bar of the window
* @param icon Icon in the title bar of the window (for platforms which support this).
* On macOS individual windows can't have a separate icon. To change the icon in the Dock,
* set it via `iconFile` in build.gradle
* (https://github.com/JetBrains/compose-jb/tree/master/tutorials/Native_distributions_and_local_execution#platform-specific-options)
* @param decoration Specifies the decoration for this window.
Expand All @@ -118,14 +118,15 @@ import javax.swing.JMenuBar
* If you return false, the key event will be sent to this [onKeyEvent]'s parent.
* @param content Content of the window
*/
@ExperimentalComposeUiApi
@Composable
fun Window(
onCloseRequest: () -> Unit,
state: WindowState = rememberWindowState(),
visible: Boolean = true,
title: String = "Untitled",
icon: Painter? = null,
decoration: WindowDecoration = WindowDecoration.SystemDefault,
decoration: WindowDecoration,
transparent: Boolean = false,
resizable: Boolean = true,
enabled: Boolean = true,
Expand Down Expand Up @@ -305,9 +306,9 @@ fun Window(
* will be visible;
* - native resources will not be released. They will be released only when [Window]
* will leave the composition.
* @param title Title in the titlebar of the window
* @param icon Icon in the titlebar of the window (for platforms which support this).
* On macOs individual windows can't have a separate icon. To change the icon in the Dock,
* @param title Title in the title bar of the window
* @param icon Icon in the title bar of the window (for platforms which support this).
* On macOS individual windows can't have a separate icon. To change the icon in the Dock,
* set it via `iconFile` in build.gradle
* (https://github.com/JetBrains/compose-jb/tree/master/tutorials/Native_distributions_and_local_execution#platform-specific-options)
* @param undecorated Disables or enables decorations for this window.
Expand All @@ -328,36 +329,14 @@ fun Window(
* If you return false, the key event will be sent to this [onKeyEvent]'s parent.
* @param content Content of the window
*/
@Deprecated(
level = DeprecationLevel.WARNING,
message = "Replaced by an overload that takes a decoration argument",
replaceWith = ReplaceWith("Window(" +
"onCloseRequest," +
"state," +
"visible," +
"title," +
"icon," +
"if (undecorated) WindowDecoration.Undecorated() else WindowDecoration.SystemDefault," +
"transparent," +
"resizable," +
"enabled," +
"focusable," +
"alwaysOnTop," +
"onPreviewKeyEvent," +
"onKeyEvent," +
"content" +
")",
"androidx.compose.ui.window.WindowDecoration"
)
)
@Composable
fun Window(
onCloseRequest: () -> Unit,
state: WindowState = rememberWindowState(),
visible: Boolean = true,
title: String = "Untitled",
icon: Painter? = null,
undecorated: Boolean,
undecorated: Boolean = false,
transparent: Boolean = false,
resizable: Boolean = true,
enabled: Boolean = true,
Expand Down Expand Up @@ -414,9 +393,9 @@ fun Window(
* will be visible;
* - native resources will not be released. They will be released only when [Window]
* will leave the composition.
* @param title Title in the titlebar of the window
* @param icon Icon in the titlebar of the window (for platforms which support this).
* On macOs individual windows can't have a separate icon. To change the icon in the Dock,
* @param title Title in the title bar of the window
* @param icon Icon in the title bar of the window (for platforms which support this).
* On macOS individual windows can't have a separate icon. To change the icon in the Dock,
* set it via `iconFile` in build.gradle
* (https://github.com/JetBrains/compose-jb/tree/master/tutorials/Native_distributions_and_local_execution#platform-specific-options)
* @param decoration Specifies the decoration for this window.
Expand All @@ -441,12 +420,13 @@ fun Window(
* (when the last window is closed, and all [LaunchedEffect]s are complete).
* @param content Content of the window
*/
@ExperimentalComposeUiApi
fun singleWindowApplication(
state: WindowState = WindowState(),
visible: Boolean = true,
title: String = "Untitled",
icon: Painter? = null,
decoration: WindowDecoration = WindowDecoration.SystemDefault,
decoration: WindowDecoration,
transparent: Boolean = false,
resizable: Boolean = true,
enabled: Boolean = true,
Expand Down Expand Up @@ -503,9 +483,9 @@ fun singleWindowApplication(
* will be visible;
* - native resources will not be released. They will be released only when [Window]
* will leave the composition.
* @param title Title in the titlebar of the window
* @param icon Icon in the titlebar of the window (for platforms which support this).
* On macOs individual windows can't have a separate icon. To change the icon in the Dock,
* @param title Title in the title bar of the window
* @param icon Icon in the title bar of the window (for platforms which support this).
* On macOS individual windows can't have a separate icon. To change the icon in the Dock,
* set it via `iconFile` in build.gradle
* (https://github.com/JetBrains/compose-jb/tree/master/tutorials/Native_distributions_and_local_execution#platform-specific-options)
* @param undecorated Disables or enables decorations for this window.
Expand All @@ -530,34 +510,12 @@ fun singleWindowApplication(
* (when the last window is closed, and all [LaunchedEffect]s are complete).
* @param content Content of the window
*/
@Deprecated(
level = DeprecationLevel.WARNING,
message = "Replaced by an overload that takes a decoration argument",
replaceWith = ReplaceWith("singleWindowApplication(" +
"state," +
"visible," +
"title," +
"icon," +
"if (undecorated) WindowDecoration.Undecorated() else WindowDecoration.SystemDefault," +
"transparent," +
"resizable," +
"enabled," +
"focusable," +
"alwaysOnTop," +
"onPreviewKeyEvent," +
"onKeyEvent," +
"content," +
"exitProcessOnExit" +
")",
"androidx.compose.ui.window.WindowDecoration"
)
)
fun singleWindowApplication(
state: WindowState = WindowState(),
visible: Boolean = true,
title: String = "Untitled",
icon: Painter? = null,
undecorated: Boolean,
undecorated: Boolean = false,
transparent: Boolean = false,
resizable: Boolean = true,
enabled: Boolean = true,
Expand Down Expand Up @@ -596,8 +554,8 @@ fun singleWindowApplication(
*
* The [update] block can be run multiple times (on the UI thread as well) due to recomposition,
* and it is the right place to set [ComposeWindow] properties depending on state.
* When state changes, the block will be reexecuted to set the new properties.
* Note the block will also be ran once right after the [create] block completes.
* When state changes, the block will be re-executed to set the new properties.
* Note the block will also be run once right after the [create] block completes.
*
* Window is needed for creating window's that still can't be created with
* the default Compose function [androidx.compose.ui.window.Window]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package androidx.compose.ui.window

import androidx.compose.runtime.Immutable
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.WindowDecoration.Companion.Undecorated
Expand All @@ -25,6 +26,7 @@ import androidx.compose.ui.window.WindowDecoration.SystemDefault
/**
* Defines the options for window decoration.
*/
@ExperimentalComposeUiApi
sealed interface WindowDecoration {

/**
Expand Down Expand Up @@ -61,6 +63,7 @@ internal class UndecoratedWindowDecoration(val resizerThickness: Dp): WindowDeco
/**
* Default values for window decoration.
*/
@ExperimentalComposeUiApi
object WindowDecorationDefaults {
/**
* The default thickness of the resizers in an undecorated window.
Expand Down