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

macOS: native rounded borders for popups #772

Merged
merged 3 commits into from Dec 14, 2023
Merged

Conversation

DevCharly
Copy link
Collaborator

This PR enables native macOS rounded borders (including drop shadow) for popups. (issue #715)

PopupMenu:

image

ComboBox (macOS theme):

image

ToolTip:

image

The rounded popup borders are enabled by default for all themes and
use the same UI properties and client property as in PR #643.

Additionally there are 4 new UI properties:

PopupMenu.roundedBorderWidth
ComboBox.roundedBorderWidth
ToolTip.roundedBorderWidth
Popup.roundedBorderWidth

The first three are used for JPopupMenu, JComboBox and JToolTip.
The last one is used for other components shown as popup via PopupFactory.getPopup().

There is also a client property Popup.roundedBorderWidth that allows changing rounded border width for specific popups.

roundedBorderWidth is used only on macOS.
The default value is 0 for light themes (because macOS always adds a thin dark border),
and 1 for dark themes (to add a lighter border to the popup, otherwise it is difficult to distinguish the popup from the background).

@DevCharly
Copy link
Collaborator Author

I've tested this only on macOS 10.14 (Intel) and on 13.3 (M1).

Would be great to get some feedback whether this works without problems on other macOS versions.

Prebuilt binaries are available here (requires GitHub login):
https://github.com/JFormDesigner/FlatLaf/suites/18901204850/artifacts/1103682403

- removed `FlatNativeMacLibrary.getWindowPtr()` because it is too dangerous to use `windowPtr` (which is `NSWindow*`) in Java (using invalid window pointer would crash app)
- made `getNSWindow()` 20x faster
- catch exceptions in `getNSWindow()`
- digitally signed dylibs
@DevCharly DevCharly merged commit 4e19169 into main Dec 14, 2023
9 checks passed
@DevCharly DevCharly added this to the 3.3 milestone Dec 14, 2023
@DevCharly DevCharly deleted the macos-rounded-popups branch December 14, 2023 22:59
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

1 participant