Skip to content

Commit

Permalink
Merge pull request #254 from solver-it-sro/AG_135/hack2
Browse files Browse the repository at this point in the history
window relayout hack again
  • Loading branch information
jsuchal authored Aug 9, 2023
2 parents 98e45e3 + d331864 commit b88ceeb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
4 changes: 4 additions & 0 deletions src/main/java/digital/slovensko/autogram/ui/gui/GUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,12 @@ public void showVisualization(Visualization visualization, Autogram autogram) {
stage.setOnCloseRequest(e -> cancelJob(visualization.getJob()));

stage.sizeToScene();



GUIUtils.suppressDefaultFocus(stage, controller);
GUIUtils.showOnTop(stage);
GUIUtils.hackToForceRelayout(stage);
setUserFriendlyPositionAndLimits(stage);
}

Expand Down
7 changes: 7 additions & 0 deletions src/main/java/digital/slovensko/autogram/ui/gui/GUIUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,11 @@ public static String exceptionToString(Exception exception) {

return writer.toString();
}

public static void hackToForceRelayout(Stage stage) {
// this MUST be run after stage was shown to work on all platforms
var w = stage.getScene().getWindow();
// This forces layout recalculation and fixes issue https://github.com/slovensko-digital/autogram/issues/172
w.setHeight(w.getHeight() - 1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,6 @@ public SigningDialogController(Visualization visualization, Autogram autogram, G
public void initialize() {
refreshSigningKey();
visualization.initialize(this);

Platform.runLater(() -> {
var w = mainBox.getScene().getWindow();
// This forces layout recalculation and fixes issue https://github.com/slovensko-digital/autogram/issues/172
w.setHeight(w.getHeight() - 1);
});

}

public void onMainButtonPressed(ActionEvent event) {
Expand All @@ -89,10 +82,8 @@ public void refreshSigningKey() {
mainButton.getStyleClass().add("autogram-button--secondary");
changeKeyButton.setVisible(false);
} else {
mainButton.setText("Podpísať ako "
+ DSSUtils.parseCN(key.getCertificate().getSubject().getRFC2253()));
mainButton.getStyleClass()
.removeIf(style -> style.equals("autogram-button--secondary"));
mainButton.setText("Podpísať ako " + DSSUtils.parseCN(key.getCertificate().getSubject().getRFC2253()));
mainButton.getStyleClass().removeIf(style -> style.equals("autogram-button--secondary"));
changeKeyButton.setVisible(true);
}
}
Expand Down Expand Up @@ -153,8 +144,7 @@ public void showPDFVisualization(String base64EncodedPdf) {

public void showImageVisualization(CommonDocument doc) {
// TODO what about visualization
imageVisualization.fitWidthProperty()
.bind(imageVisualizationContainer.widthProperty().subtract(4));
imageVisualization.fitWidthProperty().bind(imageVisualizationContainer.widthProperty().subtract(4));
imageVisualization.setImage(new Image(doc.openStream()));
imageVisualization.setPreserveRatio(true);
imageVisualization.setSmooth(true);
Expand Down

0 comments on commit b88ceeb

Please sign in to comment.