X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.plugin.core%2Fsrc%2Fnet%2Fmograsim%2Fplugin%2FSimulationPreview.java;h=b8488d50d1c50a7c073a3afd60fe032e421aefd4;hb=a2815c569225ca01628436d32a82abeea12359c5;hp=381a2bc69f25a24b42ef75ec8e168087be280d7c;hpb=26d9949f46bb25f77297b5c3134a809104b3c7c4;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 381a2bc6..b8488d50 100644 --- a/net.mograsim.plugin.core/src/net/mograsim/plugin/SimulationPreview.java +++ b/net.mograsim.plugin.core/src/net/mograsim/plugin/SimulationPreview.java @@ -17,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; @@ -81,11 +89,15 @@ public class SimulationPreview implements IThemePreview ui.zoom(3.5, 10, 10); exec.startLiveExecution(); + + currentTheme.addPropertyChangeListener(e -> ui.redraw()); } @Override public void dispose() { exec.stopLiveExecution(); + if (Preferences.current() == currentThemePreferences) + Preferences.setPreferences(oldPreferences); } }