From b29d43a7e34c973b13cee439bf8405580a5ff30a Mon Sep 17 00:00:00 2001 From: Victor Date: Sun, 10 Sep 2017 11:23:15 +0300 Subject: [PATCH] Ability to change editor font size --- .../com/annimon/hotarufx/ui/FontAwesome.java | 2 ++ .../ui/controller/EditorController.java | 17 +++++++++++++++++ app/src/main/resources/fxml/Editor.fxml | 19 +++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/app/src/main/java/com/annimon/hotarufx/ui/FontAwesome.java b/app/src/main/java/com/annimon/hotarufx/ui/FontAwesome.java index 207cb71..3ef3d7e 100644 --- a/app/src/main/java/com/annimon/hotarufx/ui/FontAwesome.java +++ b/app/src/main/java/com/annimon/hotarufx/ui/FontAwesome.java @@ -24,6 +24,8 @@ public enum FontAwesome { QUESTION_CIRCLE("\uf059", "question-circle"), REDO("\uf01e", "redo"), SCISSORS("\uf0c4", "scissors", "cut"), + SEARCH_PLUS("\uf00e", "search-plus"), + SEARCH_MINUS("\uf010", "search-minus"), UNDO("\uf0e2", "undo"); @Getter diff --git a/app/src/main/java/com/annimon/hotarufx/ui/controller/EditorController.java b/app/src/main/java/com/annimon/hotarufx/ui/controller/EditorController.java index e756016..d77b586 100644 --- a/app/src/main/java/com/annimon/hotarufx/ui/controller/EditorController.java +++ b/app/src/main/java/com/annimon/hotarufx/ui/controller/EditorController.java @@ -127,6 +127,23 @@ public class EditorController implements Initializable, DocumentListener { .isPresent(); } + @FXML + private void handleMenuIncreaseFontSize(ActionEvent event) { + changeFontSize(+1); + } + + @FXML + private void handleMenuDecreaseFontSize(ActionEvent event) { + changeFontSize(-1); + } + + private void changeFontSize(int delta) { + if (editor.getFont() == null) return; + val newSize = (int) editor.getFont().getSize() + delta; + if (8 > newSize || newSize > 40) return; + editor.setStyle("-fx-font-size: " + newSize + "px"); + } + @FXML private void handleMenuAbout(ActionEvent event) { val stage = new Stage(); diff --git a/app/src/main/resources/fxml/Editor.fxml b/app/src/main/resources/fxml/Editor.fxml index 670c14a..5dcc044 100644 --- a/app/src/main/resources/fxml/Editor.fxml +++ b/app/src/main/resources/fxml/Editor.fxml @@ -35,6 +35,8 @@ + + @@ -95,6 +97,23 @@ + + +