From 1b373d969418117e7498dd708c3f83d216db32b4 Mon Sep 17 00:00:00 2001 From: DieGurke <55625494+DieGurke@users.noreply.github.com> Date: Thu, 23 Jul 2020 11:11:30 +0200 Subject: [PATCH] Adjusted MessageControl and linked css --- .../envoy/client/ui/listcell/MessageControl.java | 13 +++++++++---- client/src/main/resources/css/base.css | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/client/src/main/java/envoy/client/ui/listcell/MessageControl.java b/client/src/main/java/envoy/client/ui/listcell/MessageControl.java index a132b55..418660b 100644 --- a/client/src/main/java/envoy/client/ui/listcell/MessageControl.java +++ b/client/src/main/java/envoy/client/ui/listcell/MessageControl.java @@ -16,8 +16,7 @@ import javafx.scene.control.Label; import javafx.scene.control.MenuItem; import javafx.scene.image.Image; import javafx.scene.image.ImageView; -import javafx.scene.layout.HBox; -import javafx.scene.layout.VBox; +import javafx.scene.layout.*; import envoy.client.data.LocalDB; import envoy.client.ui.AudioControl; @@ -110,12 +109,17 @@ public class MessageControl extends Label { final var textLabel = new Label(message.getText()); textLabel.setMaxWidth(430); textLabel.setWrapText(true); - vbox.getChildren().add(textLabel); + HBox hBoxBottom = new HBox(); + hBoxBottom.getChildren().add(textLabel); // Setting the message status icon and background color if (message.getSenderID() == localDB.getUser().getID()) { final var statusIcon = new ImageView(statusImages.get(message.getStatus())); statusIcon.setPreserveRatio(true); - vbox.getChildren().add(statusIcon); + Region space = new Region(); + hBoxBottom.setHgrow(space, Priority.ALWAYS); + hBoxBottom.getChildren().add(space); + hBoxBottom.getChildren().add(statusIcon); + hBoxBottom.setAlignment(Pos.BOTTOM_RIGHT); getStyleClass().add("own-message"); ownMessage = true; hbox.setAlignment(Pos.CENTER_RIGHT); @@ -123,6 +127,7 @@ public class MessageControl extends Label { getStyleClass().add("received-message"); ownMessage = false; } + vbox.getChildren().add(hBoxBottom); // Adjusting height and weight of the cell to the corresponding ListView paddingProperty().setValue(new Insets(5, 20, 5, 20)); setContextMenu(contextMenu); diff --git a/client/src/main/resources/css/base.css b/client/src/main/resources/css/base.css index cee70a2..9ffe4ff 100644 --- a/client/src/main/resources/css/base.css +++ b/client/src/main/resources/css/base.css @@ -70,13 +70,13 @@ .received-message { -fx-alignment: center-left; - -fx-background-radius: 4.0em; + -fx-background-radius: 1.3em; -fx-text-alignment: right; } .own-message { -fx-alignment: center-right; - -fx-background-radius: 4.0em; + -fx-background-radius: 1.3em; -fx-text-alignment: left; }