From 4e124466f8c3309ce8b1e6300739289e08f01066 Mon Sep 17 00:00:00 2001 From: crschnick Date: Sun, 23 Apr 2023 14:30:45 +0000 Subject: [PATCH] The add ability to expand and collapse connections --- .../comp/storage/store/StoreEntryComp.java | 1 + .../comp/storage/store/StoreEntrySection.java | 31 ++++++++++++------- .../comp/storage/store/StoreEntryWrapper.java | 5 +++ .../app/resources/style/store-entry-comp.css | 2 +- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryComp.java b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryComp.java index 70145e9e..0fdc5a8c 100644 --- a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryComp.java +++ b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryComp.java @@ -159,6 +159,7 @@ public class StoreEntryComp extends SimpleComp { var found = entry.getDefaultActionProvider().getValue(); if (entry.getState().getValue().equals(DataStoreEntry.State.COMPLETE_BUT_INVALID) || found == null) { entry.getEntry().refresh(true); + entry.getExpanded().set(true); } if (found != null) { diff --git a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntrySection.java b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntrySection.java index f821b093..9b2d020e 100644 --- a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntrySection.java +++ b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntrySection.java @@ -5,12 +5,12 @@ import io.xpipe.app.fxcomps.Comp; import io.xpipe.app.fxcomps.CompStructure; import io.xpipe.app.fxcomps.augment.GrowAugment; import io.xpipe.app.fxcomps.impl.HorizontalComp; +import io.xpipe.app.fxcomps.impl.IconButtonComp; import io.xpipe.app.fxcomps.impl.VerticalComp; import io.xpipe.app.fxcomps.util.BindingsHelper; import javafx.beans.binding.Bindings; import javafx.scene.layout.*; import javafx.scene.paint.Color; -import org.kordamp.ikonli.javafx.FontIcon; import java.util.List; @@ -27,15 +27,21 @@ public class StoreEntrySection extends Comp> { @Override public CompStructure createBase() { var root = new StoreEntryComp(section.getWrapper()).apply(struc -> HBox.setHgrow(struc.get(), Priority.ALWAYS)); - var icon = Comp.of(() -> { - var padding = new FontIcon("mdi2c-circle-double"); - padding.setIconSize(14); - var pain = new StackPane(padding); - pain.setMinWidth(20); - pain.setMaxHeight(20); - return pain; - }); - List> topEntryList = top ? List.of(root) : List.of(icon, root); + var button = new IconButtonComp( + Bindings.createStringBinding( + () -> section.getWrapper().getExpanded().get() + && section.getChildren().size() > 0 + ? "mdal-keyboard_arrow_down" + : "mdal-keyboard_arrow_right", + section.getWrapper().getExpanded()), + () -> { + section.getWrapper().toggleExpanded(); + }) + .apply(struc -> struc.get().setPrefWidth(40)) + .disable(BindingsHelper.persist( + Bindings.size(section.getChildren()).isEqualTo(0))) + .grow(false, true); + List> topEntryList = List.of(button, root); var all = section.getChildren(); var shown = BindingsHelper.filteredContentBinding( @@ -58,8 +64,9 @@ public class StoreEntrySection extends Comp> { new HorizontalComp(topEntryList), new HorizontalComp(List.of(spacer, content)) .apply(struc -> struc.get().setFillHeight(true)) - .hide(BindingsHelper.persist( - Bindings.size(section.getChildren()).isEqualTo(0))))) + .hide(BindingsHelper.persist(Bindings.or( + Bindings.not(section.getWrapper().getExpanded()), + Bindings.size(section.getChildren()).isEqualTo(0)))))) .createStructure(); } } diff --git a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryWrapper.java b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryWrapper.java index a510c3b3..5ed1778e 100644 --- a/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryWrapper.java +++ b/app/src/main/java/io/xpipe/app/comp/storage/store/StoreEntryWrapper.java @@ -33,6 +33,7 @@ public class StoreEntryWrapper implements StorageFilter.Filterable { private final BooleanProperty renamable = new SimpleBooleanProperty(); private final BooleanProperty refreshable = new SimpleBooleanProperty(); private final BooleanProperty deletable = new SimpleBooleanProperty(); + private final BooleanProperty expanded = new SimpleBooleanProperty(true); public StoreEntryWrapper(DataStoreEntry entry) { this.entry = entry; @@ -157,6 +158,10 @@ public class StoreEntryWrapper implements StorageFilter.Filterable { }); } + public void toggleExpanded() { + this.expanded.set(!expanded.getValue()); + } + @Override public boolean shouldShow(String filter) { return getName().toLowerCase().contains(filter.toLowerCase()) diff --git a/app/src/main/resources/io/xpipe/app/resources/style/store-entry-comp.css b/app/src/main/resources/io/xpipe/app/resources/style/store-entry-comp.css index ad7f870f..0ea37436 100644 --- a/app/src/main/resources/io/xpipe/app/resources/style/store-entry-comp.css +++ b/app/src/main/resources/io/xpipe/app/resources/style/store-entry-comp.css @@ -23,7 +23,7 @@ -fx-opacity: 0.5; } .store-entry-comp { --fx-padding: 6px; +-fx-padding: 6px 6px 6px 0; }