Skip to content
Snippets Groups Projects
Commit 6f45718a authored by Edvard Granheim Harbo's avatar Edvard Granheim Harbo
Browse files

Merge branch 'MainView' into 'dev'

Changed the topbar into a button function in the menu

See merge request !24
parents 394d3490 f6461236
No related branches found
No related tags found
2 merge requests!54Final release,!24Changed the topbar into a button function in the menu
package edu.ntnu.idatt2003.mappevurderingprog2.views.Components;
import edu.ntnu.idatt2003.mappevurderingprog2.controllers.GameController;
import edu.ntnu.idatt2003.mappevurderingprog2.views.View;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
public class ExistingFractalsButton extends Button {
private final VBox transformationButtons;
private final Button backButton;
public ExistingFractalsButton(View view, GameController gameController, CreateNewFractal transformations) {
super("Choose Existing Fractals");
AffineTransformationButton affineButton = new AffineTransformationButton(view, view.getMainCanvas(), gameController);
JuliaTransformationButton juliaButton = new JuliaTransformationButton(view, view.getMainCanvas(), gameController);
backButton = new Button("Back");
backButton.setOnAction(event -> hideTransformationButtons());
transformationButtons = new VBox(10, affineButton, juliaButton, backButton);
transformationButtons.setVisible(false);
this.setOnAction(event -> toggleTransformationButtonsVisibility());
}
private void toggleTransformationButtonsVisibility() {
transformationButtons.setVisible(!transformationButtons.isVisible());
this.setVisible(false); // Hide "Choose Existing Fractals" button
}
private void hideTransformationButtons() {
transformationButtons.setVisible(false);
this.setVisible(true); // Show "Choose Existing Fractals" button
}
public VBox getTransformationButtons() {
return transformationButtons;
}
}
package edu.ntnu.idatt2003.mappevurderingprog2.views.Components;
import edu.ntnu.idatt2003.mappevurderingprog2.controllers.GameController;
import edu.ntnu.idatt2003.mappevurderingprog2.views.View;
import javafx.scene.control.ToolBar;
public class MainBar extends ToolBar {
private View view;
private GameController gameController; // Added GameController as a field
public MainBar(View view, GameController gameController) {
this.view = view;
this.gameController = gameController; // Initialize GameController
// Pass gameController to each button
AffineTransformationButton affineTransformationButton = new AffineTransformationButton(view, view.getMainCanvas(), gameController);
this.getItems().add(affineTransformationButton);
JuliaTransformationButton juliaTransformationButton = new JuliaTransformationButton(view, view.getMainCanvas(), gameController);
this.getItems().add(juliaTransformationButton);
}
}
\ No newline at end of file
package edu.ntnu.idatt2003.mappevurderingprog2.views.Components; package edu.ntnu.idatt2003.mappevurderingprog2.views.Components;
import edu.ntnu.idatt2003.mappevurderingprog2.controllers.GameController;
import edu.ntnu.idatt2003.mappevurderingprog2.utils.Size; import edu.ntnu.idatt2003.mappevurderingprog2.utils.Size;
import edu.ntnu.idatt2003.mappevurderingprog2.views.View;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.geometry.Insets; import javafx.geometry.Insets;
import javafx.geometry.Pos; import javafx.geometry.Pos;
...@@ -8,14 +10,17 @@ import javafx.scene.layout.VBox; ...@@ -8,14 +10,17 @@ import javafx.scene.layout.VBox;
public class Menu extends VBox { public class Menu extends VBox {
private final CreateNewFractal transformations = new CreateNewFractal(); private final CreateNewFractal transformations = new CreateNewFractal();
private ExistingFractalsButton existingFractalsButton;
public Menu() { public Menu(View view, GameController gameController) {
existingFractalsButton = new ExistingFractalsButton(view, gameController, transformations);
initializeMenu(); initializeMenu();
} }
private void initializeMenu() { private void initializeMenu() {
clearLeftBoxUI(); clearLeftBoxUI();
getChildren().addAll(createMenuLabel(),transformations.getTransformations()); getChildren().addAll(createMenuLabel(), transformations.getTransformations(), existingFractalsButton,
existingFractalsButton.getTransformationButtons());
setupMenu(); setupMenu();
} }
......
...@@ -2,14 +2,11 @@ package edu.ntnu.idatt2003.mappevurderingprog2.views; ...@@ -2,14 +2,11 @@ package edu.ntnu.idatt2003.mappevurderingprog2.views;
import edu.ntnu.idatt2003.mappevurderingprog2.controllers.GameController; import edu.ntnu.idatt2003.mappevurderingprog2.controllers.GameController;
import edu.ntnu.idatt2003.mappevurderingprog2.models.chaos.ChaosCanvas; import edu.ntnu.idatt2003.mappevurderingprog2.models.chaos.ChaosCanvas;
import edu.ntnu.idatt2003.mappevurderingprog2.models.chaos.ChaosGame;
import edu.ntnu.idatt2003.mappevurderingprog2.models.chaos.ChaosGameDescription; import edu.ntnu.idatt2003.mappevurderingprog2.models.chaos.ChaosGameDescription;
import edu.ntnu.idatt2003.mappevurderingprog2.models.chaos.ChaosGameDescriptionFactory;
import edu.ntnu.idatt2003.mappevurderingprog2.models.chaos.ChaosGameFileHandler;
import edu.ntnu.idatt2003.mappevurderingprog2.models.chaos.ChaosGameObserver; import edu.ntnu.idatt2003.mappevurderingprog2.models.chaos.ChaosGameObserver;
import edu.ntnu.idatt2003.mappevurderingprog2.utils.Colorpalette; import edu.ntnu.idatt2003.mappevurderingprog2.utils.Colorpalette;
import edu.ntnu.idatt2003.mappevurderingprog2.utils.Size; import edu.ntnu.idatt2003.mappevurderingprog2.utils.Size;
import edu.ntnu.idatt2003.mappevurderingprog2.views.Components.MainBar;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import edu.ntnu.idatt2003.mappevurderingprog2.views.Components.Menu; import edu.ntnu.idatt2003.mappevurderingprog2.views.Components.Menu;
...@@ -18,6 +15,7 @@ import javafx.geometry.Insets; ...@@ -18,6 +15,7 @@ import javafx.geometry.Insets;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.canvas.Canvas; import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext; import javafx.scene.canvas.GraphicsContext;
import javafx.scene.control.Separator;
import javafx.scene.layout.Background; import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill; import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.BorderPane; import javafx.scene.layout.BorderPane;
...@@ -62,13 +60,11 @@ public class View extends BorderPane implements ChaosGameObserver { ...@@ -62,13 +60,11 @@ public class View extends BorderPane implements ChaosGameObserver {
mainCanvas = new Canvas(600, 400); mainCanvas = new Canvas(600, 400);
MainBar mainBar = new MainBar( this, gameController);
this.setTop(mainBar);
this.setCenter(mainCanvas); this.setCenter(mainCanvas);
this.menu = new Menu(); this.menu = new Menu(this, gameController);
this.setLeft(menu); this.setLeft(menu);
new Separator();
return new Scene(this, Size.getScreenWidth(),Size.getScreenHeight()); return new Scene(this, Size.getScreenWidth(),Size.getScreenHeight());
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment