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

[Titlebar] Support Transparent Titlebar API. #3164

Open
Sanlorng opened this issue May 13, 2023 · 4 comments
Open

[Titlebar] Support Transparent Titlebar API. #3164

Sanlorng opened this issue May 13, 2023 · 4 comments
Labels
desktop enhancement New feature or request undecorated window Issue with `Window(undecorated = true)` window management

Comments

@Sanlorng
Copy link

Sanlorng commented May 13, 2023

Description: Would you consider supporting an interface for making a transparent title bar? The Undecorated parameter cannot be easily implemented into an effect similar to ExtendContentToTitleBar in UWP applications which has system default caption button, system default corner shape, system default hit test, system default shadow and system default border. And Jetbrains/jewel seems to only be able to achieve partial effects on JBR.

Proposal:

    val state = rememberWindowState(extendToTitleBar = true)
    val contentColor = LocalContentColor.current
    LaunchEffect(state, contentColor) {
        state.titleBarBackgroundColor = Color.Transparent  
        state.captionButtonInactiveBackgroundColor = Color.Transparent
        state.captionButtonForegroundColor = contentColor.copy(0.87f)
        state.captionButtonInactiveForegroundColor = contentColor.copy(0.38f)
    }

    Window(state = state) {
        Column {
             Row(
                 modifier =  Modifier
                     .fillMaxWidth()
                     .wrapContentWidth(aligment = Aligment.End)
                     .height(WindowInsets.TitleBar.asPaddingValues().calculatePaddingTop())
            ){
                 Button(modifier = Modifier.padding(end = WindowInsets.CaptionButtons.asPaddingValues().calculatePaddingEnd(LocalRTL.current))) {
                    Text(text = "Button in titleBar")
                }
            }
        }

    }
    

Expect Behaviour : App content extend to TitleBar,and button in titleBar can padding caption buttons and interactive. Window has a system default look and feel instead of Undecorated window

@igordmn
Copy link
Collaborator

igordmn commented May 15, 2023

Thanks for proposal!

We had multiple missing features regarding customizing titlebars on different OS'es.

In the future we will revisit them, and make a consistent API that works for all OS'es (with specific API for each OS probably).

Not sure yet, but it probably won't be a part of WindowState, because its purpose to hoist states that can be changed by an user (resizing/repositioning window). It will be as an parameter of Window (one of the options is to combine some existing parameters into one rich parameter).

@mahozad
Copy link
Contributor

mahozad commented Aug 19, 2023

Here is a solution for native shadows and animations for undecorated app in Windows:

@igordmn igordmn added the undecorated window Issue with `Window(undecorated = true)` label Oct 6, 2023
@wwalkingg
Copy link

I think it's sufficient to not display the TitleBar, but retain the shadow and the ability to resize.

@Sanlorng
Copy link
Author

Sanlorng commented Oct 8, 2023

I think it's sufficient to not display the TitleBar, but retain the shadow and the ability to resize.

I think CaptionButton is equally important for a desktop application. If developers need to draw their own CaptionButton, then the developer will have to write some wndProc-related code in order to support Windows 11 Snap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
desktop enhancement New feature or request undecorated window Issue with `Window(undecorated = true)` window management
Projects
None yet
Development

No branches or pull requests

4 participants