Skip to content

Commit 677d66d

Browse files
committed
moved the menu on top
1 parent b8c9905 commit 677d66d

1 file changed

Lines changed: 10 additions & 23 deletions

File tree

src/main/java/app/Main.java

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import javafx.animation.AnimationTimer;
99
import javafx.application.Application;
1010
import javafx.geometry.Insets;
11-
import javafx.geometry.Pos;
1211
import javafx.scene.Node;
1312
import javafx.scene.Scene;
1413
import javafx.scene.canvas.Canvas;
@@ -26,8 +25,6 @@
2625
import javafx.scene.control.ToggleGroup;
2726
import javafx.scene.layout.BorderPane;
2827
import javafx.scene.layout.HBox;
29-
import javafx.scene.control.ScrollPane;
30-
import javafx.scene.control.SplitPane;
3128
import javafx.scene.layout.StackPane;
3229
import javafx.scene.layout.VBox;
3330
import javafx.scene.paint.Color;
@@ -57,9 +54,8 @@ public class Main extends Application {
5754
TextField algFilter;
5855
Label status;
5956
BorderPane root;
60-
VBox right;
61-
ScrollPane rightScroll;
6257
MenuBar menuBar;
58+
HBox controlBar;
6359
ChoiceBox<ThemeOption> themeChoice;
6460
ChoiceBox<Accent> accentChoice;
6561
ChoiceBox<String> fontChoice;
@@ -125,17 +121,13 @@ public void start(Stage stage) {
125121
barModeChoice.getItems().addAll(BarMode.RAINBOW, BarMode.ACCENT, BarMode.CUSTOM);
126122
barModeChoice.getSelectionModel().selectFirst();
127123

124+
controlBar = buildControlBar(shuffle, run);
128125
root = new BorderPane();
129126
menuBar = buildMenu(stage);
130-
root.setTop(menuBar);
127+
VBox header = new VBox(menuBar, controlBar);
128+
root.setTop(header);
131129
StackPane center = new StackPane(canvas);
132-
right = buildRightPanel(shuffle, run);
133-
rightScroll = new ScrollPane(right);
134-
rightScroll.setFitToWidth(true);
135-
rightScroll.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
136-
SplitPane split = new SplitPane(center, rightScroll);
137-
split.setDividerPositions(0.75);
138-
root.setCenter(split);
130+
root.setCenter(center);
139131
Scene scene = new Scene(root, 1100, 600);
140132

141133
canvas.widthProperty().bind(center.widthProperty());
@@ -262,9 +254,8 @@ void applyTheme() {
262254
String acc = toHex(accent.color());
263255
root.setStyle("-fx-background-color:" + bg + "; -fx-base:" + panel + "; -fx-control-inner-background:" + panel + "; -fx-text-fill:" + text + "; -fx-accent:" + acc + "; -fx-focus-color:" + acc + "; -fx-faint-focus-color:" + acc + "33; -fx-font-family: " + fontFamily + "; -fx-font-size: 12px;");
264256
menuBar.setStyle("-fx-background-color:" + panel + "; -fx-text-fill:" + text + ";");
265-
right.setStyle("-fx-background-color:" + panel + "; -fx-border-color:" + acc + "; -fx-border-width:1;");
266-
rightScroll.setStyle("-fx-background:" + panel + "; -fx-background-color:" + panel + ";");
267-
for (Node n : right.getChildren()) {
257+
controlBar.setStyle("-fx-background-color:" + panel + "; -fx-border-color:" + acc + "; -fx-border-width:0 0 1 0;");
258+
for (Node n : controlBar.getChildren()) {
268259
if (n instanceof Label l) l.setTextFill(theme.text());
269260
}
270261
for (Node n : menuBar.getChildrenUnmodifiable()) {
@@ -480,19 +471,15 @@ void openAbout(Stage owner) {
480471
s.showAndWait();
481472
}
482473

483-
VBox buildRightPanel(Button shuffle, Button run) {
484-
VBox box = new VBox(8,
485-
label("Controls"),
474+
HBox buildControlBar(Button shuffle, Button run) {
475+
HBox box = new HBox(10,
486476
label("Algorithm"), algFilter, alg,
487477
label("Size"), size, sizeField,
488478
label("Speed"), speed, speedField,
489479
shuffle, run,
490480
label("Status"), status
491481
);
492-
box.setPadding(new Insets(12));
493-
box.setPrefWidth(260);
494-
box.setMinWidth(220);
495-
box.setAlignment(Pos.TOP_LEFT);
482+
box.setPadding(new Insets(6, 8, 6, 8));
496483
return box;
497484
}
498485

0 commit comments

Comments
 (0)