From 07ad467c73c5593106507f7c6ac7b7df57877a65 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Wed, 23 Nov 2022 16:32:09 +0100 Subject: [PATCH 1/2] Windows 11: use rounded popups with system border and system drop shadow --- .../flatlaf/ui/FlatNativeWindowsLibrary.java | 106 ++++++++++++++++++ .../formdev/flatlaf/ui/FlatPopupFactory.java | 47 ++++++++ .../com/formdev/flatlaf/ui/FlatUIUtils.java | 4 + .../com/formdev/flatlaf/util/SystemInfo.java | 25 ++++- .../flatlaf-natives-windows/build.gradle.kts | 5 +- .../src/main/cpp/FlatWndProc.cpp | 4 +- .../src/main/cpp/FlatWndProc.h | 2 - .../src/main/cpp/WinWrapper.cpp | 102 +++++++++++++++++ ...mdev_flatlaf_ui_FlatNativeWindowsLibrary.h | 53 +++++++++ 9 files changed, 338 insertions(+), 10 deletions(-) create mode 100644 flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatNativeWindowsLibrary.java create mode 100644 flatlaf-natives/flatlaf-natives-windows/src/main/cpp/WinWrapper.cpp create mode 100644 flatlaf-natives/flatlaf-natives-windows/src/main/headers/com_formdev_flatlaf_ui_FlatNativeWindowsLibrary.h diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatNativeWindowsLibrary.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatNativeWindowsLibrary.java new file mode 100644 index 00000000..9df5ae23 --- /dev/null +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatNativeWindowsLibrary.java @@ -0,0 +1,106 @@ +/* + * Copyright 2022 FormDev Software GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.formdev.flatlaf.ui; + +import java.awt.Window; + +/** + * Native methods for Windows. + *

+ * Note: This is private API. Do not use! + * + * @author Karl Tauber + * @since 3.1 + */ +public class FlatNativeWindowsLibrary +{ + private static long osBuildNumber = Long.MIN_VALUE; + + public static boolean isLoaded() { + return FlatNativeLibrary.isLoaded(); + } + + /** + * Gets the Windows operating system build number. + *

+ * Invokes Win32 API method {@code GetVersionEx()} and returns {@code OSVERSIONINFO.dwBuildNumber}. + * See https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getversionexa + */ + public static long getOSBuildNumber() { + if( osBuildNumber == Long.MIN_VALUE ) + osBuildNumber = getOSBuildNumberImpl(); + return osBuildNumber; + } + + /** + * Invokes Win32 API method {@code GetVersionEx()} and returns {@code OSVERSIONINFO.dwBuildNumber}. + * See https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getversionexa + */ + private native static long getOSBuildNumberImpl(); + + /** + * Gets the Windows window handle (HWND) for the given Swing window. + *

+ * Note that the underlying Windows window must be already created, + * otherwise this method returns zero. Use following to ensure this: + *

{@code
+	 * if( !window.isDisplayable() )
+	 *     window.addNotify();
+	 * }
+ * or invoke this method after packing the window. E.g. + *
{@code
+	 * window.pack();
+	 * long hwnd = getHWND( window );
+	 * }
+ */ + public native static long getHWND( Window window ); + + /** + * DWM_WINDOW_CORNER_PREFERENCE + * see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_window_corner_preference + */ + public static final int + DWMWCP_DEFAULT = 0, + DWMWCP_DONOTROUND = 1, + DWMWCP_ROUND = 2, + DWMWCP_ROUNDSMALL = 3; + + /** + * Sets the rounded corner preference for the window. + * Allowed values are {@link #DWMWCP_DEFAULT}, {@link #DWMWCP_DONOTROUND}, + * {@link #DWMWCP_ROUND} and {@link #DWMWCP_ROUNDSMALL}. + *

+ * Invokes Win32 API method {@code DwmSetWindowAttribute(DWMWA_WINDOW_CORNER_PREFERENCE)}. + * See https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmsetwindowattribute + *

+ * Supported since Windows 11 Build 22000. + */ + public native static boolean setWindowCornerPreference( long hwnd, int cornerPreference ); + + /** + * Sets the color of the window border. + * The red/green/blue values must be in range {@code 0 - 255}. + * If red is {@code -1}, then the system default border color is used (useful to reset the border color). + * If red is {@code -2}, then no border is painted. + *

+ * Invokes Win32 API method {@code DwmSetWindowAttribute(DWMWA_BORDER_COLOR)}. + * See https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmsetwindowattribute + *

+ * Supported since Windows 11 Build 22000. + */ + public native static boolean setWindowBorderColor( long hwnd, int red, int green, int blue ); +} diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupFactory.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupFactory.java index c58b72eb..1ea34982 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupFactory.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupFactory.java @@ -52,6 +52,8 @@ import javax.swing.SwingUtilities; import javax.swing.ToolTipManager; import javax.swing.UIManager; import javax.swing.border.Border; +import javax.swing.border.EmptyBorder; +import javax.swing.border.LineBorder; import com.formdev.flatlaf.FlatClientProperties; import com.formdev.flatlaf.util.SystemInfo; import com.formdev.flatlaf.util.UIScale; @@ -88,6 +90,14 @@ public class FlatPopupFactory if( SystemInfo.isMacOS || SystemInfo.isLinux ) return new NonFlashingPopup( getPopupForScreenOfOwner( owner, contents, x, y, true ), contents ); + // Windows 11 with FlatLaf native library can use rounded corners and shows drop shadow for heavy weight popups + if( SystemInfo.isWindows_11_orLater && FlatNativeWindowsLibrary.isLoaded() ) { + NonFlashingPopup popup = new NonFlashingPopup( getPopupForScreenOfOwner( owner, contents, x, y, true ), contents ); + if( popup.popupWindow != null ) + setupWindows11Border( popup.popupWindow, contents ); + return popup; + } + // create drop shadow popup return new DropShadowPopup( getPopupForScreenOfOwner( owner, contents, x, y, forceHeavyWeight ), owner, contents ); } @@ -300,6 +310,43 @@ public class FlatPopupFactory ((JComponent)owner).getToolTipLocation( me ) != null; } + private static void setupWindows11Border( Window popupWindow, Component contents ) { + // make sure that the Windows 11 window is created + if( !popupWindow.isDisplayable() ) + popupWindow.addNotify(); + + // get window handle + long hwnd = FlatNativeWindowsLibrary.getHWND( popupWindow ); + + // set corner preference + FlatNativeWindowsLibrary.setWindowCornerPreference( hwnd, FlatNativeWindowsLibrary.DWMWCP_ROUNDSMALL ); + + // set border color + int red = -1; // use system default color + int green = 0; + int blue = 0; + if( contents instanceof JComponent ) { + Border border = ((JComponent)contents).getBorder(); + border = FlatUIUtils.unwrapNonUIResourceBorder( border ); + + // get color from border of contents (e.g. JPopupMenu or JToolTip) + Color borderColor = null; + if( border instanceof FlatLineBorder ) + borderColor = ((FlatLineBorder)border).getLineColor(); + else if( border instanceof LineBorder ) + borderColor = ((LineBorder)border).getLineColor(); + else if( border instanceof EmptyBorder ) + red = -2; // do not paint border + + if( borderColor != null ) { + red = borderColor.getRed(); + green = borderColor.getGreen(); + blue = borderColor.getBlue(); + } + } + FlatNativeWindowsLibrary.setWindowBorderColor( hwnd, red, green, blue ); + } + //---- class NonFlashingPopup --------------------------------------------- private class NonFlashingPopup diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatUIUtils.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatUIUtils.java index 2378eefa..c43df699 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatUIUtils.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatUIUtils.java @@ -200,6 +200,10 @@ public class FlatUIUtils return (border instanceof UIResource) ? new NonUIResourceBorder( border ) : border; } + static Border unwrapNonUIResourceBorder( Border border ) { + return (border instanceof NonUIResourceBorder) ? ((NonUIResourceBorder)border).delegate : border; + } + public static int minimumWidth( JComponent c, int minimumWidth ) { return FlatClientProperties.clientPropertyInt( c, FlatClientProperties.MINIMUM_WIDTH, minimumWidth ); } diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/util/SystemInfo.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/util/SystemInfo.java index 8678afcd..6be6e98f 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/util/SystemInfo.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/util/SystemInfo.java @@ -18,6 +18,7 @@ package com.formdev.flatlaf.util; import java.util.Locale; import java.util.StringTokenizer; +import com.formdev.flatlaf.ui.FlatNativeWindowsLibrary; /** * Provides information about the current system. @@ -34,9 +35,7 @@ public class SystemInfo // OS versions public static final long osVersion; public static final boolean isWindows_10_orLater; - /** Note: This requires Java 8u321, 11.0.14, 17.0.2 or 18 (or later). - * (see https://bugs.openjdk.java.net/browse/JDK-8274840) - * @since 2 */ public static final boolean isWindows_11_orLater; + /** @since 2 */ public static final boolean isWindows_11_orLater; public static final boolean isMacOS_10_11_ElCapitan_orLater; public static final boolean isMacOS_10_14_Mojave_orLater; public static final boolean isMacOS_10_15_Catalina_orLater; @@ -80,8 +79,6 @@ public class SystemInfo // OS versions osVersion = scanVersion( System.getProperty( "os.version" ) ); isWindows_10_orLater = (isWindows && osVersion >= toVersion( 10, 0, 0, 0 )); - isWindows_11_orLater = (isWindows_10_orLater && osName.length() > "windows ".length() && - scanVersion( osName.substring( "windows ".length() ) ) >= toVersion( 11, 0, 0, 0 )); isMacOS_10_11_ElCapitan_orLater = (isMacOS && osVersion >= toVersion( 10, 11, 0, 0 )); isMacOS_10_14_Mojave_orLater = (isMacOS && osVersion >= toVersion( 10, 14, 0, 0 )); isMacOS_10_15_Catalina_orLater = (isMacOS && osVersion >= toVersion( 10, 15, 0, 0 )); @@ -119,6 +116,24 @@ public class SystemInfo isMacFullWindowContentSupported = javaVersion >= toVersion( 11, 0, 8, 0 ) || (javaVersion >= toVersion( 1, 8, 0, 292 ) && !isJava_9_orLater); + + + // Note: Keep following at the end of this block because (optional) loading + // of native library uses fields of this class. E.g. isX86_64 + + // Windows 11 detection is implemented in Java 8u321, 11.0.14, 17.0.2 and 18 (or later). + // (see https://bugs.openjdk.java.net/browse/JDK-8274840) + // For older Java versions, use native library to get OS build number. + boolean isWin_11_orLater = false; + try { + isWin_11_orLater = (isWindows_10_orLater && + (scanVersion( StringUtils.removeLeading( osName, "windows " ) ) >= toVersion( 11, 0, 0, 0 )) || + (FlatNativeWindowsLibrary.isLoaded() && FlatNativeWindowsLibrary.getOSBuildNumber() >= 22000)); + } catch( Throwable ex ) { + // catch to avoid that application can not start if native library is not up-to-date + LoggingFacade.INSTANCE.logSevere( null, ex ); + } + isWindows_11_orLater = isWin_11_orLater; } public static long scanVersion( String version ) { diff --git a/flatlaf-natives/flatlaf-natives-windows/build.gradle.kts b/flatlaf-natives/flatlaf-natives-windows/build.gradle.kts index 99acaf2a..69490664 100644 --- a/flatlaf-natives/flatlaf-natives-windows/build.gradle.kts +++ b/flatlaf-natives/flatlaf-natives-windows/build.gradle.kts @@ -22,6 +22,7 @@ plugins { flatlafJniHeaders { headers = listOf( + "com_formdev_flatlaf_ui_FlatNativeWindowsLibrary.h", "com_formdev_flatlaf_ui_FlatWindowsNativeWindowBorder.h", "com_formdev_flatlaf_ui_FlatWindowsNativeWindowBorder_WndProc.h" ) @@ -74,8 +75,8 @@ tasks { linkerArgs.addAll( toolChain.map { when( it ) { - is Gcc, is Clang -> listOf( "-l${jawt}", "-lUser32", "-lGdi32", "-lshell32", "-lAdvAPI32", "-lKernel32" ) - is VisualCpp -> listOf( "${jawt}.lib", "User32.lib", "Gdi32.lib", "shell32.lib", "AdvAPI32.lib", "Kernel32.lib", "/NODEFAULTLIB" ) + is Gcc, is Clang -> listOf( "-l${jawt}", "-lUser32", "-lGdi32", "-lshell32", "-lAdvAPI32", "-lKernel32", "-lDwmapi" ) + is VisualCpp -> listOf( "${jawt}.lib", "User32.lib", "Gdi32.lib", "shell32.lib", "AdvAPI32.lib", "Kernel32.lib", "Dwmapi.lib", "/NODEFAULTLIB" ) else -> emptyList() } } ) diff --git a/flatlaf-natives/flatlaf-natives-windows/src/main/cpp/FlatWndProc.cpp b/flatlaf-natives/flatlaf-natives-windows/src/main/cpp/FlatWndProc.cpp index 77b8006d..45d6b850 100644 --- a/flatlaf-natives/flatlaf-natives-windows/src/main/cpp/FlatWndProc.cpp +++ b/flatlaf-natives/flatlaf-natives-windows/src/main/cpp/FlatWndProc.cpp @@ -29,6 +29,8 @@ * @author Karl Tauber */ +HWND getWindowHandle( JNIEnv* env, jobject window ); + //---- JNI methods ------------------------------------------------------------ extern "C" @@ -540,7 +542,7 @@ void FlatWndProc::setMenuItemState( HMENU systemMenu, int item, bool enabled ) { ::SetMenuItemInfo( systemMenu, item, FALSE, &mii ); } -HWND FlatWndProc::getWindowHandle( JNIEnv* env, jobject window ) { +HWND getWindowHandle( JNIEnv* env, jobject window ) { JAWT awt; awt.version = JAWT_VERSION_1_4; if( !JAWT_GetAWT( env, &awt ) ) diff --git a/flatlaf-natives/flatlaf-natives-windows/src/main/cpp/FlatWndProc.h b/flatlaf-natives/flatlaf-natives-windows/src/main/cpp/FlatWndProc.h index 768b7779..96e255d1 100644 --- a/flatlaf-natives/flatlaf-natives-windows/src/main/cpp/FlatWndProc.h +++ b/flatlaf-natives/flatlaf-natives-windows/src/main/cpp/FlatWndProc.h @@ -67,6 +67,4 @@ private: void sendMessageToClientArea( HWND hwnd, int uMsg, LPARAM lParam ); void openSystemMenu( HWND hwnd, int x, int y ); void setMenuItemState( HMENU systemMenu, int item, bool enabled ); - - static HWND getWindowHandle( JNIEnv* env, jobject window ); }; diff --git a/flatlaf-natives/flatlaf-natives-windows/src/main/cpp/WinWrapper.cpp b/flatlaf-natives/flatlaf-natives-windows/src/main/cpp/WinWrapper.cpp new file mode 100644 index 00000000..37fc9e84 --- /dev/null +++ b/flatlaf-natives/flatlaf-natives-windows/src/main/cpp/WinWrapper.cpp @@ -0,0 +1,102 @@ +/* + * Copyright 2022 FormDev Software GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// avoid inlining of printf() +#define _NO_CRT_STDIO_INLINE + +#include +#include +#include "com_formdev_flatlaf_ui_FlatNativeWindowsLibrary.h" + +/** + * @author Karl Tauber + */ + +// see FlatWndProc.cpp +HWND getWindowHandle( JNIEnv* env, jobject window ); + +//---- Utility ---------------------------------------------------------------- + +extern "C" +JNIEXPORT jlong JNICALL Java_com_formdev_flatlaf_ui_FlatNativeWindowsLibrary_getOSBuildNumberImpl + ( JNIEnv* env, jclass cls ) +{ + OSVERSIONINFO info; + info.dwOSVersionInfoSize = sizeof( info ); + if( !::GetVersionEx( &info ) ) + return 0; + return info.dwBuildNumber; +} + +extern "C" +JNIEXPORT jlong JNICALL Java_com_formdev_flatlaf_ui_FlatNativeWindowsLibrary_getHWND + ( JNIEnv* env, jclass cls, jobject window ) +{ + return reinterpret_cast( getWindowHandle( env, window ) ); +} + +//---- Desktop Window Manager (DWM) ------------------------------------------- + +// define constants that may not available in older development environments + +#ifndef DWMWA_COLOR_DEFAULT + +#define DWMWA_WINDOW_CORNER_PREFERENCE 33 +#define DWMWA_BORDER_COLOR 34 + +typedef enum { + DWMWCP_DEFAULT = 0, + DWMWCP_DONOTROUND = 1, + DWMWCP_ROUND = 2, + DWMWCP_ROUNDSMALL = 3 +} DWM_WINDOW_CORNER_PREFERENCE; + +// Use this constant to reset any window part colors to the system default behavior +#define DWMWA_COLOR_DEFAULT 0xFFFFFFFF + +// Use this constant to specify that a window part should not be rendered +#define DWMWA_COLOR_NONE 0xFFFFFFFE + +#endif + + +extern "C" +JNIEXPORT jboolean JNICALL Java_com_formdev_flatlaf_ui_FlatNativeWindowsLibrary_setWindowCornerPreference + ( JNIEnv* env, jclass cls, jlong hwnd, jint cornerPreference ) +{ + if( hwnd == 0 ) + return FALSE; + + DWM_WINDOW_CORNER_PREFERENCE attr = (DWM_WINDOW_CORNER_PREFERENCE) cornerPreference; + return ::DwmSetWindowAttribute( reinterpret_cast( hwnd ), DWMWA_WINDOW_CORNER_PREFERENCE, &attr, sizeof( attr ) ) == S_OK; +} + +extern "C" +JNIEXPORT jboolean JNICALL Java_com_formdev_flatlaf_ui_FlatNativeWindowsLibrary_setWindowBorderColor + ( JNIEnv* env, jclass cls, jlong hwnd, jint red, jint green, jint blue ) +{ + if( hwnd == 0 ) + return FALSE; + + COLORREF attr; + if( red == -1 ) + attr = DWMWA_COLOR_DEFAULT; + else if( red == -2 ) + attr = DWMWA_COLOR_NONE; + else + attr = RGB( red, green, blue ); + return ::DwmSetWindowAttribute( reinterpret_cast( hwnd ), DWMWA_BORDER_COLOR, &attr, sizeof( attr ) ) == S_OK; +} diff --git a/flatlaf-natives/flatlaf-natives-windows/src/main/headers/com_formdev_flatlaf_ui_FlatNativeWindowsLibrary.h b/flatlaf-natives/flatlaf-natives-windows/src/main/headers/com_formdev_flatlaf_ui_FlatNativeWindowsLibrary.h new file mode 100644 index 00000000..921c7a99 --- /dev/null +++ b/flatlaf-natives/flatlaf-natives-windows/src/main/headers/com_formdev_flatlaf_ui_FlatNativeWindowsLibrary.h @@ -0,0 +1,53 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class com_formdev_flatlaf_ui_FlatNativeWindowsLibrary */ + +#ifndef _Included_com_formdev_flatlaf_ui_FlatNativeWindowsLibrary +#define _Included_com_formdev_flatlaf_ui_FlatNativeWindowsLibrary +#ifdef __cplusplus +extern "C" { +#endif +#undef com_formdev_flatlaf_ui_FlatNativeWindowsLibrary_DWMWCP_DEFAULT +#define com_formdev_flatlaf_ui_FlatNativeWindowsLibrary_DWMWCP_DEFAULT 0L +#undef com_formdev_flatlaf_ui_FlatNativeWindowsLibrary_DWMWCP_DONOTROUND +#define com_formdev_flatlaf_ui_FlatNativeWindowsLibrary_DWMWCP_DONOTROUND 1L +#undef com_formdev_flatlaf_ui_FlatNativeWindowsLibrary_DWMWCP_ROUND +#define com_formdev_flatlaf_ui_FlatNativeWindowsLibrary_DWMWCP_ROUND 2L +#undef com_formdev_flatlaf_ui_FlatNativeWindowsLibrary_DWMWCP_ROUNDSMALL +#define com_formdev_flatlaf_ui_FlatNativeWindowsLibrary_DWMWCP_ROUNDSMALL 3L +/* + * Class: com_formdev_flatlaf_ui_FlatNativeWindowsLibrary + * Method: getOSBuildNumberImpl + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_com_formdev_flatlaf_ui_FlatNativeWindowsLibrary_getOSBuildNumberImpl + (JNIEnv *, jclass); + +/* + * Class: com_formdev_flatlaf_ui_FlatNativeWindowsLibrary + * Method: getHWND + * Signature: (Ljava/awt/Window;)J + */ +JNIEXPORT jlong JNICALL Java_com_formdev_flatlaf_ui_FlatNativeWindowsLibrary_getHWND + (JNIEnv *, jclass, jobject); + +/* + * Class: com_formdev_flatlaf_ui_FlatNativeWindowsLibrary + * Method: setWindowCornerPreference + * Signature: (JI)Z + */ +JNIEXPORT jboolean JNICALL Java_com_formdev_flatlaf_ui_FlatNativeWindowsLibrary_setWindowCornerPreference + (JNIEnv *, jclass, jlong, jint); + +/* + * Class: com_formdev_flatlaf_ui_FlatNativeWindowsLibrary + * Method: setWindowBorderColor + * Signature: (JIII)Z + */ +JNIEXPORT jboolean JNICALL Java_com_formdev_flatlaf_ui_FlatNativeWindowsLibrary_setWindowBorderColor + (JNIEnv *, jclass, jlong, jint, jint, jint); + +#ifdef __cplusplus +} +#endif +#endif From 9014435d4d79d1981ca73314545c79379ae3eb79 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Fri, 27 Jan 2023 15:00:11 +0100 Subject: [PATCH 2/2] Windows 11: made rounded popup border configurable via UI properties and client property --- CHANGELOG.md | 2 + .../formdev/flatlaf/FlatClientProperties.java | 19 +++++ .../formdev/flatlaf/ui/FlatPopupFactory.java | 80 +++++++++++++++---- .../formdev/flatlaf/ui/FlatPopupMenuUI.java | 4 + .../com/formdev/flatlaf/FlatLaf.properties | 8 ++ .../flatlaf/themes/FlatMacDarkLaf.properties | 2 + .../flatlaf/themes/FlatMacLightLaf.properties | 2 + .../dumps/uidefaults/FlatDarkLaf_1.8.0.txt | 4 + .../dumps/uidefaults/FlatLightLaf_1.8.0.txt | 4 + .../dumps/uidefaults/FlatMacDarkLaf_1.8.0.txt | 4 + .../uidefaults/FlatMacLightLaf_1.8.0.txt | 4 + .../dumps/uidefaults/FlatTestLaf_1.8.0.txt | 4 + .../flatlaf/themeeditor/FlatLafUIKeys.txt | 4 + 13 files changed, 126 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b909a04e..40c7c8d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ FlatLaf Change Log #### New features and improvements +- Windows 11: Popups (`JPopupMenu`, `JComboBox`, `JToolTip`, etc.) now use + native Windows 11 rounded borders and drop shadows. - Fonts: - Added **Roboto Mono** (https://fonts.google.com/specimen/Roboto+Mono). (PR #639, issue #638) diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java index 6bbd3afe..ee16de4c 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java @@ -268,6 +268,25 @@ public interface FlatClientProperties //---- Popup -------------------------------------------------------------- + /** + * Specifies the popup border corner radius if the component is shown in a popup + * or if the component is the owner of another component that is shown in a popup. + *

