Avoid resize flicker by passing to aspect ratio to the constructor

This commit is contained in:
0xb00bface 2020-10-03 16:48:21 +02:00
parent 9e68876022
commit 0e71729fb9
2 changed files with 5 additions and 4 deletions

View File

@ -105,11 +105,12 @@ public class ThumbCell extends StackPane {
.build(CacheLoader.from(ThumbCell::getStreamResolution));
private ThumbOverviewTab parent;
public ThumbCell(ThumbOverviewTab parent, Model model, Recorder recorder) {
public ThumbCell(ThumbOverviewTab parent, Model model, Recorder recorder, double aspectRatio) {
this.parent = parent;
this.thumbCellList = parent.grid.getChildren();
this.model = model;
this.recorder = recorder;
this.imgAspectRatio = aspectRatio;
recording = recorder.isTracked(model);
model.setSuspended(recorder.isSuspended(model));
this.setStyle("-fx-background-color: -fx-base");

View File

@ -382,8 +382,6 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
if(!found) {
ThumbCell newCell = createThumbCell(model, recorder);
newCell.setIndex(index);
newCell.setImageAspectRatio(imageAspectRatio);
newCell.preserveAspectRatioProperty().bind(preserveAspectRatio);
positionChangedOrNew.add(newCell);
}
index++;
@ -414,7 +412,9 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
}
ThumbCell createThumbCell(Model model, Recorder recorder) {
ThumbCell newCell = new ThumbCell(this, model, recorder);
ThumbCell newCell = new ThumbCell(this, model, recorder, imageAspectRatio);
newCell.setImageAspectRatio(imageAspectRatio);
newCell.preserveAspectRatioProperty().bind(preserveAspectRatio);
newCell.addEventHandler(ContextMenuEvent.CONTEXT_MENU_REQUESTED, event -> {
suspendUpdates(true);
popup = createContextMenu(newCell);