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

Introduce YaruWindowTitleBar & YaruDialogTitleBar #455

Merged
merged 20 commits into from Jan 9, 2023
Merged

Introduce YaruWindowTitleBar & YaruDialogTitleBar #455

merged 20 commits into from Jan 9, 2023

Conversation

jpnurmi
Copy link
Member

@jpnurmi jpnurmi commented Dec 6, 2022

YaruWindowTitleBar and YaruDialogTitleBar are based on YaruTitleBar but provide slightly different behavior. The dialog variant has no minimize and maximize buttons by default, doesn't react to double clicks, and calls Navigator.maybePop when closed.

Active Inactive
image image
image image

@jpnurmi jpnurmi marked this pull request as draft December 6, 2022 08:18
@jpnurmi

This comment was marked as outdated.

@Feichtmeier
Copy link
Member

For the window titlebar I would recommend

#222222 (Color0xFF222222)
It would be nice to have a color arg though and just make 222222 the default

I would leave the dialogbar as it is

Thank you very much for making this happen!
We could add this to the appbar of the pages on the right side in the xample

@Jupi007
Copy link
Member

Jupi007 commented Dec 6, 2022

Awesome 😍

@Jupi007
Copy link
Member

Jupi007 commented Dec 6, 2022

Here is my design point of view on this:

  • The title should use: TextStyle(fontSize: 14, fontWeight: FontWeight.w500).
  • AppBar background should use Colors.black with 0.075 of opacity on the light theme, and 0.2 on the dark theme.
  • AppBar bottom border should use Colors.black with 0.1 of opacity on the light theme, and 0.2 on the dark theme.
  • Window controls should be spaced of 10 from the window edge, and of 14 from each others.
Light theme Dark Theme
TitleBar image Capture d’écran du 2022-12-06 18-10-36
DialogBar Capture d’écran du 2022-12-06 18-26-35 Capture d’écran du 2022-12-06 18-27-26

Also, I really like the idea of DialogBar which can control window position, with the same look as the TitleBar. This behaviour "emulate" a second window, while still being in the same one. Also, as the title bar is now flutter, we cannot move the window when a dialog is open, so it is important that dialog can do this action.

Another point, it would be nice to add a backdrop state to the title bar, so we can identify which window is focused more easily.

@jpnurmi
Copy link
Member Author

jpnurmi commented Dec 6, 2022

Here is my design point of view on this

Thank you! Looks very nice!

Another point, it would be nice to add a backdrop state to the title bar, so we can identify which window is focused more easily.

Is it enough to have different colors for active and inactive states or does it need some sort of backdrop effect?

@Feichtmeier
Copy link
Member

Do we really always need a background for dialog titlebars? I think even the gnomers are stepping away from this. Maybe we could have an option to remove both border and background color without too many hacks?

@Jupi007
Copy link
Member

Jupi007 commented Dec 6, 2022

Is it enough to have different colors for active and inactive states or does it need some sort of backdrop effect?

Maybe can we do like Libadwaita, by remove titlebar background and tone down everything inside?

@jpnurmi
Copy link
Member Author

jpnurmi commented Dec 6, 2022

Maybe we could have an option to remove both border and background color without too many hacks?

We can make the colors etc. themable so one can change the values in one place

@Jupi007
Copy link
Member

Jupi007 commented Dec 6, 2022

Do we really always need a background for dialog titlebars? I think even the gnomers are stepping away from this. Maybe we could have an option to remove both border and background color without too many hacks?

In fact I like both solutions 🙂
So the best imo would be to have a titlebar style for dialogs by default, but leave the option for a fully transparent one.
With a named controller, and/or with theming options like said @jpnurmi

@jpnurmi
Copy link
Member Author

jpnurmi commented Dec 6, 2022

How's this? All of our theme classes can be used as Flutter theme extensions:

YaruTheme(
  extensions: [
    YaruTitleBarThemeData(
      backgroundColor: MaterialStateProperty.all(Colors.transparent),
    ),
    YaruFooBarThemeData(
      ...
    ),
  ]
  builder: (context, yaru, child) => MaterialApp(
    theme: yaru.theme,
    darkTheme: yaru.darkTheme,
    home: ...
  ),
)

@jpnurmi
Copy link
Member Author

jpnurmi commented Dec 6, 2022

Any ideas on how to deal with different platforms?

Leave it up to the user to only create a YaruWindowTitleBar on Linux? It's pretty straightforward to delete the GtkHeaderBar from my_application.cc on Linux but on other platforms, you'd have to make the window frameless and then you lose resizing. Oh, and on Web you don't want anything there.

@jpnurmi
Copy link
Member Author

jpnurmi commented Dec 6, 2022

macOS 🙃

image
image

@jpnurmi
Copy link
Member Author

jpnurmi commented Dec 6, 2022

Both Windows and macOS need some minor tweaks but we might be able to make this work somewhat sensibly on all desktop platforms.

image

@Feichtmeier
Copy link
Member

How's this? All of our theme classes can be used as Flutter theme extensions:

YaruTheme(
  extensions: [
    YaruTitleBarThemeData(
      backgroundColor: MaterialStateProperty.all(Colors.transparent),
    ),
    YaruFooBarThemeData(
      ...
    ),
  ]
  builder: (context, yaru, child) => MaterialApp(
    theme: yaru.theme,
    darkTheme: yaru.darkTheme,
    home: ...
  ),
)

Very nice

@Feichtmeier
Copy link
Member

Any ideas on how to deal with different platforms?

