X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=plugins%2Fnet.mograsim.plugin.core%2Fsrc%2Fnet%2Fmograsim%2Fplugin%2Fviews%2FLogicUIPart.java;h=42c2db4a55f7852ce8ce816776a79d960136bb0d;hb=46d4c053db9a363185a9dce28fcefbc3bf9d6afd;hp=49c6fa435ee1396034ea17a190345bca1c7f3cb7;hpb=76c2b3eab6cec47490bb75713356152deb5d07ed;p=Mograsim.git 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 49c6fa43..42c2db4a 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 @@ -6,7 +6,10 @@ import org.eclipse.e4.ui.model.application.ui.basic.MPart; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Slider; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.ViewPart; @@ -51,6 +54,8 @@ public class LogicUIPart extends ViewPart GridLayout layout = new GridLayout(1, true); parent.setLayout(layout); + addSimulationControlWidgets(parent); + ui = new LogicUICanvas(parent, SWT.NONE, m.getModel()); ui.addTransformListener((x, y, z) -> part.setDirty(z < 1)); ZoomableCanvasUserInput userInput = new ZoomableCanvasUserInput(ui); @@ -79,6 +84,51 @@ public class LogicUIPart extends ViewPart exec.startLiveExecution(); } + private void addSimulationControlWidgets(Composite parent) + { + Composite c = new Composite(parent, SWT.NONE); + c.setLayout(new GridLayout(4, false)); + Button pauseButton = new Button(c, SWT.TOGGLE); + pauseButton.setText("Running"); + + pauseButton.addListener(SWT.Selection, e -> + { + if (!pauseButton.getSelection()) + { + pauseButton.setText("Running"); + exec.unpauseLiveExecution(); + } else + { + pauseButton.setText("Paused"); + exec.pauseLiveExecution(); + } + }); + + Label speedLabel = new Label(c, SWT.NONE); + speedLabel.setText("Simulation Speed: "); + + Slider slider = new Slider(c, SWT.NONE); + slider.setMinimum(1); + slider.setMaximum(100 + slider.getThumb()); + slider.setIncrement(1); + + Label speedPercentageLabel = new Label(c, SWT.NONE); + speedPercentageLabel.setText("100%"); + + slider.addListener(SWT.Selection, e -> + { + int selection = slider.getSelection(); + speedPercentageLabel.setText(selection + "%"); + + exec.setSpeedPercentage(slider.getSelection()); + }); + slider.setSelection(100); + + c.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL)); + c.pack(); + c.setVisible(true); + } + @Override public void setFocus() {