jfx icon indicating copy to clipboard operation
jfx copied to clipboard

8271557: Undecorated interactive stage style

Open mstr2 opened this issue 3 years ago • 52 comments

This PR introduces StageStyle.UNDECORATED_INTERACTIVE. This style is similiar to StageStyle.UNDECORATED, but adds platform-specific interactions to the window.

For all platforms, this includes move and resize behaviors. On Windows, it also includes Aero behaviors (snap to screen edges, dock at top to maximize, etc.).

Additionally, on Windows this style adds window animations and a drop shadow (both of which StageStyle.UNDECORATED lacks).

This new style can be used to create custom window decorations without losing window interactions.

ezgif-2-013a29cf85a4

Applications that use this stage style need to provide an implementation of WindowRegionClassifier to let the JavaFX windowing subsystem know which parts of the window should afford window interactions:

stage.initStyle(StageStyle.UNDECORATED_INTERACTIVE);

stage.initRegionClassifier(new WindowRegionClassifier() {
    @Override
    public WindowRegion classify(double x, double y, Node nodeAtPosition) {

        // Regions can be identified by the node under the current cursor position...
        if (nodeAtPosition == titleBar) {
            return WindowRegion.TITLE;
        }
        
        // ...or by window coordinates
        if (x < 10) {
            return WindowRegion.LEFT;
        }
        
        if (x > primaryStage.getWidth() - 10) {
            return WindowRegion.RIGHT;
        }

        return WindowRegion.CLIENT;

    }
});

If a window region is not returned from the classifier, no interaction will be available for this region.


Progress

  • [x] Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • [x] Change must not contain extraneous whitespace
  • [x] Commit message must refer to an issue

Warning

 ⚠️ Patch contains a binary file (apps/samples/3DViewer/src/test/resources/com/javafx/importers/dae/test-data-maya/duke.png)

