From e12ef436cad40169c5cb9299eb83906e5ce9b033 Mon Sep 17 00:00:00 2001 From: Daniel Kirschten Date: Tue, 28 May 2019 14:56:25 +0200 Subject: [PATCH] Added code for testing automatic redraws for model changes --- LogicUI/src/era/mi/gui/examples/Playground.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/LogicUI/src/era/mi/gui/examples/Playground.java b/LogicUI/src/era/mi/gui/examples/Playground.java index f5567598..78524b7d 100644 --- a/LogicUI/src/era/mi/gui/examples/Playground.java +++ b/LogicUI/src/era/mi/gui/examples/Playground.java @@ -1,10 +1,13 @@ package era.mi.gui.examples; +import org.eclipse.swt.SWT; + import era.mi.gui.LogicUIStandalone; import era.mi.gui.model.ViewModel; import era.mi.gui.model.components.GUIAndGate; import era.mi.gui.model.components.GUINotGate; import era.mi.gui.model.wires.GUIWire; +import net.haspamelodica.swt.helper.swtobjectwrappers.Point; public class Playground { @@ -16,17 +19,19 @@ public class Playground { ViewModel model = new ViewModel(); LogicUIStandalone ui = new LogicUIStandalone(model); - addComponentsAndWires(model); + addComponentsAndWires(ui, model); ui.run(); } - public static void addComponentsAndWires(ViewModel model) + public static void addComponentsAndWires(LogicUIStandalone ui, ViewModel model) { GUIAndGate andGate = new GUIAndGate(model); andGate.moveTo(10, 10); GUINotGate notGate = new GUINotGate(model); notGate.moveTo(10, 40); - new GUIWire(model, andGate.getPins().get(0), notGate.getPins().get(1)); + new GUIWire(model, andGate.getPins().get(0), notGate.getPins().get(1), new Point(20, 50)); + + ui.getLogicUICanvas().addListener(SWT.KeyDown, e -> notGate.moveTo(150, 10)); } } \ No newline at end of file -- 2.17.1