Fix navbar width alignment

This commit is contained in:
crschnick
2026-04-19 12:11:18 +00:00
parent 6f4c93b2a2
commit 01625eedbf
3 changed files with 15 additions and 13 deletions
@@ -85,7 +85,6 @@ public class BrowserBreadcrumbBar extends SimpleRegionBuilder {
Callback<Breadcrumbs.BreadCrumbItem<FilePath>, ? extends Node> dividerFactory) {
var breadcrumbs = new Breadcrumbs<FilePath>();
breadcrumbs.setMinWidth(0);
model.getCurrentPath().subscribe(val -> {
PlatformThread.runLaterIfNeeded(() -> {
if (val == null) {
@@ -98,18 +98,21 @@ public class BrowserNavBarComp extends RegionStructureBuilder<HBox, BrowserNavBa
pathRegion.focusedProperty(),
PlatformThread.sync(model.getInOverview())));
var stack = new StackPane(pathRegion, breadcrumbsRegion);
stack.setAlignment(Pos.CENTER_LEFT);
StackPane.setMargin(breadcrumbsRegion, new Insets(0, 10, 0, 10));
stack.setMinWidth(0);
pathRegion.prefHeightProperty().bind(stack.heightProperty());
stack.widthProperty().addListener((observable, oldValue, newValue) -> {
setMargin(stack, breadcrumbsRegion);
});
model.getCurrentPath().addListener((observable, oldValue, newValue) -> {
PlatformThread.runLaterIfNeeded(() -> {
setMargin(stack, breadcrumbsRegion);
Platform.runLater(() -> {
setAlignment(stack, breadcrumbsRegion);
});
});
model.getCurrentPath().addListener((observable, oldValue, newValue) -> {
PlatformThread.runLaterIfNeeded(() -> {
setAlignment(stack, breadcrumbsRegion);
});
});
setAlignment(stack, breadcrumbsRegion);
// Prevent overflow
var clip = new Rectangle();
@@ -135,12 +138,12 @@ public class BrowserNavBarComp extends RegionStructureBuilder<HBox, BrowserNavBa
return new Structure(topBox, pathRegion, historyButton);
}
private void setMargin(StackPane stackPane, Region region) {
private void setAlignment(StackPane stackPane, Region region) {
var off = region.getWidth() - stackPane.getWidth();
if (off <= 0) {
StackPane.setMargin(region, new Insets(0, 0, 0, 0));
if (off <= -20) {
stackPane.setAlignment(Pos.CENTER_LEFT);
} else {
StackPane.setMargin(region, new Insets(0, 20, 0, -off - 20));
stackPane.setAlignment(Pos.CENTER_RIGHT);
}
}
@@ -175,7 +175,7 @@
}
.browser .breadcrumbs {
-fx-padding: 0px 10px 0px 10px;
-fx-padding: 0;
}
.browser .breadcrumbs {