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

feat(macos): title_bar_style and hidden_title window options, closes #2663 #3965

Merged
merged 10 commits into from
Sep 30, 2022

Conversation

probablykasper
Copy link
Member

@probablykasper probablykasper commented Apr 25, 2022

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Docs
  • New Binding issue #___
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change?

  • Yes, and the changes were approved in issue #___
  • No

Checklist

  • When resolving issues, they are referenced in the PR's title (e.g fix: remove a typo, closes #___, #___)
  • A change file is added if any packages will require a version bump due to this PR per the instructions in the readme.
  • I have added a convincing reason for adding this feature, if necessary

Other information

I assume this needs to wait for v2

@probablykasper probablykasper requested a review from a team April 25, 2022 19:44
@probablykasper probablykasper requested a review from a team as a code owner April 25, 2022 19:44
Copy link
Member

@amrbashir amrbashir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this needs to wait for v2

These APIs existed when tao was being audited so if it is really a high demand feature, we can maybe include it?

core/tauri-runtime-wry/src/lib.rs Outdated Show resolved Hide resolved
@probablykasper
Copy link
Member Author

These APIs existed when tao was being audited so if it is really a high demand feature, we can maybe include it?

It is the most upvoted issue, so it sure does have demand

@probablykasper probablykasper requested a review from a team April 26, 2022 06:57
@probablykasper probablykasper force-pushed the macos-transparent-titlebar branch from c38e2a5 to a67005d Compare April 26, 2022 17:06
@xuchaoqian
Copy link
Contributor

xuchaoqian commented May 1, 2022

These APIs existed when tao was being audited so if it is really a high demand feature, we can maybe include it?

Yes, it is really a high demand feature.
Lots of apps need to customize title bar. This is a very useful and basic feature for them.

@betamos
Copy link
Contributor

betamos commented Jun 24, 2022

I use this in my Tauri fork. I love it.

Screen Shot 2022-06-24 at 12 31 34 PM

Some thoughts on the feature itself:

  • It's much preferable to use real window chroming than faking it with browser markup, especially for MacOS:
    • Alt-button works and changes the meaning of buttons.
    • Hovering gives me menus of moving window to the side/different screen, etc.
    • Traffic lights tone out to gray when window is blurred.
    • Whenever the OS vendor changes their UI, the app won't look outdated.
  • Details matter. Just like how we want the Tauri website to look professional and modern, many designers, devs and users care about those same things. TL;DR: I think it's worth prioritizing.
  • Dragging the app can become less intuitive without title bar and it's important to consider from a UX perspective. I solved it by making all non-interactive elements draggable (here's how). This improves UX also on other platforms.

Some technical thoughts:

  • You are likely to want to want minor MacOS CSS tweaks due to the visual differences of the title bar:
    • Platform CSS media-queries don't work that well, so...
    • You have to check platform through tauri.os.platform() and change the CSS that way
    • [untested] Use small/large viewport units in your CSS.
  • The fullsize_content_view param does not appear to have any effect. I have both transparent_titlebar and hidden_title turned on.
  • I think the enum API would be better than booleans. It's easier to document and takes up shorter space. It also prevents invalid/ineffective combinations of the underlying booleans.

@probablykasper probablykasper requested a review from a team as a code owner June 24, 2022 22:04
@probablykasper
Copy link
Member Author

probablykasper commented Jun 25, 2022

I'm not sure if going the TitleBarStyle enum route is ideal. There are a few different situations to cover:

  • Showing the title bar
  • Transparent titlebar with fullsize content view. This allows you to put html under the titlebar.
  • Transparent titlebar without fullsize content view. This gives you a different look without needing to worry about different OS versions having different title bar heights and you don't run into [feat] [macOS] Configure acceptsFirstMouse for specific elements #4316

None of the above "hide" the titlebar, because the title and traffic lights can still be visible. In fact, in tao (and Xcode storyboards), hiding the titlebar

  • hides the traffic lights
  • disables the window border
  • disables rounded window corners

@probablykasper probablykasper changed the title feat(macos): transparent_titlebar window option, closes #2663 feat(macos): title_bar_style and hidden_title window options, closes #2663 Jun 25, 2022
@probablykasper
Copy link
Member Author

Went with this:

enum TitleBarStyle {
  Visible,
  Transparent,
  Hidden,
}

@JonasKruckenberg
Copy link
Member

JonasKruckenberg commented Jun 25, 2022

I solved it by making all non-interactive elements draggable

You mean all elements within the titlebar?

Went with this:

enum TitleBarStyle {
 Visible,
 Transparent,
 Hidden,
}

I like this 👍

@betamos
Copy link
Contributor

betamos commented Jun 25, 2022

You mean all elements within the titlebar?

No, everywhere in the window. I've seen it on some apps in the wild and it's great. Works for people that assume you have to drag from top too, so no learning curve, and no other downsides afaik.

@probablykasper
Copy link
Member Author

I like this 👍

@JonasKruckenberg Sorry, this is actually what I went with:

enum TitleBarStyle {
Visible,
Transparent,
Overlay,
}

The reasoning is what I explained above

@xuchaoqian

This comment was marked as off-topic.

@gradddev

This comment was marked as off-topic.

@p0ryae

This comment was marked as off-topic.

@tauri-apps tauri-apps locked as off-topic and limited conversation to collaborators Jul 12, 2022
@lucasfernog
Copy link
Member

Looks good to me, but I'm not seeing any differences with the Transparent mode (though Overlay looks amazing!) @probablykasper

@lucasfernog lucasfernog merged commit 321f3fe into dev Sep 30, 2022
@lucasfernog lucasfernog deleted the macos-transparent-titlebar branch September 30, 2022 20:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants