6565import javafx .scene .control .Alert ;
6666import javafx .scene .control .ButtonType ;
6767import javafx .scene .control .Label ;
68+ import javafx .scene .control .ProgressIndicator ;
6869import javafx .scene .control .TextInputDialog ;
6970import javafx .scene .input .KeyCode ;
7071import javafx .scene .input .MouseButton ;
@@ -95,6 +96,7 @@ public class FxLauncher extends Application {
9596 private ActionMap actionMap ;
9697 private Cursor configuredCursor = Cursor .DEFAULT ;
9798 private javafx .scene .Scene fxScene ;
99+ private StackPane runtimeLoadingOverlay ;
98100 private File runtimeProjectRoot ;
99101 private ProjectHotReloadTracker hotReloadTracker ;
100102 private double mouseX = 0 ;
@@ -108,6 +110,7 @@ public class FxLauncher extends Application {
108110 private long lastPerfHudUpdateNs = -1L ;
109111 private double smoothedProcessCpu = Double .NaN ;
110112 private double smoothedFps = Double .NaN ;
113+ private boolean firstFrameRendered ;
111114
112115 public static void launch (Engine eng ) {
113116 launch (eng , false );
@@ -143,6 +146,8 @@ public void start(Stage primaryStage) {
143146 this .canvas = new Canvas (width , height );
144147 this .phoneRenderer = new PhoneRenderer ();
145148 root .getChildren ().addAll (this .canvas , this .phoneRenderer );
149+ this .runtimeLoadingOverlay = createRuntimeLoadingOverlay ();
150+ root .getChildren ().add (this .runtimeLoadingOverlay );
146151 this .osBean = ManagementFactory .getPlatformMXBean (OperatingSystemMXBean .class );
147152 if (showPerfHud ) {
148153 this .perfHud = createPerfHud ();
@@ -467,12 +472,42 @@ public void handle(long now) {
467472 } else {
468473 drawDefaultScene (w , h );
469474 }
475+ hideRuntimeLoadingOverlayAfterFirstFrame ();
470476 }
471477 }
472478 };
473479 timer .start ();
474480 }
475481
482+ private StackPane createRuntimeLoadingOverlay () {
483+ ProgressIndicator indicator = new ProgressIndicator ();
484+ indicator .setMouseTransparent (true );
485+ indicator .setMaxSize (42 , 42 );
486+ indicator .setStyle (
487+ "-fx-progress-color: #e8d8ad;"
488+ + "-fx-background-color: rgba(10, 10, 10, 0.72);"
489+ + "-fx-background-radius: 8;"
490+ + "-fx-padding: 10;" );
491+
492+ StackPane overlay = new StackPane (indicator );
493+ overlay .setMouseTransparent (true );
494+ overlay .setPickOnBounds (false );
495+ overlay .setAlignment (Pos .CENTER );
496+ overlay .setStyle ("-fx-background-color: rgba(0, 0, 0, 0.35);" );
497+ return overlay ;
498+ }
499+
500+ private void hideRuntimeLoadingOverlayAfterFirstFrame () {
501+ if (firstFrameRendered ) return ;
502+ firstFrameRendered = true ;
503+ if (runtimeLoadingOverlay == null ) return ;
504+ runtimeLoadingOverlay .setVisible (false );
505+ if (runtimeLoadingOverlay .getParent () instanceof StackPane parent ) {
506+ parent .getChildren ().remove (runtimeLoadingOverlay );
507+ }
508+ runtimeLoadingOverlay = null ;
509+ }
510+
476511 private HBox createPerfHud () {
477512 perfCpuLabel = createPerfHudLabel ("CPU --" , "#f27333" );
478513 perfJvmLabel = createPerfHudLabel ("JVN -- MB" , "#49a5ff" );
0 commit comments