Skip to content

Commit

Permalink
macOS native bar (MCreator#4279)
Browse files Browse the repository at this point in the history
* Adapted look to macOS

* Inverted equals to fix issue

* Single variable to detect menu bar type

---------

Co-authored-by: KlemenDEV <[email protected]>
  • Loading branch information
Max094Reikeb and KlemenDEV authored Oct 20, 2023
1 parent 0c1d9c7 commit 49b9b60
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions src/main/java/net/mcreator/ui/MainMenuBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package net.mcreator.ui;

import net.mcreator.io.OS;
import net.mcreator.ui.component.SocialButtons;
import net.mcreator.ui.component.util.ComponentUtils;
import net.mcreator.ui.ide.CodeEditorView;
Expand Down Expand Up @@ -45,30 +46,32 @@ public class MainMenuBar extends JMenuBar {
public MainMenuBar(MCreator mcreator) {
this.mcreator = mcreator;

setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, (Color) UIManager.get("MCreatorLAF.BLACK_ACCENT")));

JMenu logo = new JMenu(" MCreator");
logo.setMnemonic('M');
logo.setIcon(new ImageIcon(ImageUtils.resizeAA(UIRES.getAppIcon().getImage(), 14, 14)));
boolean macOSscreenMenuBar =
OS.getOS() == OS.MAC && "true".equals(System.getProperty("apple.laf.useScreenMenuBar"));

logo.add(mcreator.actionRegistry.mcreatorWebsite);
logo.add(mcreator.actionRegistry.mcreatorCommunity);
SocialButtons socialButtons = new SocialButtons();
socialButtons.setBorder(BorderFactory.createEmptyBorder(3, 29, 7, 0));
logo.add(socialButtons);
logo.addSeparator();
logo.add(mcreator.actionRegistry.donate);
logo.addSeparator();
logo.add(mcreator.actionRegistry.mcreatorPublish);
setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, (Color) UIManager.get("MCreatorLAF.BLACK_ACCENT")));

add(logo);
if (!macOSscreenMenuBar) {
JMenu logo = new JMenu(" MCreator");
logo.setMnemonic('M');
logo.setIcon(new ImageIcon(ImageUtils.resizeAA(UIRES.getAppIcon().getImage(), 14, 14)));
logo.add(mcreator.actionRegistry.mcreatorWebsite);
logo.add(mcreator.actionRegistry.mcreatorCommunity);
SocialButtons socialButtons = new SocialButtons();
socialButtons.setBorder(BorderFactory.createEmptyBorder(3, 29, 7, 0));
logo.add(socialButtons);
logo.addSeparator();
logo.add(mcreator.actionRegistry.donate);
logo.addSeparator();
logo.add(mcreator.actionRegistry.mcreatorPublish);
add(logo);
}

JMenu file = L10N.menu("menubar.file");
file.setMnemonic('F');
file.add(mcreator.actionRegistry.newWorkspace);
file.addSeparator();
file.add(mcreator.actionRegistry.openWorkspace);

if (mcreator.getApplication() != null) {
JMenu recentWorkspacesList = new JMenu(L10N.t("menubar.file.recent"));
int number = 0;
Expand Down Expand Up @@ -138,7 +141,6 @@ public MainMenuBar(MCreator mcreator) {

JMenu workspace = L10N.menu("menubar.workspace");
workspace.setMnemonic('S');

workspace.addSeparator();
workspace.add(mcreator.actionRegistry.setCreativeTabItemOrder);
workspace.add(mcreator.actionRegistry.injectDefaultTags);
Expand All @@ -149,7 +151,6 @@ public MainMenuBar(MCreator mcreator) {
workspace.addSeparator();
workspace.add(mcreator.actionRegistry.exportToDeobfJAR);
workspace.add(mcreator.actionRegistry.exportToJAR);

add(workspace);

JMenu resources = L10N.menu("menubar.resources");
Expand Down Expand Up @@ -233,6 +234,12 @@ public MainMenuBar(MCreator mcreator) {
help.add(mcreator.actionRegistry.help);
help.add(mcreator.actionRegistry.support);
help.add(mcreator.actionRegistry.knowledgeBase);
if (macOSscreenMenuBar) {
help.addSeparator();
help.add(mcreator.actionRegistry.mcreatorWebsite);
help.add(mcreator.actionRegistry.mcreatorCommunity);
help.add(mcreator.actionRegistry.mcreatorPublish);
}
help.addSeparator();
help.add(mcreator.actionRegistry.showShortcuts);
help.addSeparator();
Expand Down

0 comments on commit 49b9b60

Please sign in to comment.