Skip to content
This repository was archived by the owner on May 31, 2024. It is now read-only.

feat: Add About window #82

Merged
merged 3 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions examples/folie.cty
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
POS 50%, 50%
FOR i FROM 0 TO 3600 {
COLOR i MOD 255, (i * 2) MOD 255, (i * 3) MOD 255
FWD i
TURN 179.5
}
45 changes: 45 additions & 0 deletions src/main/java/fr/cyu/chromatynk/editor/AboutWindowController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package fr.cyu.chromatynk.editor;

import javafx.stage.Stage;
import javafx.fxml.FXML;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;

/**
* The controller for the About window.
* @author JordanViknar
* @see CodeEditorController
*/
public class AboutWindowController {
@FXML
private ImageView iconImageView;

private final Stage stage;

/**
* Initializes the About window controller.
* @param stage the stage to use
*/
@SuppressWarnings("exports")
public AboutWindowController(Stage stage) {
this.stage = stage;
}

/**
* Initializes the About window, setting the icon image.
*/
@FXML
public void initialize() {
// Load the icon
Image icon = new Image(getClass().getResourceAsStream("/icon.png"));
iconImageView.setImage(icon);
}

/**
* Closes the About window.
*/
@FXML
private void closeWindow() {
stage.close();
}
}
40 changes: 36 additions & 4 deletions src/main/java/fr/cyu/chromatynk/editor/CodeEditorController.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,6 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
graphicsContext.setFill(Color.WHITE);
graphicsContext.fillRect(0, 0, canvas.getWidth(), canvas.getHeight());

// Makes the bottom bar's background slightly darker
bottomBar.setStyle("-fx-background-color: rgba(0, 0, 0, 0.07);");

// Only show relevant UI when in step-by-step mode
stepByStepControls.setVisible(stepByStepCheckbox.isSelected());
stepByStepCheckbox.selectedProperty().addListener((observable, oldValue, newValue) -> {stepByStepControls.setVisible(newValue);});
Expand Down Expand Up @@ -351,11 +348,18 @@ public void clearCanvas() {
statusLabel.setText("Le dessin a été manuellement effacé.");
}

/**
* Wipes the canvas used for the cursors.
*/
private void clearCursorCanvas() {
GraphicsContext graphicsContext = cursorCanvas.getGraphicsContext2D();
graphicsContext.clearRect(0, 0, cursorCanvas.getWidth(), cursorCanvas.getHeight());
}

/**
* Opens the window used to change the size of the canvas.
* @param event
*/
@FXML
private void modifyCanvas(ActionEvent event) {
try {
Expand All @@ -365,7 +369,7 @@ private void modifyCanvas(ActionEvent event) {
Stage stage = new Stage();
fxmlLoader.setController(new ChangeCanvasSizeController(this, stage));
stage.initModality(Modality.APPLICATION_MODAL);
stage.setTitle("Changer la taille du canvas");
stage.setTitle("Changer la taille du canevas");
stage.setScene(new Scene(fxmlLoader.load()));
stage.setResizable(false);
stage.setMinWidth(200);
Expand All @@ -381,6 +385,34 @@ private void modifyCanvas(ActionEvent event) {
}
}

/**
* Opens the About window.
*/
@FXML
public void openAboutWindow() {
try {
// Prepare and load the FXML file
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/AboutWindow.fxml"));

Stage stage = new Stage();
fxmlLoader.setController(new AboutWindowController(stage));

stage.initModality(Modality.APPLICATION_MODAL);
stage.setTitle("À propos de Chromat'ynk");

stage.setScene(new Scene(fxmlLoader.load()));
stage.setResizable(false);

// Add icon
Image icon = new Image(getClass().getResourceAsStream("/icon.png"));
stage.getIcons().add(icon);

stage.show();
} catch (Exception e) {
e.printStackTrace();
}
}

/**
* Closes the application.
*/
Expand Down
47 changes: 47 additions & 0 deletions src/main/resources/AboutWindow.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.canvas.*?>
<?import javafx.scene.paint.*?>
<?import javafx.scene.effect.*?>
<?import javafx.scene.image.ImageView?>

<BorderPane xmlns:fx="http://javafx.com/fxml">
<padding><Insets topRightBottomLeft="10"/></padding>

<top>
<VBox alignment="CENTER" spacing="10">
<ImageView fx:id="iconImageView" fitWidth="80" fitHeight="80" preserveRatio="true"/>
<Label text="Chromat'ynk 1.0.0" style="-fx-font-size: 1.5em; -fx-font-weight: bold;"/>
</VBox>
</top>

<center>
<VBox alignment="CENTER" spacing="10">
<padding><Insets topRightBottomLeft="10"/></padding>

<Label wrapText="true" maxWidth="400" style="-fx-alignment: center; -fx-text-alignment: center;" text="Chromat'ynk permet à ses utilisateurs de dessiner des formes arbitraires sur un canevas en utilisant des instructions simples."/>

<Label text="Développé par :"/>
<GridPane hgap="10" vgap="10" alignment="CENTER" style="-fx-background-color: rgba(0, 0, 0, 0.07);">
<padding><Insets topRightBottomLeft="5"/></padding>

<Label text="Iltotore" GridPane.columnIndex="0"/>
<Label text="JordanViknar" GridPane.columnIndex="1"/>
<Label text="gorosumo" GridPane.columnIndex="2"/>
<Label text="LiliRoseGicquel" GridPane.columnIndex="0" GridPane.rowIndex="1"/>
<Label text="Harruki2k" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
</GridPane>
</VBox>
</center>

<bottom>
<HBox alignment="CENTER">
<padding><Insets topRightBottomLeft="5"/></padding>

<Button text="OK" onAction="#closeWindow"/>
</HBox>
</bottom>
</BorderPane>
2 changes: 1 addition & 1 deletion src/main/resources/ChangeCanvasSizeWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<GridPane xmlns:fx="http://javafx.com/fxml" alignment="CENTER" hgap="10" vgap="10">
<padding>
<Insets top="10" right="10" bottom="10" left="10"/>
<Insets topRightBottomLeft="10"/>
</padding>

<Label text="Longueur :"/>
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/CodeEditor.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<items>
<MenuItem text="Enregistrer sous" onAction="#saveImage"/>
<SeparatorMenuItem/>
<MenuItem text="Changer la taille du canvas" onAction="#modifyCanvas"/>
<MenuItem text="Changer la taille du canevas" onAction="#modifyCanvas"/>
<MenuItem text="Effacer" onAction="#clearCanvas"/>
</items>
</Menu>
Expand Down Expand Up @@ -57,7 +57,7 @@
</Menu>
<Menu text="Aide">
<items>
<MenuItem text="À propos"/>
<MenuItem text="À propos" onAction="#openAboutWindow"/>
</items>
</Menu>
</menus>
Expand Down Expand Up @@ -129,7 +129,7 @@
</center>

<bottom>
<HBox fx:id="bottomBar" spacing="10">
<HBox fx:id="bottomBar" spacing="10" style="-fx-background-color: rgba(0, 0, 0, 0.07);">
<padding>
<Insets topRightBottomLeft="10" />
</padding>
Expand Down