X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=net.mograsim.plugin.core%2Fsrc%2Fnet%2Fmograsim%2Fplugin%2FSimulationPreview.java;h=42fada842ec659552a23622f5de584458a5d1050;hb=aacd9de307f43bd19065ace45688a49af064f5a5;hp=381a2bc69f25a24b42ef75ec8e168087be280d7c;hpb=0a9344ab19795856d42636b938c806d509f31542;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..42fada84 100644 --- a/net.mograsim.plugin.core/src/net/mograsim/plugin/SimulationPreview.java +++ b/net.mograsim.plugin.core/src/net/mograsim/plugin/SimulationPreview.java @@ -7,35 +7,43 @@ import org.eclipse.ui.themes.IThemePreview; import net.haspamelodica.swt.helper.swtobjectwrappers.Point; import net.mograsim.logic.core.timeline.Timeline; -import net.mograsim.logic.ui.LogicExecuter; -import net.mograsim.logic.ui.LogicUICanvas; -import net.mograsim.logic.ui.model.ViewModelModifiable; -import net.mograsim.logic.ui.model.components.GUIManualSwitch; -import net.mograsim.logic.ui.model.components.GUINotGate; -import net.mograsim.logic.ui.model.components.GUIOrGate; -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.logic.model.LogicExecuter; +import net.mograsim.logic.model.LogicUICanvas; +import net.mograsim.logic.model.model.ViewModelModifiable; +import net.mograsim.logic.model.model.components.atomic.GUIManualSwitch; +import net.mograsim.logic.model.model.components.atomic.GUINotGate; +import net.mograsim.logic.model.model.components.atomic.GUIOrGate; +import net.mograsim.logic.model.model.wires.GUIWire; +import net.mograsim.logic.model.model.wires.WireCrossPoint; +import net.mograsim.logic.model.modeladapter.LogicModelParameters; +import net.mograsim.logic.model.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; params.wireTravelTime = 10; - GUIManualSwitch rIn = new GUIManualSwitch(model); + GUIManualSwitch rIn = new GUIManualSwitch(model, 1); rIn.moveTo(10, 10); - GUIManualSwitch sIn = new GUIManualSwitch(model); + GUIManualSwitch sIn = new GUIManualSwitch(model, 1); sIn.moveTo(10, 70); GUIOrGate or1 = new GUIOrGate(model, 1); @@ -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); } }