Improve yes no toggle display for categories

This commit is contained in:
crschnick
2025-11-22 22:18:04 +00:00
parent 473ddc528d
commit 6cdb386d9c
22 changed files with 36 additions and 5 deletions

View File

@@ -5,6 +5,7 @@ import io.xpipe.app.comp.CompStructure;
import io.xpipe.app.comp.SimpleCompStructure;
import io.xpipe.app.platform.PlatformThread;
import javafx.application.Platform;
import javafx.beans.property.Property;
import javafx.beans.value.ObservableValue;
import javafx.scene.control.ToggleButton;
@@ -14,6 +15,7 @@ import javafx.scene.layout.HBox;
import atlantafx.base.theme.Styles;
import java.util.Map;
import java.util.Objects;
public class ToggleGroupComp<T> extends Comp<CompStructure<HBox>> {
@@ -39,8 +41,11 @@ public class ToggleGroupComp<T> extends Comp<CompStructure<HBox>> {
box.getChildren().clear();
for (var entry : val.entrySet()) {
var b = new ToggleButton(entry.getValue().getValue());
if (entry.getKey() == null) {
b.disableProperty().bind(b.selectedProperty());
}
b.setOnAction(e -> {
if (entry.getKey().equals(value.getValue())) {
if (Objects.equals(entry.getKey(), value.getValue())) {
value.setValue(null);
} else {
value.setValue(entry.getKey());
@@ -49,9 +54,15 @@ public class ToggleGroupComp<T> extends Comp<CompStructure<HBox>> {
});
group.getToggles().add(b);
box.getChildren().add(b);
if (entry.getKey().equals(value.getValue())) {
if (Objects.equals(entry.getKey(), value.getValue())) {
b.setSelected(true);
}
value.addListener((observable, oldValue, newValue) -> {
if (Objects.equals(newValue, entry.getKey())) {
b.setSelected(true);
}
});
}
if (box.getChildren().size() > 0) {

View File

@@ -281,8 +281,9 @@ public class OptionsBuilder {
public OptionsBuilder addYesNoToggle(Property<Boolean> prop) {
var map = new LinkedHashMap<Boolean, ObservableValue<String>>();
map.put(Boolean.FALSE, AppI18n.observable("app.no"));
map.put(Boolean.TRUE, AppI18n.observable("app.yes"));
map.put(Boolean.FALSE, AppI18n.observable("no"));
map.put(null, AppI18n.observable("inherit"));
map.put(Boolean.TRUE, AppI18n.observable("yes"));
var comp = new ToggleGroupComp<>(prop, new SimpleObjectProperty<>(map));
pushComp(comp);
props.add(prop);

View File

@@ -359,7 +359,7 @@
-fx-background-color: -color-success-1;
}
.browser .table-row-cell:folder:drag-over {
.browser .table-row-cell:drag-over {
-fx-background-color: -color-success-muted;
}

View File

@@ -156,6 +156,7 @@
.toggle-group-comp .toggle-button {
-fx-padding: 3 10;
-fx-opacity: 1.0;
}
.root .ikonli-font-icon.graphic.supported {