diff --git a/gtk2_ardour/editor_regions.cc b/gtk2_ardour/editor_regions.cc index 7993fd5380..6bc695bd63 100644 --- a/gtk2_ardour/editor_regions.cc +++ b/gtk2_ardour/editor_regions.cc @@ -363,7 +363,7 @@ EditorRegions::set_session (ARDOUR::Session* s) { SessionHandlePtr::set_session (s); - ARDOUR::Region::RegionPropertyChanged.connect (region_property_connection, MISSING_INVALIDATOR, boost::bind (&EditorRegions::region_changed, this, _1, _2), gui_context ()); + ARDOUR::Region::RegionsPropertyChanged.connect (region_property_connection, MISSING_INVALIDATOR, boost::bind (&EditorRegions::regions_changed, this, _1, _2), gui_context ()); ARDOUR::RegionFactory::CheckNewRegion.connect (check_new_region_connection, MISSING_INVALIDATOR, boost::bind (&EditorRegions::add_region, this, _1), gui_context ()); redisplay (); @@ -390,7 +390,9 @@ EditorRegions::add_region (boost::shared_ptr region) } PropertyChange pc; - region_changed (region, pc); + boost::shared_ptr rl (new RegionList); + rl->push_back (region); + regions_changed (rl, pc); } void @@ -435,38 +437,42 @@ EditorRegions::remove_unused_regions () } void -EditorRegions::region_changed (boost::shared_ptr r, const PropertyChange& what_changed) +EditorRegions::regions_changed (boost::shared_ptr rl, const PropertyChange& what_changed) { - RegionRowMap::iterator map_it = region_row_map.find (r); + for (RegionList::const_iterator i = rl->begin (); i != rl->end(); ++i) { + boost::shared_ptr r = *i; - boost::shared_ptr pl = r->playlist (); - if (!(pl && _session && _session->playlist_is_active (pl))) { - /* this region is not on an active playlist - * maybe it got deleted, or whatever */ - if (map_it != region_row_map.end ()) { - Gtk::TreeModel::iterator r = map_it->second; - region_row_map.erase (map_it); - _model->erase (r); + RegionRowMap::iterator map_it = region_row_map.find (r); + + boost::shared_ptr pl = r->playlist (); + if (!(pl && _session && _session->playlist_is_active (pl))) { + /* this region is not on an active playlist + * maybe it got deleted, or whatever */ + if (map_it != region_row_map.end ()) { + Gtk::TreeModel::iterator r = map_it->second; + region_row_map.erase (map_it); + _model->erase (r); + } + return; } - return; - } - if (map_it != region_row_map.end ()) { - /* found the region, update its row properties */ - TreeModel::Row row = *(map_it->second); - populate_row (r, row, what_changed); + if (map_it != region_row_map.end ()) { + /* found the region, update its row properties */ + TreeModel::Row row = *(map_it->second); + populate_row (r, row, what_changed); - } else { - /* new region, add it to the list */ - TreeModel::iterator iter = _model->append (); - TreeModel::Row row = *iter; - region_row_map.insert (pair, Gtk::TreeModel::iterator> (r, iter)); + } else { + /* new region, add it to the list */ + TreeModel::iterator iter = _model->append (); + TreeModel::Row row = *iter; + region_row_map.insert (pair, Gtk::TreeModel::iterator> (r, iter)); - /* set the properties that don't change */ - row[_columns.region] = r; + /* set the properties that don't change */ + row[_columns.region] = r; - /* now populate the properties that might change... */ - populate_row (r, row, PropertyChange ()); + /* now populate the properties that might change... */ + populate_row (r, row, PropertyChange ()); + } } } diff --git a/gtk2_ardour/editor_regions.h b/gtk2_ardour/editor_regions.h index 921d4b6afc..4c2f46f49b 100644 --- a/gtk2_ardour/editor_regions.h +++ b/gtk2_ardour/editor_regions.h @@ -121,7 +121,7 @@ private: void freeze_tree_model (); void thaw_tree_model (); - void region_changed (boost::shared_ptr, PBD::PropertyChange const &); + void regions_changed (boost::shared_ptr, PBD::PropertyChange const &); void selection_changed (); sigc::connection _change_connection; diff --git a/gtk2_ardour/editor_sources.cc b/gtk2_ardour/editor_sources.cc index bf7ff03f1b..b13adc0396 100644 --- a/gtk2_ardour/editor_sources.cc +++ b/gtk2_ardour/editor_sources.cc @@ -321,7 +321,7 @@ EditorSources::set_session (ARDOUR::Session* s) SessionHandlePtr::set_session (s); if (s) { - ARDOUR::Region::RegionPropertyChanged.connect (source_property_connection, MISSING_INVALIDATOR, boost::bind (&EditorSources::source_changed, this, _1, _2), gui_context ()); + ARDOUR::Region::RegionsPropertyChanged.connect (source_property_connection, MISSING_INVALIDATOR, boost::bind (&EditorSources::regions_changed, this, _1, _2), gui_context ()); ARDOUR::RegionFactory::CheckNewRegion.connect (add_source_connection, MISSING_INVALIDATOR, boost::bind (&EditorSources::add_source, this, _1), gui_context()); @@ -506,21 +506,25 @@ EditorSources::add_source (boost::shared_ptr region) } void -EditorSources::source_changed (boost::shared_ptr region, PBD::PropertyChange const &) +EditorSources::regions_changed (boost::shared_ptr rl, PBD::PropertyChange const &) { - if (!region->whole_file ()) { - /*this isn't on our list anyway; we can ignore it*/ - return; - } + for (RegionList::const_iterator r = rl->begin (); r != rl->end(); ++r) { + boost::shared_ptr region = *r; - TreeModel::iterator i; - TreeModel::Children rows = _model->children(); + if (!region->whole_file ()) { + /*this isn't on our list anyway; we can ignore it*/ + return; + } - for (i = rows.begin(); i != rows.end(); ++i) { - boost::shared_ptr rr = (*i)[_columns.region]; - if (region == rr) { - populate_row(*i, region); - break; + TreeModel::iterator i; + TreeModel::Children rows = _model->children(); + + for (i = rows.begin(); i != rows.end(); ++i) { + boost::shared_ptr rr = (*i)[_columns.region]; + if (region == rr) { + populate_row(*i, region); + break; + } } } } diff --git a/gtk2_ardour/editor_sources.h b/gtk2_ardour/editor_sources.h index abc01ff9c8..9923c2f679 100644 --- a/gtk2_ardour/editor_sources.h +++ b/gtk2_ardour/editor_sources.h @@ -92,7 +92,7 @@ private: void freeze_tree_model (); void thaw_tree_model (); - void source_changed (boost::shared_ptr, PBD::PropertyChange const&); + void regions_changed (boost::shared_ptr, PBD::PropertyChange const&); void populate_row (Gtk::TreeModel::Row row, boost::shared_ptr region); void selection_changed (); diff --git a/gtk2_ardour/editor_summary.cc b/gtk2_ardour/editor_summary.cc index a262eae6b7..d29c3a2a02 100644 --- a/gtk2_ardour/editor_summary.cc +++ b/gtk2_ardour/editor_summary.cc @@ -117,7 +117,7 @@ EditorSummary::set_session (Session* s) */ if (_session) { - Region::RegionPropertyChanged.connect (region_property_connection, invalidator (*this), boost::bind (&EditorSummary::set_background_dirty, this), gui_context()); + Region::RegionsPropertyChanged.connect (region_property_connection, invalidator (*this), boost::bind (&EditorSummary::set_background_dirty, this), gui_context()); PresentationInfo::Change.connect (route_ctrl_id_connection, invalidator (*this), boost::bind (&EditorSummary::set_background_dirty, this), gui_context()); _editor->playhead_cursor()->PositionChanged.connect (position_connection, invalidator (*this), boost::bind (&EditorSummary::playhead_position_changed, this, _1), gui_context()); _session->StartTimeChanged.connect (_session_connections, invalidator (*this), boost::bind (&EditorSummary::set_background_dirty, this), gui_context()); diff --git a/gtk2_ardour/luasignal_syms.h b/gtk2_ardour/luasignal_syms.h index cd572db6e4..0ab8189152 100644 --- a/gtk2_ardour/luasignal_syms.h +++ b/gtk2_ardour/luasignal_syms.h @@ -82,7 +82,7 @@ STATIC(DiskOverrun, &ARDOUR::DiskWriter::Overrun, 0) STATIC(DiskUnderrun, &ARDOUR::DiskReader::Underrun, 0) // Region static -STATIC(RegionPropertyChanged, &ARDOUR::Region::RegionPropertyChanged, 2) +STATIC(RegionsPropertyChanged, &ARDOUR::Region::RegionsPropertyChanged, 2) // Timers STATIC(LuaTimerS, &LuaInstance::LuaTimerS, 0) diff --git a/gtk2_ardour/recorder_ui.cc b/gtk2_ardour/recorder_ui.cc index 874b64bf72..66a5eab8e4 100644 --- a/gtk2_ardour/recorder_ui.cc +++ b/gtk2_ardour/recorder_ui.cc @@ -393,7 +393,7 @@ RecorderUI::set_session (Session* s) _session->config.ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&RecorderUI::parameter_changed, this, _1), gui_context ()); - Region::RegionPropertyChanged.connect (*this, invalidator (*this), boost::bind (&RecorderUI::region_changed, this, _1, _2), gui_context()); + Region::RegionsPropertyChanged.connect (*this, invalidator (*this), boost::bind (&RecorderUI::regions_changed, this, _1, _2), gui_context()); _session->StartTimeChanged.connect (_session_connections, invalidator (*this), boost::bind (&RecorderUI::gui_extents_changed, this), gui_context()); _session->EndTimeChanged.connect (_session_connections, invalidator (*this), boost::bind (&RecorderUI::gui_extents_changed, this), gui_context()); _session->RecordStateChanged.connect (_session_connections, invalidator (*this), boost::bind (&RecorderUI::update_sensitivity, this), gui_context()); @@ -795,7 +795,7 @@ RecorderUI::port_pretty_name_changed (string pn) } void -RecorderUI::region_changed (boost::shared_ptr, PBD::PropertyChange const& what_changed) +RecorderUI::regions_changed (boost::shared_ptr, PBD::PropertyChange const& what_changed) { PBD::PropertyChange interests; interests.add (ARDOUR::Properties::position); diff --git a/gtk2_ardour/recorder_ui.h b/gtk2_ardour/recorder_ui.h index 3cea3425bd..31adb02e32 100644 --- a/gtk2_ardour/recorder_ui.h +++ b/gtk2_ardour/recorder_ui.h @@ -80,7 +80,7 @@ private: void parameter_changed (std::string const&); void presentation_info_changed (PBD::PropertyChange const&); void gui_extents_changed (); - void region_changed (boost::shared_ptr, PBD::PropertyChange const&); + void regions_changed (boost::shared_ptr, PBD::PropertyChange const&); void start_updating (); void stop_updating (); diff --git a/share/scripts/_hook_test.lua b/share/scripts/_hook_test.lua index a2c3b87630..eccdbeb74d 100644 --- a/share/scripts/_hook_test.lua +++ b/share/scripts/_hook_test.lua @@ -7,11 +7,11 @@ ardour { function signals () s = LuaSignal.Set() - --s:add ({[LuaSignal.SoloActive] = true, [LuaSignal.RegionPropertyChanged] = true}) + --s:add ({[LuaSignal.SoloActive] = true, [LuaSignal.RegionsPropertyChanged] = true}) s:add ( { [LuaSignal.SoloActive] = true, - [LuaSignal.RegionPropertyChanged] = true + [LuaSignal.RegionsPropertyChanged] = true } ) --for k,v in pairs (s:table()) do print (k, v) end @@ -26,15 +26,17 @@ function factory (params) Session:goto_start() end - if (signal == LuaSignal.RegionPropertyChanged) then - obj,pch = ... + if (signal == LuaSignal.RegionsPropertyChanged) then + rl,pch = ... file = io.open ("/tmp/test" ,"a") io.output (file) - io.write (string.format ("Region: '%s' pos-changed: %s, length-changed: %s\n", - obj:name (), - tostring (pch:containsSamplePos (ARDOUR.Properties.Start)), - tostring (pch:containsSamplePos (ARDOUR.Properties.Length)) - )) + for region in rl:iter() do + io.write (string.format ("Region: '%s' pos-changed: %s, length-changed: %s\n", + region:name (), + tostring (pch:containsSamplePos (ARDOUR.Properties.Position)), + tostring (pch:containsSamplePos (ARDOUR.Properties.Length)) + )) + end io.close (file) end end diff --git a/share/scripts/_osc_hook_example.lua b/share/scripts/_osc_hook_example.lua index 738822eb53..b5fa6cc4f2 100644 --- a/share/scripts/_osc_hook_example.lua +++ b/share/scripts/_osc_hook_example.lua @@ -18,7 +18,7 @@ function signals () s:add ( { [LuaSignal.SoloActive] = true, - [LuaSignal.RegionPropertyChanged] = true, + [LuaSignal.RegionsPropertyChanged] = true, [LuaSignal.Exported] = true, [LuaSignal.TransportStateChange] = true } @@ -40,13 +40,15 @@ function factory (params) elseif (signal == LuaSignal.TransportStateChange) then tx:send ("/session/transport", "if", Session:transport_sample(), Session:transport_speed()) - elseif (signal == LuaSignal.RegionPropertyChanged) then - obj,pch = ... - tx:send ("/region_property_changed", "sTTiii", - obj:name (), - (pch:containsSamplePos (ARDOUR.Properties.Start)), - (pch:containsSamplePos (ARDOUR.Properties.Length)), - obj:position (), obj:start (), obj:length ()) + elseif (signal == LuaSignal.RegionsPropertyChanged) then + rl,pch = ... + for region in rl:iter() do + tx:send ("/region_property_changed", "sTTiii", + region:name (), + (pch:containsSamplePos (ARDOUR.Properties.Start)), + (pch:containsSamplePos (ARDOUR.Properties.Length)), + region:position (), region:start (), region:length ()) + end end end end