13
0

Rework time info box updates on region selection change

Should provide better performance as we now only listen for changes in the
selected regions. Testing every changed region to see if its in
the selection was not working very well under some circumstances.
This commit is contained in:
nick_m 2017-06-17 04:08:56 +10:00
parent d1932b23b3
commit fb761a6fa7
2 changed files with 35 additions and 37 deletions

View File

@ -28,11 +28,12 @@
#include "ardour/profile.h"
#include "ardour/session.h"
#include "time_info_box.h"
#include "audio_clock.h"
#include "editor.h"
#include "control_point.h"
#include "automation_line.h"
#include "control_point.h"
#include "editor.h"
#include "region_view.h"
#include "time_info_box.h"
#include "pbd/i18n.h"
@ -136,7 +137,6 @@ TimeInfoBox::TimeInfoBox (std::string state_node_name, bool with_punch)
Editor::instance().get_selection().TimeChanged.connect (sigc::mem_fun (*this, &TimeInfoBox::selection_changed));
Editor::instance().get_selection().RegionsChanged.connect (sigc::mem_fun (*this, &TimeInfoBox::selection_changed));
Region::RegionPropertyChanged.connect (region_property_connections, invalidator (*this), boost::bind (&TimeInfoBox::region_property_change, this, _1, _2), gui_context());
Editor::instance().MouseModeChanged.connect (editor_connections, invalidator(*this), boost::bind (&TimeInfoBox::track_mouse_mode, this), gui_context());
}
@ -156,30 +156,6 @@ TimeInfoBox::track_mouse_mode ()
selection_changed ();
}
void
TimeInfoBox::region_property_change (boost::shared_ptr<ARDOUR::Region> r, const PBD::PropertyChange& what_changed)
{
Selection& selection (Editor::instance().get_selection());
if (selection.regions.empty()) {
return;
}
PBD::PropertyChange our_interests;
our_interests.add (ARDOUR::Properties::position);
our_interests.add (ARDOUR::Properties::length);
our_interests.add (ARDOUR::Properties::start);
if (!what_changed.contains (our_interests)) {
return;
}
if (selection.regions.contains (r)) {
selection_changed ();
}
}
bool
TimeInfoBox::clock_button_release_event (GdkEventButton* ev, AudioClock* src)
{
@ -254,12 +230,29 @@ TimeInfoBox::set_session (Session* s)
}
}
void
TimeInfoBox::region_selection_changed ()
{
framepos_t s, e;
Selection& selection (Editor::instance().get_selection());
s = selection.regions.start();
e = selection.regions.end_frame();
selection_start->set_off (false);
selection_end->set_off (false);
selection_length->set_off (false);
selection_start->set (s);
selection_end->set (e);
selection_length->set (e, false, s);
}
void
TimeInfoBox::selection_changed ()
{
framepos_t s, e;
Selection& selection (Editor::instance().get_selection());
region_property_connections.drop_connections();
switch (Editor::instance().current_mouse_mode()) {
case Editing::MouseContent:
@ -304,14 +297,19 @@ TimeInfoBox::selection_changed ()
selection_length->set (e - s + 1);
}
} else {
s = selection.regions.start();
e = selection.regions.end_frame();
selection_start->set_off (false);
selection_end->set_off (false);
selection_length->set_off (false);
selection_start->set (s);
selection_end->set (e);
selection_length->set (e - s + 1);
/* this is more efficient than tracking changes per region in large selections */
std::set<boost::shared_ptr<ARDOUR::Playlist> > playlists;
for (RegionSelection::iterator s = selection.regions.begin(); s != selection.regions.end(); ++s) {
boost::shared_ptr<Playlist> pl = (*s)->region()->playlist();
if (pl) {
playlists.insert (pl);
}
}
for (std::set<boost::shared_ptr<ARDOUR::Playlist> >::iterator ps = playlists.begin(); ps != playlists.end(); ++ps) {
(*ps)->ContentsChanged.connect (region_property_connections, invalidator (*this),
boost::bind (&TimeInfoBox::region_selection_changed, this), gui_context());
}
region_selection_changed ();
}
break;

View File

@ -70,13 +70,13 @@ private:
PBD::ScopedConnectionList region_property_connections;
void selection_changed ();
void region_selection_changed ();
void sync_selection_mode (AudioClock*);
void sync_punch_mode (AudioClock*);
bool clock_button_release_event (GdkEventButton* ev, AudioClock* src);
void track_mouse_mode ();
void region_property_change (boost::shared_ptr<ARDOUR::Region> r, const PBD::PropertyChange& what_changed);
};
#endif /* __time_info_box_h__ */