From 8543e94040ab012390ab9c743dbcf5eecd466964 Mon Sep 17 00:00:00 2001 From: DieGurke Date: Thu, 1 Oct 2020 22:59:07 +0200 Subject: [PATCH] Added ability to remove users from quick select list --- .../client/ui/control/QuickSelectControl.java | 16 +++++++++++++--- .../client/ui/controller/GroupCreationTab.java | 4 +++- client/src/main/resources/css/dark.css | 5 +++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/client/src/main/java/envoy/client/ui/control/QuickSelectControl.java b/client/src/main/java/envoy/client/ui/control/QuickSelectControl.java index f8b286e..6585ff5 100644 --- a/client/src/main/java/envoy/client/ui/control/QuickSelectControl.java +++ b/client/src/main/java/envoy/client/ui/control/QuickSelectControl.java @@ -1,11 +1,12 @@ package envoy.client.ui.control; import javafx.geometry.Pos; -import javafx.scene.control.Label; +import javafx.scene.control.*; import javafx.scene.image.ImageView; import javafx.scene.layout.VBox; import javafx.scene.shape.Rectangle; +import envoy.client.ui.controller.GroupCreationTab; import envoy.client.util.IconUtil; import envoy.data.User; @@ -15,7 +16,17 @@ import envoy.data.User; */ public class QuickSelectControl extends VBox { - public QuickSelectControl(User user) { + public QuickSelectControl(User user, GroupCreationTab tab) { + Button removeBtn = new Button(); + removeBtn.setPrefSize(10, 10); + removeBtn.setMaxSize(10, 10); + removeBtn.setMinSize(10, 10); + removeBtn.setAlignment(Pos.TOP_RIGHT); + removeBtn.setOnMouseClicked(evt -> { + tab.removeFromQuickSelection(this); + }); + removeBtn.setId("remove-button"); + getChildren().add(removeBtn); // Profile picture ImageView contactProfilePic = new ImageView(IconUtil.loadIconThemeSensitive("user_icon", 32)); @@ -38,5 +49,4 @@ public class QuickSelectControl extends VBox { getStyleClass().add("quick-select"); } - } diff --git a/client/src/main/java/envoy/client/ui/controller/GroupCreationTab.java b/client/src/main/java/envoy/client/ui/controller/GroupCreationTab.java index 7970c5d..8f055dd 100644 --- a/client/src/main/java/envoy/client/ui/controller/GroupCreationTab.java +++ b/client/src/main/java/envoy/client/ui/controller/GroupCreationTab.java @@ -91,7 +91,7 @@ public class GroupCreationTab implements EventListener { @FXML private void userListClicked() { createButton.setDisable(userList.getSelectionModel().isEmpty() || groupNameField.getText().isBlank()); - quickSelectList.getItems().add(new QuickSelectControl(userList.getSelectionModel().getSelectedItem())); + quickSelectList.getItems().add(new QuickSelectControl(userList.getSelectionModel().getSelectedItem(), this)); } /** @@ -157,6 +157,8 @@ public class GroupCreationTab implements EventListener { return localDB.getChats().stream().map(Chat::getRecipient).filter(Group.class::isInstance).map(Contact::getName).anyMatch(newName::equals); } + public void removeFromQuickSelection(QuickSelectControl element) { quickSelectList.getItems().remove(element); } + @FXML private void backButtonClicked() { eventBus.dispatch(new BackEvent()); diff --git a/client/src/main/resources/css/dark.css b/client/src/main/resources/css/dark.css index eb52eed..e2ef2e7 100644 --- a/client/src/main/resources/css/dark.css +++ b/client/src/main/resources/css/dark.css @@ -83,3 +83,8 @@ -fx-text-fill: white; -fx-background-color: transparent; } + +#remove-button { + -fx-background-color: red; + -fx-background-radius: 1em; +}