소스 검색

changed mainWindow StageStyle to UNDECORATED
removed main_window_title area
moved main_window_resize functions to MainWindowController
put add vault button under the vault list and wrapped both in a ScrollPane
bound vault list height properties to amount of entries and width to scroll pane width
add listener to scroll down after adding a vault
moved preferences button under vault list
new style classes for new elements
changed wording

Jan-Peter Klein 1 년 전
부모
커밋
e038348dca

+ 27 - 1
src/main/java/org/cryptomator/ui/mainwindow/MainWindowController.java

@@ -1,6 +1,7 @@
 package org.cryptomator.ui.mainwindow;
 
 import org.apache.commons.lang3.SystemUtils;
+import org.cryptomator.common.settings.Settings;
 import org.cryptomator.common.vaults.Vault;
 import org.cryptomator.common.vaults.VaultListManager;
 import org.cryptomator.ui.common.FxController;
@@ -22,13 +23,15 @@ public class MainWindowController implements FxController {
 
 	private final Stage window;
 	private final ReadOnlyObjectProperty<Vault> selectedVault;
+	private final Settings settings;
 
 	public StackPane root;
 
 	@Inject
-	public MainWindowController(@MainWindow Stage window, ObjectProperty<Vault> selectedVault) {
+	public MainWindowController(@MainWindow Stage window, ObjectProperty<Vault> selectedVault, Settings settings) {
 		this.window = window;
 		this.selectedVault = selectedVault;
+		this.settings = settings;
 	}
 
 	@FXML
@@ -38,6 +41,29 @@ public class MainWindowController implements FxController {
 			root.getStyleClass().add("os-windows");
 		}
 		window.focusedProperty().addListener(this::mainWindowFocusChanged);
+
+		if (!neverTouched()) {
+			window.setHeight(settings.windowHeight.get() > window.getMinHeight() ? settings.windowHeight.get() : window.getMinHeight());
+			window.setWidth(settings.windowWidth.get() > window.getMinWidth() ? settings.windowWidth.get() : window.getMinWidth());
+			window.setX(settings.windowXPosition.get());
+			window.setY(settings.windowYPosition.get());
+		}
+		window.widthProperty().addListener((_,_,_) -> savePositionalSettings());
+		window.heightProperty().addListener((_,_,_) -> savePositionalSettings());
+		window.xProperty().addListener((_,_,_) -> savePositionalSettings());
+		window.yProperty().addListener((_,_,_) -> savePositionalSettings());
+	}
+
+	private boolean neverTouched() {
+		return (settings.windowHeight.get() == 0) && (settings.windowWidth.get() == 0) && (settings.windowXPosition.get() == 0) && (settings.windowYPosition.get() == 0);
+	}
+
+	@FXML
+	public void savePositionalSettings() {
+		settings.windowWidth.setValue(window.getWidth());
+		settings.windowHeight.setValue(window.getHeight());
+		settings.windowXPosition.setValue(window.getX());
+		settings.windowYPosition.setValue(window.getY());
 	}
 
 	private void mainWindowFocusChanged(Observable observable) {

+ 0 - 1
src/main/java/org/cryptomator/ui/mainwindow/MainWindowModule.java

@@ -41,7 +41,6 @@ abstract class MainWindowModule {
 	static Stage provideMainWindow(@PrimaryStage Stage stage, StageInitializer initializer) {
 		initializer.accept(stage);
 		stage.setTitle("Cryptomator");
-		stage.initStyle(StageStyle.UNDECORATED);
 		stage.setMinWidth(650);
 		stage.setMinHeight(440);
 		return stage;

+ 28 - 1
src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java

@@ -9,6 +9,7 @@ import org.cryptomator.ui.addvaultwizard.AddVaultWizardComponent;
 import org.cryptomator.ui.common.FxController;
 import org.cryptomator.ui.common.VaultService;
 import org.cryptomator.ui.fxapp.FxApplicationWindows;
+import org.cryptomator.ui.preferences.SelectedPreferencesTab;
 import org.cryptomator.ui.removevault.RemoveVaultComponent;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -27,13 +28,16 @@ import javafx.geometry.Side;
 import javafx.scene.control.Button;
 import javafx.scene.control.ContextMenu;
 import javafx.scene.control.ListView;
+import javafx.scene.control.ScrollPane;
 import javafx.scene.input.ContextMenuEvent;
 import javafx.scene.input.DragEvent;
 import javafx.scene.input.KeyCode;
 import javafx.scene.input.KeyEvent;
 import javafx.scene.input.MouseEvent;
 import javafx.scene.input.TransferMode;
+import javafx.scene.layout.HBox;
 import javafx.scene.layout.StackPane;
+import javafx.scene.layout.VBox;
 import javafx.stage.Stage;
 import java.io.File;
 import java.io.IOException;
@@ -71,8 +75,11 @@ public class VaultListController implements FxController {
 	private final FxApplicationWindows appWindows;
 
 	public ListView<Vault> vaultList;
+	public ScrollPane scrollPane;
+	public VBox vbox;
 	public StackPane root;
 	public Button addVaultBtn;
+	public HBox addVaultArea;
 	@FXML
 	private ContextMenu addVaultContextMenu;
 
@@ -106,6 +113,21 @@ public class VaultListController implements FxController {
 	public void initialize() {
 		vaultList.setItems(vaults);
 		vaultList.setCellFactory(cellFactory);
+
+		vaultList.prefHeightProperty().bind(vaultList.fixedCellSizeProperty().multiply(vaultList.getItems().size()));
+		vaultList.maxHeightProperty().bind(vaultList.prefHeightProperty());
+		vaultList.prefWidthProperty().bind(scrollPane.widthProperty());
+
+		vbox.heightProperty().addListener((_, oldValue, newValue) -> {
+			if(newValue.doubleValue()>oldValue.doubleValue()){
+				scrollPane.setVvalue(1.0);
+			}
+		});
+
+		vaults.addListener((ListChangeListener<Vault>) c -> {
+			vaultList.prefHeightProperty().bind(vaultList.fixedCellSizeProperty().multiply(vaultList.getItems().size()));
+			});
+
 		selectedVault.bind(vaultList.getSelectionModel().selectedItemProperty());
 		vaults.addListener((ListChangeListener.Change<? extends Vault> c) -> {
 			while (c.next()) {
@@ -171,7 +193,7 @@ public class VaultListController implements FxController {
 		if (addVaultContextMenu.isShowing()) {
 			addVaultContextMenu.hide();
 		} else {
-			addVaultContextMenu.show(addVaultBtn, Side.BOTTOM, 0.0, 0.0);
+			addVaultContextMenu.show(addVaultArea, Side.BOTTOM, 0.0, 0.0);
 		}
 	}
 
@@ -247,6 +269,11 @@ public class VaultListController implements FxController {
 		}
 	}
 
+	@FXML
+	public void showPreferences() {
+		appWindows.showPreferencesWindow(SelectedPreferencesTab.ANY);
+	}
+
 	// Getter and Setter
 
 	public BooleanBinding emptyVaultListProperty() {

+ 21 - 0
src/main/resources/css/dark_theme.css

@@ -341,6 +341,27 @@
 	-fx-background-color: CONTROL_BG_ARMED;
 }
 
+.vault-list-box {
+	-fx-background-color: CONTROL_BG_NORMAL;
+}
+
+.add-vault-btn {
+	-fx-background-color: CONTROL_BG_NORMAL;
+}
+.add-vault-btn .icon {
+	-fx-fill: TEXT_FILL_MUTED;
+}
+.add-vault-btn-label {
+	-fx-font-family: 'Open Sans SemiBold';
+	-fx-font-size: 1.0em;
+}
+
+.preferences-btn {
+	-fx-background-color: MAIN_BG;
+	-fx-border-color: CONTROL_BORDER_NORMAL transparent transparent transparent;
+	-fx-border-width: 1px 0 0 0;
+}
+
 /*******************************************************************************
  *                                                                             *
  * ScrollBar                                                                   *

+ 20 - 0
src/main/resources/css/light_theme.css

@@ -340,6 +340,26 @@
 	-fx-background-color: CONTROL_BG_ARMED;
 }
 
+.vault-list-box {
+	-fx-background-color: CONTROL_BG_NORMAL;
+}
+
+.add-vault-btn {
+	-fx-background-color: CONTROL_BG_NORMAL;
+}
+.add-vault-btn .icon {
+	-fx-fill: GRAY_4;
+}
+.add-vault-btn-label {
+	-fx-font-family: 'Open Sans SemiBold';
+	-fx-font-size: 1.0em;
+}
+
+.preferences-btn {
+	-fx-border-color: CONTROL_BORDER_NORMAL transparent transparent transparent;
+	-fx-border-width: 1px 0 0 0;
+}
+
 /*******************************************************************************
  *                                                                             *
  * ScrollBar                                                                   *

+ 0 - 2
src/main/resources/fxml/main_window.fxml

@@ -9,11 +9,9 @@
 		   fx:controller="org.cryptomator.ui.mainwindow.MainWindowController"
 		   styleClass="main-window">
 	<VBox minWidth="650">
-		<fx:include source="main_window_title.fxml" VBox.vgrow="NEVER"/>
 		<SplitPane dividerPositions="0.33" orientation="HORIZONTAL" VBox.vgrow="ALWAYS">
 			<fx:include source="vault_list.fxml" SplitPane.resizableWithParent="false"/>
 			<fx:include source="vault_detail.fxml" SplitPane.resizableWithParent="true"/>
 		</SplitPane>
 	</VBox>
-	<fx:include source="main_window_resize.fxml"/>
 </StackPane>

+ 35 - 19
src/main/resources/fxml/vault_list.fxml

@@ -1,38 +1,54 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <?import org.cryptomator.ui.controls.FontAwesome5IconView?>
-<?import javafx.scene.control.Button?>
 <?import javafx.scene.control.Label?>
 <?import javafx.scene.control.ListView?>
 <?import javafx.scene.layout.Region?>
 <?import javafx.scene.layout.StackPane?>
 <?import javafx.scene.layout.VBox?>
-<?import javafx.scene.shape.Arc?>
 <?import javafx.scene.control.ContextMenu?>
 <?import javafx.scene.control.MenuItem?>
+<?import javafx.scene.layout.HBox?>
+<?import javafx.geometry.Insets?>
+<?import javafx.scene.control.ScrollPane?>
 <StackPane xmlns:fx="http://javafx.com/fxml"
 		   xmlns="http://javafx.com/javafx"
 		   fx:id="root"
 		   fx:controller="org.cryptomator.ui.mainwindow.VaultListController"
 		   minWidth="206">
-	<VBox>
-		<StackPane VBox.vgrow="ALWAYS">
-			<ListView fx:id="vaultList" editable="true" fixedCellSize="60">
-				<contextMenu>
-					<fx:include source="vault_list_contextmenu.fxml"/>
-				</contextMenu>
-			</ListView>
-			<VBox visible="${controller.emptyVaultList}" spacing="6" alignment="CENTER">
-				<Region VBox.vgrow="ALWAYS"/>
-				<Label VBox.vgrow="NEVER" text="%main.vaultlist.emptyList.onboardingInstruction" textAlignment="CENTER" wrapText="true"/>
-				<Arc VBox.vgrow="NEVER" styleClass="onboarding-overlay-arc" type="OPEN" centerX="50" centerY="0" radiusY="100" radiusX="50" startAngle="0" length="-60" strokeWidth="1"/>
+	<VBox styleClass="vault-list-box">
+		<ScrollPane fx:id="scrollPane" hbarPolicy="NEVER">
+			<VBox fx:id="vbox">
+				<ListView fx:id="vaultList" editable="true" fixedCellSize="60">
+					<contextMenu>
+						<fx:include source="vault_list_contextmenu.fxml"/>
+					</contextMenu>
+				</ListView>
+				<HBox fx:id="addVaultArea" styleClass="add-vault-btn" spacing="12" onMouseClicked="#toggleMenu">
+					<padding>
+						<Insets topRightBottomLeft="12"/>
+					</padding>
+					<VBox alignment="CENTER" minWidth="20">
+						<FontAwesome5IconView glyph="PLUS" styleClass="icon" HBox.hgrow="NEVER" glyphSize="16"/>
+					</VBox>
+					<VBox spacing="4" HBox.hgrow="ALWAYS" >
+						<Label styleClass="add-vault-btn-label" text="%main.vaultlist.addVaultBtn" />
+					</VBox>
+				</HBox>
 			</VBox>
-		</StackPane>
-		<Button fx:id="addVaultBtn" onAction="#toggleMenu" styleClass="toolbar-button" text="%main.vaultlist.addVaultBtn" alignment="BASELINE_CENTER" maxWidth="Infinity" contentDisplay="RIGHT">
-			<graphic>
-				<FontAwesome5IconView glyph="CARET_DOWN"/>
-			</graphic>
-		</Button>
+		</ScrollPane>
+		<Region VBox.vgrow="ALWAYS"/>
+		<HBox spacing="12" styleClass="preferences-btn" onMouseClicked="#showPreferences">
+			<padding>
+				<Insets topRightBottomLeft="12"/>
+			</padding>
+			<VBox alignment="CENTER" minWidth="20">
+				<FontAwesome5IconView glyph="COG" HBox.hgrow="NEVER" glyphSize="16"/>
+			</VBox>
+			<VBox spacing="4" HBox.hgrow="ALWAYS">
+				<Label styleClass="header-label" text="%preferences.title"/>
+			</VBox>
+		</HBox>
 		<fx:define>
 			<ContextMenu fx:id="addVaultContextMenu">
 				<items>

+ 1 - 1
src/main/resources/i18n/strings.properties

@@ -389,7 +389,7 @@ main.vaultlist.contextMenu.unlock=Unlock…
 main.vaultlist.contextMenu.unlockNow=Unlock Now
 main.vaultlist.contextMenu.vaultoptions=Show Vault Options
 main.vaultlist.contextMenu.reveal=Reveal Drive
-main.vaultlist.addVaultBtn=Add
+main.vaultlist.addVaultBtn=Add Vault
 main.vaultlist.addVaultBtn.menuItemNew=New Vault...
 main.vaultlist.addVaultBtn.menuItemExisting=Existing Vault...
 ## Vault Detail