Skip to content

Commit 5ef3bd6

Browse files
committed
Use CSS formating instead of Rectangle
1 parent 662d1fb commit 5ef3bd6

File tree

3 files changed

+33
-62
lines changed

3 files changed

+33
-62
lines changed

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

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
package edu.wpi.grip.ui;
22

33
import javafx.fxml.FXML;
4-
import javafx.scene.Cursor;
5-
import javafx.scene.Parent;
64
import javafx.scene.input.MouseEvent;
7-
import javafx.scene.paint.Color;
8-
import javafx.scene.shape.Rectangle;
95
import javafx.scene.text.Text;
106

117
import javax.inject.Inject;
@@ -15,54 +11,9 @@ public class AboutDialogController {
1511
@Inject
1612
private Main main;
1713

18-
@FXML
19-
private Parent root;
20-
2114
@FXML
2215
private Text versionNumberText;
2316

24-
@FXML
25-
private Rectangle githubRectangle;
26-
27-
@FXML
28-
private Text githubText;
29-
30-
@FXML
31-
private Rectangle documentationRectangle;
32-
33-
@FXML
34-
private Text documentationText;
35-
36-
private static final Color CLEAR_COLOR = new Color(0.0, 0.0, 0.0, 0.0);
37-
38-
@FXML
39-
void mouseEnteredDocumentationButton(MouseEvent event) {
40-
documentationRectangle.setFill(Color.GRAY);
41-
documentationText.setFill(Color.WHITE);
42-
root.getScene().setCursor(Cursor.HAND);
43-
}
44-
45-
@FXML
46-
void mouseEnteredGithubButton(MouseEvent event) {
47-
githubRectangle.setFill(Color.GRAY);
48-
githubText.setFill(Color.WHITE);
49-
root.getScene().setCursor(Cursor.HAND);
50-
}
51-
52-
@FXML
53-
void mouseExitedDocumentationButton(MouseEvent event) {
54-
documentationRectangle.setFill(CLEAR_COLOR);
55-
documentationText.setFill(Color.BLACK);
56-
root.getScene().setCursor(Cursor.DEFAULT);
57-
}
58-
59-
@FXML
60-
void mouseExitedGithubButton(MouseEvent event) {
61-
githubRectangle.setFill(CLEAR_COLOR);
62-
githubText.setFill(Color.BLACK);
63-
root.getScene().setCursor(Cursor.DEFAULT);
64-
}
65-
6617
@FXML
6718
void mousePressedDocumentationButton(MouseEvent event) {
6819
main.getHostServices().showDocument("http://wpilib.screenstepslive.com/s/4485/m/50711");
@@ -76,10 +27,6 @@ void mousePressedGithubButton(MouseEvent event) {
7627
@FXML
7728
void initialize() {
7829
assert versionNumberText != null : "fx:id=\"versionNumberText\" was not injected: check your FXML file 'AboutDialog.fxml'.";
79-
assert githubRectangle != null : "fx:id=\"githubRectangle\" was not injected: check your FXML file 'AboutDialog.fxml'.";
80-
assert githubText != null : "fx:id=\"githubText\" was not injected: check your FXML file 'AboutDialog.fxml'.";
81-
assert documentationRectangle != null : "fx:id=\"documentationRectangle\" was not injected: check your FXML file 'AboutDialog.fxml'.";
82-
assert documentationText != null : "fx:id=\"documentationText\" was not injected: check your FXML file 'AboutDialog.fxml'.";
8330

8431
versionNumberText.setText("Version " + edu.wpi.grip.core.Main.class.getPackage().getImplementationVersion());
8532
}

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

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
<?import javafx.scene.layout.Pane?>
88
<?import javafx.scene.layout.StackPane?>
99
<?import javafx.scene.layout.VBox?>
10-
<?import javafx.scene.shape.Rectangle?>
1110
<?import javafx.scene.text.Font?>
1211
<?import javafx.scene.text.Text?>
1312

14-
<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+
<VBox fx:id="root" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
14+
prefHeight="330.0" prefWidth="600.0" stylesheets="@GRIP.css" xmlns="http://javafx.com/javafx/8.0.65"
15+
xmlns:fx="http://javafx.com/fxml/1" fx:controller="edu.wpi.grip.ui.AboutDialogController">
1516
<children>
1617
<Pane VBox.vgrow="ALWAYS" />
1718
<HBox>
@@ -38,30 +39,43 @@
3839
<Pane VBox.vgrow="ALWAYS" />
3940
<HBox>
4041
<children>
41-
<StackPane onMouseEntered="#mouseEnteredGithubButton" onMouseExited="#mouseExitedGithubButton" onMousePressed="#mousePressedGithubButton">
42+
<StackPane onMousePressed="#mousePressedGithubButton" styleClass="about-button">
4243
<children>
43-
<Rectangle fx:id="githubRectangle" arcHeight="20.0" arcWidth="20.0" fill="#ffffff00" height="20.0" stroke="#ffffff00" strokeType="INSIDE" strokeWidth="0.0" width="65.0" />
44-
<Text fx:id="githubText" strokeType="OUTSIDE" strokeWidth="0.0" text="➔ Github">
44+
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="➔ Github">
4545
<font>
4646
<Font name="Roboto Regular" size="14.0" />
4747
</font>
4848
</Text>
4949
</children>
50+
<opaqueInsets>
51+
<Insets />
52+
</opaqueInsets>
53+
<HBox.margin>
54+
<Insets left="-3.0" />
55+
</HBox.margin>
56+
<padding>
57+
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
58+
</padding>
5059
</StackPane>
5160
</children>
5261
</HBox>
5362
<Pane VBox.vgrow="ALWAYS" />
5463
<HBox>
5564
<children>
56-
<StackPane onMouseEntered="#mouseEnteredDocumentationButton" onMouseExited="#mouseExitedDocumentationButton" onMousePressed="#mousePressedDocumentationButton">
65+
<StackPane onMousePressed="#mousePressedDocumentationButton" styleClass="about-button">
5766
<children>
58-
<Rectangle fx:id="documentationRectangle" arcHeight="20.0" arcWidth="20.0" fill="#ffffff00" height="20.0" stroke="#ffffff00" strokeType="INSIDE" strokeWidth="0.0" width="205.0" />
59-
<Text fx:id="documentationText" strokeType="OUTSIDE" strokeWidth="0.0" text="➔ ScreenSteps Documentation">
67+
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="➔ ScreenSteps Documentation">
6068
<font>
6169
<Font name="Roboto Regular" size="14.0" />
6270
</font>
6371
</Text>
6472
</children>
73+
<HBox.margin>
74+
<Insets left="-3.0" />
75+
</HBox.margin>
76+
<padding>
77+
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
78+
</padding>
6579
</StackPane>
6680
</children>
6781
</HBox>

ui/src/main/resources/edu/wpi/grip/ui/GRIP.css

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,4 +233,14 @@ VBox.sockets {
233233

234234
.info-label {
235235
-fx-font-weight: bold;
236-
}
236+
}
237+
238+
.about-button:hover {
239+
-fx-background-color: gray;
240+
-fx-background-radius: 12;
241+
-fx-cursor: hand;
242+
}
243+
244+
.about-button:hover Text {
245+
-fx-fill: white;
246+
}

0 commit comments

Comments
 (0)