diff --git a/app/src/main/java/io/xpipe/app/action/ActionShortcutComp.java b/app/src/main/java/io/xpipe/app/action/ActionShortcutComp.java index db35f8da8..b295ddcbc 100644 --- a/app/src/main/java/io/xpipe/app/action/ActionShortcutComp.java +++ b/app/src/main/java/io/xpipe/app/action/ActionShortcutComp.java @@ -63,7 +63,6 @@ public class ActionShortcutComp extends SimpleComp { var copyButton = new ButtonComp(null, new FontIcon("mdi2c-clipboard-multiple-outline"), () -> { ClipboardHelper.copyUrl(url.getValue()); }) - .grow(false, true) .descriptor(d -> d.nameKey("copyUrl")); var field = new TextFieldComp(url); field.apply(struc -> struc.get().setEditable(false)); @@ -89,7 +88,6 @@ public class ActionShortcutComp extends SimpleComp { DesktopHelper.browseFileInDirectory(file); }); }) - .grow(false, true) .descriptor(d -> d.nameKey("createShortcut")); var field = new TextFieldComp(name); var group = new InputGroupComp(List.of(field, copyButton)); @@ -109,7 +107,6 @@ public class ActionShortcutComp extends SimpleComp { ClipboardHelper.copyUrl(sa.toNode().toPrettyString()); } }) - .grow(false, true) .descriptor(d -> d.nameKey("copyBody")); var field = new TextFieldComp(prop, true); field.apply(struc -> struc.get().setEditable(false)); diff --git a/app/src/main/java/io/xpipe/app/browser/file/BrowserTransferComp.java b/app/src/main/java/io/xpipe/app/browser/file/BrowserTransferComp.java index ba5dd5dd2..2f5460993 100644 --- a/app/src/main/java/io/xpipe/app/browser/file/BrowserTransferComp.java +++ b/app/src/main/java/io/xpipe/app/browser/file/BrowserTransferComp.java @@ -75,8 +75,7 @@ public class BrowserTransferComp extends SimpleComp { }, sourceItem.get().getProgress()); } - }) - .grow(false, true); + }); var dragNotice = new LabelComp(AppI18n.observable("dragLocalFiles")) .apply(struc -> struc.get().setGraphic(new FontIcon("mdi2h-hand-back-left-outline"))) .apply(struc -> struc.get().setWrapText(true)) diff --git a/app/src/main/java/io/xpipe/app/comp/Comp.java b/app/src/main/java/io/xpipe/app/comp/Comp.java index 072e2bdbc..1e15c1271 100644 --- a/app/src/main/java/io/xpipe/app/comp/Comp.java +++ b/app/src/main/java/io/xpipe/app/comp/Comp.java @@ -175,66 +175,6 @@ public abstract class Comp> { return apply(struc -> struc.get().getStyleClass().add(styleClass)); } - public Comp grow(boolean width, boolean height) { - return apply(struc -> { - struc.get().parentProperty().addListener((c, o, n) -> { - if (o instanceof Region) { - if (width) { - struc.get().prefWidthProperty().unbind(); - } - if (height) { - struc.get().prefHeightProperty().unbind(); - } - } - - bindGrow(struc.get(), n, width, height); - }); - - bindGrow(struc.get(), struc.get().getParent(), width, height); - }); - } - - private void bindGrow(Region r, Node parent, boolean width, boolean height) { - if (!(parent instanceof Region p)) { - return; - } - - if (width) { - r.prefWidthProperty() - .bind(Bindings.createDoubleBinding( - () -> { - var val = p.getWidth() - - p.getInsets().getLeft() - - p.getInsets().getRight(); - if (val <= 0) { - return Region.USE_COMPUTED_SIZE; - } - - // Floor to prevent rounding issues which cause an infinite growing - return Math.floor(val); - }, - p.widthProperty(), - p.insetsProperty())); - } - if (height) { - r.prefHeightProperty() - .bind(Bindings.createDoubleBinding( - () -> { - var val = p.getHeight() - - p.getInsets().getTop() - - p.getInsets().getBottom(); - if (val <= 0) { - return Region.USE_COMPUTED_SIZE; - } - - // Floor to prevent rounding issues which cause an infinite growing - return Math.floor(val); - }, - p.heightProperty(), - p.insetsProperty())); - } - } - public Comp descriptor(Consumer c) { var desc = CompDescriptor.builder(); c.accept(desc); diff --git a/app/src/main/java/io/xpipe/app/comp/base/ContextualFileReferenceChoiceComp.java b/app/src/main/java/io/xpipe/app/comp/base/ContextualFileReferenceChoiceComp.java index 801badb8d..a97485c1a 100644 --- a/app/src/main/java/io/xpipe/app/comp/base/ContextualFileReferenceChoiceComp.java +++ b/app/src/main/java/io/xpipe/app/comp/base/ContextualFileReferenceChoiceComp.java @@ -91,9 +91,7 @@ public class ContextualFileReferenceChoiceComp extends Comp> false, directory, filter); - }) - .styleClass(sync != null ? Styles.CENTER_PILL : Styles.RIGHT_PILL) - .grow(false, true); + }); var gitShareButton = new ButtonComp(null, new FontIcon("mdi2g-git"), () -> { if (!DataStorageSyncHandler.getInstance().supportsSync()) { @@ -157,7 +155,6 @@ public class ContextualFileReferenceChoiceComp extends Comp> }); gitShareButton.styleClass("git-sync-file-button"); gitShareButton.descriptor(d -> d.nameKey("gitShareFileTooltip")); - gitShareButton.styleClass(Styles.RIGHT_PILL).grow(false, true); gitShareButton.disable(Bindings.createBooleanBinding( () -> { return filePath.getValue() != null @@ -171,7 +168,7 @@ public class ContextualFileReferenceChoiceComp extends Comp> if (sync != null) { nodes.add(gitShareButton); } - var layout = new HorizontalComp(nodes).apply(struc -> struc.get().setFillHeight(true)); + var layout = new InputGroupComp(nodes).setMainReference(path).apply(struc -> struc.get().setFillHeight(true)); layout.apply(struc -> { struc.get().focusedProperty().addListener((observable, oldValue, newValue) -> { @@ -219,8 +216,6 @@ public class ContextualFileReferenceChoiceComp extends Comp> }, filePath)); combo.hgrow(); - combo.styleClass(Styles.LEFT_PILL); - combo.grow(false, true); return combo; } @@ -233,9 +228,7 @@ public class ContextualFileReferenceChoiceComp extends Comp> filePath.setValue(newValue != null && !newValue.isBlank() ? FilePath.of(newValue.strip()) : null); }); var fileNameComp = new TextFieldComp(prop) - .apply(struc -> HBox.setHgrow(struc.get(), Priority.ALWAYS)) - .styleClass(Styles.LEFT_PILL) - .grow(false, true); + .apply(struc -> HBox.setHgrow(struc.get(), Priority.ALWAYS)); if (prompt != null) { fileNameComp.apply(struc -> { diff --git a/app/src/main/java/io/xpipe/app/comp/base/InputGroupComp.java b/app/src/main/java/io/xpipe/app/comp/base/InputGroupComp.java index f178dca3a..6cc16b546 100644 --- a/app/src/main/java/io/xpipe/app/comp/base/InputGroupComp.java +++ b/app/src/main/java/io/xpipe/app/comp/base/InputGroupComp.java @@ -18,13 +18,21 @@ public class InputGroupComp extends Comp> { private final List> entries; - @Setter private Comp mainReference; public InputGroupComp(List> comps) { entries = List.copyOf(comps); } + public InputGroupComp setMainReference(Comp mainReference) { + this.mainReference = mainReference; + return this; + } + + public InputGroupComp setMainReference(int index) { + return setMainReference(entries.get(index)); + } + @Override public CompStructure createBase() { InputGroup b = new InputGroup(); diff --git a/app/src/main/java/io/xpipe/app/comp/base/SecretFieldComp.java b/app/src/main/java/io/xpipe/app/comp/base/SecretFieldComp.java index 9c8099ba0..251bd9a31 100644 --- a/app/src/main/java/io/xpipe/app/comp/base/SecretFieldComp.java +++ b/app/src/main/java/io/xpipe/app/comp/base/SecretFieldComp.java @@ -121,7 +121,6 @@ public class SecretFieldComp extends Comp { var copyButton = new ButtonComp(null, new FontIcon("mdi2c-clipboard-multiple-outline"), () -> { ClipboardHelper.copyPassword(value.getValue()); }) - .grow(false, true) .descriptor(d -> d.nameKey("copy")); var list = new ArrayList>(); diff --git a/app/src/main/java/io/xpipe/app/hub/comp/StoreIconChoiceDialog.java b/app/src/main/java/io/xpipe/app/hub/comp/StoreIconChoiceDialog.java index ed0f1191f..5b73af0d6 100644 --- a/app/src/main/java/io/xpipe/app/hub/comp/StoreIconChoiceDialog.java +++ b/app/src/main/java/io/xpipe/app/hub/comp/StoreIconChoiceDialog.java @@ -40,11 +40,10 @@ public class StoreIconChoiceDialog { var filterText = new SimpleStringProperty(); var filter = new FilterComp(filterText).hgrow(); filter.focusOnShow(); - var github = new ButtonComp(null, new FontIcon("mdomz-settings"), () -> { + var settings = new ButtonComp(null, new FontIcon("mdomz-settings"), () -> { overlay.close(); AppPrefs.get().selectCategory("icons"); - }) - .grow(false, true); + }); var modal = ModalOverlay.of( "chooseCustomIcon", new StoreIconChoiceComp( @@ -63,7 +62,7 @@ public class StoreIconChoiceDialog { finish(); }) .prefWidth(600)); - modal.addButtonBarComp(github); + modal.addButtonBarComp(settings); modal.addButtonBarComp(filter); modal.addButton(new ModalButton( "clear", diff --git a/app/src/main/java/io/xpipe/app/prefs/DeveloperCategory.java b/app/src/main/java/io/xpipe/app/prefs/DeveloperCategory.java index 1530f87cb..b636e44d2 100644 --- a/app/src/main/java/io/xpipe/app/prefs/DeveloperCategory.java +++ b/app/src/main/java/io/xpipe/app/prefs/DeveloperCategory.java @@ -3,6 +3,7 @@ package io.xpipe.app.prefs; import io.xpipe.app.comp.Comp; import io.xpipe.app.comp.base.ButtonComp; import io.xpipe.app.comp.base.HorizontalComp; +import io.xpipe.app.comp.base.InputGroupComp; import io.xpipe.app.comp.base.TextFieldComp; import io.xpipe.app.core.AppProperties; import io.xpipe.app.issue.TrackEvent; @@ -57,15 +58,12 @@ public class DeveloperCategory extends AppPrefsCategory { }); }; - var runLocalCommand = new HorizontalComp(List.of( + var runLocalCommand = new InputGroupComp(List.of( new TextFieldComp(localCommand) .apply(struc -> struc.get().setPromptText("Local command")) - .styleClass(Styles.LEFT_PILL) - .grow(false, true) .hgrow(), - new ButtonComp(null, new FontIcon("mdi2p-play"), test) - .styleClass(Styles.RIGHT_PILL) - .grow(false, true))) + new ButtonComp(null, new FontIcon("mdi2p-play"), test))) + .setMainReference(0) .padding(new Insets(15, 0, 0, 0)) .apply(struc -> struc.get().setAlignment(Pos.CENTER_LEFT)) .apply(struc -> struc.get().setFillHeight(true)) diff --git a/ext/base/src/main/java/io/xpipe/ext/base/host/HostAddressChoiceComp.java b/ext/base/src/main/java/io/xpipe/ext/base/host/HostAddressChoiceComp.java index ddcfdd062..7f13e214e 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/host/HostAddressChoiceComp.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/host/HostAddressChoiceComp.java @@ -56,7 +56,6 @@ public class HostAddressChoiceComp extends Comp> { currentAddress.setValue(null); adding.set(false); }); - addButton.styleClass(Styles.CENTER_PILL).grow(false, true); addButton.descriptor(d -> d.nameKey("addAnotherHostName")); var nodes = new ArrayList>(); @@ -180,9 +179,7 @@ public class HostAddressChoiceComp extends Comp> { }); }); combo.hgrow(); - combo.styleClass(Styles.LEFT_PILL); combo.styleClass("host-address-choice-comp"); - combo.grow(false, true); return combo; } } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/identity/IdentitySelectComp.java b/ext/base/src/main/java/io/xpipe/ext/base/identity/IdentitySelectComp.java index 8e9e70acd..9aad3080b 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/identity/IdentitySelectComp.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/identity/IdentitySelectComp.java @@ -159,12 +159,12 @@ public class IdentitySelectComp extends Comp> { addNamedIdentity(); } }); - addButton.styleClass(Styles.RIGHT_PILL).grow(false, true).descriptor(d -> d.nameKey("addReusableIdentity")); + addButton.descriptor(d -> d.nameKey("addReusableIdentity")); var nodes = new ArrayList>(); nodes.add(createComboBox()); nodes.add(addButton); - var layout = new HorizontalComp(nodes).apply(struc -> struc.get().setFillHeight(true)); + var layout = new InputGroupComp(nodes).setMainReference(0).apply(struc -> struc.get().setFillHeight(true)); layout.apply(struc -> { struc.get().focusedProperty().addListener((observable, oldValue, newValue) -> { @@ -269,7 +269,6 @@ public class IdentitySelectComp extends Comp> { }); combo.apply(struc -> struc.get().setEditable(allowUserInput)); combo.styleClass(Styles.LEFT_PILL); - combo.grow(false, true); combo.apply(struc -> { var binding = Bindings.createStringBinding( diff --git a/ext/base/src/main/java/io/xpipe/ext/base/identity/ssh/CustomAgentStrategy.java b/ext/base/src/main/java/io/xpipe/ext/base/identity/ssh/CustomAgentStrategy.java index 2909af177..bd6fbaeb2 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/identity/ssh/CustomAgentStrategy.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/identity/ssh/CustomAgentStrategy.java @@ -53,8 +53,7 @@ public class CustomAgentStrategy implements SshIdentityStrategy { new ButtonComp(null, new FontIcon("mdomz-settings"), () -> { AppPrefs.get().selectCategory("ssh"); }) - .padding(new Insets(7)) - .grow(false, true))) + .padding(new Insets(7)))) .spacing(9); return new OptionsBuilder()