+ * Note that this is not available on all platforms since it requires special support. + * Supported platforms: + *

+ * Windows 11 (x86 or x86_64): Only two corner radiuses are supported + * by the OS: {@code DWMWCP_ROUND} is 8px and {@code DWMWCP_ROUNDSMALL} is 4px. + * If this value is {@code 1 - 4}, then {@code DWMWCP_ROUNDSMALL} is used. + * If it is {@code >= 5}, then {@code DWMWCP_ROUND} is used. + *

+ * Component {@link javax.swing.JComponent}
+ * Value type {@link java.lang.Integer}
+ * + * @since 3.1 + */ + String POPUP_BORDER_CORNER_RADIUS = "Popup.borderCornerRadius"; + /** * Specifies whether a drop shadow is painted if the component is shown in a popup * or if the component is the owner of another component that is shown in a popup. diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupFactory.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupFactory.java index 1ea34982..cb0f4f3d 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupFactory.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupFactory.java @@ -43,6 +43,7 @@ import java.lang.reflect.Method; import javax.swing.JComponent; import javax.swing.JLayeredPane; import javax.swing.JPanel; +import javax.swing.JPopupMenu; import javax.swing.JToolTip; import javax.swing.JWindow; import javax.swing.Popup; @@ -54,6 +55,7 @@ import javax.swing.UIManager; import javax.swing.border.Border; import javax.swing.border.EmptyBorder; import javax.swing.border.LineBorder; +import javax.swing.plaf.basic.BasicComboPopup; import com.formdev.flatlaf.FlatClientProperties; import com.formdev.flatlaf.util.SystemInfo; import com.formdev.flatlaf.util.UIScale; @@ -91,10 +93,13 @@ public class FlatPopupFactory return new NonFlashingPopup( getPopupForScreenOfOwner( owner, contents, x, y, true ), contents ); // Windows 11 with FlatLaf native library can use rounded corners and shows drop shadow for heavy weight popups - if( SystemInfo.isWindows_11_orLater && FlatNativeWindowsLibrary.isLoaded() ) { + int borderCornerRadius; + if( isWindows11BorderSupported() && + (borderCornerRadius = getBorderCornerRadius( owner, contents )) > 0 ) + { NonFlashingPopup popup = new NonFlashingPopup( getPopupForScreenOfOwner( owner, contents, x, y, true ), contents ); if( popup.popupWindow != null ) - setupWindows11Border( popup.popupWindow, contents ); + setupWindows11Border( popup.popupWindow, contents, borderCornerRadius ); return popup; } @@ -176,19 +181,39 @@ public class FlatPopupFactory } private boolean isOptionEnabled( Component owner, Component contents, String clientKey, String uiKey ) { - if( owner instanceof JComponent ) { - Boolean b = FlatClientProperties.clientPropertyBooleanStrict( (JComponent) owner, clientKey, null ); - if( b != null ) - return b; + Object value = getOption( owner, contents, clientKey, uiKey ); + return (value instanceof Boolean) ? (Boolean) value : false; + } + + private int getBorderCornerRadius( Component owner, Component contents ) { + String uiKey = + (contents instanceof BasicComboPopup) ? "ComboBox.borderCornerRadius" : + (contents instanceof JPopupMenu) ? "PopupMenu.borderCornerRadius" : + (contents instanceof JToolTip) ? "ToolTip.borderCornerRadius" : + "Popup.borderCornerRadius"; + + Object value = getOption( owner, contents, FlatClientProperties.POPUP_BORDER_CORNER_RADIUS, uiKey ); + return (value instanceof Integer) ? (Integer) value : 0; + } + + /** + * Get option from: + *

    + *
  1. client property {@code clientKey} of {@code owner} + *
  2. client property {@code clientKey} of {@code contents} + *
  3. UI property {@code uiKey} + *
+ */ + private Object getOption( Component owner, Component contents, String clientKey, String uiKey ) { + for( Component c : new Component[] { owner, contents } ) { + if( c instanceof JComponent ) { + Object value = ((JComponent)c).getClientProperty( clientKey ); + if( value != null ) + return value; + } } - if( contents instanceof JComponent ) { - Boolean b = FlatClientProperties.clientPropertyBooleanStrict( (JComponent) contents, clientKey, null ); - if( b != null ) - return b; - } - - return UIManager.getBoolean( uiKey ); + return UIManager.get( uiKey ); } /** @@ -310,7 +335,11 @@ public class FlatPopupFactory ((JComponent)owner).getToolTipLocation( me ) != null; } - private static void setupWindows11Border( Window popupWindow, Component contents ) { + private static boolean isWindows11BorderSupported() { + return SystemInfo.isWindows_11_orLater && FlatNativeWindowsLibrary.isLoaded(); + } + + private static void setupWindows11Border( Window popupWindow, Component contents, int borderCornerRadius ) { // make sure that the Windows 11 window is created if( !popupWindow.isDisplayable() ) popupWindow.addNotify(); @@ -319,7 +348,10 @@ public class FlatPopupFactory long hwnd = FlatNativeWindowsLibrary.getHWND( popupWindow ); // set corner preference - FlatNativeWindowsLibrary.setWindowCornerPreference( hwnd, FlatNativeWindowsLibrary.DWMWCP_ROUNDSMALL ); + int cornerPreference = (borderCornerRadius <= 4) + ? FlatNativeWindowsLibrary.DWMWCP_ROUNDSMALL // 4px + : FlatNativeWindowsLibrary.DWMWCP_ROUND; // 8px + FlatNativeWindowsLibrary.setWindowCornerPreference( hwnd, cornerPreference ); // set border color int red = -1; // use system default color @@ -347,6 +379,16 @@ public class FlatPopupFactory FlatNativeWindowsLibrary.setWindowBorderColor( hwnd, red, green, blue ); } + private static void resetWindows11Border( Window popupWindow ) { + // get window handle + long hwnd = FlatNativeWindowsLibrary.getHWND( popupWindow ); + if( hwnd == 0 ) + return; + + // reset corner preference + FlatNativeWindowsLibrary.setWindowCornerPreference( hwnd, FlatNativeWindowsLibrary.DWMWCP_DONOTROUND ); + } + //---- class NonFlashingPopup --------------------------------------------- private class NonFlashingPopup @@ -478,6 +520,14 @@ public class FlatPopupFactory oldDropShadowWindowBackground = dropShadowWindow.getBackground(); dropShadowWindow.setBackground( new Color( 0, true ) ); } + + // Windows 11: reset corner preference on reused heavy weight popups + if( isWindows11BorderSupported() ) { + resetWindows11Border( popupWindow ); + if( dropShadowWindow != null ) + resetWindows11Border( dropShadowWindow ); + } + } else { mediumWeightPanel = (Panel) SwingUtilities.getAncestorOfClass( Panel.class, contents ); if( mediumWeightPanel != null ) { diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupMenuUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupMenuUI.java index 7e24ea32..1ade7a7a 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupMenuUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPopupMenuUI.java @@ -67,6 +67,7 @@ import javax.swing.plaf.basic.BasicComboPopup; import javax.swing.plaf.basic.BasicMenuItemUI; import javax.swing.plaf.basic.BasicPopupMenuUI; import javax.swing.plaf.basic.DefaultMenuLayout; +import com.formdev.flatlaf.FlatClientProperties; import com.formdev.flatlaf.ui.FlatStylingSupport.Styleable; import com.formdev.flatlaf.ui.FlatStylingSupport.StyleableUI; import com.formdev.flatlaf.util.LoggingFacade; @@ -297,6 +298,9 @@ public class FlatPopupMenuUI popup.addMenuKeyListener( this ); updateArrowButtons(); + + putClientProperty( FlatClientProperties.POPUP_BORDER_CORNER_RADIUS, + UIManager.getInt( "PopupMenu.borderCornerRadius" ) ); } void scroll( int unitsToScroll ) { diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties index 76334d80..358c3cec 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties @@ -288,6 +288,7 @@ ComboBox.buttonPressedArrowColor = @buttonPressedArrowColor ComboBox.popupInsets = 0,0,0,0 ComboBox.selectionInsets = 0,0,0,0 ComboBox.selectionArc = 0 +ComboBox.borderCornerRadius = $Popup.borderCornerRadius #---- Component ---- @@ -503,6 +504,7 @@ PasswordField.revealIcon = com.formdev.flatlaf.icons.FlatRevealIcon #---- Popup ---- +Popup.borderCornerRadius = 4 Popup.dropShadowPainted = true Popup.dropShadowInsets = -4,-4,4,4 @@ -511,6 +513,7 @@ Popup.dropShadowInsets = -4,-4,4,4 PopupMenu.border = com.formdev.flatlaf.ui.FlatPopupMenuBorder PopupMenu.borderInsets = 4,1,4,1 +PopupMenu.borderCornerRadius = $Popup.borderCornerRadius PopupMenu.background = @menuBackground PopupMenu.scrollArrowColor = @buttonArrowColor @@ -880,6 +883,11 @@ ToolBar.spacingBorder = $Button.toolbar.spacingInsets ToolTipManager.enableToolTipMode = activeApplication +#---- ToolTip ---- + +ToolTip.borderCornerRadius = $Popup.borderCornerRadius + + #---- Tree ---- Tree.border = 1,1,1,1 diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/themes/FlatMacDarkLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/themes/FlatMacDarkLaf.properties index 53374035..6dc08502 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/themes/FlatMacDarkLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/themes/FlatMacDarkLaf.properties @@ -149,6 +149,7 @@ ComboBox.selectionBackground = @menuSelectionBackground ComboBox.popupInsets = 5,0,5,0 ComboBox.selectionInsets = 0,5,0,5 ComboBox.selectionArc = 8 +ComboBox.borderCornerRadius = 8 #---- Component ---- @@ -205,6 +206,7 @@ PasswordField.selectionForeground = @textSelectionForeground #---- PopupMenu ---- PopupMenu.borderInsets = 6,1,6,1 +PopupMenu.borderCornerRadius = 8 #---- ProgressBar ---- diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/themes/FlatMacLightLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/themes/FlatMacLightLaf.properties index 5a411a85..fd9c1ef4 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/themes/FlatMacLightLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/themes/FlatMacLightLaf.properties @@ -150,6 +150,7 @@ ComboBox.selectionBackground = @menuSelectionBackground ComboBox.popupInsets = 5,0,5,0 ComboBox.selectionInsets = 0,5,0,5 ComboBox.selectionArc = 8 +ComboBox.borderCornerRadius = 8 #---- Component ---- @@ -206,6 +207,7 @@ PasswordField.selectionForeground = @textSelectionForeground #---- PopupMenu ---- PopupMenu.borderInsets = 6,1,6,1 +PopupMenu.borderCornerRadius = 8 #---- ProgressBar ---- diff --git a/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt index 307b0774..e3dd8733 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt @@ -198,6 +198,7 @@ ColumnControlButton.iconColor #a8a8a8 HSL 0 0 66 javax.swing.plaf.Colo ComboBox.background #46494b HSL 204 3 28 javax.swing.plaf.ColorUIResource [UI] ComboBox.border [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatRoundBorder [UI] +ComboBox.borderCornerRadius 4 ComboBox.buttonArrowColor #9b9b9b HSL 0 0 61 javax.swing.plaf.ColorUIResource [UI] ComboBox.buttonBackground #46494b HSL 204 3 28 javax.swing.plaf.ColorUIResource [UI] ComboBox.buttonDarkShadow #7a7d7f HSL 204 2 49 javax.swing.plaf.ColorUIResource [UI] @@ -734,6 +735,7 @@ PasswordFieldUI com.formdev.flatlaf.ui.FlatPasswordFieldUI #---- Popup ---- +Popup.borderCornerRadius 4 Popup.dropShadowColor #000000 HSL 0 0 0 javax.swing.plaf.ColorUIResource [UI] Popup.dropShadowInsets -4,-4,4,4 javax.swing.plaf.InsetsUIResource [UI] Popup.dropShadowOpacity 0.25 @@ -745,6 +747,7 @@ Popup.dropShadowPainted true PopupMenu.background #303234 HSL 210 4 20 javax.swing.plaf.ColorUIResource [UI] PopupMenu.border [lazy] 4,1,4,1 false com.formdev.flatlaf.ui.FlatPopupMenuBorder [UI] lineColor=#5d6061 HSL 195 2 37 javax.swing.plaf.ColorUIResource [UI] lineThickness=1.000000 PopupMenu.borderColor #5d6061 HSL 195 2 37 javax.swing.plaf.ColorUIResource [UI] +PopupMenu.borderCornerRadius 4 PopupMenu.borderInsets 4,1,4,1 javax.swing.plaf.InsetsUIResource [UI] PopupMenu.consumeEventOnClose false PopupMenu.font [active] $defaultFont [UI] @@ -1345,6 +1348,7 @@ ToolBarUI com.formdev.flatlaf.ui.FlatToolBarUI ToolTip.background #1e2021 HSL 200 5 12 javax.swing.plaf.ColorUIResource [UI] ToolTip.border [lazy] 4,6,4,6 false com.formdev.flatlaf.ui.FlatEmptyBorder [UI] +ToolTip.borderCornerRadius 4 ToolTip.font [active] $defaultFont [UI] ToolTip.foreground #bbbbbb HSL 0 0 73 javax.swing.plaf.ColorUIResource [UI] diff --git a/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt index 61deb998..cc96e871 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt @@ -202,6 +202,7 @@ ColumnControlButton.iconColor #737373 HSL 0 0 45 javax.swing.plaf.Colo ComboBox.background #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI] ComboBox.border [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatRoundBorder [UI] +ComboBox.borderCornerRadius 4 ComboBox.buttonArrowColor #666666 HSL 0 0 40 javax.swing.plaf.ColorUIResource [UI] ComboBox.buttonBackground #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI] ComboBox.buttonDarkShadow #9c9c9c HSL 0 0 61 javax.swing.plaf.ColorUIResource [UI] @@ -739,6 +740,7 @@ PasswordFieldUI com.formdev.flatlaf.ui.FlatPasswordFieldUI #---- Popup ---- +Popup.borderCornerRadius 4 Popup.dropShadowColor #000000 HSL 0 0 0 javax.swing.plaf.ColorUIResource [UI] Popup.dropShadowInsets -4,-4,4,4 javax.swing.plaf.InsetsUIResource [UI] Popup.dropShadowOpacity 0.15 @@ -750,6 +752,7 @@ Popup.dropShadowPainted true PopupMenu.background #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI] PopupMenu.border [lazy] 4,1,4,1 false com.formdev.flatlaf.ui.FlatPopupMenuBorder [UI] lineColor=#aeaeae HSL 0 0 68 javax.swing.plaf.ColorUIResource [UI] lineThickness=1.000000 PopupMenu.borderColor #aeaeae HSL 0 0 68 javax.swing.plaf.ColorUIResource [UI] +PopupMenu.borderCornerRadius 4 PopupMenu.borderInsets 4,1,4,1 javax.swing.plaf.InsetsUIResource [UI] PopupMenu.consumeEventOnClose false PopupMenu.font [active] $defaultFont [UI] @@ -1350,6 +1353,7 @@ ToolBarUI com.formdev.flatlaf.ui.FlatToolBarUI ToolTip.background #fafafa HSL 0 0 98 javax.swing.plaf.ColorUIResource [UI] ToolTip.border [lazy] 4,6,4,6 false com.formdev.flatlaf.ui.FlatLineBorder [UI] lineColor=#919191 HSL 0 0 57 javax.swing.plaf.ColorUIResource [UI] lineThickness=1.000000 +ToolTip.borderCornerRadius 4 ToolTip.font [active] $defaultFont [UI] ToolTip.foreground #000000 HSL 0 0 0 javax.swing.plaf.ColorUIResource [UI] diff --git a/flatlaf-testing/dumps/uidefaults/FlatMacDarkLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatMacDarkLaf_1.8.0.txt index 616ee024..d5ce84ef 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatMacDarkLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatMacDarkLaf_1.8.0.txt @@ -202,6 +202,7 @@ ColumnControlButton.iconColor #c7c7c7 HSL 0 0 78 javax.swing.plaf.Colo ComboBox.background #565656 HSL 0 0 34 javax.swing.plaf.ColorUIResource [UI] ComboBox.border [lazy] 3,3,3,3 false com.formdev.flatlaf.ui.FlatRoundBorder [UI] +ComboBox.borderCornerRadius 8 ComboBox.buttonArrowColor #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI] ComboBox.buttonBackground #007aff HSL 211 100 50 javax.swing.plaf.ColorUIResource [UI] ComboBox.buttonDarkShadow #ffffff19 10% HSLA 0 0 100 10 javax.swing.plaf.ColorUIResource [UI] @@ -742,6 +743,7 @@ PasswordFieldUI com.formdev.flatlaf.ui.FlatPasswordFieldUI #---- Popup ---- +Popup.borderCornerRadius 4 Popup.dropShadowColor #000000 HSL 0 0 0 javax.swing.plaf.ColorUIResource [UI] Popup.dropShadowInsets -4,-4,4,4 javax.swing.plaf.InsetsUIResource [UI] Popup.dropShadowOpacity 0.25 @@ -753,6 +755,7 @@ Popup.dropShadowPainted true PopupMenu.background #323232 HSL 0 0 20 javax.swing.plaf.ColorUIResource [UI] PopupMenu.border [lazy] 6,1,6,1 false com.formdev.flatlaf.ui.FlatPopupMenuBorder [UI] lineColor=#444444 HSL 0 0 27 javax.swing.plaf.ColorUIResource [UI] lineThickness=1.000000 PopupMenu.borderColor #444444 HSL 0 0 27 javax.swing.plaf.ColorUIResource [UI] +PopupMenu.borderCornerRadius 8 PopupMenu.borderInsets 6,1,6,1 javax.swing.plaf.InsetsUIResource [UI] PopupMenu.consumeEventOnClose false PopupMenu.font [active] $defaultFont [UI] @@ -1355,6 +1358,7 @@ ToolBarUI com.formdev.flatlaf.ui.FlatToolBarUI ToolTip.background #0f0f0f HSL 0 0 6 javax.swing.plaf.ColorUIResource [UI] ToolTip.border [lazy] 4,6,4,6 false com.formdev.flatlaf.ui.FlatEmptyBorder [UI] +ToolTip.borderCornerRadius 4 ToolTip.font [active] $defaultFont [UI] ToolTip.foreground #dddddd HSL 0 0 87 javax.swing.plaf.ColorUIResource [UI] diff --git a/flatlaf-testing/dumps/uidefaults/FlatMacLightLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatMacLightLaf_1.8.0.txt index 842358d5..5e310c45 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatMacLightLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatMacLightLaf_1.8.0.txt @@ -207,6 +207,7 @@ ColumnControlButton.iconColor #888888 HSL 0 0 53 javax.swing.plaf.Colo ComboBox.background #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI] ComboBox.border [lazy] 3,3,3,3 false com.formdev.flatlaf.ui.FlatRoundBorder [UI] +ComboBox.borderCornerRadius 8 ComboBox.buttonArrowColor #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI] ComboBox.buttonBackground #007aff HSL 211 100 50 javax.swing.plaf.ColorUIResource [UI] ComboBox.buttonDarkShadow #00000026 15% HSLA 0 0 0 15 javax.swing.plaf.ColorUIResource [UI] @@ -746,6 +747,7 @@ PasswordFieldUI com.formdev.flatlaf.ui.FlatPasswordFieldUI #---- Popup ---- +Popup.borderCornerRadius 4 Popup.dropShadowColor #000000 HSL 0 0 0 javax.swing.plaf.ColorUIResource [UI] Popup.dropShadowInsets -4,-4,4,4 javax.swing.plaf.InsetsUIResource [UI] Popup.dropShadowOpacity 0.15 @@ -757,6 +759,7 @@ Popup.dropShadowPainted true PopupMenu.background #ececec HSL 0 0 93 javax.swing.plaf.ColorUIResource [UI] PopupMenu.border [lazy] 6,1,6,1 false com.formdev.flatlaf.ui.FlatPopupMenuBorder [UI] lineColor=#b1b1b1 HSL 0 0 69 javax.swing.plaf.ColorUIResource [UI] lineThickness=1.000000 PopupMenu.borderColor #b1b1b1 HSL 0 0 69 javax.swing.plaf.ColorUIResource [UI] +PopupMenu.borderCornerRadius 8 PopupMenu.borderInsets 6,1,6,1 javax.swing.plaf.InsetsUIResource [UI] PopupMenu.consumeEventOnClose false PopupMenu.font [active] $defaultFont [UI] @@ -1359,6 +1362,7 @@ ToolBarUI com.formdev.flatlaf.ui.FlatToolBarUI ToolTip.background #fefefe HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI] ToolTip.border [lazy] 4,6,4,6 false com.formdev.flatlaf.ui.FlatLineBorder [UI] lineColor=#949494 HSL 0 0 58 javax.swing.plaf.ColorUIResource [UI] lineThickness=1.000000 +ToolTip.borderCornerRadius 4 ToolTip.font [active] $defaultFont [UI] ToolTip.foreground #262626 HSL 0 0 15 javax.swing.plaf.ColorUIResource [UI] diff --git a/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt index d7364c28..b4d6568c 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt @@ -220,6 +220,7 @@ ColumnControlButton.actionIcon [lazy] 10,10 com.formdev.flatlaf.swingx.icons. ComboBox.background #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI] ComboBox.border [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatRoundBorder [UI] +ComboBox.borderCornerRadius 4 ComboBox.buttonArrowColor #666666 HSL 0 0 40 javax.swing.plaf.ColorUIResource [UI] ComboBox.buttonBackground #f0f0f0 HSL 0 0 94 javax.swing.plaf.ColorUIResource [UI] ComboBox.buttonDarkShadow #696969 HSL 0 0 41 javax.swing.plaf.ColorUIResource [UI] @@ -765,6 +766,7 @@ PasswordFieldUI com.formdev.flatlaf.ui.FlatPasswordFieldUI #---- Popup ---- +Popup.borderCornerRadius 4 Popup.dropShadowColor #00ff00 HSL 120 100 50 javax.swing.plaf.ColorUIResource [UI] Popup.dropShadowInsets -6,6,6,6 javax.swing.plaf.InsetsUIResource [UI] Popup.dropShadowOpacity 0.5 @@ -776,6 +778,7 @@ Popup.dropShadowPainted true PopupMenu.background #ffffff HSL 0 0 100 javax.swing.plaf.ColorUIResource [UI] PopupMenu.border [lazy] 4,1,4,1 false com.formdev.flatlaf.ui.FlatPopupMenuBorder [UI] lineColor=#0000ff HSL 240 100 50 javax.swing.plaf.ColorUIResource [UI] lineThickness=1.000000 PopupMenu.borderColor #0000ff HSL 240 100 50 javax.swing.plaf.ColorUIResource [UI] +PopupMenu.borderCornerRadius 4 PopupMenu.borderInsets 4,1,4,1 javax.swing.plaf.InsetsUIResource [UI] PopupMenu.consumeEventOnClose false PopupMenu.font [active] $defaultFont [UI] @@ -1395,6 +1398,7 @@ ToolBarUI com.formdev.flatlaf.ui.FlatToolBarUI ToolTip.background #eeeeff HSL 240 100 97 javax.swing.plaf.ColorUIResource [UI] ToolTip.border [lazy] line: #000000 HSL 0 0 0 java.awt.Color 1 false 1,1,1,1 true javax.swing.plaf.BorderUIResource$LineBorderUIResource [UI] +ToolTip.borderCornerRadius 4 ToolTip.font [active] $defaultFont [UI] ToolTip.foreground #ff0000 HSL 0 100 50 javax.swing.plaf.ColorUIResource [UI] diff --git a/flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/FlatLafUIKeys.txt b/flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/FlatLafUIKeys.txt index 954961ee..fc593aa5 100644 --- a/flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/FlatLafUIKeys.txt +++ b/flatlaf-theme-editor/src/main/resources/com/formdev/flatlaf/themeeditor/FlatLafUIKeys.txt @@ -181,6 +181,7 @@ ColumnControlButton.iconColor ComboBox.ancestorInputMap ComboBox.background ComboBox.border +ComboBox.borderCornerRadius ComboBox.buttonArrowColor ComboBox.buttonBackground ComboBox.buttonDarkShadow @@ -594,6 +595,7 @@ PasswordField.selectionForeground PasswordField.showCapsLock PasswordField.showRevealButton PasswordFieldUI +Popup.borderCornerRadius Popup.dropShadowColor Popup.dropShadowInsets Popup.dropShadowOpacity @@ -601,6 +603,7 @@ Popup.dropShadowPainted PopupMenu.background PopupMenu.border PopupMenu.borderColor +PopupMenu.borderCornerRadius PopupMenu.borderInsets PopupMenu.consumeEventOnClose PopupMenu.font @@ -1104,6 +1107,7 @@ ToolBarSeparatorUI ToolBarUI ToolTip.background ToolTip.border +ToolTip.borderCornerRadius ToolTip.font ToolTip.foreground ToolTipManager.enableToolTipMode