From 6468415592ac728fba87bdbdfc1ff4e313f665a1 Mon Sep 17 00:00:00 2001 From: Victor Date: Wed, 6 Sep 2017 22:04:06 +0300 Subject: [PATCH] Add about window --- .../com/annimon/hotarufx/ui/FontAwesome.java | 21 ++++-- .../com/annimon/hotarufx/ui/LineText.java | 62 +++++++++++++++++ .../ui/controller/EditorController.java | 21 ++++++ app/src/main/resources/fxml/About.fxml | 69 +++++++++++++++++++ app/src/main/resources/styles/about.css | 35 ++++++++++ 5 files changed, 203 insertions(+), 5 deletions(-) create mode 100644 app/src/main/java/com/annimon/hotarufx/ui/LineText.java create mode 100644 app/src/main/resources/fxml/About.fxml create mode 100644 app/src/main/resources/styles/about.css 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 6daf900..b84c1cb 100644 --- a/app/src/main/java/com/annimon/hotarufx/ui/FontAwesome.java +++ b/app/src/main/java/com/annimon/hotarufx/ui/FontAwesome.java @@ -14,18 +14,29 @@ public class FontAwesome { } public static final String - UNDO = "\uf0e2", - REDO = "\uf01e", CLIPBOARD = "\uf0ea", - PLAY = "\uf04b" + COPYRIGHT = "\uf1f9", + FONT_AWESOME = "\uf2b4", + GITHUB = "\uf09b", + GLOBE = "\uf0ac", + PENCIL = "\uf040", + PLAY = "\uf04b", + REDO = "\uf01e", + UNDO = "\uf0e2" ; static final Map MAPPING; static { MAPPING = new HashMap<>(); - MAPPING.put("undo", UNDO); - MAPPING.put("redo", REDO); MAPPING.put("clipboard", CLIPBOARD); + MAPPING.put("copyright", COPYRIGHT); + MAPPING.put("earth", GLOBE); + MAPPING.put("font-awesome", FONT_AWESOME); + MAPPING.put("github", GITHUB); + MAPPING.put("globe", GLOBE); + MAPPING.put("pencil", PENCIL); MAPPING.put("play", PLAY); + MAPPING.put("redo", REDO); + MAPPING.put("undo", UNDO); } } diff --git a/app/src/main/java/com/annimon/hotarufx/ui/LineText.java b/app/src/main/java/com/annimon/hotarufx/ui/LineText.java new file mode 100644 index 0000000..9589815 --- /dev/null +++ b/app/src/main/java/com/annimon/hotarufx/ui/LineText.java @@ -0,0 +1,62 @@ +package com.annimon.hotarufx.ui; + +import javafx.beans.binding.Bindings; +import javafx.beans.property.BooleanProperty; +import javafx.beans.property.SimpleBooleanProperty; +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.StringProperty; +import javafx.scene.text.Text; + +public class LineText extends Text { + + private final BooleanProperty endLineBreak = new SimpleBooleanProperty(true); + private final StringProperty content = new SimpleStringProperty(""); + + public LineText() { + init(); + } + + public LineText(String text) { + super(text); + init(); + } + + public LineText(double x, double y, String text) { + super(x, y, text); + init(); + } + + private void init() { + getStyleClass().add("linetext"); + setContent(getText()); + textProperty().bind( + Bindings.when(endLineBreak) + .then(content.concat("\n")) + .otherwise(content) + ); + } + + public String getContent() { + return content.get(); + } + + public StringProperty contentProperty() { + return content; + } + + public void setContent(String content) { + this.content.set(content.replace("\\n", "\n")); + } + + public boolean isEndLineBreak() { + return endLineBreak.get(); + } + + public BooleanProperty endLineBreakProperty() { + return endLineBreak; + } + + public void setEndLineBreak(boolean endLineBreak) { + this.endLineBreak.set(endLineBreak); + } +} 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 ec08ba5..64350b0 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 @@ -23,10 +23,13 @@ import javafx.application.Platform; import javafx.beans.binding.Bindings; import javafx.event.ActionEvent; import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; +import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.TextArea; import javafx.scene.control.TitledPane; +import javafx.stage.Modality; import javafx.stage.Stage; import lombok.val; import org.fxmisc.richtext.CodeArea; @@ -89,6 +92,24 @@ public class EditorController implements Initializable, DocumentListener { @FXML private void handleMenuAbout(ActionEvent event) { + val stage = new Stage(); + stage.setTitle("About"); + stage.setResizable(false); + stage.initOwner(primaryStage); + stage.initModality(Modality.WINDOW_MODAL); + try { + val loader = new FXMLLoader(getClass().getResource("/fxml/About.fxml")); + val scene = new Scene(loader.load()); + scene.getStylesheets().addAll( + getClass().getResource("/styles/theme-dark.css").toExternalForm(), + getClass().getResource("/styles/about.css").toExternalForm() + ); + stage.setScene(scene); + stage.show(); + } catch (Exception e) { + logError("Unable to open about window"); + logPane.setExpanded(true); + } } @FXML diff --git a/app/src/main/resources/fxml/About.fxml b/app/src/main/resources/fxml/About.fxml new file mode 100644 index 0000000..6f9147a --- /dev/null +++ b/app/src/main/resources/fxml/About.fxml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + https://github.com/aNNiMON/HotaruFX + + + https://annimon.com/ + + + + + + + + + + + + + + + + http://fontawesome.io + + + + + + + + + Copyright (c) 2013-2017, Tomas Mikula and contributors\n + All rights reserved.\n + \n + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n + \n + 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n + \n + 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n + \n + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + + diff --git a/app/src/main/resources/styles/about.css b/app/src/main/resources/styles/about.css new file mode 100644 index 0000000..81025bc --- /dev/null +++ b/app/src/main/resources/styles/about.css @@ -0,0 +1,35 @@ +.linetext { + -fx-fill: #CCCCCC; +} +.title { + -fx-font-weight: bold; + -fx-font-size: 4em; + -fx-effect: dropshadow(three-pass-box, rgba(100,183,3,0.8), 18, 0, 0.5, 0.25); + -fx-fill: #FDFD42; +} +.h2 { + -fx-font-weight: bold; + -fx-font-size: 1.6em; +} +.h3 { + -fx-font-weight: bold; + -fx-font-size: 1.3em; +} +.h4 { + -fx-font-size: 1.19em; +} +.copyright { + -fx-font-size: 1em; + -fx-font-family: monospace; + -fx-background: #454545; + -fx-fill: #AAAAAA; +} +.bold { + -fx-font-weight: bold; +} +.italic { + -fx-font-style: italic; +} +.fa-icon { + -fx-fill: #fff; +}