Adjust message padding immediately
This commit is contained in:
parent
9ea8d24ab6
commit
00fc160550
@ -116,7 +116,7 @@ public class MessageControl extends Label {
|
|||||||
final var statusIcon = new ImageView(statusImages.get(message.getStatus()));
|
final var statusIcon = new ImageView(statusImages.get(message.getStatus()));
|
||||||
statusIcon.setPreserveRatio(true);
|
statusIcon.setPreserveRatio(true);
|
||||||
Region space = new Region();
|
Region space = new Region();
|
||||||
hBoxBottom.setHgrow(space, Priority.ALWAYS);
|
HBox.setHgrow(space, Priority.ALWAYS);
|
||||||
hBoxBottom.getChildren().add(space);
|
hBoxBottom.getChildren().add(space);
|
||||||
hBoxBottom.getChildren().add(statusIcon);
|
hBoxBottom.getChildren().add(statusIcon);
|
||||||
hBoxBottom.setAlignment(Pos.BOTTOM_RIGHT);
|
hBoxBottom.setAlignment(Pos.BOTTOM_RIGHT);
|
||||||
|
@ -17,26 +17,27 @@ import envoy.data.Message;
|
|||||||
* @since Envoy Client v0.1-beta
|
* @since Envoy Client v0.1-beta
|
||||||
*/
|
*/
|
||||||
public final class MessageListCell extends AbstractListCell<Message, MessageControl> {
|
public final class MessageListCell extends AbstractListCell<Message, MessageControl> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param listView the list view inside of which the cell will be displayed
|
* @param listView the list view inside of which the cell will be displayed
|
||||||
* @since Envoy Client v0.1-beta
|
* @since Envoy Client v0.1-beta
|
||||||
*/
|
*/
|
||||||
public MessageListCell(ListView<? extends Message> listView) {
|
public MessageListCell(ListView<? extends Message> listView) { super(listView); }
|
||||||
super(listView);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected MessageControl renderItem(Message message) {
|
protected MessageControl renderItem(Message message) {
|
||||||
final var control = new MessageControl(message);
|
final var control = new MessageControl(message);
|
||||||
listView.widthProperty()
|
listView.widthProperty().addListener((observable, oldValue, newValue) -> adjustPadding(newValue.intValue()));
|
||||||
.addListener((observable, oldValue, newValue) -> {
|
adjustPadding((int) listView.getWidth());
|
||||||
int padding = 0;
|
|
||||||
if (newValue.intValue() > 1020) padding = (newValue.intValue() - 1000) / 2;
|
|
||||||
else padding = 10;
|
|
||||||
setPadding(new Insets(0, padding, 6, padding));
|
|
||||||
});
|
|
||||||
if (control.isOwnMessage()) setAlignment(Pos.CENTER_RIGHT);
|
if (control.isOwnMessage()) setAlignment(Pos.CENTER_RIGHT);
|
||||||
else setAlignment(Pos.CENTER_LEFT);
|
else setAlignment(Pos.CENTER_LEFT);
|
||||||
return control;
|
return control;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void adjustPadding(int listWidth) {
|
||||||
|
int padding = 0;
|
||||||
|
if (listWidth > 1020) padding = (listWidth - 1000) / 2;
|
||||||
|
else padding = 10;
|
||||||
|
setPadding(new Insets(0, padding, 6, padding));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user