Skip to content

Commit

Permalink
Merge branch 'hide-and-show-welcome-window'
Browse files Browse the repository at this point in the history
  • Loading branch information
denneyl2711 committed Jul 25, 2024
2 parents 56e1634 + 43a6939 commit 042b8e9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 36 deletions.
37 changes: 3 additions & 34 deletions src/kintsugi3d/builder/javafx/ProjectIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,42 +210,11 @@ private static <ControllerType> ControllerType makeWindow(Window parentWindow, S
return fxmlLoader.getController();
}

private <ControllerType> 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> ControllerType makeWindow(Window parentWindow, String title, Flag flag, String urlString) throws IOException
{
return makeWindow(parentWindow, title, flag, Scene::new, urlString);
}

private static <ControllerType> 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();
Expand Down Expand Up @@ -654,10 +623,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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,6 @@ private void help_userManual()
public void openAboutModal()
{
ProjectIO.getInstance().openAboutModal(window);

}

private <ControllerType> ControllerType makeWindow(String title, Flag flag, String urlString) throws IOException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 042b8e9

Please sign in to comment.