@@ -785,8 +785,12 @@ public void setEnableDebugMode(final boolean enable) {
785785 * @param enable true to enable "Dark Mode", "Light Mode" otherwise
786786 */
787787 public void setEnableDarkMode (final boolean enable ) {
788- final boolean toggle = keyController != null && isDarkModeOn () != enable ;
789- if (toggle ) keyController .toggleDarkMode ();
788+ final Runnable r = () -> {
789+ final boolean toggle = keyController != null && isDarkModeOn () != enable ;
790+ if (toggle ) keyController .toggleDarkMode ();
791+ };
792+ if (SwingUtilities .isEventDispatchThread ()) r .run ();
793+ else SwingUtilities .invokeLater (r );
790794 }
791795
792796 /**
@@ -1810,10 +1814,10 @@ private void displayMsg(final String msg, final int msecs) {
18101814 if (frame != null ) {
18111815 SwingUtilities .invokeLater (() -> {
18121816 if (msg == null || msg .isEmpty ()) {
1813- frame .status . setText ( frame . statusPlaceHolder );
1817+ frame .updateStatusMsg ( );
18141818 return ;
18151819 }
1816- final Timer timer = new Timer (msecs , e -> frame .status . setText ( frame . statusPlaceHolder ));
1820+ final Timer timer = new Timer (msecs , e -> frame .updateStatusMsg ( ));
18171821 timer .setRepeats (false );
18181822 timer .start ();
18191823 frame .status .setText (msg );
@@ -2667,7 +2671,7 @@ public void setFont(final Font font, final float angle, final ColorRGB color) {
26672671 public boolean saveSnapshot () {
26682672 final String filename = String .format ("RecViewer%s.png" , SNTUtils .getTimeStamp ());
26692673 final File file = new File (prefs .getSnapshotDir (), filename );
2670- boolean saved = false ;
2674+ boolean saved ;
26712675 try {
26722676 saved = saveSnapshot (file );
26732677 } catch (final IllegalArgumentException | IOException | GLException e ) {
@@ -3119,17 +3123,7 @@ public void setViewMode(final ViewMode newView) {
31193123 getView ().shoot ();
31203124 currentView = newView ;
31213125 if (frame != null ) {
3122- final boolean locked = !isRotationEnabled ();
3123- SwingUtilities .invokeLater (() -> {
3124- frame .status .setIcon (IconFactory .menuIcon (
3125- locked ? GLYPH .LOCK : GLYPH .LOCK_OPEN , java .awt .Color .GRAY ));
3126- frame .status .setToolTipText (locked
3127- ? "Rotation locked (constrained view)"
3128- : "Rotation unlocked (free view)" );
3129- frame .status .setText (locked
3130- ? "Rotation disabled in locked view: Use Ctrl+click to change view mode"
3131- : frame .statusPlaceHolder );
3132- });
3126+ frame .updateStatusMsg ();
31333127 }
31343128 }
31353129
@@ -3350,7 +3344,8 @@ private class ViewerFrame extends FrameSwing implements IFrame {
33503344 private static final long serialVersionUID = 1L ;
33513345 private static final int DEF_WIDTH = 800 ;
33523346 private static final int DEF_HEIGHT = 600 ;
3353- private final String statusPlaceHolder ;
3347+ private final String STATUS_DEF_UNLOCKED ;
3348+ private final String STATUS_DEF_LOCKED ;
33543349
33553350 private AChart chart ;
33563351 private Component canvas ;
@@ -3361,6 +3356,7 @@ private class ViewerFrame extends FrameSwing implements IFrame {
33613356 private int savedDividerLocation = -1 ;
33623357 private JLabel status ;
33633358 private boolean managerVisible ;
3359+ private boolean statusVisible = true ;
33643360
33653361 // displays and full screen
33663362 private java .awt .Point loc ;
@@ -3387,9 +3383,10 @@ public ViewerFrame(final AChart chart, final int width, final int height, final
33873383 GuiUtils .setLookAndFeel ();
33883384 GuiUtils .removeIcon (this );
33893385 final String title = (chart .viewer .isSNTInstance ()) ? " (SNT)" : " (" + chart .viewer .getID () + ")" ;
3390- statusPlaceHolder = (includeManager )
3386+ STATUS_DEF_UNLOCKED = (includeManager )
33913387 ? "Press H (or F1) for Help. Press " + GuiUtils .ctrlKey () + "+Shift+P for Command Palette..."
33923388 : "Press H (or F1) for Help..." ;
3389+ STATUS_DEF_LOCKED = "Rotation disabled: Use Ctrl+click to change view mode" ;
33933390 initialize (chart , new Rectangle (width , height ), "Reconstruction Viewer" + title );
33943391 if (PlatformUtils .isLinux ()) new MultiDisplayUtil (this );
33953392 if (gConfiguration == null )
@@ -3448,6 +3445,30 @@ public ViewerFrame(final AChart chart, final int width, final int height, final
34483445 toFront ();
34493446 }
34503447
3448+ /** Applies the current theme colors (derived from the chart background) to the status bar. */
3449+ void applyStatusColors (final Color bg , final Color fg ) {
3450+ final java .awt .Color awtBg = toAWTColor (bg );
3451+ final java .awt .Color awtFg = toAWTColor (fg );
3452+ if (status .getParent () != null )
3453+ status .getParent ().setBackground (awtBg );
3454+ status .setBackground (awtBg );
3455+ status .setForeground (awtFg );
3456+ }
3457+
3458+ void updateStatusMsg () {
3459+ final boolean locked = !chart .isRotationEnabled ();
3460+ SwingUtilities .invokeLater (() -> {
3461+ status .setIcon (IconFactory .menuIcon (
3462+ locked ? GLYPH .LOCK : GLYPH .LOCK_OPEN , status .getForeground ()));
3463+ status .setToolTipText (locked
3464+ ? "Rotation locked (constrained view)"
3465+ : "Rotation unlocked (free view)" );
3466+ status .setText ((locked ) ?
3467+ currentView .description + " View | " + STATUS_DEF_LOCKED :
3468+ STATUS_DEF_UNLOCKED );
3469+ });
3470+ }
3471+
34513472 public void replaceCurrentChart (final AChart chart ) {
34523473 this .chart = chart ;
34533474 canvas = (Component ) chart .getCanvas ();
@@ -3549,7 +3570,7 @@ public void initialize(final Chart chart, final Rectangle bounds, final String t
35493570 setTitle (title );
35503571 final BorderLayout layout = new BorderLayout ();
35513572 setLayout (layout );
3552- status = new JLabel (statusPlaceHolder );
3573+ status = new JLabel (STATUS_DEF_UNLOCKED );
35533574 status .setBorder (javax .swing .BorderFactory .createEmptyBorder (0 , 8 , 0 , 0 ));
35543575 status .setFocusable (false );
35553576 status .setBackground (toAWTColor (chart .view ().getBackgroundColor ()));
@@ -3652,6 +3673,7 @@ void exitFullScreen() {
36523673 if (managerPanel != null && managerVisible ) showManagerPanel ();
36533674 if (lightController != null ) lightController .setVisible (true );
36543675 if (allenNavigator != null ) allenNavigator .dialog .setVisible (true );
3676+ status .setVisible (statusVisible );
36553677 isFullScreen = false ;
36563678 }
36573679 }
@@ -3670,7 +3692,8 @@ void enterFullScreen() {
36703692 }
36713693 if (lightController != null ) lightController .setVisible (false );
36723694 if (allenNavigator != null ) allenNavigator .dialog .setVisible (false );
3673- frame .status .setVisible (false );
3695+ statusVisible = status .isVisible ();
3696+ status .setVisible (false );
36743697 setExtendedState (JFrame .MAXIMIZED_BOTH );
36753698 isFullScreen = true ;
36763699 displayBanner ("Entered Full Screen. Press Shift+F (or \" Esc\" ) to exit..." );
@@ -9315,10 +9338,8 @@ public boolean handleSlaveThread(final MouseEvent e) {
93159338 }
93169339
93179340 private void rotateLive (final Coord2d move ) {
9318- if (!chart .isRotationEnabled ()) {
9319- displayMsg ("Rotation disabled in constrained view" );
9320- } else {
9321- rotate (move , true );
9341+ if (chart .isRotationEnabled ()) {
9342+ rotate (move , true );
93229343 }
93239344 }
93249345
@@ -9734,7 +9755,8 @@ public boolean canHandle(KeyEvent e, boolean doublePress) {
97349755 @ Override
97359756 public void execute (KeyEvent e , boolean doublePress ) {
97369757 if (e .isShiftDown () && frame != null ) {
9737- frame .status .setVisible (!frame .status .isVisible ());
9758+ frame .statusVisible = !frame .status .isVisible ();
9759+ frame .status .setVisible (frame .statusVisible );
97389760 } else {
97399761 saveScreenshot ();
97409762 }
@@ -9942,9 +9964,8 @@ private void toggleDarkMode() {
99429964 newBackground = Color .BLACK ;
99439965 }
99449966 if (frame != null ) {
9945- frame .status .getParent ().setBackground (toAWTColor (newBackground ));
9946- frame .status .setBackground (toAWTColor (newBackground ));
9947- frame .status .setForeground (toAWTColor (newForeground ));
9967+ frame .applyStatusColors (newBackground , newForeground );
9968+ frame .updateStatusMsg (); // refresh icon color to match new theme
99489969 }
99499970 view .setBackgroundColor (newBackground );
99509971 view .getAxis ().getLayout ().setGridColor (newForeground );
0 commit comments