Synchronize layout model

This commit is contained in:
crschnick 2024-02-19 00:45:56 +00:00
parent d29614afcc
commit a3cb5f2f42
2 changed files with 13 additions and 2 deletions

View file

@ -32,7 +32,7 @@ public class AppLayoutComp extends Comp<CompStructure<Pane>> {
model.getSelected()))))); model.getSelected())))));
var pane = new BorderPane(); 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.setCenter(multi.createRegion());
pane.setRight(sidebar.createRegion()); pane.setRight(sidebar.createRegion());
pane.getStyleClass().add("background"); pane.getStyleClass().add("background");

View file

@ -5,6 +5,7 @@ import io.xpipe.app.browser.BrowserModel;
import io.xpipe.app.comp.DeveloperTabComp; import io.xpipe.app.comp.DeveloperTabComp;
import io.xpipe.app.comp.store.StoreLayoutComp; import io.xpipe.app.comp.store.StoreLayoutComp;
import io.xpipe.app.fxcomps.Comp; import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.util.PlatformThread;
import io.xpipe.app.prefs.AppPrefsComp; import io.xpipe.app.prefs.AppPrefsComp;
import io.xpipe.app.util.LicenseProvider; import io.xpipe.app.util.LicenseProvider;
import javafx.beans.property.Property; import javafx.beans.property.Property;
@ -18,7 +19,6 @@ import lombok.extern.jackson.Jacksonized;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@Getter
public class AppLayoutModel { public class AppLayoutModel {
@Data @Data
@ -48,13 +48,24 @@ public class AppLayoutModel {
@Getter @Getter
private final SavedState savedState; private final SavedState savedState;
@Getter
private final List<Entry> entries; private final List<Entry> entries;
private final Property<Entry> selected; private final Property<Entry> selected;
private final ObservableValue<Entry> selectedWrapper;
public AppLayoutModel(SavedState savedState) { public AppLayoutModel(SavedState savedState) {
this.savedState = savedState; this.savedState = savedState;
this.entries = createEntryList(); this.entries = createEntryList();
this.selected = new SimpleObjectProperty<>(entries.get(1)); this.selected = new SimpleObjectProperty<>(entries.get(1));
this.selectedWrapper = PlatformThread.sync(selected);
}
public Property<Entry> getSelectedInternal() {
return selected;
}
public ObservableValue<Entry> getSelected() {
return selectedWrapper;
} }
public void selectBrowser() { public void selectBrowser() {