From 013ec977324d98d7c4b243ddad86d84b94abdc62 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 18 Jan 2007 04:34:00 +0000 Subject: [PATCH] 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 --- gtk2_ardour/editor_mouse.cc | 1 - gtk2_ardour/editor_ops.cc | 20 ++++++++++++++++--- gtk2_ardour/selection.cc | 40 ++++++++++++++++++++++++++++++++++++- 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 @@ -621,6 +621,44 @@ Selection::empty () ; } +void +Selection::toggle (const vector& autos) +{ + for (vector::const_iterator x = autos.begin(); x != autos.end(); ++x) { + (*x)->set_selected (!(*x)->get_selected()); + } +} + +void +Selection::toggle (list& selectables) +{ + RegionView* rv; + AutomationSelectable* as; + vector rvs; + vector autos; + + for (std::list::iterator i = selectables.begin(); i != selectables.end(); ++i) { + if ((rv = dynamic_cast (*i)) != 0) { + rvs.push_back (rv); + } else if ((as = dynamic_cast (*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& selectables) { @@ -645,7 +683,7 @@ Selection::add (list& 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&); - void add (list&); + void set (std::list&); + void add (std::list&); + void toggle (std::list&); void set (TimeAxisView*); - void set (const list&); + void set (const std::list&); void set (RegionView*); void set (std::vector&); long set (TimeAxisView*, nframes_t, nframes_t); void set (ARDOUR::AutomationList*); void set (boost::shared_ptr); - void set (const list >&); + void set (const std::list >&); void set (boost::shared_ptr); void set (AutomationSelectable*); void toggle (TimeAxisView*); - void toggle (const list&); + void toggle (const std::list&); void toggle (RegionView*); void toggle (std::vector&); long toggle (nframes_t, nframes_t); void toggle (ARDOUR::AutomationList*); void toggle (boost::shared_ptr); - void toggle (const list >&); + void toggle (const std::list >&); void toggle (boost::shared_ptr); + void toggle (const std::vector&); void add (TimeAxisView*); - void add (const list&); + void add (const std::list&); void add (RegionView*); void add (std::vector&); long add (nframes_t, nframes_t); void add (ARDOUR::AutomationList*); void add (boost::shared_ptr); - void add (const list >&); + void add (const std::list >&); void add (boost::shared_ptr); void remove (TimeAxisView*); - void remove (const list&); + void remove (const std::list&); void remove (RegionView*); void remove (uint32_t selection_id); void remove (nframes_t, nframes_t); void remove (ARDOUR::AutomationList*); void remove (boost::shared_ptr); - void remove (const list >&); + void remove (const std::list >&); void remove (boost::shared_ptr); + void remove (const list&); void replace (uint32_t time_index, nframes_t start, nframes_t end);