refactor MIDISceneChange color property addition by moving it into SceneChange to...
[ardour.git] / libs / ardour / midi_scene_changer.cc
index 75a1a98cb74b0c63dba24c5c43145606626b8045..285a370402eade62ccfd61e6fffb937b365f140c 100644 (file)
@@ -310,6 +310,19 @@ MIDISceneChanger::program_change_input (MIDI::Parser& parser, MIDI::byte program
 
        MIDISceneChange* msc =new MIDISceneChange (channel, bank, program & 0x7f);
 
+        /* check for identical scene change so we can re-use color, if any */
+
+        Locations::LocationList copy (locations->list());
+
+        for (Locations::LocationList::const_iterator l = copy.begin(); l != copy.end(); ++l) {
+                boost::shared_ptr<MIDISceneChange> sc = boost::dynamic_pointer_cast<MIDISceneChange>((*l)->scene_change());
+
+                if (sc && (*sc.get()) == *msc) {
+                        msc->set_color (sc->color ());
+                        break;
+                }
+        }
+
        loc->set_scene_change (boost::shared_ptr<MIDISceneChange> (msc));
        
        /* this will generate a "changed" signal to be emitted by locations,