From 8e3d2fd56553d406672d1a306674879de3986216 Mon Sep 17 00:00:00 2001 From: 0xboobface <0xboobface@gmail.com> Date: Mon, 22 Oct 2018 18:22:26 +0200 Subject: [PATCH] Use the selected thumb size on all tabs --- src/main/java/ctbrec/ui/ThumbCell.java | 5 ++-- src/main/java/ctbrec/ui/ThumbOverviewTab.java | 27 ++++++++++++------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/main/java/ctbrec/ui/ThumbCell.java b/src/main/java/ctbrec/ui/ThumbCell.java index 00a3febb..3df795e5 100644 --- a/src/main/java/ctbrec/ui/ThumbCell.java +++ b/src/main/java/ctbrec/ui/ThumbCell.java @@ -49,7 +49,6 @@ import javafx.util.Duration; public class ThumbCell extends StackPane { private static final transient Logger LOG = LoggerFactory.getLogger(ThumbCell.class); - public static int width = 180; private static final Duration ANIMATION_DURATION = new Duration(250); private Model model; @@ -171,7 +170,7 @@ public class ThumbCell extends StackPane { resolutionTag.setVisible(true); } }); - setThumbWidth(width); + setThumbWidth(Config.getInstance().getSettings().thumbWidth); setRecording(recording); if(Config.getInstance().getSettings().determineResolution) { @@ -257,7 +256,7 @@ public class ThumbCell extends StackPane { public void changed(ObservableValue observable, Number oldValue, Number newValue) { if(newValue.doubleValue() == 1.0) { imgAspectRatio = img.getHeight() / img.getWidth(); - setThumbWidth(width); + setThumbWidth(Config.getInstance().getSettings().thumbWidth); iv.setImage(img); } } diff --git a/src/main/java/ctbrec/ui/ThumbOverviewTab.java b/src/main/java/ctbrec/ui/ThumbOverviewTab.java index 3424651c..7b071297 100644 --- a/src/main/java/ctbrec/ui/ThumbOverviewTab.java +++ b/src/main/java/ctbrec/ui/ThumbOverviewTab.java @@ -143,7 +143,6 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener { restartUpdateService(); }); - ThumbCell.width = Config.getInstance().getSettings().thumbWidth; HBox thumbSizeSelector = new HBox(5); Label l = new Label("Thumb Size"); l.setPadding(new Insets(5,0,0,0)); @@ -155,18 +154,11 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener { thumbWidths.add(270); thumbWidths.add(360); thumbWidth = new ComboBox<>(new ObservableListWrapper<>(thumbWidths)); - thumbWidth.getSelectionModel().select(new Integer(ThumbCell.width)); + thumbWidth.getSelectionModel().select(new Integer(Config.getInstance().getSettings().thumbWidth)); thumbWidth.setOnAction((e) -> { int width = thumbWidth.getSelectionModel().getSelectedItem(); - ThumbCell.width = width; Config.getInstance().getSettings().thumbWidth = width; - for (Node node : grid.getChildren()) { - ThumbCell cell = (ThumbCell) node; - cell.setThumbWidth(width); - } - for (ThumbCell cell : filteredThumbCells) { - cell.setThumbWidth(width); - } + updateThumbSize(); }); thumbSizeSelector.getChildren().add(thumbWidth); BorderPane.setMargin(thumbSizeSelector, new Insets(5)); @@ -184,6 +176,20 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener { setContent(root); } + private void updateThumbSize() { + int width = Config.getInstance().getSettings().thumbWidth; + thumbWidth.getSelectionModel().select(new Integer(width));; + for (Node node : grid.getChildren()) { + if(node instanceof ThumbCell) { + ThumbCell cell = (ThumbCell) node; + cell.setThumbWidth(width); + } + } + for (ThumbCell cell : filteredThumbCells) { + cell.setThumbWidth(width); + } + } + private void handlePageNumberInput() { try { int page = Integer.parseInt(pageInput.getText()); @@ -586,6 +592,7 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener { updateService.restart(); } } + updateThumbSize(); } @Override