From 5045f9d777247d015153da1388abba103a08e05c Mon Sep 17 00:00:00 2001 From: Christian Femers Date: Sat, 21 Sep 2019 23:25:51 +0200 Subject: [PATCH] Added hover text to make clear that pressing running will pause the sim. This might still need a better solution from an UX perspective --- .../mograsim/plugin/views/LogicUIPart.java | 53 +++++++++++++++++-- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/views/LogicUIPart.java b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/views/LogicUIPart.java index 42c2db4a..a36ae8cc 100644 --- a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/views/LogicUIPart.java +++ b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/views/LogicUIPart.java @@ -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() { -- 2.17.1