Skip to content

Commit 885ec01

Browse files
committed
Add About window
1 parent 8af109c commit 885ec01

File tree

4 files changed

+112
-0
lines changed

4 files changed

+112
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package edu.wpi.grip.ui;
2+
3+
import javafx.fxml.FXML;
4+
import javafx.scene.Parent;
5+
import javafx.scene.text.Text;
6+
import javafx.stage.Stage;
7+
8+
public class AboutDialogController {
9+
10+
@FXML
11+
private Parent root;
12+
13+
@FXML
14+
private Text versionNumberText;
15+
16+
@FXML
17+
void initialize() {
18+
assert versionNumberText != null : "fx:id=\"versionNumberText\" was not injected: check your FXML file 'AboutDialog.fxml'.";
19+
20+
versionNumberText.setText("Version " + edu.wpi.grip.core.Main.class.getPackage().getImplementationVersion());
21+
}
22+
}
23+

ui/src/main/java/edu/wpi/grip/ui/MainWindowController.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
import edu.wpi.grip.ui.util.DPIUtility;
1717
import javafx.application.Platform;
1818
import javafx.fxml.FXML;
19+
import javafx.fxml.FXMLLoader;
1920
import javafx.scene.Parent;
21+
import javafx.scene.Scene;
2022
import javafx.scene.control.ButtonType;
2123
import javafx.scene.control.Dialog;
2224
import javafx.scene.control.SplitPane;
@@ -26,6 +28,7 @@
2628
import javafx.scene.layout.Region;
2729
import javafx.stage.FileChooser;
2830
import javafx.stage.FileChooser.ExtensionFilter;
31+
import javafx.stage.Stage;
2932
import org.controlsfx.control.StatusBar;
3033

3134
import javax.inject.Inject;
@@ -209,6 +212,15 @@ public void showProjectSettingsEditor() {
209212
});
210213
}
211214

215+
@FXML
216+
public void showProjectAboutDialog() throws IOException {
217+
Parent about = FXMLLoader.load(Main.class.getResource("AboutDialog.fxml"));
218+
Stage aboutDialogStage = new Stage();
219+
aboutDialogStage.setScene(new Scene(about));
220+
aboutDialogStage.setAlwaysOnTop(true);
221+
aboutDialogStage.show();
222+
}
223+
212224
@FXML
213225
public void quit() {
214226
if (showConfirmationDialogAndWait()) {
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<?import javafx.geometry.Insets?>
4+
<?import javafx.scene.image.Image?>
5+
<?import javafx.scene.image.ImageView?>
6+
<?import javafx.scene.layout.HBox?>
7+
<?import javafx.scene.layout.Pane?>
8+
<?import javafx.scene.layout.VBox?>
9+
<?import javafx.scene.text.Font?>
10+
<?import javafx.scene.text.Text?>
11+
12+
<VBox fx:id="root" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="330.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="edu.wpi.grip.ui.AboutDialogController">
13+
<children>
14+
<Pane VBox.vgrow="ALWAYS" />
15+
<HBox>
16+
<children>
17+
<Pane HBox.hgrow="ALWAYS" />
18+
<ImageView fitHeight="156.0" fitWidth="156.0" pickOnBounds="true" preserveRatio="true">
19+
<image>
20+
<Image url="@icons/grip.png" />
21+
</image>
22+
</ImageView>
23+
<Pane HBox.hgrow="ALWAYS" />
24+
<VBox HBox.hgrow="ALWAYS">
25+
<children>
26+
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="GRIP">
27+
<font>
28+
<Font name="Roboto Bold" size="64.0" />
29+
</font>
30+
</Text>
31+
<Text fx:id="versionNumberText" strokeType="OUTSIDE" strokeWidth="0.0" text="Version 0.0.0">
32+
<font>
33+
<Font name="Roboto Regular" size="14.0" />
34+
</font>
35+
</Text>
36+
</children>
37+
</VBox>
38+
<Pane HBox.hgrow="ALWAYS" />
39+
</children>
40+
</HBox>
41+
<Pane VBox.vgrow="ALWAYS">
42+
<VBox.margin>
43+
<Insets />
44+
</VBox.margin>
45+
</Pane>
46+
<HBox>
47+
<children>
48+
<Pane HBox.hgrow="ALWAYS" />
49+
<Text fill="#818181" strokeType="OUTSIDE" strokeWidth="0.0" text="GRIP is licensed under a 3 Clause BSD License">
50+
<font>
51+
<Font name="Roboto Regular" size="12.0" />
52+
</font></Text>
53+
<Pane HBox.hgrow="ALWAYS" />
54+
</children>
55+
<padding>
56+
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
57+
</padding>
58+
</HBox>
59+
</children>
60+
</VBox>

ui/src/main/resources/edu/wpi/grip/ui/MainWindow.fxml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,23 @@
132132
</graphic>
133133
</MenuItem>
134134
</Menu>
135+
<Menu text="Help">
136+
<MenuItem text="About" onAction="#showProjectAboutDialog">
137+
<graphic>
138+
<ImageView styleClass="menu-graphic">
139+
<fitWidth>
140+
<DPIUtility fx:constant="SMALL_ICON_SIZE"/>
141+
</fitWidth>
142+
<fitHeight>
143+
<DPIUtility fx:constant="SMALL_ICON_SIZE"/>
144+
</fitHeight>
145+
<image>
146+
<Image url="@icons/grip.png"/>
147+
</image>
148+
</ImageView>
149+
</graphic>
150+
</MenuItem>
151+
</Menu>
135152
</MenuBar>
136153
<SplitPane dividerPositions="0.6" orientation="VERTICAL" VBox.vgrow="ALWAYS">
137154
<items>

0 commit comments

Comments
 (0)