diff --git a/client/src/main/java/ctbrec/ui/news/StatusPane.java b/client/src/main/java/ctbrec/ui/news/StatusPane.java
index 2ffdd107..d4f4d02b 100644
--- a/client/src/main/java/ctbrec/ui/news/StatusPane.java
+++ b/client/src/main/java/ctbrec/ui/news/StatusPane.java
@@ -3,21 +3,32 @@ package ctbrec.ui.news;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
+import java.util.Set;
import ctbrec.io.HtmlParser;
import ctbrec.ui.DesktopIntegration;
+import javafx.collections.ObservableList;
import javafx.geometry.Insets;
+import javafx.geometry.Orientation;
import javafx.geometry.Pos;
+import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
+import javafx.scene.control.ScrollBar;
+import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextArea;
import javafx.scene.layout.StackPane;
+import javafx.scene.shape.Rectangle;
public class StatusPane extends StackPane {
+ TextArea content;
+ Button reply;
+
public StatusPane(Status status) {
String text = HtmlParser.getText("
" + status.getContent() + "
", "div");
- TextArea content = new TextArea(text);
+
+ content = new TextArea(text);
content.setMaxHeight(130);
content.setEditable(false);
content.setWrapText(true);
@@ -26,14 +37,49 @@ public class StatusPane extends StackPane {
ZonedDateTime createdAt = status.getCreationTime();
String creationTime = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT, FormatStyle.SHORT).format(createdAt);
Label time = new Label(creationTime);
+ time.setStyle("-fx-background-color: -fx-base");
+ time.setOpacity(.7);
+ time.setPadding(new Insets(3));
+ time.setOnMouseEntered(evt -> time.setOpacity(1));
+ time.setOnMouseExited(evt -> time.setOpacity(.7));
getChildren().add(time);
- StackPane.setMargin(time, new Insets(5));
+ StackPane.setMargin(time, new Insets(5, 5, 5, 10));
StackPane.setAlignment(time, Pos.BOTTOM_LEFT);
+ Rectangle clip = new Rectangle(time.getWidth(), time.getHeight());
+ clip.heightProperty().bind(time.heightProperty());
+ clip.widthProperty().bind(time.widthProperty());
+ clip.setArcHeight(5);
+ clip.arcWidthProperty().bind(clip.arcHeightProperty());
+ time.setClip(clip);
- Button reply = new Button("Reply");
+ reply = new Button("Reply");
reply.setOnAction((evt) -> DesktopIntegration.open(status.getUrl()));
getChildren().add(reply);
- StackPane.setMargin(reply, new Insets(5));
+ StackPane.setMargin(reply, new Insets(5, 5, 5, 5));
StackPane.setAlignment(reply, Pos.BOTTOM_RIGHT);
}
+
+ @Override
+ protected void layoutChildren() {
+ ObservableList childrenUnmodifiable = content.getChildrenUnmodifiable();
+ for (Node node : childrenUnmodifiable) {
+ if (node instanceof ScrollPane) {
+ ScrollPane scrollPane = (ScrollPane) node;
+ Set nodes = scrollPane.lookupAll(".scroll-bar");
+ for (final Node child : nodes) {
+ if (child instanceof ScrollBar) {
+ ScrollBar sb = (ScrollBar) child;
+ if (sb.getOrientation() == Orientation.VERTICAL) {
+ if (sb.isVisible()) {
+ StackPane.setMargin(reply, new Insets(5, 22, 5, 5));
+ } else {
+ StackPane.setMargin(reply, new Insets(5, 5, 5, 5));
+ }
+ }
+ }
+ }
+ }
+ }
+ super.layoutChildren();
+ }
}