feat: help i'm struggling

This commit is contained in:
Emi Boucly 2025-03-18 20:28:21 +01:00
parent 041f721ed5
commit a8b2a0ced6
4 changed files with 25 additions and 23 deletions

View file

@ -11,7 +11,7 @@ public class HelloApplication extends Application {
@Override @Override
public void start(Stage stage) throws IOException { public void start(Stage stage) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hello-view.fxml")); FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hello-view.fxml"));
Scene scene = new Scene(fxmlLoader.load(), 320, 240); Scene scene = new Scene(fxmlLoader.load(), 1280, 720);
stage.setTitle("PixelWriter"); stage.setTitle("PixelWriter");
stage.setScene(scene); stage.setScene(scene);
stage.show(); stage.show();

View file

@ -50,7 +50,7 @@ public class HelloController implements Initializable {
loadButton.setOnAction(this::onActionLoad); loadButton.setOnAction(this::onActionLoad);
newCanvasButton.setOnAction(this::onActionCreateCanvas); newCanvasButton.setOnAction(this::onActionCreateCanvas);
scrollPane.setOnScroll(this::onScrollZoom); scrollPane.setOnScroll(this::onScrollZoom);
scrollPane.getParent().setOnKeyPressed(this::onActionKeyPressed); scrollPane.setOnKeyPressed(this::onActionKeyPressed);
brushSizeLabel.textProperty().bind(brushSizeSlider.valueProperty().asString()); brushSizeLabel.textProperty().bind(brushSizeSlider.valueProperty().asString());
setupCanvas(); setupCanvas();
scrollPane.prefViewportHeightProperty().bind(pane.layoutYProperty()); scrollPane.prefViewportHeightProperty().bind(pane.layoutYProperty());

View file

@ -27,11 +27,11 @@ public class NewCanvasController implements Initializable {
createButton.setOnAction(this::create); createButton.setOnAction(this::create);
createButton.disableProperty().bind(validator.containsErrorsProperty()); createButton.disableProperty().bind(validator.containsErrorsProperty());
cancelButton.setOnAction(this::close); cancelButton.setOnAction(this::close);
widthTextField.setOnAction(this::create);
validator.createCheck() validator.createCheck()
.decorates(createButton) .decorates(createButton)
.dependsOn("width", heightTextField.textProperty()) .dependsOn("width", widthTextField.textProperty())
.dependsOn("height", widthTextField.textProperty()) .dependsOn("height", heightTextField.textProperty())
.withMethod(this::checkWidthHeight) .withMethod(this::checkWidthHeight)
.immediate(); .immediate();
} }

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.canvas.Canvas?> <?import javafx.scene.canvas.Canvas?>
<?import javafx.scene.control.Label?> <?import javafx.scene.control.Label?>
<?import javafx.scene.control.Menu?> <?import javafx.scene.control.Menu?>
@ -70,28 +71,29 @@
<Slider fx:id="brushSizeSlider" blockIncrement="1.0" majorTickUnit="5.0" max="10.0" minorTickCount="9" showTickLabels="true" showTickMarks="true" snapToTicks="true" GridPane.rowIndex="1" /> <Slider fx:id="brushSizeSlider" blockIncrement="1.0" majorTickUnit="5.0" max="10.0" minorTickCount="9" showTickLabels="true" showTickMarks="true" snapToTicks="true" GridPane.rowIndex="1" />
</children> </children>
</GridPane> </GridPane>
</children></VBox> </children>
<GridPane> <padding>
<columnConstraints> <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
<ColumnConstraints hgrow="ALWAYS" /> </padding></VBox>
<ColumnConstraints hgrow="SOMETIMES" /> <ScrollPane fx:id="scrollPane" cache="true" cacheHint="QUALITY" depthTest="ENABLE" hbarPolicy="ALWAYS" style="-fx-background-color: #666666; -fx-background: #666666;" vbarPolicy="ALWAYS">
</columnConstraints> <content>
<rowConstraints> <GridPane>
<RowConstraints vgrow="ALWAYS" /> <columnConstraints>
<RowConstraints vgrow="SOMETIMES" /> <ColumnConstraints halignment="CENTER" hgrow="SOMETIMES" minWidth="10.0" />
</rowConstraints> </columnConstraints>
<children> <rowConstraints>
<ScrollPane fx:id="scrollPane" cache="true" cacheHint="QUALITY" depthTest="ENABLE" hbarPolicy="ALWAYS" style="-fx-background-color: #666666; -fx-background: #666666;" vbarPolicy="ALWAYS" GridPane.hgrow="ALWAYS" GridPane.vgrow="ALWAYS"> <RowConstraints minHeight="10.0" valignment="CENTER" vgrow="SOMETIMES" />
<content> </rowConstraints>
<children>
<Pane fx:id="pane"> <Pane fx:id="pane">
<children> <children>
<Canvas fx:id="drawingCanvas" height="600.0" nodeOrientation="INHERIT" width="800.0" /> <Canvas fx:id="drawingCanvas" height="600.0" nodeOrientation="INHERIT" translateX="10.0" translateY="10.0" width="800.0" />
</children> </children>
</Pane> </Pane>
</content> </children>
</ScrollPane> </GridPane>
</children> </content>
</GridPane> </ScrollPane>
</items> </items>
</SplitPane> </SplitPane>
</children> </children>