Adjusted MessageControl and linked css

This commit is contained in:
DieGurke 2020-07-23 11:11:30 +02:00
parent 8837273982
commit 1b373d9694
2 changed files with 11 additions and 6 deletions

View File

@ -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);

View File

@ -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;
}