Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
mstr2 committed Oct 18, 2024
1 parent 575fcfd commit 13630a3
Show file tree
Hide file tree
Showing 13 changed files with 108 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,12 @@ public final boolean supportsUnifiedWindows() {
return _supportsUnifiedWindows();
}

protected abstract boolean _supportsExtendedWindows();
public final boolean supportsExtendedWindows() {
checkEventThread();
return _supportsExtendedWindows();
}

protected boolean _supportsSystemMenu() {
// Overridden in subclasses
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,11 @@ protected boolean _supportsInputMethods() {
return false;
}

@Override
protected boolean _supportsExtendedWindows() {
return true;
}

@Override
protected native int _getKeyCodeForChar(char c, int hint);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ protected boolean _supportsTransparentWindows() {
return false;
}

@Override
protected boolean _supportsExtendedWindows() {
return false;
}

/**
* Hides / Shows iOS status bar.
* @param hidden
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,11 @@ protected boolean _supportsTransparentWindows() {
return true;
}

@Override
protected boolean _supportsExtendedWindows() {
return true;
}

@Override native protected boolean _supportsSystemMenu();

// NOTE: this will not return a valid result until the native _runloop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ public NonClientHandler getNonClientHandler() {
maximize(!isMaximized());
} else if (clickCount == 1) {
_performWindowDrag(getRawHandle());
return true;
}
}
}
Expand All @@ -188,7 +187,7 @@ public NonClientHandler getNonClientHandler() {
public ObservableValue<WindowOverlayMetrics> windowOverlayMetrics() {
if (windowOverlayMetrics == null) {
windowOverlayMetrics = ObjectConstant.valueOf(
new WindowOverlayMetrics(HorizontalDirection.LEFT, new Dimension2D(68, 0)));
new WindowOverlayMetrics(HorizontalDirection.LEFT, new Dimension2D(78, 38)));
}

return windowOverlayMetrics;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,11 @@ protected boolean _supportsUnifiedWindows() {
return false;
}

@Override
protected boolean _supportsExtendedWindows() {
return false;
}

@Override
public boolean hasTwoLevelFocus() {
return deviceFlags[DEVICE_PC_KEYBOARD] == 0 && deviceFlags[DEVICE_5WAY] > 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,11 @@ protected boolean _supportsTransparentWindows() {

@Override native protected boolean _supportsUnifiedWindows();

@Override
protected boolean _supportsExtendedWindows() {
return true;
}

@Override
public String getDataDirectory() {
checkEventThread();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,8 @@ public boolean isSupported(ConditionalFeature feature) {
return Application.GetApplication().supportsTransparentWindows();
case UNIFIED_WINDOW:
return Application.GetApplication().supportsUnifiedWindows();
case EXTENDED_WINDOW:
return Application.GetApplication().supportsExtendedWindows();
case TWO_LEVEL_FOCUS:
return Application.GetApplication().hasTwoLevelFocus();
case VIRTUAL_KEYBOARD:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -159,6 +159,15 @@ public enum ConditionalFeature {
*/
UNIFIED_WINDOW,

/**
* Indicates that a system supports {@link javafx.stage.StageStyle#EXTENDED}.
* <p>
* This feature is currently supported on Windows, Linux, and macOS.
*
* @since 24
*/
EXTENDED_WINDOW,

/**
* Indicates whether or not controls should use two-level focus. Two-level
* focus is when separate operations are needed in some controls to first
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,46 @@
import javafx.geometry.Pos;
import javafx.geometry.VPos;
import javafx.scene.Node;
import javafx.stage.StageStyle;

/**
* A client-area header bar that is used as a replacement for the system-provided header bar in stages
* with the {@link StageStyle#EXTENDED} style. This class enables the <em>drag to move</em> and
* <em>double-click to maximize</em> behaviors that are usually afforded by system-provided header bars.
* <p>
* {@code HeaderBar} is also a layout container that allows applications to lay out scene graph nodes
* in three areas: left, center, and right. {@code HeaderBar} ensures that the left and right areas
* account for the default window buttons (minimize, maximize, close). The center area is laid out
* with respect to the window, so that nodes will appear centered in the window regardless of the
* platform-specific placement of default window buttons.
*
* <h2>Optional layout constraints</h2>
* An application may set constraints on individual children to customize their layout.
* For each constraint, {@code HeaderBar} provides static getter and setter methods.
* <table style="white-space: nowrap">
* <caption>Layout constraints of {@code HeaderBar}</caption>
* <thead>
* <tr><th>Constraint</th><th>Type</th><th>Description</th></tr>
* </thead>
* <tbody>
* <tr><th>alignment</th><td>{@link Pos}</td>
* <td>The alignment of the child within its area of the {@code HeaderBar}.</td>
* </tr>
* <tr><th>margin</th>
* <td>{@link Insets}</td><td>Margin space around the outside of the child.</td>
* </tr>
* </tbody>
* </table>
*
* <h2>Example</h2>
* <pre>{@code
* var button = new Button("My button");
* HeaderBar.setAlignment(button, Pos.CENTER_LEFT);
* HeaderBar.setMargin(button, new Insets(5));
* myHeaderBar.setCenter(button);
* }</pre>
*
* @since 24
*/
public class HeaderBar extends HeaderBarBase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
* point for custom header bar implementations. This class enables the <em>drag to move</em> and
* <em>double-click to maximize</em> behaviors that are usually afforded by system-provided header bars.
* <p>
* Client-area header bars are used as a replacement for system-provided header bars in stages
* Client-area header bars are used as a replacement for the system-provided header bar in stages
* with the {@link StageStyle#EXTENDED} style.
* <p>
* Most application developers should use the {@link HeaderBar} implementation instead of
Expand Down
26 changes: 24 additions & 2 deletions modules/javafx.graphics/src/main/java/javafx/stage/StageStyle.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@

package javafx.stage;

import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HeaderBar;

/**
* This enum defines the possible styles for a {@code Stage}.
* @since JavaFX 2.0
Expand Down Expand Up @@ -69,8 +72,27 @@ public enum StageStyle {
UNIFIED,

/**
* Defines a {@code Stage} style in which the client area is extended into the non-client area,
* allowing applications to place scene graph nodes in the title bar area of the stage.
* Defines a {@code Stage} style in which the client area is extended into the header bar area, removing
* the separation between the two areas and allowing applications to place scene graph nodes in the header
* bar area of the stage.
* <p>
* An extended window has the default window buttons (minimize, maximize, close), but no system-provided
* draggable header bar. Applications need to provide their own header bar by placing the {@link HeaderBar}
* control in the scene graph. Usually, this is combined with a {@link BorderPane} root container:
* <pre>{@code
* public class MyApp extends Application {
* @Override
* public void start(Stage stage) {
* var headerBar = new HeaderBar();
* var root = new BorderPane();
* root.setTop(headerBar);
*
* stage.setScene(new Scene(root));
* stage.initStyle(StageStyle.EXTENDED);
* stage.show();
* }
* }
* }</pre>
*
* @since 24
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,8 @@ static jlong _createWindowCommonDo(JNIEnv *env, jobject jWindow, jlong jOwnerPtr

if ((jStyleMask & com_sun_glass_ui_Window_EXTENDED) != 0) {
[window->nsWindow setTitlebarAppearsTransparent:YES];
[window->nsWindow setToolbar:[NSToolbar new]];
[window->nsWindow setToolbarStyle:NSWindowToolbarStyleUnifiedCompact];
}

if ((jStyleMask & com_sun_glass_ui_Window_UNIFIED) != 0) {
Expand Down

0 comments on commit 13630a3

Please sign in to comment.