1919package com .carlfx .worldclock ;
2020
2121import javafx .animation .Interpolator ;
22+ import javafx .animation .KeyFrame ;
23+ import javafx .animation .KeyValue ;
24+ import javafx .animation .Timeline ;
2225import javafx .animation .TranslateTransition ;
2326import javafx .application .Application ;
2427import javafx .application .Platform ;
@@ -106,9 +109,8 @@ public void start(Stage stage) throws IOException {
106109
107110 // load the config form
108111 Pane centerPane = new Pane ();
109-
110112 FXMLLoader configLocationLoader = new FXMLLoader (App .class .getResource ("config-locations.fxml" ));
111- Parent configPane = configLocationLoader .load ();
113+ Pane configPane = configLocationLoader .load ();
112114 ConfigLocationsController configController = configLocationLoader .getController ();
113115
114116 // locations is a singleton from the config controller.
@@ -146,12 +148,13 @@ public void start(Stage stage) throws IOException {
146148 clockList .getChildren ()
147149 .addAll (locations .stream ()
148150 .map ( location -> createOneClock (webEngine , location )) /* Create clock from FXML */
149- .collect ( Collectors . toList () ));
151+ .toList ());
150152
151153 scrollPane .getStyleClass ().add ("clock-background" );
152154
153155 // Animate toggle between Config view vs World Clock List view
154156 windowContainer .addEventHandler (CONFIG_SHOWING , event -> {
157+ // Location list will slide out of view.
155158 TranslateTransition moveList = new TranslateTransition ();
156159 moveList .setNode (scrollPane );
157160 moveList .setDuration (Duration .millis (400 ));
@@ -166,10 +169,9 @@ public void start(Stage stage) throws IOException {
166169 moveList .setToX (0 );
167170 }
168171
172+ // Config Pane slide in view
169173 TranslateTransition moveConfig = new TranslateTransition ();
170-
171174 moveConfig .setNode (configPane );
172-
173175 moveConfig .setDuration (Duration .millis (400 ));
174176 if (!windowController .isConfigShowing ()) {
175177 scrollPane .toFront ();
@@ -183,10 +185,35 @@ public void start(Stage stage) throws IOException {
183185 moveConfig .setFromX (-scrollPane .getWidth () + scrollPane .getPadding ().getLeft () + scrollPane .getPadding ().getRight ());
184186 moveConfig .setToX (0 );
185187 }
188+ // also move bottom portion to size.
189+ // Create a Timeline for the animation
190+ // Timeline moveBottomTimeline = new Timeline();
191+ //
192+ // if (!windowController.isConfigShowing()) {
193+ // // Create a KeyValue to set the height to the initial value
194+ // KeyFrame startFrame = new KeyFrame(Duration.ZERO, new KeyValue(centerPane.maxWidthProperty(), scrollPane.getHeight()));
195+ //
196+ // // Create a KeyValue to set the height to the final value
197+ // KeyFrame endFrame = new KeyFrame(Duration.millis(400), new KeyValue(centerPane.maxWidthProperty(), configPane.heightProperty().get()));
198+ //
199+ // // Add a KeyFrame to the timeline, linking the KeyValue with the duration
200+ // moveBottomTimeline.getKeyFrames().addAll(startFrame, endFrame);
201+ // } else {
202+ // // Create a KeyValue to set the height to the initial value
203+ // KeyFrame startFrame = new KeyFrame(Duration.ZERO, new KeyValue(centerPane.maxWidthProperty(), configPane.heightProperty().get()));
204+ //
205+ // // Create a KeyValue to set the height to the final value
206+ // KeyFrame endFrame = new KeyFrame(Duration.millis(400), new KeyValue(centerPane.maxWidthProperty(), scrollPane.getHeight()));
207+ //
208+ // // Add a KeyFrame to the timeline, linking the KeyValue with the duration
209+ // moveBottomTimeline.getKeyFrames().addAll(startFrame, endFrame);
210+ // }
211+
186212// System.out.println("clock list width " + clockList.getWidth());
187213// System.out.println("config pane width " + configPane.getBoundsInParent().getWidth());
188214// System.out.println("window bar width " + windowBar.getBoundsInParent().getWidth());
189215// System.out.println(" image width " + mapImage.getBoundsInParent().getWidth());
216+ // moveBottomTimeline.playFromStart();
190217 moveConfig .playFromStart ();
191218 moveList .playFromStart ();
192219 });
0 commit comments