optimised cellSize binding and removed unused imports

This commit is contained in:
Jan-Peter Klein 2024-10-01 18:56:21 +02:00
parent ce82593fc6
commit 2d96d2e5c6
No known key found for this signature in database
GPG Key ID: 90EDA3A7C822FD0E
3 changed files with 10 additions and 9 deletions

View File

@ -10,8 +10,6 @@ import org.cryptomator.ui.controls.FontAwesome5Icon;
import org.cryptomator.ui.controls.FontAwesome5IconView;
import javax.inject.Inject;
import javafx.beans.binding.Bindings;
import javafx.beans.binding.BooleanBinding;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.ObservableValue;

View File

@ -71,8 +71,7 @@ public class VaultListController implements FxController {
private final BooleanProperty draggingVaultOver = new SimpleBooleanProperty();
private final ResourceBundle resourceBundle;
private final FxApplicationWindows appWindows;
private final Settings settings;
private final ObservableValue<Double> cellSize;
public ListView<Vault> vaultList;
public StackPane root;
@FXML
@ -102,20 +101,17 @@ public class VaultListController implements FxController {
this.vaultListManager = vaultListManager;
this.resourceBundle = resourceBundle;
this.appWindows = appWindows;
this.settings = settings;
this.emptyVaultList = Bindings.isEmpty(vaults);
selectedVault.addListener(this::selectedVaultDidChange);
cellSize = settings.compactMode.map(compact -> compact ? 30.0 : 60.0);
}
public void initialize() {
vaultList.setItems(vaults);
vaultList.setCellFactory(cellFactory);
vaultList.fixedCellSizeProperty().bind(Bindings.createDoubleBinding(() ->
settings.compactMode.get() ? 30.0 : 60.0, settings.compactMode));
selectedVault.bind(vaultList.getSelectionModel().selectedItemProperty());
vaults.addListener((ListChangeListener.Change<? extends Vault> c) -> {
while (c.next()) {
@ -280,5 +276,12 @@ public class VaultListController implements FxController {
return draggingVaultOver.get();
}
public ObservableValue<Double> cellSizeProperty() {
return cellSize;
}
public Double getCellSize() {
return cellSize.getValue();
}
}

View File

@ -18,7 +18,7 @@
minWidth="206">
<VBox>
<StackPane VBox.vgrow="ALWAYS">
<ListView fx:id="vaultList" editable="true" fixedCellSize="60">
<ListView fx:id="vaultList" editable="true" fixedCellSize="${controller.cellSize}">
<contextMenu>
<fx:include source="vault_list_contextmenu.fxml"/>
</contextMenu>