diff --git a/main/ui/src/main/java/org/cryptomator/ui/controls/DirectoryListCell.java b/main/ui/src/main/java/org/cryptomator/ui/controls/DirectoryListCell.java index 86ad0f68a..125f884ba 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/controls/DirectoryListCell.java +++ b/main/ui/src/main/java/org/cryptomator/ui/controls/DirectoryListCell.java @@ -8,18 +8,23 @@ *******************************************************************************/ package org.cryptomator.ui.controls; +import org.cryptomator.ui.model.Vault; + import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; +import javafx.geometry.Pos; import javafx.scene.control.ContentDisplay; import javafx.scene.control.ContextMenu; +import javafx.scene.control.Label; +import javafx.scene.control.OverrunStyle; import javafx.scene.control.Tooltip; +import javafx.scene.layout.HBox; +import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.scene.paint.Paint; import javafx.scene.shape.Circle; -import org.cryptomator.ui.model.Vault; - -public class DirectoryListCell extends DraggableListCell implements ChangeListener { +public class DirectoryListCell extends DraggableListCellimplements ChangeListener { // fill: #FD4943, stroke: #E1443F private static final Color RED_FILL = Color.rgb(253, 73, 67); @@ -30,12 +35,25 @@ public class DirectoryListCell extends DraggableListCell implements Chang private static final Color GREEN_STROKE = Color.rgb(48, 183, 64); private final Circle statusIndicator = new Circle(4.5); + private final Label nameText = new Label(); + private final Label pathText = new Label(); + private final VBox vbox = new VBox(4.0, nameText, pathText); + private final HBox hbox = new HBox(6.0, statusIndicator, vbox); private ContextMenu vaultContextMenu; public DirectoryListCell() { - setGraphic(statusIndicator); - setGraphicTextGap(12.0); - setContentDisplay(ContentDisplay.LEFT); + hbox.setAlignment(Pos.CENTER_LEFT); + hbox.setPrefWidth(1); + vbox.setFillWidth(true); + + nameText.textFillProperty().bind(this.textFillProperty()); + nameText.fontProperty().bind(this.fontProperty()); + + pathText.setTextOverrun(OverrunStyle.ELLIPSIS); + pathText.getStyleClass().add("detail-label"); + + setGraphic(hbox); + setContentDisplay(ContentDisplay.GRAPHIC_ONLY); } @Override @@ -46,12 +64,14 @@ public class DirectoryListCell extends DraggableListCell implements Chang } super.updateItem(item, empty); if (item == null) { - setText(null); + nameText.setText(null); + pathText.setText(null); setTooltip(null); setContextMenu(null); statusIndicator.setVisible(false); } else { - setText(item.getName()); + nameText.setText(item.getName()); + pathText.setText(item.getDisplayablePath()); setTooltip(new Tooltip(item.getPath().toString())); statusIndicator.setVisible(true); item.unlockedProperty().addListener(this); diff --git a/main/ui/src/main/java/org/cryptomator/ui/model/Vault.java b/main/ui/src/main/java/org/cryptomator/ui/model/Vault.java index 4241c0777..a1ded7f3d 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/model/Vault.java +++ b/main/ui/src/main/java/org/cryptomator/ui/model/Vault.java @@ -13,6 +13,7 @@ import java.io.Serializable; import java.io.UncheckedIOException; import java.nio.file.FileAlreadyExistsException; import java.nio.file.Path; +import java.nio.file.Paths; import java.text.Normalizer; import java.text.Normalizer.Form; import java.util.HashSet; @@ -23,6 +24,7 @@ import java.util.concurrent.atomic.AtomicReference; import org.apache.commons.lang3.CharUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.SystemUtils; import org.cryptomator.common.LazyInitializer; import org.cryptomator.common.Optionals; import org.cryptomator.crypto.engine.InvalidPassphraseException; @@ -185,6 +187,17 @@ public class Vault implements Serializable, CryptoFileSystemDelegate { return path; } + public String getDisplayablePath() { + Path homeDir = Paths.get(SystemUtils.USER_HOME); + if (path.startsWith(homeDir)) { + Path relativePath = homeDir.relativize(path); + String homePrefix = SystemUtils.IS_OS_WINDOWS ? "~\\" : "~/"; + return homePrefix + relativePath.toString(); + } else { + return path.toString(); + } + } + /** * @return Directory name without preceeding path components and file extension */ diff --git a/main/ui/src/main/resources/css/linux_theme.css b/main/ui/src/main/resources/css/linux_theme.css index c725308d0..64446ad4f 100644 --- a/main/ui/src/main/resources/css/linux_theme.css +++ b/main/ui/src/main/resources/css/linux_theme.css @@ -14,6 +14,7 @@ -fx-font-size: 12px; COLOR_TEXT: #444; + COLOR_TEXT_LIGHT: #888; COLOR_TEXT_DISABLED: #BBB; COLOR_HYPERLINK: #0069D9; COLOR_BORDER: #D3D3D3; @@ -120,7 +121,7 @@ } .list-cell { - -fx-padding: 0.8em 0.5em 0.8em 0.5em; + -fx-padding: 0.5em; -fx-text-fill: COLOR_TEXT; } @@ -128,6 +129,11 @@ -fx-background-color: COLOR_VGRAD_DARK; } +.list-cell .detail-label { + -fx-text-fill: COLOR_TEXT_LIGHT; + -fx-font-size: 0.8em; +} + /******************************************************************************* * * * ScrollBar * diff --git a/main/ui/src/main/resources/css/mac_theme.css b/main/ui/src/main/resources/css/mac_theme.css index d9c10b2a5..8cbe91c89 100644 --- a/main/ui/src/main/resources/css/mac_theme.css +++ b/main/ui/src/main/resources/css/mac_theme.css @@ -14,6 +14,7 @@ -fx-font-size: 13px; COLOR_TEXT: #000; + COLOR_TEXT_LIGHT: #888; COLOR_TEXT_DISABLED: #B5B5B5; COLOR_HYPERLINK: #0069D9; COLOR_BORDER: #C8C8C8; @@ -151,7 +152,7 @@ } .list-cell { -fx-background-color: #FFF; - -fx-padding: 0.8em 0.5em 0.8em 0.5em; + -fx-padding: 6px; -fx-text-fill: COLOR_TEXT; -fx-opacity: 1; } @@ -170,6 +171,17 @@ -fx-text-fill: #FFF; } +.list-cell .detail-label { + -fx-text-fill: COLOR_TEXT_LIGHT; + -fx-font-size: 0.8em; +} + +.list-view:focused > .virtual-flow > .clipped-container > .sheet > .list-cell:focused .detail-label, +.list-view > .virtual-flow > .clipped-container > .sheet > .list-cell:filled:selected .detail-label, +.list-view > .virtual-flow > .clipped-container > .sheet > .list-cell:filled:selected:hover .detail-label{ + -fx-text-fill: #FFF; +} + /******************************************************************************* * * * ScrollBar * @@ -302,9 +314,9 @@ ******************************************************************************/ .tooltip { - -fx-background-color: COLOR_BORDER; + -fx-background-color: COLOR_BORDER, COLOR_BACKGROUND; -fx-padding: 0.2em 0.4em 0.2em 0.4em; - -fx-effect: dropshadow(three-pass-box, rgba(0,0,0,0.8), 2, 0, 0, 0); + -fx-effect: dropshadow(three-pass-box, rgba(0,0,0,0.5), 2, 0, 0, 0); -fx-font-size: 0.8em; } diff --git a/main/ui/src/main/resources/css/win_theme.css b/main/ui/src/main/resources/css/win_theme.css index 11bd49458..fd09f370d 100644 --- a/main/ui/src/main/resources/css/win_theme.css +++ b/main/ui/src/main/resources/css/win_theme.css @@ -138,7 +138,7 @@ } .list-cell { -fx-background-color: #FFF; - -fx-padding: 0.8em 0.5em 0.8em 0.5em; + -fx-padding: 0.6em; -fx-text-fill: COLOR_TEXT; -fx-opacity: 1; } @@ -154,6 +154,11 @@ -fx-background-color: #F7F7F7; } +.list-cell .detail-label { + -fx-text-fill: COLOR_TEXT_DISABLED; + -fx-font-size: 0.8em; +} + /******************************************************************************* * * * ScrollBar *