From: Mark Slee Date: Sat, 19 Oct 2013 20:07:47 +0000 (-0700) Subject: Call onTransitionEnd() after active X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=c1d777c91652c808bbf8bb196d85eeb0287b0be7;p=SugarCubes.git Call onTransitionEnd() after active --- diff --git a/_Presets.pde b/_Presets.pde index ada8bb1..7743cbf 100644 --- a/_Presets.pde +++ b/_Presets.pde @@ -4,7 +4,7 @@ interface PresetListener { public void onPresetStored(Preset preset); } -class PresetManager { +class PresetManager implements LXParameter.Listener { public static final int NUM_PRESETS = 8; public static final String FILENAME = "data/presets.txt"; @@ -13,7 +13,8 @@ class PresetManager { private final Preset[] presets = new Preset[NUM_PRESETS]; private final List listeners = new ArrayList(); - private LXPattern loadedPreset = null; + private Preset loadedPreset = null; + private LXPattern loadedPattern = null; PresetManager() { for (int i = 0; i < presets.length; ++i) { @@ -43,12 +44,31 @@ class PresetManager { public void store(int index) { presets[index].store(midiEngine.getFocusedPattern()); + select(index); } public void onPresetLoaded(Preset preset, LXPattern pattern) { + if (loadedPattern != pattern) { + if (loadedPattern != null) { + for (LXParameter p : loadedPattern.getParameters()) { + ((LXListenableParameter) p).removeListener(this); + } + } + } for (PresetListener listener : listeners) { listener.onPresetLoaded(preset); } + loadedPreset = preset; + loadedPattern = pattern; + for (LXParameter p : loadedPattern.getParameters()) { + ((LXListenableParameter) p).addListener(this); + } + } + + public void onParameterChanged(LXParameter p) { + for (PresetListener listener : listeners) { + listener.onPresetDirty(loadedPreset); + } } public void write() { diff --git a/code/HeronLX.jar b/code/HeronLX.jar index 3a64906..de2032b 100755 Binary files a/code/HeronLX.jar and b/code/HeronLX.jar differ