From a3cb5f2f422a6bb0da9669ae72bbe6dbeb1b87ca Mon Sep 17 00:00:00 2001 From: crschnick Date: Mon, 19 Feb 2024 00:45:56 +0000 Subject: [PATCH] Synchronize layout model --- .../main/java/io/xpipe/app/comp/AppLayoutComp.java | 2 +- .../main/java/io/xpipe/app/core/AppLayoutModel.java | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/comp/AppLayoutComp.java b/app/src/main/java/io/xpipe/app/comp/AppLayoutComp.java index 9f241d155..53503c7d4 100644 --- a/app/src/main/java/io/xpipe/app/comp/AppLayoutComp.java +++ b/app/src/main/java/io/xpipe/app/comp/AppLayoutComp.java @@ -32,7 +32,7 @@ public class AppLayoutComp extends Comp> { model.getSelected()))))); var pane = new BorderPane(); - var sidebar = new SideMenuBarComp(model.getSelected(), model.getEntries()); + var sidebar = new SideMenuBarComp(model.getSelectedInternal(), model.getEntries()); pane.setCenter(multi.createRegion()); pane.setRight(sidebar.createRegion()); pane.getStyleClass().add("background"); diff --git a/app/src/main/java/io/xpipe/app/core/AppLayoutModel.java b/app/src/main/java/io/xpipe/app/core/AppLayoutModel.java index 996c46f72..942411fd6 100644 --- a/app/src/main/java/io/xpipe/app/core/AppLayoutModel.java +++ b/app/src/main/java/io/xpipe/app/core/AppLayoutModel.java @@ -5,6 +5,7 @@ import io.xpipe.app.browser.BrowserModel; import io.xpipe.app.comp.DeveloperTabComp; import io.xpipe.app.comp.store.StoreLayoutComp; import io.xpipe.app.fxcomps.Comp; +import io.xpipe.app.fxcomps.util.PlatformThread; import io.xpipe.app.prefs.AppPrefsComp; import io.xpipe.app.util.LicenseProvider; import javafx.beans.property.Property; @@ -18,7 +19,6 @@ import lombok.extern.jackson.Jacksonized; import java.util.ArrayList; import java.util.List; -@Getter public class AppLayoutModel { @Data @@ -48,13 +48,24 @@ public class AppLayoutModel { @Getter private final SavedState savedState; + @Getter private final List entries; private final Property selected; + private final ObservableValue selectedWrapper; public AppLayoutModel(SavedState savedState) { this.savedState = savedState; this.entries = createEntryList(); this.selected = new SimpleObjectProperty<>(entries.get(1)); + this.selectedWrapper = PlatformThread.sync(selected); + } + + public Property getSelectedInternal() { + return selected; + } + + public ObservableValue getSelected() { + return selectedWrapper; } public void selectBrowser() {