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

Support custom title bar color on OSX #177

Closed
zakiso opened this issue Jul 1, 2019 · 11 comments
Closed

Support custom title bar color on OSX #177

zakiso opened this issue Jul 1, 2019 · 11 comments
Labels
enhancement New feature or request MacOS Specifically concerns MacOS plugin Issue about an existing or possible plugin

Comments

@zakiso
Copy link

zakiso commented Jul 1, 2019

Some OSX app has a great view, like this:
image

Is there any chance of getting this for go flutter app?

This can be achieved by using the following flags on NSWindow, assuming the window background color is set accordingly (example in Swift).

window.titlebarAppearsTransparent = true
window.titleVisibility = .hidden
window.styleMask.insert(NSWindowStyleMask.fullSizeContentView)
@GeertJohan GeertJohan added enhancement New feature or request MacOS Specifically concerns MacOS labels Jul 2, 2019
@GeertJohan
Copy link
Member

This may be possible to implement as plugin, maybe even compatible with https://github.com/mchome/flutter_statusbarcolor (I'm not sure if osx supports all features of flutter_statusbarcolor?)

@GeertJohan GeertJohan added the plugin Issue about an existing or possible plugin label Jul 2, 2019
@zakiso
Copy link
Author

zakiso commented Jul 10, 2019

I don't know glfw if provide this capability, if glfw has this capability add an option on options.go is more simple maybe.
I don't really understand go and glfw, when I‘m free I will investigate it.
Also hope someone implement it early.

@zephylac
Copy link
Collaborator

I've looked into it, and started to write a plugin. It seems that go implementation of GLFW doesn't support title bar etc.
It only supports func (w *Window) SetTitle(title string).
But GLFW in C seems to support C.glfwGetCurrentContext().glClearColor() which apparently changes background color.
Here's the code I've started writing : https://github.com/zephylac/statusbarcolor.
I've followed the implementation from https://github.com/mchome/flutter_statusbarcolor

Even if we can change color by using GLFW, we won't be able to differentiate status bar and navigation bar.

@pchampio
Copy link
Member

pchampio commented Jul 10, 2019

@zephylac @zakiso here is a blog describing how to set titlebarAppearsTransparent and backgroundColor on a GLFW window. http://svenandersson.se/2016/rendering-to-full-size-of-an-nswindow-using-glfw3.html

It's possible to get the native NSWindow using go-glfw

IMO, I think the plugin should call window.GetCocoaWindow() in golang. And then, with the uintptr, you could call some objective-c code to do the actual modification. example of CGO objective-c bindings

@zephylac
Copy link
Collaborator

Ok but we want the plugin to be cross-platform? We will need to implement for each patform then.

@pchampio
Copy link
Member

we want the plugin to be cross-platform?

Yes and No, The feature asked by @zakiso is about an OSX dependent request. To resolve the issue, OSX code needs to be written.
If someone has the same request on another platform (windows for example), then we will have to write windows code to solves the windows issue.

A shared interface can be exposed to each platform, (same way we handle textinput). But for now this isn't the question.
Let's start by writing a OSX only plugin.

@zephylac
Copy link
Collaborator

I'll draft a PR on plugins then to follow the WIP.

zephylac added a commit to zephylac/title_bar that referenced this issue Jul 10, 2019
@zephylac
Copy link
Collaborator

Now we can:

  • Change status bar color
  • Change status transparency
  • Hide / show status bar
  • Hide / show minimize widget button
  • Hide / show close widget button

I found out that we could also implement some others features like fullscreen (which we already handle) and transparency but this is more related to the window in itself than status bar.

I decided to not follow https://github.com/mchome/flutter_statusbarcolor since we add much more feature available.

@zakiso
Copy link
Author

zakiso commented Jul 12, 2019

I have tested this plugin, but found a weird problem. I called the method channel function on program started, but status bar color not changed. I have two display, when I drag the window into another display then the status bar color changed.

@zephylac
Copy link
Collaborator

Can you send your example, I'll try to replicate it.

@pchampio
Copy link
Member

pchampio commented Jul 29, 2019

I'm pleased to see the community making plugins. The proof of concept made by zephylac is quite impressive.
Closing the issue, please use the zephylac/title_bar issue tracker.

@go-flutter-desktop go-flutter-desktop locked and limited conversation to collaborators Jul 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request MacOS Specifically concerns MacOS plugin Issue about an existing or possible plugin
Development

No branches or pull requests

4 participants