Skip to content

Commit df910dc

Browse files
committed
fix resizing
1 parent bd9d3ce commit df910dc

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/main/java/app/Main.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import javafx.scene.control.MenuBar;
2222
import javafx.scene.control.MenuItem;
2323
import javafx.scene.control.RadioMenuItem;
24+
import javafx.scene.control.ScrollPane;
2425
import javafx.scene.control.SeparatorMenuItem;
2526
import javafx.scene.control.Slider;
2627
import javafx.scene.control.TextField;
@@ -62,6 +63,7 @@ public class Main extends Application {
6263
MenuBar menuBar;
6364
HBox controlBar;
6465
Region accentBar;
66+
ScrollPane controlScroll;
6567
ChoiceBox<ThemeOption> themeChoice;
6668
ChoiceBox<Accent> accentChoice;
6769
ChoiceBox<String> fontChoice;
@@ -134,7 +136,12 @@ public void start(Stage stage) {
134136
menuBar = buildMenu(stage);
135137
accentBar = new Region();
136138
accentBar.setPrefHeight(3);
137-
VBox header = new VBox(accentBar, menuBar, controlBar);
139+
controlScroll = new ScrollPane(controlBar);
140+
controlScroll.setFitToHeight(true);
141+
controlScroll.setFitToWidth(true);
142+
controlScroll.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
143+
controlScroll.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
144+
VBox header = new VBox(accentBar, menuBar, controlScroll);
138145
root.setTop(header);
139146
StackPane center = new StackPane(canvas);
140147
root.setCenter(center);
@@ -271,6 +278,7 @@ void applyTheme() {
271278
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;");
272279
menuBar.setStyle("-fx-background-color:" + panel + "; -fx-text-fill:" + text + ";");
273280
controlBar.setStyle("-fx-background-color:" + panel + "; -fx-border-color:" + acc + "; -fx-border-width:0 0 1 0;");
281+
controlScroll.setStyle("-fx-background:" + panel + "; -fx-background-color:" + panel + ";");
274282
accentBar.setStyle("-fx-background-color:" + acc + ";");
275283
for (Node n : controlBar.getChildren()) {
276284
if (n instanceof Label l) l.setTextFill(theme.text());
@@ -333,11 +341,15 @@ void draw() {
333341
int n = arr.length;
334342
if (n == 0) return;
335343
double barW = w / n;
344+
double drawW = Math.max(1, barW);
336345
for (int i = 0; i < n; i++) {
337346
double v = arr[i];
338347
double barH = (v / n) * (h - 20);
348+
if (barH > h - 2) barH = h - 2;
349+
if (barH < 1) barH = 1;
339350
double x = i * barW;
340351
double y = h - barH;
352+
if (y < 0) y = 0;
341353
Color c;
342354
if (barMode == BarMode.RAINBOW) {
343355
double hue = (v / n) * 300;
@@ -349,7 +361,7 @@ void draw() {
349361
c = Color.hsb(base.getHue(), Math.max(0.25, base.getSaturation()), val);
350362
}
351363
g.setFill(c);
352-
g.fillRect(x, y, barW - 1, barH);
364+
g.fillRect(x, y, drawW, barH);
353365
}
354366
}
355367

0 commit comments

Comments
 (0)