@@ -915,7 +915,8 @@ private void updateRebuildCanvasButton() {
915915 private interface UIState {
916916 void enter ();
917917 int getStateId ();
918- }
918+ default void exit () {}
919+ }
919920
920921 // State registry
921922 private final Map <Integer , UIState > states = new HashMap <>();
@@ -950,9 +951,15 @@ private void initializeStates() {
950951 */
951952 public void changeState (final int newState ) {
952953 if (newState == currentState || plugin == null ) return ; // plugin may be null when exiting
954+
955+ // Call exit() on current state
956+ UIState oldState = states .get (currentState );
957+ if (oldState != null ) oldState .exit ();
958+
953959 currentState = newState ;
954960
955961 SwingUtilities .invokeLater (() -> {
962+ if (currentState != newState ) return ; // Verify state hasn't changed since we queued this
956963 UIState state = states .get (newState );
957964 if (state != null ) {
958965 state .enter ();
@@ -1087,11 +1094,37 @@ public int getStateId() {
10871094 }
10881095
10891096 private class RunningCmdState implements UIState {
1097+ private static final String [] BRAILLE = {"⠋" , "⠙" , "⠹" , "⠸" , "⠼" , "⠴" , "⠦" , "⠧" , "⠇" , "⠏" };
1098+ private static final String [] SPINNER_FRAMES ;
1099+ static {
1100+ SPINNER_FRAMES = new String [BRAILLE .length ];
1101+ for (int i = 0 ; i < BRAILLE .length ; i ++) {
1102+ SPINNER_FRAMES [i ] = "<html><strong>Running Command... <span style='font-size:1.1em'>"
1103+ + BRAILLE [i ] + " " + BRAILLE [i ] + " " + BRAILLE [i ] + "</span></strong></html>" ;
1104+ }
1105+ }
1106+ Timer runningAnimationTimer ;
1107+ private int spinnerIndex = 0 ;
1108+
10901109 @ Override
10911110 public void enter () {
10921111 updateStatusText ("Running Command..." );
10931112 disableEverything ();
1094- }
1113+ spinnerIndex = 0 ;
1114+ runningAnimationTimer = new Timer (150 , e -> {
1115+ spinnerIndex = (spinnerIndex + 1 ) % SPINNER_FRAMES .length ;
1116+ statusText .setText (SPINNER_FRAMES [spinnerIndex ]);
1117+ });
1118+ runningAnimationTimer .start ();
1119+ }
1120+
1121+ @ Override
1122+ public void exit () {
1123+ if (runningAnimationTimer != null ) {
1124+ runningAnimationTimer .stop ();
1125+ runningAnimationTimer = null ;
1126+ }
1127+ }
10951128
10961129 @ Override
10971130 public int getStateId () {
@@ -4284,7 +4317,7 @@ protected void abortCurrentOperation() {// FIXME: MOVE TO SNT?
42844317 }
42854318 }
42864319 if (activeWorker != null && !activeWorker .isDone ()) activeWorker .kill ();
4287- changeState (WAITING_TO_START_PATH );
4320+ changeState (plugin . tracingHalted ? TRACING_PAUSED : WAITING_TO_START_PATH );
42884321 }
42894322
42904323 protected void launchSigmaPaletteAround (final int x , final int y ) {
0 commit comments