Update GUI Region[s]PropertyChanged signal handlers (2/3)

This commit is contained in:
Robin Gareus 2021-05-07 22:45:28 +02:00
parent 2ff8f5a5de
commit 283cade057
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
10 changed files with 78 additions and 64 deletions

View File

@ -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> region)
}
PropertyChange pc;
region_changed (region, pc);
boost::shared_ptr<RegionList> 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<Region> r, const PropertyChange& what_changed)
EditorRegions::regions_changed (boost::shared_ptr<RegionList> 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<Region> r = *i;
boost::shared_ptr<ARDOUR::Playlist> 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<ARDOUR::Playlist> 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<boost::shared_ptr<ARDOUR::Region>, 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<boost::shared_ptr<ARDOUR::Region>, 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 ());
}
}
}

View File

@ -121,7 +121,7 @@ private:
void freeze_tree_model ();
void thaw_tree_model ();
void region_changed (boost::shared_ptr<ARDOUR::Region>, PBD::PropertyChange const &);
void regions_changed (boost::shared_ptr<ARDOUR::RegionList>, PBD::PropertyChange const &);
void selection_changed ();
sigc::connection _change_connection;

View File

@ -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<ARDOUR::Region> region)
}
void
EditorSources::source_changed (boost::shared_ptr<ARDOUR::Region> region, PBD::PropertyChange const &)
EditorSources::regions_changed (boost::shared_ptr<ARDOUR::RegionList> 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> 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<ARDOUR::Region> 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<ARDOUR::Region> rr = (*i)[_columns.region];
if (region == rr) {
populate_row(*i, region);
break;
}
}
}
}

View File

@ -92,7 +92,7 @@ private:
void freeze_tree_model ();
void thaw_tree_model ();
void source_changed (boost::shared_ptr<ARDOUR::Region>, PBD::PropertyChange const&);
void regions_changed (boost::shared_ptr<ARDOUR::RegionList>, PBD::PropertyChange const&);
void populate_row (Gtk::TreeModel::Row row, boost::shared_ptr<ARDOUR::Region> region);
void selection_changed ();

View File

@ -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());

View File

@ -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)

View File

@ -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<ARDOUR::Region>, PBD::PropertyChange const& what_changed)
RecorderUI::regions_changed (boost::shared_ptr<ARDOUR::RegionList>, PBD::PropertyChange const& what_changed)
{
PBD::PropertyChange interests;
interests.add (ARDOUR::Properties::position);

View File

@ -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<ARDOUR::Region>, PBD::PropertyChange const&);
void regions_changed (boost::shared_ptr<ARDOUR::RegionList>, PBD::PropertyChange const&);
void start_updating ();
void stop_updating ();

View File

@ -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

View File

@ -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