Initialize scene with stage size in SceneContext

This apparently fixes the rendering issues when switching scenes, while
keeping the stage size constant (unless the user resizes the stage).
This commit is contained in:
Kai S. K. Engelbart 2020-11-20 14:01:00 +01:00
parent e3052a2133
commit 67ebc6be83
Signed by: kske
GPG Key ID: 8BEB13EC5DF7EF13
3 changed files with 16 additions and 12 deletions

View File

@ -66,12 +66,11 @@ public final class SceneContext implements EventListener {
if (scene == null) {
// One-time scene initialization
scene = new Scene(root);
scene = new Scene(root, stage.getWidth(), stage.getHeight());
applyCSS();
stage.setScene(scene);
} else {
scene.setRoot(root);
stage.sizeToScene();
}
stage.setResizable(info.resizable);

View File

@ -24,8 +24,8 @@
<GridPane maxHeight="-Infinity" maxWidth="-Infinity"
minHeight="400.0" minWidth="500.0"
prefHeight="${screen.visualBounds.height}"
prefWidth="${screen.visualBounds.width}"
prefHeight="${screen.visualBounds.height}"
xmlns="http://javafx.com/javafx/11.0.1"
xmlns:fx="http://javafx.com/fxml/1"
fx:controller="envoy.client.ui.controller.ChatScene">
@ -57,8 +57,7 @@
<content>
<AnchorPane minHeight="0.0" minWidth="0.0">
<children>
<VBox prefHeight="3000.0"
prefWidth="316.0">
<VBox prefHeight="3000.0" prefWidth="316.0">
<children>
<VBox id="search-panel" maxHeight="-Infinity"
minHeight="-Infinity" prefHeight="80.0" prefWidth="316.0">
@ -156,8 +155,7 @@
<Insets left="15.0" top="5.0" right="10.0" />
</HBox.margin>
</ImageView>
<Region id="transparent-background"
HBox.hgrow="ALWAYS" />
<Region id="transparent-background" HBox.hgrow="ALWAYS" />
<Button fx:id="settingsButton" mnemonicParsing="false"
onAction="#settingsButtonClicked" prefHeight="30.0"
prefWidth="30.0" alignment="CENTER_RIGHT">

View File

@ -7,11 +7,16 @@
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<VBox alignment="TOP_RIGHT" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="envoy.client.ui.controller.SettingsScene">
<VBox alignment="TOP_RIGHT" maxHeight="-Infinity" minHeight="400.0"
minWidth="500.0" xmlns="http://javafx.com/javafx/11.0.1"
xmlns:fx="http://javafx.com/fxml/1"
fx:controller="envoy.client.ui.controller.SettingsScene">
<children>
<HBox prefHeight="389.0" prefWidth="600.0">
<children>
<ListView id="message-list" fx:id="settingsList" onMouseClicked="#settingsListClicked" prefHeight="200.0" prefWidth="200.0">
<ListView id="message-list" fx:id="settingsList"
onMouseClicked="#settingsListClicked" prefHeight="200.0"
prefWidth="200.0">
<opaqueInsets>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</opaqueInsets>
@ -22,7 +27,8 @@
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
</ListView>
<TitledPane fx:id="titledPane" collapsible="false" prefHeight="400.0" prefWidth="400.0">
<TitledPane fx:id="titledPane" collapsible="false"
prefHeight="400.0" prefWidth="400.0">
<HBox.margin>
<Insets bottom="10.0" left="5.0" right="10.0" top="10.0" />
</HBox.margin>
@ -32,7 +38,8 @@
</TitledPane>
</children>
</HBox>
<Button defaultButton="true" mnemonicParsing="true" onMouseClicked="#backButtonClicked" text="_Back">
<Button defaultButton="true" mnemonicParsing="true"
onMouseClicked="#backButtonClicked" text="_Back">
<opaqueInsets>
<Insets />
</opaqueInsets>