#include "automation_time_axis.h"
#include "public_editor.h"
#include "control_point.h"
+#include "vca_time_axis.h"
#include "pbd/i18n.h"
: tracks (e)
, editor (e)
, next_time_id (0)
- , _no_tracks_changed (false)
{
clear ();
Selection::clear_tracks (bool with_signal)
{
if (!tracks.empty()) {
+ PresentationInfo::ChangeSuspender cs;
+
for (TrackViewList::iterator x = tracks.begin(); x != tracks.end(); ++x) {
(*x)->set_selected (false);
}
+
tracks.clear ();
- if (!_no_tracks_changed && with_signal) {
- TracksChanged();
- }
}
}
void
Selection::toggle (const TrackViewList& track_list)
{
+ PresentationInfo::ChangeSuspender cs;
+
for (TrackViewList::const_iterator i = track_list.begin(); i != track_list.end(); ++i) {
+ if (dynamic_cast<VCATimeAxisView*> (*i)) {
+ continue;
+ }
toggle ((*i));
}
}
void
Selection::toggle (TimeAxisView* track)
{
+ if (dynamic_cast<VCATimeAxisView*> (track)) {
+ return;
+ }
+
TrackSelection::iterator i;
if ((i = find (tracks.begin(), tracks.end(), track)) == tracks.end()) {
- track->set_selected (true);
tracks.push_back (track);
+ track->set_selected (true);
} else {
- track->set_selected (false);
tracks.erase (i);
+ track->set_selected (false);
}
- if (!_no_tracks_changed) {
- TracksChanged();
- }
}
void
}
void
-Selection::add (const TrackViewList& track_list)
+Selection::add (TrackViewList const & track_list)
{
clear_objects(); //enforce object/range exclusivity
+ PresentationInfo::ChangeSuspender cs;
+
TrackViewList added = tracks.add (track_list);
if (!added.empty()) {
for (TrackViewList::iterator x = added.begin(); x != added.end(); ++x) {
+ if (dynamic_cast<VCATimeAxisView*> (*x)) {
+ continue;
+ }
(*x)->set_selected (true);
}
- if (!_no_tracks_changed) {
- TracksChanged ();
- }
}
}
void
Selection::add (TimeAxisView* track)
{
+ if (dynamic_cast<VCATimeAxisView*> (track)) {
+ return;
+ }
clear_objects(); //enforce object/range exclusivity
TrackViewList tr;
{
list<TimeAxisView*>::iterator i;
if ((i = find (tracks.begin(), tracks.end(), track)) != tracks.end()) {
- track->set_selected (false);
- tracks.erase (i);
+ /* erase first, because set_selected() will remove the track
+ from the selection, invalidating the iterator.
- if (!_no_tracks_changed) {
- TracksChanged();
- }
+ In fact, we don't really even need to do the erase, but this is
+ a hangover of axis view selection being in the GUI.
+ */
+ tracks.erase (i);
+ track->set_selected (false);
}
}
void
Selection::remove (const TrackViewList& track_list)
{
- bool changed = false;
+ PresentationInfo::ChangeSuspender cs;
for (TrackViewList::const_iterator i = track_list.begin(); i != track_list.end(); ++i) {
TrackViewList::iterator x = find (tracks.begin(), tracks.end(), *i);
+
if (x != tracks.end()) {
- (*i)->set_selected (false);
tracks.erase (x);
- changed = true;
- }
- }
-
- if (changed) {
- if (!_no_tracks_changed) {
- TracksChanged();
+ (*i)->set_selected (false);
}
}
}
void
Selection::set (TimeAxisView* track)
{
+ if (dynamic_cast<VCATimeAxisView*> (track)) {
+ return;
+ }
clear_objects (); //enforce object/range exclusivity
- clear_tracks (false);
+
+ PresentationInfo::ChangeSuspender cs;
+
+ if (!tracks.empty()) {
+
+ if (tracks.size() == 1 && tracks.front() == track) {
+ /* already single selection: nothing to do */
+ return;
+ }
+
+ for (TrackViewList::iterator x = tracks.begin(); x != tracks.end(); ++x) {
+ (*x)->set_selected (false);
+ }
+
+ tracks.clear ();
+ }
+
add (track);
}
Selection::set (const TrackViewList& track_list)
{
clear_objects(); //enforce object/range exclusivity
- clear_tracks (false);
+
+ PresentationInfo::ChangeSuspender cs;
+
+ if (!tracks.empty()) {
+
+ /* cannot use set<T>::operator== (set<T> const &) here, because
+ * apparently the ordering used within 2 sets is not
+ * necessarily the same.
+ */
+
+ if (tracks.size() == track_list.size()) {
+ bool missing = false;
+
+ for (TrackViewList::const_iterator x = track_list.begin(); x != track_list.end(); ++x) {
+ if (dynamic_cast<VCATimeAxisView*> (*x)) {
+ continue;
+ }
+ if (find (tracks.begin(), tracks.end(), *x) == tracks.end()) {
+ missing = true;
+ }
+ }
+
+ if (!missing) {
+ /* already same selection: nothing to do */
+ return;
+ }
+ }
+
+ /* argument is different from existing selection */
+
+ for (TrackViewList::iterator x = tracks.begin(); x != tracks.end(); ++x) {
+ if (dynamic_cast<VCATimeAxisView*> (*x)) {
+ continue;
+ }
+ (*x)->set_selected (false);
+ }
+
+ tracks.clear ();
+ }
+
add (track_list);
}
i = tmp;
}
}
-
-void
-Selection::block_tracks_changed (bool yn)
-{
- _no_tracks_changed = yn;
-}