From 49ecba6c23333890f92a33358db06e12cf6d7078 Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R Date: Tue, 21 Jul 2020 08:41:41 +0200 Subject: [PATCH] Add binding from list width to message padding --- .../envoy/client/ui/listcell/MessageListCell.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/client/src/main/java/envoy/client/ui/listcell/MessageListCell.java b/client/src/main/java/envoy/client/ui/listcell/MessageListCell.java index 44c51bb..9e194df 100644 --- a/client/src/main/java/envoy/client/ui/listcell/MessageListCell.java +++ b/client/src/main/java/envoy/client/ui/listcell/MessageListCell.java @@ -1,5 +1,6 @@ package envoy.client.ui.listcell; +import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.control.ListView; @@ -20,12 +21,18 @@ public final class MessageListCell extends AbstractListCell listView) { super(listView); } + public MessageListCell(ListView listView) { + super(listView); + } @Override protected MessageControl renderItem(Message message) { final var control = new MessageControl(message); - maxWidthProperty().bind(listView.widthProperty().multiply(0.6)); + listView.widthProperty() + .addListener((observable, oldValue, newValue) -> { + int padding = Math.min(100, newValue.intValue() / 10); + setPadding(new Insets(0, padding, 0, padding)); + }); if (control.isOwnMessage()) setAlignment(Pos.CENTER_RIGHT); else setAlignment(Pos.CENTER_LEFT); return control;