From 78d706d2e49972c40da5acefdad9c133bbdbba8e Mon Sep 17 00:00:00 2001 From: denneyl2711 Date: Thu, 25 Jul 2024 11:07:40 -0500 Subject: [PATCH 1/2] Welcome window hides and shows according to About window opening and closing. --- src/kintsugi3d/builder/javafx/ProjectIO.java | 31 ++----------------- .../controllers/menubar/AboutController.java | 2 ++ .../menubar/MenubarController.java | 1 - .../scene/WelcomeWindowController.java | 2 +- 4 files changed, 6 insertions(+), 30 deletions(-) diff --git a/src/kintsugi3d/builder/javafx/ProjectIO.java b/src/kintsugi3d/builder/javafx/ProjectIO.java index 1dad3cee..0951ab1c 100644 --- a/src/kintsugi3d/builder/javafx/ProjectIO.java +++ b/src/kintsugi3d/builder/javafx/ProjectIO.java @@ -210,31 +210,6 @@ private static ControllerType makeWindow(Window parentWindow, S return fxmlLoader.getController(); } - private ControllerType makeWindow(String title, Flag flag, Window window, String urlString) throws IOException - { - URL url = MenubarController.class.getClassLoader().getResource(urlString); - if (url == null) - { - throw new FileNotFoundException(urlString); - } - FXMLLoader fxmlLoader = new FXMLLoader(url); - Parent root = fxmlLoader.load(); - Stage stage = new Stage(); - stage.getIcons().add(new Image(new File("Kintsugi3D-icon.png").toURI().toURL().toString())); - stage.setTitle(title); - stage.setScene(new Scene(root)); - stage.initOwner(window); - - stage.setResizable(false); - - flag.set(true); - stage.addEventHandler(WindowEvent.WINDOW_CLOSE_REQUEST, param -> flag.set(false)); - - stage.show(); - - return fxmlLoader.getController(); - } - private static ControllerType makeWindow(Window parentWindow, String title, Flag flag, String urlString) throws IOException { return makeWindow(parentWindow, title, flag, Scene::new, urlString); @@ -654,10 +629,10 @@ public void openAboutModal(Window window) { try { - AboutController aboutController = makeWindow( - "About Kintsugi 3D Builder", aboutWindowOpen, window, "fxml/menubar/About.fxml"); + AboutController aboutController = makeWindow(window, + "About Kintsugi 3D Builder", aboutWindowOpen, "fxml/menubar/About.fxml"); aboutController.init(); - + WelcomeWindowController.getInstance().hide(); } catch (Exception e) { diff --git a/src/kintsugi3d/builder/javafx/controllers/menubar/AboutController.java b/src/kintsugi3d/builder/javafx/controllers/menubar/AboutController.java index dc0a74c2..4f3fb8cb 100644 --- a/src/kintsugi3d/builder/javafx/controllers/menubar/AboutController.java +++ b/src/kintsugi3d/builder/javafx/controllers/menubar/AboutController.java @@ -15,6 +15,7 @@ import javafx.scene.control.ScrollPane; import javafx.scene.shape.Rectangle; import javafx.scene.text.Text; +import kintsugi3d.builder.javafx.controllers.scene.WelcomeWindowController; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,6 +43,7 @@ public void init(){ backgroundRectangle.setWidth(scrollPane.getWidth()); backgroundRectangle.setHeight(aboutText.getLayoutBounds().getHeight() + 20); // +20 to account for margins + aboutText.getScene().getWindow().setOnCloseRequest(e->WelcomeWindowController.getInstance().showIfNoModelLoaded()); } catch (IOException e) { diff --git a/src/kintsugi3d/builder/javafx/controllers/menubar/MenubarController.java b/src/kintsugi3d/builder/javafx/controllers/menubar/MenubarController.java index 415b12c6..85362d30 100644 --- a/src/kintsugi3d/builder/javafx/controllers/menubar/MenubarController.java +++ b/src/kintsugi3d/builder/javafx/controllers/menubar/MenubarController.java @@ -501,7 +501,6 @@ private void help_userManual() public void openAboutModal() { ProjectIO.getInstance().openAboutModal(window); - } private ControllerType makeWindow(String title, Flag flag, String urlString) throws IOException diff --git a/src/kintsugi3d/builder/javafx/controllers/scene/WelcomeWindowController.java b/src/kintsugi3d/builder/javafx/controllers/scene/WelcomeWindowController.java index 2eafd29c..74b910b6 100644 --- a/src/kintsugi3d/builder/javafx/controllers/scene/WelcomeWindowController.java +++ b/src/kintsugi3d/builder/javafx/controllers/scene/WelcomeWindowController.java @@ -158,7 +158,7 @@ public void openSystemSettingsModal() { } public void openAboutModal() { - ProjectIO.getInstance().openAboutModal(window); + ProjectIO.getInstance().openAboutModal(parentWindow); } public void addAccelerator(KeyCombination keyCodeCombo, Runnable r) { From 43a693987998c695f7cdb09a752a8ef5182e5de4 Mon Sep 17 00:00:00 2001 From: denneyl2711 Date: Thu, 25 Jul 2024 11:12:09 -0500 Subject: [PATCH 2/2] Removed another unused makeWindow(). --- src/kintsugi3d/builder/javafx/ProjectIO.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/kintsugi3d/builder/javafx/ProjectIO.java b/src/kintsugi3d/builder/javafx/ProjectIO.java index 0951ab1c..cbab24fd 100644 --- a/src/kintsugi3d/builder/javafx/ProjectIO.java +++ b/src/kintsugi3d/builder/javafx/ProjectIO.java @@ -215,12 +215,6 @@ private static ControllerType makeWindow(Window parentWindow, S return makeWindow(parentWindow, title, flag, Scene::new, urlString); } - private static ControllerType makeWindow( - Window parentWindow, String title, Flag flag, int width, int height, String urlString) throws IOException - { - return makeWindow(parentWindow, title, flag, root -> new Scene(root, width, height), urlString); - } - public boolean isCreateProjectWindowOpen() { return loaderWindowOpen.get();