Make thumbnail size configurable
Add combobox on the bottom of ThumbOverviewTab. Add integer thumbWidth to the Settings to save and restore the selected value between sessions. Set the selected value for all thumbnails on all tabs.
This commit is contained in:
parent
e0ff933cba
commit
7d36586b04
|
@ -1,6 +1,7 @@
|
|||
1.4.3
|
||||
========================
|
||||
* Added possibility to switch the video resolution for a recording
|
||||
* Added selection box below the overview pages to change the thumbnail size
|
||||
|
||||
1.4.2
|
||||
========================
|
||||
|
|
|
@ -37,4 +37,6 @@ public class Settings {
|
|||
public String proxyPort;
|
||||
public String proxyUser;
|
||||
public String proxyPassword;
|
||||
public int thumbWidth = 180;
|
||||
|
||||
}
|
||||
|
|
|
@ -58,9 +58,7 @@ import okhttp3.Response;
|
|||
public class ThumbCell extends StackPane {
|
||||
|
||||
private static final transient Logger LOG = LoggerFactory.getLogger(ThumbCell.class);
|
||||
|
||||
private static final int WIDTH = 180;
|
||||
private static final int HEIGHT = 135;
|
||||
public static int width = 180;
|
||||
private static final Duration ANIMATION_DURATION = new Duration(250);
|
||||
|
||||
// this acts like a cache, once the stream resolution for a model has been determined, we don't do it again (until ctbrec is restarted)
|
||||
|
@ -98,18 +96,16 @@ public class ThumbCell extends StackPane {
|
|||
|
||||
iv = new ImageView();
|
||||
setImage(model.getPreview());
|
||||
iv.setFitWidth(WIDTH);
|
||||
iv.setFitHeight(HEIGHT);
|
||||
iv.setSmooth(true);
|
||||
getChildren().add(iv);
|
||||
|
||||
nameBackground = new Rectangle(WIDTH, 20);
|
||||
nameBackground = new Rectangle();
|
||||
nameBackground.setFill(recording ? colorRecording : colorNormal);
|
||||
nameBackground.setOpacity(.7);
|
||||
StackPane.setAlignment(nameBackground, Pos.BOTTOM_CENTER);
|
||||
getChildren().add(nameBackground);
|
||||
|
||||
topicBackground = new Rectangle(WIDTH, 115);
|
||||
topicBackground = new Rectangle();
|
||||
topicBackground.setFill(Color.BLACK);
|
||||
topicBackground.setOpacity(0);
|
||||
StackPane.setAlignment(topicBackground, Pos.TOP_LEFT);
|
||||
|
@ -138,11 +134,7 @@ public class ThumbCell extends StackPane {
|
|||
topic.setFont(new Font("Sansserif", 13));
|
||||
topic.setTextAlignment(TextAlignment.LEFT);
|
||||
topic.setOpacity(0);
|
||||
topic.prefHeight(110);
|
||||
topic.maxHeight(110);
|
||||
int margin = 4;
|
||||
topic.maxWidth(WIDTH-margin*2);
|
||||
topic.setWrappingWidth(WIDTH-margin*2);
|
||||
StackPane.setMargin(topic, new Insets(margin));
|
||||
StackPane.setAlignment(topic, Pos.TOP_CENTER);
|
||||
getChildren().add(topic);
|
||||
|
@ -188,8 +180,7 @@ public class ThumbCell extends StackPane {
|
|||
}
|
||||
});
|
||||
|
||||
setMinSize(WIDTH, HEIGHT);
|
||||
setPrefSize(WIDTH, HEIGHT);
|
||||
setThumbWidth(width);
|
||||
|
||||
setRecording(recording);
|
||||
if(Config.getInstance().getSettings().determineResolution) {
|
||||
|
@ -542,4 +533,25 @@ public class ThumbCell extends StackPane {
|
|||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setThumbWidth(int width) {
|
||||
int height = width * 3 / 4;
|
||||
setSize(width, height);
|
||||
}
|
||||
|
||||
private void setSize(int w, int h) {
|
||||
iv.setFitWidth(w);
|
||||
iv.setFitHeight(h);
|
||||
setMinSize(w, h);
|
||||
setPrefSize(w, h);
|
||||
nameBackground.setWidth(w);
|
||||
nameBackground.setHeight(20);
|
||||
topicBackground.setWidth(w);
|
||||
topicBackground.setHeight(h-nameBackground.getHeight());
|
||||
topic.prefHeight(h-25);
|
||||
topic.maxHeight(h-25);
|
||||
int margin = 4;
|
||||
topic.maxWidth(w-margin*2);
|
||||
topic.setWrappingWidth(w-margin*2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,9 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.sun.javafx.collections.ObservableListWrapper;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.HttpClient;
|
||||
import ctbrec.Model;
|
||||
import ctbrec.ModelParser;
|
||||
|
@ -35,6 +38,8 @@ import javafx.geometry.Insets;
|
|||
import javafx.scene.Node;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.control.TextField;
|
||||
|
@ -69,6 +74,8 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
|
|||
Button pageNext = new Button("▶");
|
||||
private volatile boolean updatesSuspended = false;
|
||||
|
||||
private ComboBox<Integer> thumbWidth;
|
||||
|
||||
public ThumbOverviewTab(String title, String url, boolean loginRequired) {
|
||||
super(title);
|
||||
this.url = url;
|
||||
|
@ -121,11 +128,44 @@ 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));
|
||||
thumbSizeSelector.getChildren().add(l);
|
||||
List<Integer> thumbWidths = new ArrayList<>();
|
||||
thumbWidths.add(180);
|
||||
thumbWidths.add(200);
|
||||
thumbWidths.add(220);
|
||||
thumbWidths.add(270);
|
||||
thumbWidths.add(360);
|
||||
thumbWidth = new ComboBox<>(new ObservableListWrapper<>(thumbWidths));
|
||||
thumbWidth.getSelectionModel().select(new Integer(ThumbCell.width));
|
||||
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);
|
||||
}
|
||||
});
|
||||
thumbSizeSelector.getChildren().add(thumbWidth);
|
||||
BorderPane.setMargin(thumbSizeSelector, new Insets(5));
|
||||
|
||||
|
||||
BorderPane bottomPane = new BorderPane();
|
||||
bottomPane.setLeft(pagination);
|
||||
bottomPane.setRight(thumbSizeSelector);
|
||||
|
||||
BorderPane root = new BorderPane();
|
||||
root.setPadding(new Insets(5));
|
||||
root.setTop(search);
|
||||
root.setCenter(scrollPane);
|
||||
root.setBottom(pagination);
|
||||
root.setBottom(bottomPane);
|
||||
setContent(root);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue