From ad4b52f92ad16bf309bfa9f18af55127c05794b7 Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Tue, 16 Oct 2018 19:01:50 +0200 Subject: [PATCH] Adapt ComboBox and CheckBox positioning and layout --- desktop/src/main/java/bisq/desktop/bisq.css | 5 ++ .../MobileNotificationsView.java | 9 ++- .../main/overlays/windows/FilterWindow.java | 2 +- .../windows/SendAlertMessageWindow.java | 2 +- .../windows/ShowWalletDataWindow.java | 2 +- .../settings/preferences/PreferencesView.java | 23 ++++--- .../java/bisq/desktop/util/FormBuilder.java | 66 ++++++------------- .../main/java/bisq/desktop/util/Layout.java | 1 + 8 files changed, 43 insertions(+), 67 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/bisq.css b/desktop/src/main/java/bisq/desktop/bisq.css index 05374f3eb2..9070ef1c75 100644 --- a/desktop/src/main/java/bisq/desktop/bisq.css +++ b/desktop/src/main/java/bisq/desktop/bisq.css @@ -274,6 +274,11 @@ bg color of non edit textFields: fafafa -jfx-unfocus-color: -bs-rd-grey-line; } +.jfx-combo-box > .list-cell { + -fx-text-fill: -bs-rd-black; + -fx-font-family: "IBM Plex Sans Medium"; +} + .jfx-combo-box > .arrow-button > .arrow { -fx-background-color: null; -fx-border-color: -jfx-unfocus-color; diff --git a/desktop/src/main/java/bisq/desktop/main/account/content/notifications/MobileNotificationsView.java b/desktop/src/main/java/bisq/desktop/main/account/content/notifications/MobileNotificationsView.java index 4fe4a4a3cb..c220b64cd1 100644 --- a/desktop/src/main/java/bisq/desktop/main/account/content/notifications/MobileNotificationsView.java +++ b/desktop/src/main/java/bisq/desktop/main/account/content/notifications/MobileNotificationsView.java @@ -432,8 +432,7 @@ public class MobileNotificationsView extends ActivatableView { useSoundCheckBox = FormBuilder.addLabelCheckBox(root, gridRow, Res.get("account.notifications.useSound.label"), - "", - Layout.FIRST_ROW_AND_GROUP_DISTANCE).second; + Layout.FIRST_ROW_AND_GROUP_DISTANCE); useSoundCheckBox.setSelected(preferences.isUseSoundForMobileNotifications()); useSoundCheckBoxListener = (observable, oldValue, newValue) -> { mobileNotificationService.getUseSoundProperty().set(newValue); @@ -441,7 +440,7 @@ public class MobileNotificationsView extends ActivatableView { }; tradeCheckBox = FormBuilder.addLabelCheckBox(root, ++gridRow, - Res.get("account.notifications.trade.label")).second; + Res.get("account.notifications.trade.label")); tradeCheckBox.setSelected(preferences.isUseTradeNotifications()); tradeCheckBoxListener = (observable, oldValue, newValue) -> { mobileNotificationService.getUseTradeNotificationsProperty().set(newValue); @@ -449,7 +448,7 @@ public class MobileNotificationsView extends ActivatableView { }; marketCheckBox = FormBuilder.addLabelCheckBox(root, ++gridRow, - Res.get("account.notifications.market.label")).second; + Res.get("account.notifications.market.label")); marketCheckBox.setSelected(preferences.isUseMarketNotifications()); marketCheckBoxListener = (observable, oldValue, newValue) -> { mobileNotificationService.getUseMarketNotificationsProperty().set(newValue); @@ -457,7 +456,7 @@ public class MobileNotificationsView extends ActivatableView { updateMarketAlertFields(); }; priceCheckBox = FormBuilder.addLabelCheckBox(root, ++gridRow, - Res.get("account.notifications.price.label")).second; + Res.get("account.notifications.price.label")); priceCheckBox.setSelected(preferences.isUsePriceNotifications()); priceCheckBoxListener = (observable, oldValue, newValue) -> { mobileNotificationService.getUsePriceNotificationsProperty().set(newValue); diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/FilterWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/FilterWindow.java index f5bc3e5266..17f56e0dd2 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/FilterWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/FilterWindow.java @@ -135,7 +135,7 @@ public class FilterWindow extends Overlay { InputTextField seedNodesInputTextField = addLabelInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.seedNode")).second; InputTextField priceRelayNodesInputTextField = addLabelInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.priceRelayNode")).second; InputTextField btcNodesInputTextField = addLabelInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.btcNode")).second; - CheckBox preventPublicBtcNetworkCheckBox = addLabelCheckBox(gridPane, ++rowIndex, Res.get("filterWindow.preventPublicBtcNetwork")).second; + CheckBox preventPublicBtcNetworkCheckBox = addLabelCheckBox(gridPane, ++rowIndex, Res.get("filterWindow.preventPublicBtcNetwork")); final Filter filter = filterManager.getDevelopersFilter(); if (filter != null) { diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/SendAlertMessageWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/SendAlertMessageWindow.java index b668dcdad8..3365e61090 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/SendAlertMessageWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/SendAlertMessageWindow.java @@ -122,7 +122,7 @@ public class SendAlertMessageWindow extends Overlay { Label first = labelTextAreaTuple2.first; first.setMinWidth(150); CheckBox isUpdateCheckBox = addLabelCheckBox(gridPane, ++rowIndex, - Res.get("sendAlertMessageWindow.isUpdate"), "").second; + Res.get("sendAlertMessageWindow.isUpdate")); isUpdateCheckBox.setSelected(true); InputTextField versionInputTextField = addLabelInputTextField(gridPane, ++rowIndex, diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/ShowWalletDataWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/ShowWalletDataWindow.java index 6541a62cb2..c7717faecf 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/ShowWalletDataWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/ShowWalletDataWindow.java @@ -85,7 +85,7 @@ public class ShowWalletDataWindow extends Overlay { textArea.setPrefHeight(500); textArea.getStyleClass().add("small-text"); CheckBox isUpdateCheckBox = addLabelCheckBox(gridPane, ++rowIndex, - Res.get("showWalletDataWindow.includePrivKeys"), "").second; + Res.get("showWalletDataWindow.includePrivKeys")); isUpdateCheckBox.setSelected(false); isUpdateCheckBox.selectedProperty().addListener((observable, oldValue, newValue) -> { diff --git a/desktop/src/main/java/bisq/desktop/main/settings/preferences/PreferencesView.java b/desktop/src/main/java/bisq/desktop/main/settings/preferences/PreferencesView.java index e3ad677dbb..655e624562 100644 --- a/desktop/src/main/java/bisq/desktop/main/settings/preferences/PreferencesView.java +++ b/desktop/src/main/java/bisq/desktop/main/settings/preferences/PreferencesView.java @@ -189,9 +189,8 @@ public class PreferencesView extends ActivatableViewAndModeladdComboBox(root, gridRow, + selectBaseCurrencyNetworkComboBox = FormBuilder.addComboBox(root, gridRow, Res.get("settings.preferences.selectCurrencyNetwork"), Layout.FIRST_ROW_DISTANCE); - selectBaseCurrencyNetworkComboBox.setConverter(new StringConverter<>() { @Override public String toString(BaseCurrencyNetwork baseCurrencyNetwork) { @@ -206,11 +205,11 @@ public class PreferencesView extends ActivatableViewAndModeladdComboBox(root, ++gridRow, + userLanguageComboBox = FormBuilder.addComboBox(root, ++gridRow, Res.get("shared.language")); - userCountryComboBox = FormBuilder.addComboBox(root, ++gridRow, + userCountryComboBox = FormBuilder.addComboBox(root, ++gridRow, Res.get("shared.country")); - blockChainExplorerComboBox = FormBuilder.addComboBox(root, ++gridRow, + blockChainExplorerComboBox = FormBuilder.addComboBox(root, ++gridRow, Res.get("setting.preferences.explorer")); Tuple3 tuple = addLabelInputTextFieldCheckBox(root, ++gridRow, @@ -289,7 +288,7 @@ public class PreferencesView extends ActivatableViewAndModeladdComboBox(root, gridRow, Res.get("setting.preferences.prefCurrency"), + preferredTradeCurrencyComboBox = FormBuilder.addComboBox(root, gridRow, Res.get("setting.preferences.prefCurrency"), Layout.FIRST_ROW_AND_GROUP_DISTANCE); preferredTradeCurrencyComboBox.setConverter(new StringConverter() { @Override @@ -433,7 +432,7 @@ public class PreferencesView extends ActivatableViewAndModeladdComboBox(root, ++gridRow); + fiatCurrenciesComboBox = FormBuilder.addComboBox(root, ++gridRow); fiatCurrenciesComboBox.setPromptText(Res.get("setting.preferences.addFiat")); fiatCurrenciesComboBox.setButtonCell(new ListCell() { @Override @@ -495,10 +494,10 @@ public class PreferencesView extends ActivatableViewAndModel addLabelInputTextFieldCheckBox(GridPane gridPane, int rowIndex, String title, String checkBoxTitle) { - Label label = addLabel(gridPane, rowIndex, title, 0); + public static Tuple3 addTopLabelInputTextFieldCheckBox(GridPane gridPane, int rowIndex, String title, String checkBoxTitle) { + Label label = getTopLabel(title); InputTextField inputTextField = new InputTextField(); CheckBox checkBox = new AutoTooltipCheckBox(checkBoxTitle); - HBox.setMargin(checkBox, new Insets(4, 0, 0, 0)); + VBox.setMargin(checkBox, new Insets(4, 0, 0, 0)); - HBox hBox = new HBox(); - hBox.setSpacing(10); - hBox.getChildren().addAll(inputTextField, checkBox); - GridPane.setRowIndex(hBox, rowIndex); - GridPane.setColumnIndex(hBox, 1); - gridPane.getChildren().add(hBox); + VBox vBox = getTopLabelVBox(0); + + vBox.getChildren().addAll(label, inputTextField, checkBox); + GridPane.setRowIndex(vBox, rowIndex); + GridPane.setColumnIndex(vBox, 0); + gridPane.getChildren().add(vBox); return new Tuple3<>(label, inputTextField, checkBox); } @@ -616,25 +616,6 @@ public class FormBuilder { return radioButton; } - /////////////////////////////////////////////////////////////////////////////////////////// - // Label + RadioButton - /////////////////////////////////////////////////////////////////////////////////////////// - - public static Tuple2 addLabelRadioButton(GridPane gridPane, int rowIndex, ToggleGroup toggleGroup, String title, String - radioButtonTitle) { - Label label = addLabel(gridPane, rowIndex, title, 0); - - RadioButton radioButton = new AutoTooltipRadioButton(radioButtonTitle); - radioButton.setToggleGroup(toggleGroup); - radioButton.setPadding(new Insets(6, 0, 0, 0)); - GridPane.setRowIndex(radioButton, rowIndex); - GridPane.setColumnIndex(radioButton, 1); - gridPane.getChildren().add(radioButton); - - return new Tuple2<>(label, radioButton); - } - - /////////////////////////////////////////////////////////////////////////////////////////// // Label + RadioButton + RadioButton /////////////////////////////////////////////////////////////////////////////////////////// @@ -672,25 +653,18 @@ public class FormBuilder { // Label + CheckBox /////////////////////////////////////////////////////////////////////////////////////////// - public static Tuple2 addLabelCheckBox(GridPane gridPane, int rowIndex, String title) { - return addLabelCheckBox(gridPane, rowIndex, title, "", 0); + public static CheckBox addLabelCheckBox(GridPane gridPane, int rowIndex, String title) { + return addLabelCheckBox(gridPane, rowIndex, title, 0); } - public static Tuple2 addLabelCheckBox(GridPane gridPane, int rowIndex, String title, String checkBoxTitle) { - return addLabelCheckBox(gridPane, rowIndex, title, checkBoxTitle, 0); - } - - public static Tuple2 addLabelCheckBox(GridPane gridPane, int rowIndex, String title, String checkBoxTitle, double top) { - Label label = addLabel(gridPane, rowIndex, title, -3); - GridPane.setMargin(label, new Insets(top, 0, 0, 0)); - - CheckBox checkBox = new AutoTooltipCheckBox(checkBoxTitle); + public static CheckBox addLabelCheckBox(GridPane gridPane, int rowIndex, String title, double top) { + CheckBox checkBox = new AutoTooltipCheckBox(title); GridPane.setRowIndex(checkBox, rowIndex); - GridPane.setColumnIndex(checkBox, 1); - GridPane.setMargin(checkBox, new Insets(top, 0, 0, 0)); + GridPane.setColumnIndex(checkBox, 0); + GridPane.setMargin(checkBox, new Insets(top + Layout.FLOATING_LABEL_DISTANCE, 0, 0, 0)); gridPane.getChildren().add(checkBox); - return new Tuple2<>(label, checkBox); + return checkBox; } /////////////////////////////////////////////////////////////////////////////////////////// @@ -767,11 +741,10 @@ public class FormBuilder { } public static ComboBox addComboBox(GridPane gridPane, int rowIndex, String title, double top) { - Label label = null; - JFXComboBox comboBox = new JFXComboBox<>(); comboBox.setLabelFloat(true); comboBox.setPromptText(title); + comboBox.setMaxWidth(Double.MAX_VALUE); // Default ComboBox does not show promptText after clear selection. // https://stackoverflow.com/questions/50569330/how-to-reset-combobox-and-display-prompttext?noredirect=1&lq=1 @@ -789,9 +762,8 @@ public class FormBuilder { }); GridPane.setRowIndex(comboBox, rowIndex); - GridPane.setHalignment(comboBox, HPos.LEFT); GridPane.setColumnIndex(comboBox, 0); - GridPane.setMargin(comboBox, new Insets(top, 0, 0, 0)); + GridPane.setMargin(comboBox, new Insets(top + Layout.FLOATING_LABEL_DISTANCE, 0, 0, 0)); gridPane.getChildren().add(comboBox); return comboBox; @@ -1051,7 +1023,7 @@ public class FormBuilder { BalanceTextField balanceTextField = new BalanceTextField(title); GridPane.setRowIndex(balanceTextField, rowIndex); GridPane.setColumnIndex(balanceTextField, 0); - GridPane.setMargin(balanceTextField, new Insets(20, 0,0,0)); + GridPane.setMargin(balanceTextField, new Insets(20, 0, 0, 0)); gridPane.getChildren().add(balanceTextField); return balanceTextField; diff --git a/desktop/src/main/java/bisq/desktop/util/Layout.java b/desktop/src/main/java/bisq/desktop/util/Layout.java index daef600e5d..3702e19934 100644 --- a/desktop/src/main/java/bisq/desktop/util/Layout.java +++ b/desktop/src/main/java/bisq/desktop/util/Layout.java @@ -21,6 +21,7 @@ public class Layout { public static final double INITIAL_SCENE_WIDTH = 1200; public static final double INITIAL_SCENE_HEIGHT = 710; //740 public static final double FIRST_ROW_DISTANCE = 20d; + public static final double FLOATING_LABEL_DISTANCE = 20d; public static final double GROUP_DISTANCE = 40d; public static final double FIRST_ROW_AND_GROUP_DISTANCE = GROUP_DISTANCE + FIRST_ROW_DISTANCE; public static final double PADDING_WINDOW = 20d;