Skip to content

Commit

Permalink
Fix for menu items with and without icons were not aligned on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
ingokegel committed Nov 21, 2021
1 parent 36952c6 commit eef1f1d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
16 changes: 8 additions & 8 deletions modules/browser/src/main/kotlin/browser/BrowserFrame.kt
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ class BrowserFrame : JFrame() {
}
}

val setupClasspathAction = DefaultAction(getString("action.setup.class.path"), getString("action.setup.class.path.description")) {
val setupClasspathAction = DefaultAction(getString("action.setup.class.path"), getString("action.setup.class.path.description"), "") {
classpathSetupDialog.isVisible = true
}

val newWindowAction = DefaultAction(getString("action.new.window"), getString("action.new.window.description")) {
val newWindowAction = DefaultAction(getString("action.new.window"), getString("action.new.window.description"), "") {
saveWindowSettings()
BrowserFrame().isVisible = true
}.apply {
Expand All @@ -116,7 +116,7 @@ class BrowserFrame : JFrame() {
isEnabled = false
}

val newWorkspaceAction = DefaultAction(getString("action.new.workspace"), getString("action.new.workspace.description")) {
val newWorkspaceAction = DefaultAction(getString("action.new.workspace"), getString("action.new.workspace.description"), "") {
if (frameContent.closeAllTabs()) {
workspaceFile = null
config.clear()
Expand All @@ -142,25 +142,25 @@ class BrowserFrame : JFrame() {
}
}

val saveClassesAction = DefaultAction(getString("action.save.open.classes"), getString("action.save.open.classes.description")) {
val saveClassesAction = DefaultAction(getString("action.save.open.classes"), getString("action.save.open.classes.description"), "") {
if (saveClassesFileChooser.select()) {
frameContent.saveClassesToDirectory(saveClassesFileChooser.selectedFile)
}
}

val saveWorkspaceAsAction = DefaultAction(getString("action.save.workspace.as"), getString("action.save.workspace.as.description")) {
val saveWorkspaceAsAction = DefaultAction(getString("action.save.workspace.as"), getString("action.save.workspace.as.description"), "") {
saveWorkspace()
}.apply {
disabled()
}

val quitAction = DefaultAction(getString("action.quit")) {
val quitAction = DefaultAction(getString("action.quit"), "", "") {
if (prepareClose()) {
exit()
}
}

val closeAction = DefaultAction(getString("action.close.window")) {
val closeAction = DefaultAction(getString("action.close.window"), "", "") {
if (prepareClose()) {
isVisible = false
dispose()
Expand Down Expand Up @@ -212,7 +212,7 @@ class BrowserFrame : JFrame() {
GUIHelper.showURL("https://www.ej-technologies.com")
}

val aboutAction = DefaultAction(getString("action.about"), getString("action.about.description")) {
val aboutAction = DefaultAction(getString("action.about"), getString("action.about.description"), "") {
BrowserAboutDialog(this).isVisible = true
}

Expand Down
10 changes: 6 additions & 4 deletions modules/browser/src/main/kotlin/util/DefaultAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ class DefaultAction(

init {
if (iconFileName != null) {
putValue(SMALL_ICON, BrowserFrame.getSvgIcon(iconFileName, SMALL_ICON_SIZE))
putValue(LARGE_ICON_KEY, BrowserFrame.getSvgIcon(iconFileName, LARGE_ICON_SIZE))
} else {
putValue(SMALL_ICON, GUIHelper.ICON_EMPTY)
if (iconFileName.isEmpty()) {
putValue(SMALL_ICON, GUIHelper.ICON_EMPTY)
} else {
putValue(SMALL_ICON, BrowserFrame.getSvgIcon(iconFileName, SMALL_ICON_SIZE))
putValue(LARGE_ICON_KEY, BrowserFrame.getSvgIcon(iconFileName, LARGE_ICON_SIZE))
}
}
if (shortDescription != null) {
putValue(SHORT_DESCRIPTION, shortDescription)
Expand Down

0 comments on commit eef1f1d

Please sign in to comment.