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

Merge branch 'ExtraUserOptions' into 'dev'

Finished styling the menu

See merge request !34
parents a6bdfa2e 844728ae
No related branches found
No related tags found
2 merge requests!54Final release,!34Finished styling the menu
...@@ -5,5 +5,5 @@ import javafx.scene.paint.Color; ...@@ -5,5 +5,5 @@ import javafx.scene.paint.Color;
public final class Colorpalette{ public final class Colorpalette{
public static final Color White = Color.web("#FFFFFF"); public static final Color White = Color.web("#FFFFFF");
public static final Color Black = Color.web("#000000"); public static final Color Black = Color.web("#000000");
public static final Color Primary = Color.web("#7971EA"); public static final Color Primary = Color.web("#5072A7");
} }
\ No newline at end of file
...@@ -8,8 +8,10 @@ import javafx.scene.canvas.Canvas; ...@@ -8,8 +8,10 @@ import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext; import javafx.scene.canvas.GraphicsContext;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.Separator;
import javafx.scene.control.Slider; import javafx.scene.control.Slider;
import javafx.scene.layout.HBox; import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
public class ExtraUserOptions extends VBox { public class ExtraUserOptions extends VBox {
...@@ -21,7 +23,6 @@ public class ExtraUserOptions extends VBox { ...@@ -21,7 +23,6 @@ public class ExtraUserOptions extends VBox {
private final RotationButton rotationButton; private final RotationButton rotationButton;
private final InformationButton informationButton; private final InformationButton informationButton;
public ExtraUserOptions(Node node) { public ExtraUserOptions(Node node) {
this.node = node; this.node = node;
resetViewButton = new Button("Reset View"); resetViewButton = new Button("Reset View");
...@@ -29,22 +30,31 @@ public class ExtraUserOptions extends VBox { ...@@ -29,22 +30,31 @@ public class ExtraUserOptions extends VBox {
rotationButton = new RotationButton(node); rotationButton = new RotationButton(node);
informationButton = new InformationButton("Additional Information"); informationButton = new InformationButton("Additional Information");
zoomSlider = new Slider(0.5, 4.0, 1.0); zoomSlider = new Slider(0.5, 4.0, 1.0);
extraUserOptionsLabel();
Label rotationLabel = new Label("Rotate the view"); Label rotationLabel = new Label("Rotate the view");
rotationLabel.setStyle("-fx-font-size: 14px; ");
Label zoomLabel = new Label("Zoom");
zoomLabel.setStyle("-fx-font-size: 14px; ");
this.getChildren().addAll(resetViewButton, this.getChildren().addAll(
zoomLabel,
createZoomSliderWithLabels(), createZoomSliderWithLabels(),
rotationLabel, rotationLabel,
rotationButton, rotationButton,
createSeparator(),
resetViewButton,
clearCanvasButton, clearCanvasButton,
informationButton); informationButton
);
extraUserOptionsInitialize(); extraUserOptionsInitialize();
} }
private HBox createZoomSliderWithLabels() { private HBox createZoomSliderWithLabels() {
Label zoomInLabel = new Label("Zoom In"); Label zoomInLabel = new Label("In");
Label zoomOutLabel = new Label("Zoom Out"); Label zoomOutLabel = new Label("Out");
zoomSlider.setPrefWidth(100); zoomSlider.setPrefWidth(100);
HBox sliderWithLabels = new HBox(zoomOutLabel, zoomSlider, zoomInLabel); HBox sliderWithLabels = new HBox(zoomOutLabel, zoomSlider, zoomInLabel);
...@@ -77,12 +87,12 @@ public class ExtraUserOptions extends VBox { ...@@ -77,12 +87,12 @@ public class ExtraUserOptions extends VBox {
setPrefHeight(0.3 * screenHeight); setPrefHeight(0.3 * screenHeight);
setMaxHeight(0.3 * screenHeight); setMaxHeight(0.3 * screenHeight);
setAlignment(Pos.CENTER); setAlignment(Pos.CENTER);
setPadding(new Insets(10, 0, 10, 0)); setPadding(new Insets(10, 20, 10, 20));
setSpacing(10);
} }
private void extraUserOptionsStyling() { private void extraUserOptionsStyling() {
setPadding(new Insets(10, 10, 10, 10)); setStyle("-fx-background-color: #eed9c4;");
setStyle("-fx-background-color: #f4f4f4;");
} }
private void sliderToZoom() { private void sliderToZoom() {
...@@ -106,4 +116,18 @@ public class ExtraUserOptions extends VBox { ...@@ -106,4 +116,18 @@ public class ExtraUserOptions extends VBox {
node.setTranslateY(0); node.setTranslateY(0);
}); });
} }
private void extraUserOptionsLabel() {
Label extraUserOptionsLabel = new Label("Extra Functions");
extraUserOptionsLabel.setStyle("-fx-font-size: 16px; -fx-font-weight: bold;");
getChildren().add(extraUserOptionsLabel);
}
private Separator createSeparator() {
Separator separator = new Separator();
separator.setMaxWidth(Double.MAX_VALUE);
VBox.setVgrow(separator, Priority.ALWAYS);
return separator;
}
} }
...@@ -19,12 +19,14 @@ public class InformationButton extends Button { ...@@ -19,12 +19,14 @@ public class InformationButton extends Button {
String contentText = "Fractals use 3 primary colors to show hit density:\n" + String contentText = "Fractals use 3 primary colors to show hit density:\n" +
"Red: Top 33% hit most\nBlue: Mid 33%\nGreen: Bottom 33%\n\n" + "Red: Top 33% hit most\nBlue: Mid 33%\nGreen: Bottom 33%\n\n" +
"Right side: Main menu - create, select, edit fractals\n" + "Right side: Main menu - create, select, edit fractals\n" +
"Bottom menu: Extra user options for canvas interaction\n\n" + "Bottom menu: Extra user options for canvas interaction" +
"The reset view button brings the canvas back to its original zoom and rotation\n" +
"The clear canvas button clears the whole canvas\n\n" +
"Interact with canvas: Zoom with mouse, click-hold to move"; "Interact with canvas: Zoom with mouse, click-hold to move";
alert.setContentText(contentText); alert.setContentText(contentText);
alert.getDialogPane().setPrefWidth(400); alert.getDialogPane().setPrefWidth(400);
alert.getDialogPane().setPrefHeight(250); alert.getDialogPane().setPrefHeight(300);
alert.getDialogPane().setMinWidth(Region.USE_PREF_SIZE); alert.getDialogPane().setMinWidth(Region.USE_PREF_SIZE);
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE); alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
......
...@@ -4,30 +4,37 @@ import edu.ntnu.idatt2003.mappevurderingprog2.controllers.GameController; ...@@ -4,30 +4,37 @@ import edu.ntnu.idatt2003.mappevurderingprog2.controllers.GameController;
import edu.ntnu.idatt2003.mappevurderingprog2.views.View; import edu.ntnu.idatt2003.mappevurderingprog2.views.View;
import javafx.geometry.Pos; import javafx.geometry.Pos;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.Separator;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
public class Menu extends VBox { public class Menu extends VBox {
private ExistingFractalsMenu existingFractalsMenu; private ExistingFractalsMenu existingFractalsMenu;
private CreateFractalMenu createFractalMenu; private CreateFractalMenu createFractalMenu;
private EditFractalMenu editFractalMenu; // Add this line private EditFractalMenu editFractalMenu;
private ExtraUserOptions extraUserOptions;
public Menu(View view, GameController gameController) { public Menu(View view, GameController gameController) {
existingFractalsMenu = new ExistingFractalsMenu(view, gameController); existingFractalsMenu = new ExistingFractalsMenu(view, gameController);
createFractalMenu = new CreateFractalMenu(); createFractalMenu = new CreateFractalMenu();
editFractalMenu = new EditFractalMenu(view, gameController); // Initialize here editFractalMenu = new EditFractalMenu(view, gameController);
extraUserOptions = new ExtraUserOptions(view.getMainCanvas());
initializeMenu(); initializeMenu();
} }
private void initializeMenu() { private void initializeMenu() {
Label menuLabel = new Label("Menu"); Label menuLabel = new Label("Menu");
menuLabel.setStyle("-fx-font-size: 18px; -fx-font-weight: bold;"); menuLabel.setStyle("-fx-font-size: 20px; -fx-font-weight: bold;-fx-font-family: 'Times New Roman'");
setPrefWidth(200); setPrefWidth(200);
getChildren().addAll(menuLabel, existingFractalsMenu, createFractalMenu, editFractalMenu); // Add to children getChildren().addAll(menuLabel, new Separator(),
existingFractalsMenu,
createFractalMenu,
editFractalMenu,
new Separator(),
extraUserOptions);
setAlignment(Pos.TOP_CENTER); setAlignment(Pos.TOP_CENTER);
setSpacing(20); setSpacing(20);
setStyle("-fx-background-color: #f4f4f4;");
setStyle(" -fx-background-color: #faf0e6;");
} }
} }
\ No newline at end of file
...@@ -16,8 +16,8 @@ public class RotationButton extends HBox { ...@@ -16,8 +16,8 @@ public class RotationButton extends HBox {
public RotationButton(Node node) { public RotationButton(Node node) {
this.node = node; this.node = node;
rotateClockwise = new Button("Clockwise"); rotateClockwise = new Button("Right");
rotateCounterClockwise = new Button("Counter Clockwise"); rotateCounterClockwise = new Button("Left");
initializeUI(); initializeUI();
attachEventHandlers(); attachEventHandlers();
......
...@@ -9,8 +9,6 @@ import edu.ntnu.idatt2003.mappevurderingprog2.models.chaos.ChaosGame; ...@@ -9,8 +9,6 @@ import edu.ntnu.idatt2003.mappevurderingprog2.models.chaos.ChaosGame;
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.Zoom;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
...@@ -18,13 +16,11 @@ import java.util.List; ...@@ -18,13 +16,11 @@ import java.util.List;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.geometry.Insets; import javafx.geometry.Insets;
import javafx.geometry.Pos;
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.layout.*; import javafx.scene.layout.*;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import javafx.scene.control.Separator;
public class View extends BorderPane implements ChaosGameObserver { public class View extends BorderPane implements ChaosGameObserver {
...@@ -98,15 +94,7 @@ public class View extends BorderPane implements ChaosGameObserver { ...@@ -98,15 +94,7 @@ public class View extends BorderPane implements ChaosGameObserver {
this.setBackground(new Background(new BackgroundFill(Colorpalette.Primary, CornerRadii.EMPTY, Insets.EMPTY))); this.setBackground(new Background(new BackgroundFill(Colorpalette.Primary, CornerRadii.EMPTY, Insets.EMPTY)));
this.setCenter(mainCanvas); this.setCenter(mainCanvas);
this.menu = new Menu(this, gameController); this.menu = new Menu(this, gameController);
VBox rightContainer = new VBox();
rightContainer.setAlignment(Pos.BOTTOM_RIGHT);
rightContainer.getChildren().add(extraUserOptions);
this.setRight(rightContainer);
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