From d571afaa448f55fa6beefa26bcc466980eae0006 Mon Sep 17 00:00:00 2001 From: 0xboobface <0xboobface@gmail.com> Date: Sun, 25 Nov 2018 15:56:43 +0100 Subject: [PATCH] Use theme colors * Use theme colors * Improve aspect ratio handling for images. * Display images with rounded corners --- client/src/main/java/ctbrec/ui/ThumbCell.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/client/src/main/java/ctbrec/ui/ThumbCell.java b/client/src/main/java/ctbrec/ui/ThumbCell.java index 0ffce655..eb316656 100644 --- a/client/src/main/java/ctbrec/ui/ThumbCell.java +++ b/client/src/main/java/ctbrec/ui/ThumbCell.java @@ -81,7 +81,7 @@ public class ThumbCell extends StackPane { this.recorder = recorder; recording = recorder.isRecording(model); model.setSuspended(recorder.isSuspended(model)); - this.setStyle("-fx-background-color: lightgray"); + this.setStyle("-fx-background-color: -fx-base"); iv = new ImageView(); iv.setSmooth(true); @@ -530,8 +530,14 @@ public class ThumbCell extends StackPane { } private void setSize(int w, int h) { - iv.setFitWidth(w); - iv.setFitHeight(h); + if(iv.getImage() != null) { + double aspectRatio = iv.getImage().getWidth() / iv.getImage().getHeight(); + if(aspectRatio > 1) { + iv.setFitWidth(w); + } else { + iv.setFitHeight(h); + } + } setMinSize(w, h); setPrefSize(w, h); nameBackground.setWidth(w); @@ -545,5 +551,10 @@ public class ThumbCell extends StackPane { topic.setWrappingWidth(w-margin*2); selectionOverlay.setWidth(w); selectionOverlay.setHeight(getHeight()); + + Rectangle clip = new Rectangle(w, h); + clip.setArcWidth(10); + clip.arcHeightProperty().bind(clip.arcWidthProperty()); + this.setClip(clip); } }