Leave it up to the user to only create a YaruWindowTitleBar on Linux? It's pretty straightforward to delete the GtkHeaderBar from my_application.cc on Linux but on other platforms, you'd have to make the window frameless and then you lose resizing. Oh, and on Web you don't want anything there.

Depends on you 🙂
Currently this lib targets Linux and web
But if you can make it work on Windows and MacOS too why not . The design works on all desktops

@jpnurmi
Copy link
Member Author

jpnurmi commented Dec 7, 2022

This PR makes it possible to call windowManager.setTitleBarStyle(TitleBarStyle.hidden) to hide the GTK or Handy header bar out of the way on Linux without touching my_application.cc.

I used the same WindowManager API when testing Windows and macOS earlier. This could be a nice and cross-platform way to set things up.

@Feichtmeier
Copy link
Member

without touching my_application.cc

That's pretty awesome!

@whiskeyPeak
Copy link
Contributor

Wow! This looks absolutely gorgeous!

@larsb24
Copy link
Contributor

larsb24 commented Dec 26, 2022

Looks awesome!

One potential problem I could see though is the expected behaviour when dialogs are opened. I don't know where the intention lies, which is why I'm saying “potential” but not being able to access the titlebar or it's functions while dialogs are open could be unexpected by some users.

@jpnurmi
Copy link
Member Author

jpnurmi commented Dec 27, 2022

Thanks. The way it currently behaves is that dialog title bars allow moving the entire window and opening the popup menu. This makes dialogs feel almost like top-level windows. :)

@Jupi007
Copy link
Member

Jupi007 commented Dec 27, 2022

Yes, and this is a really good idea, because as the headerbar is now a flutter widget, it is hidden when you open a dialog.
Be able to drag the window from the dialog fix this issue.

Feichtmeier pushed a commit that referenced this pull request Jan 3, 2023
Changes extracted from #455, leaving out YaruWindow/DialogTitleBar etc.
@jpnurmi
Copy link
Member Author

jpnurmi commented Jan 3, 2023

This PR makes it possible to call windowManager.setTitleBarStyle(TitleBarStyle.hidden) to hide the GTK or Handy header bar out of the way on Linux without touching my_application.cc.

I used the same WindowManager API when testing Windows and macOS earlier. This could be a nice and cross-platform way to set things up.

I have to eat my words. It's not possible to hide the native title/header bar from Dart early enough. It's visible for a brief moment during startup.

@Feichtmeier
Copy link
Member

I have to eat my words. It's not possible to hide the native title/header bar from Dart early enough. It's visible for a brief moment during startup.

does this mean that the version where you do not touch my_application.cc shows the bar for a short moment or is it even shown when you make the known changes from handy_window?

@jpnurmi
Copy link
Member Author

jpnurmi commented Jan 9, 2023

@Jupi007 What about flutter pub upgrade (in the example)? Does it make any difference? Also, which yaru_widgets.dart commit are you on, and which Flutter version are you using?

@Jupi007
Copy link
Member

Jupi007 commented Jan 9, 2023

@jpnurmi I had already tried pub upgrade, without success.

My flutter version is:

[✓] Flutter (Channel stable, 3.3.10, on Ubuntu 22.10 5.19.0-28-generic, locale fr_FR.UTF-8)

Looks like I'm using the latest stable version.

@jpnurmi
Copy link
Member Author

jpnurmi commented Jan 9, 2023

Testing YaruWindowTitleBar with Workshops 👍

image

@Feichtmeier
Copy link
Member

Wonder why it worked for me 🤔
Maybe just delete the local repo and clone again?

@Jupi007
Copy link
Member

Jupi007 commented Jan 9, 2023

Wonder why it worked for me 🤔
Maybe just delete the local repo and clone again?

Will try this once back home 👍

@Jupi007
Copy link
Member

Jupi007 commented Jan 9, 2023

Nope, I re-cloned the project, and the exception is still present...

@Feichtmeier
Copy link
Member

Feichtmeier commented Jan 9, 2023

then the only difference that comes to my mind that is left is maybe the locale? try running flutter run with en_US

LANGUAGE=en_US flutter run

@Jupi007
Copy link
Member

Jupi007 commented Jan 9, 2023

Found the problem: it is broken in debug mode.
It runs fine with flutter run, and from VS code with the no debug mode.

I can perfectly run the example app in both mode from main, it is only this PR who is broken in debug.

@jpnurmi
Copy link
Member Author

jpnurmi commented Jan 9, 2023

Gotcha, so

isMovable().catchError((_) => true),

doesn't actually end up catching the error because WindowManager.isMovable() internally awaits the method channel invocation...

@jpnurmi jpnurmi marked this pull request as ready for review January 9, 2023 21:08
@jpnurmi
Copy link
Member Author

jpnurmi commented Jan 9, 2023

@Jupi007 Ok, should be fixed now. Please give it a try when you have time. 🙏

@Jupi007
Copy link
Member

Jupi007 commented Jan 9, 2023

Works 🥳
This is really awesome, thank you so much 😃

Copy link
Member

@Jupi007 Jupi007 left a comment

Choose a reason for hiding this comment

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

LGFM 🚀

@Feichtmeier Feichtmeier merged commit dbb5b6d into ubuntu:main Jan 9, 2023
@jpnurmi jpnurmi deleted the title-bar branch January 9, 2023 22:42
@jpnurmi
Copy link
Member Author

jpnurmi commented Jan 9, 2023

is that yaru_widgets 2.0?

@Feichtmeier
Copy link
Member

Yes 🖐️👍 I'll do a release tomorrow if you aren't faster 😉 thank you JP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants