-
Notifications
You must be signed in to change notification settings - Fork 492
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
8313424: JavaFX controls in the title bar #1605
base: master
Are you sure you want to change the base?
Conversation
👋 Welcome back mstrauss! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
/reviewers 2 reviewers |
@mstr2 has indicated that a compatibility and specification (CSR) request is needed for this pull request. @mstr2 please create a CSR request for issue JDK-8313424 with the correct fix version. This pull request cannot be integrated until the CSR request is approved. |
Hey, I'm glad to see this PR, but do you have any ideas for continuing to provide |
Very nice. I'll test on Linux and report back. |
The only difference between the two would be whether the default window buttons are provided. I don't see how a window without default window buttons would be more useful. Even heavily stylized apps like Spotify use window buttons that feel at home on the OS, that doesn't take away from a consistent look and feel. |
A few points observed on Linux:
Added later: Nice cleanup on |
I suggest we convert this PR to Draft and first discuss this in the mailing list. There are so many issues with the proposal that need to be ironed first: CSS support, height limitation (what happens when the app or CSS places too large of the component?), user-defined color/accents/transparency on Windows, to name just a few. This change also may add a significant maintenance burden to the platform, for what I feel is a very small payout. What do you think? |
This has already been discussed at various points in time, and was always received positively. The previous implementation is one of the most-upvoted feature proposals since OpenJFX moved to GitHub.
What about these things? I don't understand the question, but let me try to give some answers nontheless:
Popular demand says otherwise. |
Popular demand is good, but I would like to hear from the tech leads and the maintainers. |
To clarify about height: do all the platforms support arbitrary height? What if size set by the app/CSS exceeds the height supported by the platform? About platform preferences: will it support all the attributes of the window decorations provided by the platform? |
@tsayao Thanks for the comments. I'll have a look at the bugs that you found.
I know that dragging on interactive controls is a thing on Linux, but I don't think that we should be doing that. JavaFX applications are multi-platform apps, which means that their behavior should be consistent across platforms. Stealing mouse interactions on interactive controls is not a thing on Windows and macOS, and this has the potential to cause problems for application developers. If you want, you can declare any node in the header bar to be draggable on all platforms with
I'll have to look into that, but in general an
While that sounds useful at first, I don't think it carries its own weight. Many platforms use different styling for windows that are focused vs. windows that are not. This not only includes the header bar, but many other parts of the user interface as well. I don't think that we should be adding what would essentially be ad-hoc pseudo-classes only to HeaderBar. In addition to that, it is extremely easy for an application to do this by adding a listener to We should definitely not do pseudo-classes for light vs. dark mode. The correct way to solve this problem is with media queries (prefers-color-scheme). |
Mailing list message from quizynox at gmail.com on openjfx-dev: Hello, Thank you so much for your effort! I'm really glad this hasn't been Every modern platform supports this feature: Electron, Tauri, Wails, Qt, Unfortunately, the current UNDECORATED stage implementation lacks two That's why the implementation should be handled on the native side, which It's indeed a complex feature. For that reason, I believe the ??, 22 ???. 2024??. ? 03:24, Michael Strau? <mstrauss at openjdk.org>: -------------- next part -------------- |
Continuing on window attributes. I would like to know what is and is not supported by platform, by feature. For example: Windows
Did I miss anything? |
For the HeaderBar, I would like to see the explanation of different layout options, including the cases when all the information does not fit the window width. Which parts are contracted? How is overflow handled? |
May be I am late to the party, but I would suggest to discuss the JEP first. I would like to see the summary by platform by feature, I would like to see details of the layout, and the description if and how the proposed design responds to user preferences changes dynamically. I would also like to see alternatives. Perhaps the app developers has all the tools already (for example, creating an overlay transparent scene on top of the platform title bar?), or maybe this functionality should be rather implemented in a library. Lastly, there is a concern of adding a huge maintenance burden on the platform. Next time the major OS vendor changes the L&F or adds something to the window decorations, we are on the hook for supporting that. I am not even qualified to access the impact of this feature in the Linux world. There are so many frameworks and opinions - how do you propose to handle that? Is it going to be supported on Wayland? |
Gtk does work on Mac and Windows, maybe we can see how it handles it's HeaderBar, for reference. |
Another aspect is whether this should be a conditional feature. |
I'll eagerly invite you to dissect this PR for its merits, its pros and cons. However, your questions lead me to conclude that you haven't really looked at what I'm proposing. Half of your questions are answered just by looking at the documentation for Let me try to explain
Since there is no non-client title bar, all questions regarding the appearance or accessibility of the |
Some people have suggested that they not only need to customize the title bar, but also the window buttons. This is now possible with the latest version of this feature. The API is now designed with an on-ramp to customization:
A custom window button is just a regular JavaFX button that can be placed anywhere in the scene graph. It needs to be marked with |
Another change is the option to use multiple header bars, which now cooperate gracefully. This enables application developers to create advanced layouts, for example having two header bars in a |
@mstr2 there is still active development going on - should this PR be sent back to Draft? |
Minor comment about the Monkey Tester (it's more of a limitation due to our test sprint process). There is a more recent repo https://github.com/andy-goryachev-oracle/MonkeyTest which has a dedicated Stage page which allows for limited configuration, have you tried it?. I see that your code does a bit more, so I'll incorporate your changes into the standalone repo regardless. The jfx MT will get a refresh once our test sprint starts (March?) |
I've incorporated review feedback received so far. Looking forward to additional feedback and reviews. |
I know about the MonkeyTester mirror, but I think the tests should go into the main repository with this PR. I'll have a look at the other Stage page, and incorporate changes here. |
you are absolutely right, my earlier comment was just FYI. these changes refer to new StageStyle's directly, while the mirror enumerates which makes it backward/forward compatible. |
I've been stalking this PR since October. Can't wait to use this feature in my project. |
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
public final class HeaderButtonBehavior implements EventHandler<MouseEvent> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it might be better to call this class other than "behavior", "handler" perhaps? mouse handler?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit more than just a generic handler, it basically encapsulates the entire behavior of a window button (including setting its visibility and disabled states).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally use "Behavior" in the context of controls. Although not wrong, I also think another name might be better. Maybe "Controller"? Or "Manager"? Or ...
} else { | ||
stage.setMaximized(!stage.isMaximized()); | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be better to add a default case here, in case this enum evolves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? This isn't some external enum that might evolve out from under this code, but is part of the same feature. If the enum evolves then the resulting compiler error is a good thing as it alerts whoever added the new enum that they didn't finish implementing it.
A default makes sense when the enum might evolve separately from the use of the enum.
@@ -154,7 +154,8 @@ private MenuBar createMenu() { | |||
FX.menu(m, "_Window"); | |||
FX.item(m, orientation); | |||
FX.separator(m); | |||
FX.item(m, "Open Modal Window", this::openModalWindow); | |||
FX.item(m, "Stage Tester", this::openStageTesterWindow); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this menu item be moved under "Tools"?
It looks like this is shaping up nicely. I'll put this on my review queue. One thing I wanted to raise is that there are a few new concepts here as well as a reasonably large API surface. This feature seems like a good candidate to release as a Preview Feature (*) to get more feedback on the API before finalizing it. That would mean reviving your Preview Feature JEP / Draft PR, which you had also mentioned as something to consider in your initial Description of this PR. Do you have any thoughts on this? (*) - It can't be an incubator module (at least not without doing something unnatural like creating a subclass of Stage, and that might not even work), since the new API elements and implementation are necessarily in the |
+1 for the preview idea |
I also think that this should be a preview feature. |
Sure, do that. It might be prudent to wait for the API in this PR to stabilize, though. |
@@ -1,5 +1,5 @@ | |||
/* | |||
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved. | |||
* Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we probably want to change this to 2025 (and merge the latest master for good measure)
/** | ||
* Returns the value of a potentially private field of the specified object. | ||
* The field can be declared on any of the object's inherited classes. | ||
*/ | ||
public static Object getFieldValue(Object object, String fieldName) { | ||
@SuppressWarnings("unchecked") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this annotation still needed (the build gives no warnings when it's removed)?
|
||
sizeComboBox.valueProperty().subscribe(event -> updateMinHeight.run()); | ||
headerBar.minSystemHeightProperty().subscribe(event -> updateMinHeight.run()); | ||
headerBar.setLeading(new Button("✨")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: this is nice, but can we replace this with non-emoji character please? (messes up the line spacing in Eclipse)
Implementation of
EXTENDED
andEXTENDED_UTILITY
stage style.Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1605/head:pull/1605
$ git checkout pull/1605
Update a local copy of the PR:
$ git checkout pull/1605
$ git pull https://git.openjdk.org/jfx.git pull/1605/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1605
View PR using the GUI difftool:
$ git pr show -t 1605
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1605.diff
Using Webrev
Link to Webrev Comment