Class MacUtilities
java.lang.Object
org.tentackle.fx.MacUtilities
Utilities for Mac OS X.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected javafx.scene.image.ImageViewcreateImageView(org.kordamp.ikonli.javafx.FontIcon fontIcon) Creates anImageViewfrom aFontIcon.
The font icon is modified and must not be used anymore.protected javafx.scene.paint.ColorGets the color to render the system menu icons with.static MacUtilitiesThe singleton.protected voidobserveTheme(javafx.scene.control.MenuBar menuBar) Updates the system menu bars whenever the theme changes.
Registers the menu bar and subscribes to the theme properties on first invocation.protected javafx.scene.NodetoSystemGraphic(javafx.scene.Node graphic) Converts a menu graphic for the system menu.
FontIcons are rendered to anImageView.protected voidtoSystemMenu(javafx.scene.control.Menu menu) ConvertsFontIcons toImageViews.voidtoSystemMenuBar(javafx.scene.control.MenuBar menuBar) Installs a menubar as a system menu bar.
Used on macOS to convertFontIcons toImageViews since font icons cannot be displayed in the system menu.
The menu bar is kept up to date: since the images are rendered for the current theme, they are re-created whenever the light/dark mode or the theme changes.protected StringtoWebColor(javafx.scene.paint.Color color) Converts a color to its CSS representation.protected voidRe-creates the images of all system menu bars for the current theme.
-
Constructor Details
-
MacUtilities
public MacUtilities()Creates the MacUtilities.
-
-
Method Details
-
getInstance
-
toSystemMenuBar
public void toSystemMenuBar(javafx.scene.control.MenuBar menuBar) Installs a menubar as a system menu bar.
Used on macOS to convertFontIcons toImageViews since font icons cannot be displayed in the system menu.
The menu bar is kept up to date: since the images are rendered for the current theme, they are re-created whenever the light/dark mode or the theme changes.- Parameters:
menuBar- the menu bar
-
toSystemMenu
protected void toSystemMenu(javafx.scene.control.Menu menu) ConvertsFontIcons toImageViews.- Parameters:
menu- the menu
-
toSystemGraphic
protected javafx.scene.Node toSystemGraphic(javafx.scene.Node graphic) Converts a menu graphic for the system menu.
FontIcons are rendered to anImageView. An image view created by a former invocation is rendered again, since the color depends on the current theme. All other graphics are left unchanged.- Parameters:
graphic- the menu graphic, null if none- Returns:
- the graphic to display in the system menu, null if none
-
observeTheme
protected void observeTheme(javafx.scene.control.MenuBar menuBar) Updates the system menu bars whenever the theme changes.
Registers the menu bar and subscribes to the theme properties on first invocation.- Parameters:
menuBar- the system menu bar
-
updateSystemMenuBars
protected void updateSystemMenuBars()Re-creates the images of all system menu bars for the current theme. -
createImageView
protected javafx.scene.image.ImageView createImageView(org.kordamp.ikonli.javafx.FontIcon fontIcon) Creates anImageViewfrom aFontIcon.
The font icon is modified and must not be used anymore.- Parameters:
fontIcon- the font icon- Returns:
- the image view
-
getIconColor
protected javafx.scene.paint.Color getIconColor()Gets the color to render the system menu icons with.- Returns:
- the icon color
-
toWebColor
Converts a color to its CSS representation.- Parameters:
color- the color- Returns:
- the CSS color function
-