Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
No longer use menu buttons from FXML
- Loading branch information
Showing
5 changed files
with
88 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package org.chorusmc.chorus.menubar | ||
|
||
import javafx.scene.input.KeyCode | ||
import javafx.scene.input.KeyCodeCombination | ||
import javafx.scene.input.KeyCombination | ||
import org.chorusmc.chorus.menubar.edit.* | ||
import org.chorusmc.chorus.menubar.file.* | ||
import org.chorusmc.chorus.menubar.help.* | ||
|
||
/** | ||
* @author Gio | ||
*/ | ||
object MenuBar { | ||
|
||
val menuBarButtons | ||
get() = listOf( | ||
MenuBarMainButton( | ||
"file", | ||
listOf( | ||
MenuBarButton("file.new", CreateFile(), KeyCodeCombination(KeyCode.N, KeyCombination.CONTROL_DOWN)), | ||
MenuBarButton("file.open", Open(), KeyCodeCombination(KeyCode.O, KeyCombination.CONTROL_DOWN)), | ||
MenuBarButton("file.sftp", OpenFromSFTP(), KeyCodeCombination(KeyCode.O, KeyCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN)), | ||
MenuBarButton("file.ftp", OpenFromFTP()), | ||
MenuBarButton("file.refresh", Refresh(), KeyCodeCombination(KeyCode.F5)), | ||
MenuBarButton("file.test", TestFile(), KeyCodeCombination(KeyCode.T, KeyCombination.CONTROL_DOWN)), | ||
MenuBarButton("file.settings", Settings(), KeyCodeCombination(KeyCode.S, KeyCombination.CONTROL_DOWN, KeyCombination.ALT_DOWN)) | ||
) | ||
), | ||
MenuBarMainButton( | ||
"edit", | ||
listOf( | ||
MenuBarButton("edit.undo", Undo()), | ||
MenuBarButton("edit.redo", Redo()), | ||
MenuBarButton("edit.copy", Copy()), | ||
MenuBarButton("edit.paste", Paste()), | ||
MenuBarButton("edit.search", Search(), KeyCodeCombination(KeyCode.F, KeyCombination.CONTROL_DOWN)), | ||
MenuBarButton("edit.replace", Replace(), KeyCodeCombination(KeyCode.R, KeyCombination.CONTROL_DOWN)), | ||
MenuBarButton("edit.variables", Variables(), KeyCodeCombination(KeyCode.V, KeyCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN)) | ||
) | ||
), | ||
MenuBarMainButton( | ||
"help", | ||
listOf( | ||
MenuBarButton("help.credits", Credits()), | ||
MenuBarButton("help.report_a_bug", ReportABug()), | ||
MenuBarButton("help.donate", Donate()), | ||
MenuBarButton("help.donators_list", DonatorsList()), | ||
MenuBarButton("help.license", License()), | ||
MenuBarButton("help.check_for_updates", CheckForUpdates()) | ||
) | ||
) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.chorusmc.chorus.menubar | ||
|
||
import javafx.scene.control.MenuItem | ||
import javafx.scene.input.KeyCodeCombination | ||
import org.chorusmc.chorus.editor.events.Events | ||
import org.chorusmc.chorus.util.translate | ||
|
||
/** | ||
* @author Gio | ||
*/ | ||
class MenuBarButton(translateKey: String, action: MenuBarAction, combination: KeyCodeCombination? = null) : MenuItem(translate("bar.$translateKey")) { | ||
|
||
init { | ||
if(combination != null) super.setAccelerator(combination) | ||
Events.getMenuActions().add(action) | ||
setOnAction {action.onAction()} | ||
disableProperty().bind(action.binding) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.chorusmc.chorus.menubar | ||
|
||
import javafx.scene.control.Menu | ||
import org.chorusmc.chorus.util.translate | ||
|
||
/** | ||
* @author Gio | ||
*/ | ||
class MenuBarMainButton(translateKey: String, buttons: List<MenuBarButton>) : Menu(translate("bar.$translateKey")) { | ||
|
||
init { | ||
items.addAll(buttons) | ||
} | ||
} |