diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2007-01-18 04:34:00 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2007-01-18 04:34:00 +0000 |
commit | 013ec977324d98d7c4b243ddad86d84b94abdc62 (patch) | |
tree | 8ef847eaab6b6df2bf406eba96370c9fd4bd9301 | |
parent | 143983948ecbdc9e9e4c4f3fe2541b2bea22be87 (diff) |
make ctrl-rubber-band-select do something closer to the right thing
git-svn-id: svn://localhost/ardour2/trunk@1354 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | gtk2_ardour/editor_mouse.cc | 1 | ||||
-rw-r--r-- | gtk2_ardour/editor_ops.cc | 20 | ||||
-rw-r--r-- | gtk2_ardour/selection.cc | 40 | ||||
-rw-r--r-- | gtk2_ardour/selection.h | 23 |
4 files changed, 69 insertions, 15 deletions
diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index 8035045c6f..e49ac463da 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -4777,7 +4777,6 @@ Editor::end_rubberband_select (ArdourCanvas::Item* item, GdkEvent* event) } } else { - cerr << "Boo!\n"; selection->clear_tracks(); selection->clear_regions(); selection->clear_points (); diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index db94e44fe6..6e6d269f21 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -1394,16 +1394,30 @@ Editor::select_all_within (nframes_t start, nframes_t end, double top, double bo } if (!touched_tracks.empty()) { - selection->clear_tracks(); - selection->set (touched_tracks); + switch (op) { + case Selection::Add: + selection->add (touched_tracks); + break; + case Selection::Toggle: + selection->toggle (touched_tracks); + break; + case Selection::Set: + selection->set (touched_tracks); + break; + case Selection::Extend: + /* not defined yet */ + break; + } } begin_reversible_command (_("select all within")); switch (op) { case Selection::Add: - case Selection::Toggle: selection->add (touched); break; + case Selection::Toggle: + selection->toggle (touched); + break; case Selection::Set: selection->set (touched); break; diff --git a/gtk2_ardour/selection.cc b/gtk2_ardour/selection.cc index 76767f539d..ba0d51e606 100644 --- a/gtk2_ardour/selection.cc +++ b/gtk2_ardour/selection.cc @@ -622,6 +622,44 @@ Selection::empty () } void +Selection::toggle (const vector<AutomationSelectable*>& autos) +{ + for (vector<AutomationSelectable*>::const_iterator x = autos.begin(); x != autos.end(); ++x) { + (*x)->set_selected (!(*x)->get_selected()); + } +} + +void +Selection::toggle (list<Selectable*>& selectables) +{ + RegionView* rv; + AutomationSelectable* as; + vector<RegionView*> rvs; + vector<AutomationSelectable*> autos; + + for (std::list<Selectable*>::iterator i = selectables.begin(); i != selectables.end(); ++i) { + if ((rv = dynamic_cast<RegionView*> (*i)) != 0) { + rvs.push_back (rv); + } else if ((as = dynamic_cast<AutomationSelectable*> (*i)) != 0) { + autos.push_back (as); + } else { + fatal << _("programming error: ") + << X_("unknown selectable type passed to Selection::toggle()") + << endmsg; + /*NOTREACHED*/ + } + } + + if (!rvs.empty()) { + toggle (rvs); + } + + if (!autos.empty()) { + toggle (autos); + } +} + +void Selection::set (list<Selectable*>& selectables) { clear_regions(); @@ -645,7 +683,7 @@ Selection::add (list<Selectable*>& selectables) autos.push_back (as); } else { fatal << _("programming error: ") - << X_("unknown selectable type passed to Selection::set()") + << X_("unknown selectable type passed to Selection::add()") << endmsg; /*NOTREACHED*/ } diff --git a/gtk2_ardour/selection.h b/gtk2_ardour/selection.h index a2997cd7b5..5422888536 100644 --- a/gtk2_ardour/selection.h +++ b/gtk2_ardour/selection.h @@ -92,49 +92,52 @@ class Selection : public sigc::trackable bool selected (TimeAxisView*); bool selected (RegionView*); - void set (list<Selectable*>&); - void add (list<Selectable*>&); + void set (std::list<Selectable*>&); + void add (std::list<Selectable*>&); + void toggle (std::list<Selectable*>&); void set (TimeAxisView*); - void set (const list<TimeAxisView*>&); + void set (const std::list<TimeAxisView*>&); void set (RegionView*); void set (std::vector<RegionView*>&); long set (TimeAxisView*, nframes_t, nframes_t); void set (ARDOUR::AutomationList*); void set (boost::shared_ptr<ARDOUR::Playlist>); - void set (const list<boost::shared_ptr<ARDOUR::Playlist> >&); + void set (const std::list<boost::shared_ptr<ARDOUR::Playlist> >&); void set (boost::shared_ptr<ARDOUR::Redirect>); void set (AutomationSelectable*); void toggle (TimeAxisView*); - void toggle (const list<TimeAxisView*>&); + void toggle (const std::list<TimeAxisView*>&); void toggle (RegionView*); void toggle (std::vector<RegionView*>&); long toggle (nframes_t, nframes_t); void toggle (ARDOUR::AutomationList*); void toggle (boost::shared_ptr<ARDOUR::Playlist>); - void toggle (const list<boost::shared_ptr<ARDOUR::Playlist> >&); + void toggle (const std::list<boost::shared_ptr<ARDOUR::Playlist> >&); void toggle (boost::shared_ptr<ARDOUR::Redirect>); + void toggle (const std::vector<AutomationSelectable*>&); void add (TimeAxisView*); - void add (const list<TimeAxisView*>&); + void add (const std::list<TimeAxisView*>&); void add (RegionView*); void add (std::vector<RegionView*>&); long add (nframes_t, nframes_t); void add (ARDOUR::AutomationList*); void add (boost::shared_ptr<ARDOUR::Playlist>); - void add (const list<boost::shared_ptr<ARDOUR::Playlist> >&); + void add (const std::list<boost::shared_ptr<ARDOUR::Playlist> >&); void add (boost::shared_ptr<ARDOUR::Redirect>); void remove (TimeAxisView*); - void remove (const list<TimeAxisView*>&); + void remove (const std::list<TimeAxisView*>&); void remove (RegionView*); void remove (uint32_t selection_id); void remove (nframes_t, nframes_t); void remove (ARDOUR::AutomationList*); void remove (boost::shared_ptr<ARDOUR::Playlist>); - void remove (const list<boost::shared_ptr<ARDOUR::Playlist> >&); + void remove (const std::list<boost::shared_ptr<ARDOUR::Playlist> >&); void remove (boost::shared_ptr<ARDOUR::Redirect>); + void remove (const list<Selectable*>&); void replace (uint32_t time_index, nframes_t start, nframes_t end); |