X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.ui%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fui%2FLogicUIStandaloneGUI.java;fp=net.mograsim.logic.ui%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fui%2FLogicUIStandaloneGUI.java;h=64b442e33c04c8716cdbfd0578212a39931744c7;hb=07faf07e3acb8b2afdc2bf65a46bc868faaed0f8;hp=0000000000000000000000000000000000000000;hpb=0009789a8df6b8d4562b6e1cbfa75102a7516ea8;p=Mograsim.git diff --git a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/LogicUIStandaloneGUI.java b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/LogicUIStandaloneGUI.java new file mode 100644 index 00000000..64b442e3 --- /dev/null +++ b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/LogicUIStandaloneGUI.java @@ -0,0 +1,59 @@ +package net.mograsim.logic.ui; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasOverlay; +import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasUserInput; +import net.mograsim.logic.ui.model.ViewModel; +import net.mograsim.logic.ui.modeladapter.LogicModelParameters; + +/** + * Standalone simulation visualizer graphical user interface. + * + * @author Daniel Kirschten + */ +public class LogicUIStandaloneGUI +{ + private final Display display; + private final Shell shell; + private final LogicUICanvas ui; + + public LogicUIStandaloneGUI(ViewModel model) + { + display = new Display(); + shell = new Shell(display); + shell.setLayout(new FillLayout()); + ui = new LogicUICanvas(shell, SWT.NONE, model); + + ZoomableCanvasUserInput userInput = new ZoomableCanvasUserInput(ui); + userInput.buttonDrag = 3; + userInput.buttonZoom = 2; + userInput.enableUserInput(); + new ZoomableCanvasOverlay(ui, null).enableScale(); + + // TODO don't do this here + LogicModelParameters params = new LogicModelParameters(); + params.gateProcessTime = 50; + params.wireTravelTime = 10; +// timeline = ViewLogicModelAdapter.convert(model, params); + } + + public LogicUICanvas getLogicUICanvas() + { + return ui; + } + + /** + * Opens the UI shell. Returns when the shell is closed. + */ + public void run() + { + shell.open(); + while (!shell.isDisposed()) + if (!display.readAndDispatch()) + display.sleep(); + } +} \ No newline at end of file