Added hover text to make clear that pressing running will pause the sim.
authorChristian Femers <femers@in.tum.de>
Sat, 21 Sep 2019 21:25:51 +0000 (23:25 +0200)
committerChristian Femers <femers@in.tum.de>
Sat, 21 Sep 2019 21:25:51 +0000 (23:25 +0200)
This might still need a better solution from an UX perspective

plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/views/LogicUIPart.java

index 42c2db4..a36ae8c 100644 (file)
@@ -4,6 +4,8 @@ import javax.inject.Inject;
 
 import org.eclipse.e4.ui.model.application.ui.basic.MPart;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseTrackListener;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
@@ -89,20 +91,40 @@ public class LogicUIPart extends ViewPart
                Composite c = new Composite(parent, SWT.NONE);
                c.setLayout(new GridLayout(4, false));
                Button pauseButton = new Button(c, SWT.TOGGLE);
-               pauseButton.setText("Running");
+               pauseButton.setSelection(true);
+               setPauseText(pauseButton, false);
 
                pauseButton.addListener(SWT.Selection, e ->
                {
-                       if (!pauseButton.getSelection())
+                       setPauseText(pauseButton, false);
+                       if (pauseButton.getSelection())
                        {
-                               pauseButton.setText("Running");
                                exec.unpauseLiveExecution();
                        } else
                        {
-                               pauseButton.setText("Paused");
                                exec.pauseLiveExecution();
                        }
                });
+               pauseButton.addMouseTrackListener(new MouseTrackListener()
+               {
+                       @Override
+                       public void mouseHover(MouseEvent e)
+                       {
+                               // nothing
+                       }
+
+                       @Override
+                       public void mouseExit(MouseEvent e)
+                       {
+                               setPauseText(pauseButton, false);
+                       }
+
+                       @Override
+                       public void mouseEnter(MouseEvent e)
+                       {
+                               setPauseText(pauseButton, true);
+                       }
+               });
 
                Label speedLabel = new Label(c, SWT.NONE);
                speedLabel.setText("Simulation Speed: ");
@@ -129,6 +151,29 @@ public class LogicUIPart extends ViewPart
                c.setVisible(true);
        }
 
+       private void setPauseText(Button pauseButton, boolean hovered)
+       {
+               if (hovered)
+               {
+                       if (pauseButton.getSelection())
+                       {
+                               pauseButton.setText("Pause?");
+                       } else
+                       {
+                               pauseButton.setText("Resume?");
+                       }
+               } else
+               {
+                       if (pauseButton.getSelection())
+                       {
+                               pauseButton.setText("Running");
+                       } else
+                       {
+                               pauseButton.setText("Paused");
+                       }
+               }
+       }
+
        @Override
        public void setFocus()
        {