X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.plugin.core%2Fsrc%2Fnet%2Fmograsim%2Fplugin%2FSimulationPreview.java;h=b8488d50d1c50a7c073a3afd60fe032e421aefd4;hb=70f60681406dbd8c54d3b6e254a7d1f8bffd268d;hp=9426f2c956a241dcebd8d6452fe775c04f94b67c;hpb=1852c81ce3a63e6847fc5404f91607b553fcd882;p=Mograsim.git diff --git a/net.mograsim.plugin.core/src/net/mograsim/plugin/SimulationPreview.java b/net.mograsim.plugin.core/src/net/mograsim/plugin/SimulationPreview.java index 9426f2c9..b8488d50 100644 --- a/net.mograsim.plugin.core/src/net/mograsim/plugin/SimulationPreview.java +++ b/net.mograsim.plugin.core/src/net/mograsim/plugin/SimulationPreview.java @@ -6,7 +6,6 @@ import org.eclipse.ui.themes.ITheme; import org.eclipse.ui.themes.IThemePreview; import net.haspamelodica.swt.helper.swtobjectwrappers.Point; -import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasUserInput; import net.mograsim.logic.core.timeline.Timeline; import net.mograsim.logic.ui.LogicExecuter; import net.mograsim.logic.ui.LogicUICanvas; @@ -18,17 +17,25 @@ import net.mograsim.logic.ui.model.wires.GUIWire; import net.mograsim.logic.ui.model.wires.WireCrossPoint; import net.mograsim.logic.ui.modeladapter.LogicModelParameters; import net.mograsim.logic.ui.modeladapter.ViewLogicModelAdapter; +import net.mograsim.preferences.Preferences; public class SimulationPreview implements IThemePreview { - private LogicUICanvas ui; private LogicExecuter exec; + private Preferences oldPreferences; + private Preferences currentThemePreferences; @Override @SuppressWarnings("unused") public void createControl(Composite parent, ITheme currentTheme) { + oldPreferences = Preferences.current(); + + currentThemePreferences = new ThemePreferences(currentTheme); + // TODO this will change the global preferences; so if another LogicUICanvas redraws, it will use the "new" colors too. + Preferences.setPreferences(currentThemePreferences); + ViewModelModifiable model = new ViewModelModifiable(); LogicModelParameters params = new LogicModelParameters(); params.gateProcessTime = 50; @@ -79,26 +86,18 @@ public class SimulationPreview implements IThemePreview rIn.clicked(0, 0); ui = new LogicUICanvas(parent, SWT.NONE, model); - ZoomableCanvasUserInput userInput = new ZoomableCanvasUserInput(ui); - userInput.buttonDrag = 3; - userInput.buttonZoom = 2; - userInput.enableUserInput(); - update(currentTheme); - currentTheme.getColorRegistry().addListener(e -> update(currentTheme)); - - ui.zoomSteps(12, 10, 10); + + ui.zoom(3.5, 10, 10); exec.startLiveExecution(); - } - private void update(ITheme currentTheme) - { - ui.setBackground(currentTheme.getColorRegistry().get("net.mograsim.plugin.sim_backgound")); - ui.setForeground(currentTheme.getColorRegistry().get("net.mograsim.plugin.sim_text_color")); + currentTheme.addPropertyChangeListener(e -> ui.redraw()); } @Override public void dispose() { exec.stopLiveExecution(); + if (Preferences.current() == currentThemePreferences) + Preferences.setPreferences(oldPreferences); } }