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.control.MenuItem;
import javafx.scene.image.Image; import javafx.scene.image.Image;
import javafx.scene.image.ImageView; import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox; import javafx.scene.layout.*;
import javafx.scene.layout.VBox;
import envoy.client.data.LocalDB; import envoy.client.data.LocalDB;
import envoy.client.ui.AudioControl; import envoy.client.ui.AudioControl;
@ -110,12 +109,17 @@ public class MessageControl extends Label {
final var textLabel = new Label(message.getText()); final var textLabel = new Label(message.getText());
textLabel.setMaxWidth(430); textLabel.setMaxWidth(430);
textLabel.setWrapText(true); textLabel.setWrapText(true);
vbox.getChildren().add(textLabel); HBox hBoxBottom = new HBox();
hBoxBottom.getChildren().add(textLabel);
// Setting the message status icon and background color // Setting the message status icon and background color
if (message.getSenderID() == localDB.getUser().getID()) { if (message.getSenderID() == localDB.getUser().getID()) {
final var statusIcon = new ImageView(statusImages.get(message.getStatus())); final var statusIcon = new ImageView(statusImages.get(message.getStatus()));
statusIcon.setPreserveRatio(true); 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"); getStyleClass().add("own-message");
ownMessage = true; ownMessage = true;
hbox.setAlignment(Pos.CENTER_RIGHT); hbox.setAlignment(Pos.CENTER_RIGHT);
@ -123,6 +127,7 @@ public class MessageControl extends Label {
getStyleClass().add("received-message"); getStyleClass().add("received-message");
ownMessage = false; ownMessage = false;
} }
vbox.getChildren().add(hBoxBottom);
// Adjusting height and weight of the cell to the corresponding ListView // Adjusting height and weight of the cell to the corresponding ListView
paddingProperty().setValue(new Insets(5, 20, 5, 20)); paddingProperty().setValue(new Insets(5, 20, 5, 20));
setContextMenu(contextMenu); setContextMenu(contextMenu);

View File

@ -70,13 +70,13 @@
.received-message { .received-message {
-fx-alignment: center-left; -fx-alignment: center-left;
-fx-background-radius: 4.0em; -fx-background-radius: 1.3em;
-fx-text-alignment: right; -fx-text-alignment: right;
} }
.own-message { .own-message {
-fx-alignment: center-right; -fx-alignment: center-right;
-fx-background-radius: 4.0em; -fx-background-radius: 1.3em;
-fx-text-alignment: left; -fx-text-alignment: left;
} }