Issue

  • JDK-8271557: Undecorated interactive stage style (Enhancement - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/594/head:pull/594
$ git checkout pull/594

Update a local copy of the PR:
$ git checkout pull/594
$ git pull https://git.openjdk.org/jfx.git pull/594/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 594

View PR using the GUI difftool:
$ git pr show -t 594

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/594.diff

mstr2 avatar Jul 29 '21 19:07 mstr2

:wave: Welcome back mstrauss! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

bridgekeeper[bot] avatar Jul 29 '21 19:07 bridgekeeper[bot]

This is a great idea!

sproket avatar Jul 30 '21 00:07 sproket

great please make it happen

chengenzhao avatar Aug 14 '21 13:08 chengenzhao

Please make this happen

SDIDSA avatar Oct 05 '21 19:10 SDIDSA

This would be great for creating customized themes with different window decorations if that were to be supported some time down the line with this feature.

Is there anything blocking this from moving forward in the review process?

Col-E avatar Dec 13 '21 23:12 Col-E

This would be great for creating customized themes with different window decorations if that were to be supported some time down the line with this feature.

Is there anything blocking this from moving forward in the review process?

This PR is not yet ready for review, as I'm still working on some issues with resize flicker on Windows.

mstr2 avatar Dec 16 '21 17:12 mstr2

Any updates here?

Haven-King avatar Nov 16 '22 22:11 Haven-King

I think this is a very important PR.

Undecorated windows have become pretty much the standard nowadays for desktop apps, and the current state of affairs on Windows gives an unprofessional experience - as the minimize, maximize & restore animations are not displayed at all. Not to speak of Aero snapping.

Is there a possibility that this could be done for JavaFX 21?

TX256 avatar Jan 12 '23 14:01 TX256

Very useful PR, looking forward to it.

leewyatt avatar Jan 13 '23 02:01 leewyatt

Very much looking forward to

futurism-xm avatar Jan 13 '23 03:01 futurism-xm

非常期待

3563198204qq avatar Jan 13 '23 03:01 3563198204qq

Hi @yijunjiechen, thanks for making a comment in an OpenJDK project!

All comments and discussions in the OpenJDK Community must be made available under the OpenJDK Terms of Use. If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please Use "Add GitHub user yijunjiechen for the summary.

If you are not an OpenJDK Author, Committer or Reviewer, simply check the box below to accept the OpenJDK Terms of Use for your comments.

Your comment will be automatically restored once you have accepted the OpenJDK Terms of Use.

yijunjiechen avatar Jan 13 '23 03:01 yijunjiechen

Very useful PR, looking forward to it.

zero-zero-one-one avatar Jan 13 '23 03:01 zero-zero-one-one

Hi @LIUSHUAI2018, thanks for making a comment in an OpenJDK project!

All comments and discussions in the OpenJDK Community must be made available under the OpenJDK Terms of Use. If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please Use "Add GitHub user LIUSHUAI2018 for the summary.

If you are not an OpenJDK Author, Committer or Reviewer, simply check the box below to accept the OpenJDK Terms of Use for your comments.

Your comment will be automatically restored once you have accepted the OpenJDK Terms of Use.

LIUSHUAI2018 avatar Jan 13 '23 03:01 LIUSHUAI2018

wow,A very splendid pr, especially looking forward to incorporating it into the official version

Mr-ShiHuaYu avatar Jan 13 '23 03:01 Mr-ShiHuaYu

I am very supportive of this pr, it is hard to imagine that this feature has not been proposed until now, it is very important to build a modern application.

Anivie avatar Jan 13 '23 03:01 Anivie

nice,this PR Make it easy to customize the window

Xiaobaishushu25 avatar Jan 13 '23 03:01 Xiaobaishushu25

@bridgekeeper Sorry. I discussed this issue in a javafx community, and many people found this feature very useful, so they replied to this discussion; there may be more people replying at a time; I have caused trouble to you, sorry.

leewyatt avatar Jan 13 '23 04:01 leewyatt

It‘s a userful PR,every time I need to do it myself. I hope the official can accept it.

leck995 avatar Jan 13 '23 07:01 leck995

Would so love to see this happening.

dlemmermann avatar Jan 13 '23 12:01 dlemmermann

Can we have this by the next version?

palexdev avatar Jan 15 '23 15:01 palexdev

To allow a custom decoration control, the part of the TITLE window region would have to be transparent to allow it to be more customizable, like this:

image

Notice the rounded borders.

tsayao avatar Jan 27 '23 17:01 tsayao

@mstr2 this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout feature/windowregion
git fetch https://git.openjdk.org/jfx master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

openjdk[bot] avatar Feb 17 '23 18:02 openjdk[bot]

This PR appears to be starting with an undecorated stage and then creating all of the standard decorations including the drop shadows and resize corners and edges. Are JavaFX developers interested in customizing those areas? To provide a more modern experience the high value change is to enable access to the title bar area. On Mac and Windows it would be far easier to introduce a new stage style that is just like DECORATED but with the Scene extended upward all the way to the top of the Stage. I'm assuming this can be done on Linux but haven't tried to write the code.

In any case there are parts of this PR that can't be easily implemented on the Mac. In particular I haven't found a way to ask the OS to initiate a drag on the resize handles and get all of the usual platform behavior like snapping to the edges of other windows. You can invoke the platform's title bar drag (NSWindow performWindowDragWithEvent:).

beldenfox avatar Feb 21 '23 16:02 beldenfox

@mstr2 This pull request has been inactive for more than 8 weeks and will be automatically closed if another 8 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

bridgekeeper[bot] avatar Apr 18 '23 21:04 bridgekeeper[bot]

@mstr2 When using stage.initStyle(StageStyle.UNDECORATED_INTERACTIVE) in a Win10 system, a white line may appear on the left side of the window, and if a MenuBar is placed at the top of the window, the position of the menus may be incorrect.

aab163 avatar Apr 26 '23 07:04 aab163

@mstr2 This pull request has been inactive for more than 8 weeks and will be automatically closed if another 8 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

bridgekeeper[bot] avatar Jun 21 '23 13:06 bridgekeeper[bot]

Please keep Active

burningtnt avatar Jun 21 '23 13:06 burningtnt

Please keep active.

dlemmermann avatar Jun 21 '23 13:06 dlemmermann

Please keep active ^_^

leewyatt avatar Jun 22 '23 03:06 leewyatt