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())))));
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");

View file

@ -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<Entry> entries;
private final Property<Entry> selected;
private final ObservableValue<Entry> 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<Entry> getSelectedInternal() {
return selected;
}
public ObservableValue<Entry> getSelected() {
return selectedWrapper;
}
public void selectBrowser() {