use CoreSelection for track selection

This commit is contained in:
Paul Davis 2017-05-05 12:31:49 +01:00
parent 0c035778e1
commit dc0139d4af
33 changed files with 683 additions and 536 deletions

View file

@ -1062,3 +1062,4 @@ AutomationTimeAxisView::color () const
{ {
return gdk_color_from_rgb (_route->presentation_info().color()); return gdk_color_from_rgb (_route->presentation_info().color());
} }

View file

@ -105,8 +105,8 @@ class AutomationTimeAxisView : public TimeAxisView {
std::string state_id() const; std::string state_id() const;
static bool parse_state_id (std::string const &, PBD::ID &, bool &, Evoral::Parameter &); static bool parse_state_id (std::string const &, PBD::ID &, bool &, Evoral::Parameter &);
boost::shared_ptr<ARDOUR::AutomationControl> control() { return _control; } boost::shared_ptr<ARDOUR::AutomationControl> control() const { return _control; }
boost::shared_ptr<AutomationController> controller() { return _controller; } boost::shared_ptr<AutomationController> controller() const { return _controller; }
Evoral::Parameter parameter () const { Evoral::Parameter parameter () const {
return _parameter; return _parameter;
} }

View file

@ -27,17 +27,19 @@
#include "pbd/error.h" #include "pbd/error.h"
#include "pbd/convert.h" #include "pbd/convert.h"
#include "pbd/i18n.h"
#include <gtkmm2ext/utils.h> #include <gtkmm2ext/utils.h>
#include <gtkmm2ext/selector.h> #include <gtkmm2ext/selector.h>
#include <gtkmm2ext/gtk_ui.h> #include <gtkmm2ext/gtk_ui.h>
#include "ardour/selection.h"
#include "public_editor.h" #include "public_editor.h"
#include "ardour_ui.h" #include "ardour_ui.h"
#include "gui_object.h" #include "gui_object.h"
#include "axis_view.h" #include "axis_view.h"
#include "utils.h" #include "utils.h"
#include "pbd/i18n.h"
using namespace std; using namespace std;
using namespace Gtk; using namespace Gtk;
@ -131,10 +133,4 @@ AxisView::set_selected (bool yn)
} }
Selectable::set_selected (yn); Selectable::set_selected (yn);
boost::shared_ptr<Stripable> s = stripable ();
if (s) {
s->presentation_info().set_selected (yn);
}
} }

View file

@ -35,6 +35,10 @@
#include "prompter.h" #include "prompter.h"
#include "selectable.h" #include "selectable.h"
namespace PBD {
class Controllable;
}
namespace ARDOUR { namespace ARDOUR {
class Session; class Session;
class Stripable; class Stripable;
@ -49,14 +53,13 @@ namespace ARDOUR {
class AxisView : public virtual PBD::ScopedConnectionList, public virtual ARDOUR::SessionHandlePtr, public virtual Selectable class AxisView : public virtual PBD::ScopedConnectionList, public virtual ARDOUR::SessionHandlePtr, public virtual Selectable
{ {
public: public:
ARDOUR::Session* session() const { return _session; }
virtual std::string name() const = 0; virtual std::string name() const = 0;
virtual Gdk::Color color() const = 0; virtual Gdk::Color color() const = 0;
sigc::signal<void> Hiding; sigc::signal<void> Hiding;
virtual boost::shared_ptr<ARDOUR::Stripable> stripable() const = 0; virtual boost::shared_ptr<ARDOUR::Stripable> stripable() const = 0;
virtual boost::shared_ptr<ARDOUR::AutomationControl> control() const { return boost::shared_ptr<ARDOUR::AutomationControl>(); }
virtual std::string state_id() const = 0; virtual std::string state_id() const = 0;
/* for now, we always return properties in string form. /* for now, we always return properties in string form.

View file

@ -642,6 +642,8 @@ Editor::Editor ()
bottom_hbox.set_border_width (2); bottom_hbox.set_border_width (2);
bottom_hbox.set_spacing (3); bottom_hbox.set_spacing (3);
PresentationInfo::Change.connect (*this, MISSING_INVALIDATOR, boost::bind (&Editor::presentation_info_changed, this, _1), gui_context());
_route_groups = new EditorRouteGroups (this); _route_groups = new EditorRouteGroups (this);
_routes = new EditorRoutes (this); _routes = new EditorRoutes (this);
_regions = new EditorRegions (this); _regions = new EditorRegions (this);
@ -1038,7 +1040,7 @@ Editor::control_unselect ()
void void
Editor::control_select (boost::shared_ptr<Stripable> s, Selection::Operation op) Editor::control_select (boost::shared_ptr<Stripable> s, Selection::Operation op)
{ {
TimeAxisView* tav = axis_view_from_stripable (s); TimeAxisView* tav = time_axis_view_from_stripable (s);
if (tav) { if (tav) {
switch (op) { switch (op) {
@ -1371,6 +1373,12 @@ Editor::set_session (Session *t)
XMLNode* node = ARDOUR_UI::instance()->editor_settings(); XMLNode* node = ARDOUR_UI::instance()->editor_settings();
set_state (*node, Stateful::loading_state_version); set_state (*node, Stateful::loading_state_version);
/* catch up on selection state, etc. */
PropertyChange sc;
sc.add (Properties::selected);
presentation_info_changed (sc);
/* catch up with the playhead */ /* catch up with the playhead */
_session->request_locate (playhead_cursor->current_frame ()); _session->request_locate (playhead_cursor->current_frame ());
@ -1431,25 +1439,6 @@ Editor::set_session (Session *t)
break; break;
} }
/* catch up on selection of stripables (other selection state is lost
* when a session is closed
*/
StripableList sl;
TrackViewList tl;
_session->get_stripables (sl);
for (StripableList::const_iterator s = sl.begin(); s != sl.end(); ++s) {
if ((*s)->presentation_info().selected()) {
RouteTimeAxisView* rtav = get_route_view_by_route_id ((*s)->id());
if (rtav) {
tl.push_back (rtav);
}
}
}
if (!tl.empty()) {
selection->set (tl);
}
/* register for undo history */ /* register for undo history */
_session->register_with_memento_command_factory(id(), this); _session->register_with_memento_command_factory(id(), this);
_session->register_with_memento_command_factory(_selection_memento->id(), _selection_memento); _session->register_with_memento_command_factory(_selection_memento->id(), _selection_memento);
@ -5246,8 +5235,8 @@ Editor::region_view_removed ()
_summary->set_background_dirty (); _summary->set_background_dirty ();
} }
TimeAxisView* AxisView*
Editor::axis_view_from_stripable (boost::shared_ptr<Stripable> s) const Editor::axis_view_by_stripable (boost::shared_ptr<Stripable> s) const
{ {
for (TrackViewList::const_iterator j = track_views.begin (); j != track_views.end(); ++j) { for (TrackViewList::const_iterator j = track_views.begin (); j != track_views.end(); ++j) {
if ((*j)->stripable() == s) { if ((*j)->stripable() == s) {
@ -5258,6 +5247,17 @@ Editor::axis_view_from_stripable (boost::shared_ptr<Stripable> s) const
return 0; return 0;
} }
AxisView*
Editor::axis_view_by_control (boost::shared_ptr<AutomationControl> c) const
{
for (TrackViewList::const_iterator j = track_views.begin (); j != track_views.end(); ++j) {
if ((*j)->control() == c) {
return *j;
}
}
return 0;
}
TrackViewList TrackViewList
Editor::axis_views_from_routes (boost::shared_ptr<RouteList> r) const Editor::axis_views_from_routes (boost::shared_ptr<RouteList> r) const
@ -5265,7 +5265,7 @@ Editor::axis_views_from_routes (boost::shared_ptr<RouteList> r) const
TrackViewList t; TrackViewList t;
for (RouteList::const_iterator i = r->begin(); i != r->end(); ++i) { for (RouteList::const_iterator i = r->begin(); i != r->end(); ++i) {
TimeAxisView* tv = axis_view_from_stripable (*i); TimeAxisView* tv = time_axis_view_from_stripable (*i);
if (tv) { if (tv) {
t.push_back (tv); t.push_back (tv);
} }

View file

@ -140,14 +140,13 @@ class TimeSelection;
class RegionLayeringOrderEditor; class RegionLayeringOrderEditor;
class VerboseCursor; class VerboseCursor;
class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARDOUR::SessionHandlePtr class Editor : public PublicEditor, public PBD::ScopedConnectionList
{ {
public: public:
Editor (); Editor ();
~Editor (); ~Editor ();
void set_session (ARDOUR::Session *); void set_session (ARDOUR::Session *);
ARDOUR::Session* session() const { return _session; }
Gtk::Window* use_own_window (bool and_fill_it); Gtk::Window* use_own_window (bool and_fill_it);
@ -427,7 +426,7 @@ public:
void start_resize_line_ops (); void start_resize_line_ops ();
void end_resize_line_ops (); void end_resize_line_ops ();
TrackViewList const & get_track_views () { TrackViewList const & get_track_views () const {
return track_views; return track_views;
} }
@ -1158,7 +1157,13 @@ private:
/* track views */ /* track views */
TrackViewList track_views; TrackViewList track_views;
std::pair<TimeAxisView*, double> trackview_by_y_position (double, bool trackview_relative_offset = true) const; std::pair<TimeAxisView*, double> trackview_by_y_position (double, bool trackview_relative_offset = true) const;
TimeAxisView* axis_view_from_stripable (boost::shared_ptr<ARDOUR::Stripable>) const;
AxisView* axis_view_by_stripable (boost::shared_ptr<ARDOUR::Stripable>) const;
AxisView* axis_view_by_control (boost::shared_ptr<ARDOUR::AutomationControl>) const;
TimeAxisView* time_axis_view_from_stripable (boost::shared_ptr<ARDOUR::Stripable> s) const {
return dynamic_cast<TimeAxisView*> (axis_view_by_stripable (s));
}
TrackViewList get_tracks_for_range_action () const; TrackViewList get_tracks_for_range_action () const;
@ -1857,7 +1862,7 @@ private:
void time_selection_changed (); void time_selection_changed ();
void update_time_selection_display (); void update_time_selection_display ();
void track_selection_changed (); void presentation_info_changed (PBD::PropertyChange const &);
void region_selection_changed (); void region_selection_changed ();
sigc::connection editor_regions_selection_changed_connection; sigc::connection editor_regions_selection_changed_connection;
void sensitize_all_region_actions (bool); void sensitize_all_region_actions (bool);

View file

@ -1295,7 +1295,7 @@ Editor::drop_regions (const Glib::RefPtr<Gdk::DragContext>& /*context*/,
} }
list<boost::shared_ptr<AudioTrack> > audio_tracks; list<boost::shared_ptr<AudioTrack> > audio_tracks;
audio_tracks = session()->new_audio_track (region->n_channels(), output_chan, 0, 1, region->name(), PresentationInfo::max_order); audio_tracks = session()->new_audio_track (region->n_channels(), output_chan, 0, 1, region->name(), PresentationInfo::max_order);
rtav = dynamic_cast<RouteTimeAxisView*> (axis_view_from_stripable (audio_tracks.front())); rtav = dynamic_cast<RouteTimeAxisView*> (time_axis_view_from_stripable (audio_tracks.front()));
} else if (boost::dynamic_pointer_cast<MidiRegion> (region)) { } else if (boost::dynamic_pointer_cast<MidiRegion> (region)) {
ChanCount one_midi_port (DataType::MIDI, 1); ChanCount one_midi_port (DataType::MIDI, 1);
list<boost::shared_ptr<MidiTrack> > midi_tracks; list<boost::shared_ptr<MidiTrack> > midi_tracks;
@ -1304,7 +1304,7 @@ Editor::drop_regions (const Glib::RefPtr<Gdk::DragContext>& /*context*/,
boost::shared_ptr<ARDOUR::PluginInfo>(), boost::shared_ptr<ARDOUR::PluginInfo>(),
(ARDOUR::Plugin::PresetRecord*) 0, (ARDOUR::Plugin::PresetRecord*) 0,
(ARDOUR::RouteGroup*) 0, 1, region->name(), PresentationInfo::max_order); (ARDOUR::RouteGroup*) 0, 1, region->name(), PresentationInfo::max_order);
rtav = dynamic_cast<RouteTimeAxisView*> (axis_view_from_stripable (midi_tracks.front())); rtav = dynamic_cast<RouteTimeAxisView*> (time_axis_view_from_stripable (midi_tracks.front()));
} else { } else {
return; return;
} }

View file

@ -1443,7 +1443,7 @@ RegionMoveDrag::create_destination_time_axis (boost::shared_ptr<Region> region,
output_chan = _editor->session()->master_out()->n_inputs().n_audio(); output_chan = _editor->session()->master_out()->n_inputs().n_audio();
} }
audio_tracks = _editor->session()->new_audio_track (region->n_channels(), output_chan, 0, 1, region->name(), PresentationInfo::max_order); audio_tracks = _editor->session()->new_audio_track (region->n_channels(), output_chan, 0, 1, region->name(), PresentationInfo::max_order);
tav =_editor->axis_view_from_stripable (audio_tracks.front()); tav =_editor->time_axis_view_from_stripable (audio_tracks.front());
} else { } else {
ChanCount one_midi_port (DataType::MIDI, 1); ChanCount one_midi_port (DataType::MIDI, 1);
list<boost::shared_ptr<MidiTrack> > midi_tracks; list<boost::shared_ptr<MidiTrack> > midi_tracks;
@ -1452,7 +1452,7 @@ RegionMoveDrag::create_destination_time_axis (boost::shared_ptr<Region> region,
boost::shared_ptr<ARDOUR::PluginInfo>(), boost::shared_ptr<ARDOUR::PluginInfo>(),
(ARDOUR::Plugin::PresetRecord*) 0, (ARDOUR::Plugin::PresetRecord*) 0,
(ARDOUR::RouteGroup*) 0, 1, region->name(), PresentationInfo::max_order); (ARDOUR::RouteGroup*) 0, 1, region->name(), PresentationInfo::max_order);
tav = _editor->axis_view_from_stripable (midi_tracks.front()); tav = _editor->time_axis_view_from_stripable (midi_tracks.front());
} }
if (tav) { if (tav) {

View file

@ -146,7 +146,7 @@ Editor::show_editor_mixer (bool yn)
if (current_mixer_strip && current_mixer_strip->get_parent() == 0) { if (current_mixer_strip && current_mixer_strip->get_parent() == 0) {
global_hpacker.pack_start (*current_mixer_strip, Gtk::PACK_SHRINK ); global_hpacker.pack_start (*current_mixer_strip, Gtk::PACK_SHRINK );
global_hpacker.reorder_child (*current_mixer_strip, 0); global_hpacker.reorder_child (*current_mixer_strip, 0);
current_mixer_strip->show (); current_mixer_strip->show ();
} }
@ -285,4 +285,3 @@ Editor::mixer_strip_width_changed ()
editor_mixer_strip_width = current_mixer_strip->get_width_enum (); editor_mixer_strip_width = current_mixer_strip->get_width_enum ();
} }

View file

@ -337,7 +337,6 @@ Editor::update_time_selection_display ()
break; break;
case MouseObject: case MouseObject:
selection->clear_time (); selection->clear_time ();
selection->clear_tracks ();
selection->clear_midi_notes (); selection->clear_midi_notes ();
break; break;
case MouseDraw: case MouseDraw:

View file

@ -31,6 +31,7 @@
#include "ardour/audio_track.h" #include "ardour/audio_track.h"
#include "ardour/midi_track.h" #include "ardour/midi_track.h"
#include "ardour/route.h" #include "ardour/route.h"
#include "ardour/selection.h"
#include "ardour/session.h" #include "ardour/session.h"
#include "ardour/solo_isolate_control.h" #include "ardour/solo_isolate_control.h"
#include "ardour/utils.h" #include "ardour/utils.h"
@ -319,7 +320,6 @@ EditorRoutes::EditorRoutes (Editor* e)
_display.set_enable_search (false); _display.set_enable_search (false);
Route::PluginSetup.connect_same_thread (*this, boost::bind (&EditorRoutes::plugin_setup, this, _1, _2, _3)); Route::PluginSetup.connect_same_thread (*this, boost::bind (&EditorRoutes::plugin_setup, this, _1, _2, _3));
PresentationInfo::Change.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::presentation_info_changed, this, _1), gui_context());
} }
bool bool
@ -727,7 +727,10 @@ EditorRoutes::time_axis_views_added (list<TimeAxisView*> tavs)
} }
} }
_display.set_model (Glib::RefPtr<ListStore>()); {
PBD::Unwinder<bool> uw (_ignore_selection_change, true);
_display.set_model (Glib::RefPtr<ListStore>());
}
for (list<TimeAxisView*>::iterator x = tavs.begin(); x != tavs.end(); ++x) { for (list<TimeAxisView*>::iterator x = tavs.begin(); x != tavs.end(); ++x) {
@ -754,7 +757,6 @@ EditorRoutes::time_axis_views_added (list<TimeAxisView*> tavs)
row[_columns.is_track] = (boost::dynamic_pointer_cast<Track> (stripable) != 0); row[_columns.is_track] = (boost::dynamic_pointer_cast<Track> (stripable) != 0);
if (midi_trk) { if (midi_trk) {
row[_columns.is_input_active] = midi_trk->input_active (); row[_columns.is_input_active] = midi_trk->input_active ();
row[_columns.is_midi] = true; row[_columns.is_midi] = true;
@ -832,7 +834,11 @@ EditorRoutes::time_axis_views_added (list<TimeAxisView*> tavs)
update_input_active_display (); update_input_active_display ();
update_active_display (); update_active_display ();
_display.set_model (_model); {
PBD::Unwinder<bool> uw (_ignore_selection_change, true);
cerr << "Should ignore model/selection change\n";
_display.set_model (_model);
}
/* now update route order keys from the treeview/track display order */ /* now update route order keys from the treeview/track display order */
@ -1082,19 +1088,6 @@ EditorRoutes::sync_presentation_info_from_treeview ()
} }
} }
void
EditorRoutes::presentation_info_changed (PropertyChange const & what_changed)
{
PropertyChange soh;
soh.add (Properties::selected);
soh.add (Properties::order);
soh.add (Properties::hidden);
if (what_changed.contains (soh)) {
sync_treeview_from_presentation_info (what_changed);
}
}
void void
EditorRoutes::sync_treeview_from_presentation_info (PropertyChange const & what_changed) EditorRoutes::sync_treeview_from_presentation_info (PropertyChange const & what_changed)
{ {
@ -1169,13 +1162,18 @@ EditorRoutes::sync_treeview_from_presentation_info (PropertyChange const & what_
if (what_changed.contains (Properties::selected)) { if (what_changed.contains (Properties::selected)) {
/* by the time this is invoked, the GUI Selection model has
* already updated itself.
*/
TrackViewList tvl; TrackViewList tvl;
PBD::Unwinder<bool> uw (_ignore_selection_change, true); PBD::Unwinder<bool> uw (_ignore_selection_change, true);
/* step one: set the treeview model selection state */ /* set the treeview model selection state */
for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri) { for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri) {
boost::shared_ptr<Stripable> stripable = (*ri)[_columns.stripable]; boost::shared_ptr<Stripable> stripable = (*ri)[_columns.stripable];
if (stripable && stripable->presentation_info().selected()) { if (stripable && stripable->is_selected()) {
TimeAxisView* tav = (*ri)[_columns.tv]; TimeAxisView* tav = (*ri)[_columns.tv];
if (tav) { if (tav) {
tvl.push_back (tav); tvl.push_back (tav);
@ -1185,12 +1183,6 @@ EditorRoutes::sync_treeview_from_presentation_info (PropertyChange const & what_
_display.get_selection()->unselect (*ri); _display.get_selection()->unselect (*ri);
} }
} }
/* step two: set the Selection (for stripables/routes) */
_editor->get_selection().set (tvl);
/* step three, tell the editor */
_editor->track_selection_changed ();
} }
redisplay (); redisplay ();
@ -1645,7 +1637,7 @@ EditorRoutes::move_selected_tracks (bool up)
/* build a list that includes time axis view information */ /* build a list that includes time axis view information */
for (StripableList::const_iterator sli = sl.begin(); sli != sl.end(); ++sli) { for (StripableList::const_iterator sli = sl.begin(); sli != sl.end(); ++sli) {
TimeAxisView* tv = _editor->axis_view_from_stripable (*sli); TimeAxisView* tv = _editor->time_axis_view_from_stripable (*sli);
view_stripables.push_back (ViewStripable (tv, *sli)); view_stripables.push_back (ViewStripable (tv, *sli));
} }
@ -1666,7 +1658,7 @@ EditorRoutes::move_selected_tracks (bool up)
while (vsi != view_stripables.end()) { while (vsi != view_stripables.end()) {
if (vsi->stripable->presentation_info().selected()) { if (vsi->stripable->is_selected()) {
if (unselected_neighbour != view_stripables.end()) { if (unselected_neighbour != view_stripables.end()) {
@ -1701,7 +1693,7 @@ EditorRoutes::move_selected_tracks (bool up)
--vsi; --vsi;
if (vsi->stripable->presentation_info().selected()) { if (vsi->stripable->is_selected()) {
if (unselected_neighbour != view_stripables.end()) { if (unselected_neighbour != view_stripables.end()) {
@ -1852,6 +1844,7 @@ EditorRoutes::views () const
void void
EditorRoutes::clear () EditorRoutes::clear ()
{ {
PBD::Unwinder<bool> uw (_ignore_selection_change, true);
_display.set_model (Glib::RefPtr<Gtk::TreeStore> (0)); _display.set_model (Glib::RefPtr<Gtk::TreeStore> (0));
_model->clear (); _model->clear ();
_display.set_model (_model); _display.set_model (_model);
@ -1902,7 +1895,7 @@ EditorRoutes::show_tracks_with_regions_at_playhead ()
set<TimeAxisView*> show; set<TimeAxisView*> show;
for (RouteList::const_iterator i = r->begin(); i != r->end(); ++i) { for (RouteList::const_iterator i = r->begin(); i != r->end(); ++i) {
TimeAxisView* tav = _editor->axis_view_from_stripable (*i); TimeAxisView* tav = _editor->time_axis_view_from_stripable (*i);
if (tav) { if (tav) {
show.insert (tav); show.insert (tav);
} }

View file

@ -65,6 +65,7 @@ public:
void hide_all_tracks (bool); void hide_all_tracks (bool);
void clear (); void clear ();
void sync_presentation_info_from_treeview (); void sync_presentation_info_from_treeview ();
void sync_treeview_from_presentation_info (PBD::PropertyChange const &);
private: private:
void initial_display (); void initial_display ();
@ -78,7 +79,6 @@ private:
void on_tv_solo_safe_toggled (std::string const &); void on_tv_solo_safe_toggled (std::string const &);
void build_menu (); void build_menu ();
void presentation_info_changed (PBD::PropertyChange const &); void presentation_info_changed (PBD::PropertyChange const &);
void sync_treeview_from_presentation_info (PBD::PropertyChange const &);
void row_deleted (Gtk::TreeModel::Path const &); void row_deleted (Gtk::TreeModel::Path const &);
void visible_changed (std::string const &); void visible_changed (std::string const &);
void active_changed (std::string const &); void active_changed (std::string const &);

View file

@ -27,12 +27,14 @@
#include "ardour/playlist.h" #include "ardour/playlist.h"
#include "ardour/profile.h" #include "ardour/profile.h"
#include "ardour/route_group.h" #include "ardour/route_group.h"
#include "ardour/selection.h"
#include "ardour/session.h" #include "ardour/session.h"
#include "control_protocol/control_protocol.h" #include "control_protocol/control_protocol.h"
#include "editor_drag.h"
#include "editor.h" #include "editor.h"
#include "editor_drag.h"
#include "editor_routes.h"
#include "actions.h" #include "actions.h"
#include "audio_time_axis.h" #include "audio_time_axis.h"
#include "audio_region_view.h" #include "audio_region_view.h"
@ -267,9 +269,7 @@ Editor::set_selected_track (TimeAxisView& view, Selection::Operation op, bool no
break; break;
case Selection::Add: case Selection::Add:
if (!selection->selected (&view)) { selection->add (&view);
selection->add (&view);
}
break; break;
case Selection::Set: case Selection::Set:
@ -999,84 +999,136 @@ struct SelectionOrderSorter {
}; };
void void
Editor::track_selection_changed () Editor::presentation_info_changed (PropertyChange const & what_changed)
{ {
SelectionOrderSorter cmp; /* We cannot ensure ordering of the handlers for
selection->tracks.sort (cmp); * PresentationInfo::Changed, so we have to do everything in order
* here, as a single handler.
*/
switch (selection->tracks.size()) { for (TrackViewList::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
case 0: (*i)->set_selected (false);
break; (*i)->hide_selection ();
default:
set_selected_mixer_strip (*(selection->tracks.back()));
if (!_track_selection_change_without_scroll) {
ensure_time_axis_view_is_visible (*(selection->tracks.back()), false);
}
break;
} }
RouteNotificationListPtr routes (new RouteNotificationList); /* STEP 1: set the GUI selection state (in which TimeAxisViews for the
StripableNotificationListPtr stripables (new StripableNotificationList); * currently selected stripable/controllable duples are found and added
*/
for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { selection->core_selection_changed (what_changed);
bool yn = (find (selection->tracks.begin(), selection->tracks.end(), *i) != selection->tracks.end()); /* STEP 2: update TimeAxisView's knowledge of their selected state
*/
(*i)->set_selected (yn);
TimeAxisView::Children c = (*i)->get_child_list ();
for (TimeAxisView::Children::iterator j = c.begin(); j != c.end(); ++j) {
(*j)->set_selected (find (selection->tracks.begin(), selection->tracks.end(), j->get()) != selection->tracks.end());
}
if (yn) {
(*i)->reshow_selection (selection->time);
} else {
(*i)->hide_selection ();
}
if (yn) { PropertyChange pc;
RouteTimeAxisView* rtav = dynamic_cast<RouteTimeAxisView*> (*i); pc.add (Properties::selected);
if (rtav) {
routes->push_back (rtav->route()); if (what_changed.contains (Properties::selected)) {
stripables->push_back (rtav->route());
StripableNotificationListPtr stripables (new StripableNotificationList);
switch (selection->tracks.size()) {
case 0:
break;
default:
set_selected_mixer_strip (*(selection->tracks.back()));
if (!_track_selection_change_without_scroll) {
ensure_time_axis_view_is_visible (*(selection->tracks.back()), false);
} }
break;
} }
}
ActionManager::set_sensitive (ActionManager::track_selection_sensitive_actions, !selection->tracks.empty()); CoreSelection::StripableAutomationControls sc;
_session->selection().get_stripables (sc);
sensitize_the_right_region_actions (false); for (CoreSelection::StripableAutomationControls::const_iterator i = sc.begin(); i != sc.end(); ++i) {
/* notify control protocols */ AxisView* av = axis_view_by_stripable ((*i).stripable);
ControlProtocol::StripableSelectionChanged (stripables); if (!av) {
continue;
}
if (sfbrowser && _session && !_session->deletion_in_progress()) { TimeAxisView* tav = dynamic_cast<TimeAxisView*> (av);
uint32_t audio_track_cnt = 0;
uint32_t midi_track_cnt = 0;
for (TrackSelection::iterator x = selection->tracks.begin(); x != selection->tracks.end(); ++x) { if (!tav) {
AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*>(*x); continue; /* impossible */
}
if (atv) { if (!(*i).controllable) {
if (atv->is_audio_track()) {
audio_track_cnt++; /* "parent" track selected */
} tav->set_selected (true);
tav->reshow_selection (selection->time);
} else { } else {
MidiTimeAxisView* mtv = dynamic_cast<MidiTimeAxisView*>(*x);
if (mtv) { /* possibly a child */
if (mtv->is_midi_track()) {
midi_track_cnt++; TimeAxisView::Children c = tav->get_child_list ();
for (TimeAxisView::Children::iterator j = c.begin(); j != c.end(); ++j) {
boost::shared_ptr<AutomationControl> control = (*j)->control ();
if (control != (*i).controllable) {
continue;
}
(*j)->set_selected (true);
(*j)->reshow_selection (selection->time);
}
}
stripables->push_back ((*i).stripable);
}
ActionManager::set_sensitive (ActionManager::track_selection_sensitive_actions, !selection->tracks.empty());
sensitize_the_right_region_actions (false);
/* STEP 4: notify control protocols */
ControlProtocol::StripableSelectionChanged (stripables);
if (sfbrowser && _session && !_session->deletion_in_progress()) {
uint32_t audio_track_cnt = 0;
uint32_t midi_track_cnt = 0;
for (TrackSelection::iterator x = selection->tracks.begin(); x != selection->tracks.end(); ++x) {
AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*>(*x);
if (atv) {
if (atv->is_audio_track()) {
audio_track_cnt++;
}
} else {
MidiTimeAxisView* mtv = dynamic_cast<MidiTimeAxisView*>(*x);
if (mtv) {
if (mtv->is_midi_track()) {
midi_track_cnt++;
}
} }
} }
} }
}
sfbrowser->reset (audio_track_cnt, midi_track_cnt); sfbrowser->reset (audio_track_cnt, midi_track_cnt);
}
}
/* STEP 4: update EditorRoutes treeview */
PropertyChange soh;
soh.add (Properties::selected);
soh.add (Properties::order);
soh.add (Properties::hidden);
if (what_changed.contains (soh)) {
_routes->sync_treeview_from_presentation_info (what_changed);
} }
} }
@ -1570,28 +1622,32 @@ Editor::select_all_objects (Selection::Operation op)
{ {
list<Selectable *> touched; list<Selectable *> touched;
TrackViewList ts = track_views;
if (internal_editing() && select_all_internal_edit(op)) { if (internal_editing() && select_all_internal_edit(op)) {
return; // Selected notes return; // Selected notes
} }
TrackViewList ts;
if (selection->tracks.empty()) {
ts = track_views;
} else {
ts = selection->tracks;
}
for (TrackViewList::iterator iter = ts.begin(); iter != ts.end(); ++iter) { for (TrackViewList::iterator iter = ts.begin(); iter != ts.end(); ++iter) {
if ((*iter)->hidden()) { if ((*iter)->hidden()) {
continue; continue;
} }
(*iter)->get_selectables (0, max_framepos, 0, DBL_MAX, touched); (*iter)->get_selectables (0, max_framepos, 0, DBL_MAX, touched);
selection->add (*iter);
} }
begin_reversible_selection_op (X_("select all")); begin_reversible_selection_op (X_("select all"));
switch (op) { switch (op) {
case Selection::Add: case Selection::Add:
selection->add (touched); selection->add (touched);
break; break;
case Selection::Toggle: case Selection::Toggle:
selection->add (touched); selection->toggle (touched);
break; break;
case Selection::Set: case Selection::Set:
selection->set (touched); selection->set (touched);

View file

@ -48,6 +48,7 @@
#include "ardour/midi_track.h" #include "ardour/midi_track.h"
#include "ardour/plugin_manager.h" #include "ardour/plugin_manager.h"
#include "ardour/route_group.h" #include "ardour/route_group.h"
#include "ardour/selection.h"
#include "ardour/session.h" #include "ardour/session.h"
#include "ardour/vca.h" #include "ardour/vca.h"
#include "ardour/vca_manager.h" #include "ardour/vca_manager.h"
@ -110,6 +111,7 @@ Mixer_UI::Mixer_UI ()
, _maximised (false) , _maximised (false)
, _show_mixer_list (true) , _show_mixer_list (true)
, myactions (X_("mixer")) , myactions (X_("mixer"))
, _selection (*this, *this)
{ {
register_actions (); register_actions ();
load_bindings (); load_bindings ();
@ -683,6 +685,8 @@ Mixer_UI::remove_strip (MixerStrip* strip)
void void
Mixer_UI::presentation_info_changed (PropertyChange const & what_changed) Mixer_UI::presentation_info_changed (PropertyChange const & what_changed)
{ {
_selection.presentation_info_changed (what_changed);
PropertyChange soh; PropertyChange soh;
soh.add (Properties::selected); soh.add (Properties::selected);
soh.add (Properties::order); soh.add (Properties::order);
@ -850,7 +854,7 @@ Mixer_UI::sync_treeview_from_presentation_info (PropertyChange const & what_chan
for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) { for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
boost::shared_ptr<Stripable> stripable = (*i)->stripable(); boost::shared_ptr<Stripable> stripable = (*i)->stripable();
if (stripable && stripable->presentation_info().selected()) { if (stripable && stripable->is_selected()) {
_selection.add (*i); _selection.add (*i);
} else { } else {
_selection.remove (*i); _selection.remove (*i);
@ -891,7 +895,7 @@ Mixer_UI::strip_by_stripable (boost::shared_ptr<Stripable> s) const
} }
AxisView* AxisView*
Mixer_UI::axis_by_stripable (boost::shared_ptr<Stripable> s) const Mixer_UI::axis_view_by_stripable (boost::shared_ptr<Stripable> s) const
{ {
for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) { for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
if ((*i)->stripable() == s) { if ((*i)->stripable() == s) {
@ -902,6 +906,18 @@ Mixer_UI::axis_by_stripable (boost::shared_ptr<Stripable> s) const
return 0; return 0;
} }
AxisView*
Mixer_UI::axis_view_by_control (boost::shared_ptr<AutomationControl> c) const
{
for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
if ((*i)->control() == c) {
return (*i);
}
}
return 0;
}
bool bool
Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip) Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip)
{ {
@ -1000,6 +1016,7 @@ Mixer_UI::set_session (Session* sess)
} }
if (!_session) { if (!_session) {
_selection.clear ();
return; return;
} }
@ -1029,6 +1046,13 @@ Mixer_UI::set_session (Session* sess)
if (_visible) { if (_visible) {
show_window(); show_window();
} }
/* catch up on selection state, etc. */
PropertyChange sc;
sc.add (Properties::selected);
_selection.presentation_info_changed (sc);
start_updating (); start_updating ();
} }

View file

@ -47,6 +47,7 @@
#include "gtkmm2ext/tabbable.h" #include "gtkmm2ext/tabbable.h"
#include "gtkmm2ext/treeutils.h" #include "gtkmm2ext/treeutils.h"
#include "axis_provider.h"
#include "enums.h" #include "enums.h"
#include "route_processor_selection.h" #include "route_processor_selection.h"
@ -76,7 +77,7 @@ protected:
virtual bool row_drop_possible_vfunc (const Gtk::TreeModel::Path&, const Gtk::SelectionData&) const; virtual bool row_drop_possible_vfunc (const Gtk::TreeModel::Path&, const Gtk::SelectionData&) const;
}; };
class Mixer_UI : public Gtkmm2ext::Tabbable, public PBD::ScopedConnectionList, public ARDOUR::SessionHandlePtr class Mixer_UI : public Gtkmm2ext::Tabbable, public PBD::ScopedConnectionList, public ARDOUR::SessionHandlePtr, public AxisViewProvider
{ {
public: public:
static Mixer_UI* instance(); static Mixer_UI* instance();
@ -188,7 +189,9 @@ class Mixer_UI : public Gtkmm2ext::Tabbable, public PBD::ScopedConnectionList, p
MixerStrip* strip_by_route (boost::shared_ptr<ARDOUR::Route>) const; MixerStrip* strip_by_route (boost::shared_ptr<ARDOUR::Route>) const;
MixerStrip* strip_by_stripable (boost::shared_ptr<ARDOUR::Stripable>) const; MixerStrip* strip_by_stripable (boost::shared_ptr<ARDOUR::Stripable>) const;
AxisView* axis_by_stripable (boost::shared_ptr<ARDOUR::Stripable>) const;
AxisView* axis_view_by_stripable (boost::shared_ptr<ARDOUR::Stripable>) const;
AxisView* axis_view_by_control (boost::shared_ptr<ARDOUR::AutomationControl>) const;
void hide_all_strips (bool with_select); void hide_all_strips (bool with_select);
void unselect_all_strips(); void unselect_all_strips();

View file

@ -88,6 +88,7 @@ MonitorSection::MonitorSection (Session* s)
, solo_mute_override_button (ArdourButton::led_default_elements) , solo_mute_override_button (ArdourButton::led_default_elements)
, toggle_processorbox_button (ArdourButton::default_elements) , toggle_processorbox_button (ArdourButton::default_elements)
, _inhibit_solo_model_update (false) , _inhibit_solo_model_update (false)
, _rr_selection ()
, _ui_initialized (false) , _ui_initialized (false)
{ {

View file

@ -32,8 +32,8 @@
#include "monitor_selector.h" #include "monitor_selector.h"
#include "plugin_selector.h" #include "plugin_selector.h"
#include "route_processor_selection.h"
#include "processor_box.h" #include "processor_box.h"
#include "processor_selection.h"
namespace Gtkmm2ext { namespace Gtkmm2ext {
class TearOff; class TearOff;
@ -192,7 +192,7 @@ class MonitorSection : public RouteUI, public Gtk::EventBox
ProcessorBox* insert_box; ProcessorBox* insert_box;
PluginSelector* _plugin_selector; PluginSelector* _plugin_selector;
RouteProcessorSelection _rr_selection; ProcessorSelection _rr_selection;
void help_count_processors (boost::weak_ptr<ARDOUR::Processor> p, uint32_t* cnt) const; void help_count_processors (boost::weak_ptr<ARDOUR::Processor> p, uint32_t* cnt) const;
uint32_t count_processors (); uint32_t count_processors ();

View file

@ -34,8 +34,6 @@ class MonitorSelector : public PortMatrix
std::string disassociation_verb () const; std::string disassociation_verb () const;
std::string channel_noun () const; std::string channel_noun () const;
ARDOUR::Session* session() const { return _session; }
uint32_t n_io_ports () const; uint32_t n_io_ports () const;
boost::shared_ptr<ARDOUR::IO> const io () { return _io; } boost::shared_ptr<ARDOUR::IO> const io () { return _io; }
void setup_ports (int); void setup_ports (int);

View file

@ -378,7 +378,7 @@ PortGroupList::gather (ARDOUR::Session* session, ARDOUR::DataType type, bool inp
/* Now put the bundles that belong to these sorted RouteIOs into the PortGroup. */ /* Now put the bundles that belong to these sorted RouteIOs into the PortGroup. */
for (list<RouteIOs>::iterator i = route_ios.begin(); i != route_ios.end(); ++i) { for (list<RouteIOs>::iterator i = route_ios.begin(); i != route_ios.end(); ++i) {
TimeAxisView* tv = PublicEditor::instance().axis_view_from_stripable (i->route); TimeAxisView* tv = PublicEditor::instance().time_axis_view_from_stripable (i->route);
/* Work out which group to put these IOs' bundles in */ /* Work out which group to put these IOs' bundles in */
boost::shared_ptr<PortGroup> g; boost::shared_ptr<PortGroup> g;

View file

@ -76,9 +76,9 @@
#include "plugin_ui.h" #include "plugin_ui.h"
#include "port_insert_ui.h" #include "port_insert_ui.h"
#include "processor_box.h" #include "processor_box.h"
#include "processor_selection.h"
#include "public_editor.h" #include "public_editor.h"
#include "return_ui.h" #include "return_ui.h"
#include "route_processor_selection.h"
#include "script_selector.h" #include "script_selector.h"
#include "send_ui.h" #include "send_ui.h"
#include "timers.h" #include "timers.h"
@ -1807,14 +1807,14 @@ static std::list<Gtk::TargetEntry> drag_targets_noplugin()
} }
ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelector*()> get_plugin_selector, ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelector*()> get_plugin_selector,
RouteProcessorSelection& rsel, MixerStrip* parent, bool owner_is_mixer) ProcessorSelection& psel, MixerStrip* parent, bool owner_is_mixer)
: _parent_strip (parent) : _parent_strip (parent)
, _owner_is_mixer (owner_is_mixer) , _owner_is_mixer (owner_is_mixer)
, ab_direction (true) , ab_direction (true)
, _get_plugin_selector (get_plugin_selector) , _get_plugin_selector (get_plugin_selector)
, _placement (-1) , _placement (-1)
, _visible_prefader_processors (0) , _visible_prefader_processors (0)
, _rr_selection(rsel) , _p_selection(psel)
, processor_display (drop_targets()) , processor_display (drop_targets())
, _redisplay_pending (false) , _redisplay_pending (false)
{ {
@ -2200,7 +2200,7 @@ ProcessorBox::show_processor_menu (int arg)
const bool sensitive = !processor_display.selection().empty() && ! stub_processor_selected (); const bool sensitive = !processor_display.selection().empty() && ! stub_processor_selected ();
paste_action->set_sensitive (!_rr_selection.processors.empty()); paste_action->set_sensitive (!_p_selection.processors.empty());
cut_action->set_sensitive (sensitive && can_cut ()); cut_action->set_sensitive (sensitive && can_cut ());
copy_action->set_sensitive (sensitive); copy_action->set_sensitive (sensitive);
delete_action->set_sensitive (sensitive || stub_processor_selected ()); delete_action->set_sensitive (sensitive || stub_processor_selected ());
@ -3165,7 +3165,7 @@ ProcessorBox::cut_processors (const ProcSelection& to_be_removed)
return; return;
} }
_rr_selection.set (node); _p_selection.set (node);
no_processor_redisplay = false; no_processor_redisplay = false;
redisplay_processors (); redisplay_processors ();
@ -3189,7 +3189,7 @@ ProcessorBox::copy_processors (const ProcSelection& to_be_copied)
} }
} }
_rr_selection.set (node); _p_selection.set (node);
} }
void void
@ -3304,22 +3304,22 @@ ProcessorBox::rename_processor (boost::shared_ptr<Processor> processor)
void void
ProcessorBox::paste_processors () ProcessorBox::paste_processors ()
{ {
if (_rr_selection.processors.empty()) { if (_p_selection.processors.empty()) {
return; return;
} }
paste_processor_state (_rr_selection.processors.get_node().children(), boost::shared_ptr<Processor>()); paste_processor_state (_p_selection.processors.get_node().children(), boost::shared_ptr<Processor>());
} }
void void
ProcessorBox::paste_processors (boost::shared_ptr<Processor> before) ProcessorBox::paste_processors (boost::shared_ptr<Processor> before)
{ {
if (_rr_selection.processors.empty()) { if (_p_selection.processors.empty()) {
return; return;
} }
paste_processor_state (_rr_selection.processors.get_node().children(), before); paste_processor_state (_p_selection.processors.get_node().children(), before);
} }
void void

View file

@ -62,7 +62,7 @@
class MotionController; class MotionController;
class PluginSelector; class PluginSelector;
class PluginUIWindow; class PluginUIWindow;
class RouteProcessorSelection; class ProcessorSelection;
class MixerStrip; class MixerStrip;
namespace ARDOUR { namespace ARDOUR {
@ -414,7 +414,7 @@ class ProcessorBox : public Gtk::HBox, public PluginInterestedObject, public ARD
}; };
ProcessorBox (ARDOUR::Session*, boost::function<PluginSelector*()> get_plugin_selector, ProcessorBox (ARDOUR::Session*, boost::function<PluginSelector*()> get_plugin_selector,
RouteProcessorSelection&, MixerStrip* parent, bool owner_is_mixer = false); ProcessorSelection&, MixerStrip* parent, bool owner_is_mixer = false);
~ProcessorBox (); ~ProcessorBox ();
void set_route (boost::shared_ptr<ARDOUR::Route>); void set_route (boost::shared_ptr<ARDOUR::Route>);
@ -490,7 +490,7 @@ class ProcessorBox : public Gtk::HBox, public PluginInterestedObject, public ARD
int _placement; int _placement;
uint32_t _visible_prefader_processors; uint32_t _visible_prefader_processors;
RouteProcessorSelection& _rr_selection; ProcessorSelection& _p_selection;
static Gtkmm2ext::ActionMap myactions; static Gtkmm2ext::ActionMap myactions;
static void load_bindings (); static void load_bindings ();

View file

@ -1,5 +1,5 @@
/* /*
Copyright (C) 2000-2007 Paul Davis Copyright (C) 2004 Paul Davis
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -20,40 +20,64 @@
#ifndef __ardour_gtk_processor_selection_h__ #ifndef __ardour_gtk_processor_selection_h__
#define __ardour_gtk_processor_selection_h__ #define __ardour_gtk_processor_selection_h__
#include <vector>
#include "pbd/signals.h"
#include "pbd/xml++.h" #include "pbd/xml++.h"
class ProcessorSelection { class XMLProcessorSelection {
public: public:
ProcessorSelection() : node (0) {} XMLProcessorSelection() : node (0) {}
~ProcessorSelection() { if (node) { delete node; } } ~XMLProcessorSelection() { if (node) { delete node; } }
void set (XMLNode* n) { void set (XMLNode* n) {
if (node) { if (node) {
delete node; delete node;
} }
node = n; node = n;
} }
void add (XMLNode* newchild) { void add (XMLNode* newchild) {
if (!node) { if (!node) {
node = new XMLNode ("add"); node = new XMLNode ("add");
} }
node->add_child_nocopy (*newchild); node->add_child_nocopy (*newchild);
} }
void clear () { void clear () {
if (node) { if (node) {
delete node; delete node;
node = 0; node = 0;
} }
} }
bool empty () const { return node == 0 || node->children().empty(); } bool empty () const { return node == 0 || node->children().empty(); }
const XMLNode& get_node() const { return *node; } const XMLNode& get_node() const { return *node; }
private: private:
XMLNode* node; XMLNode* node;
}; };
class ProcessorSelection : public PBD::ScopedConnectionList, public sigc::trackable
{
public:
ProcessorSelection () {}
XMLProcessorSelection processors;
sigc::signal<void> ProcessorsChanged;
ProcessorSelection& operator= (const ProcessorSelection& other);
void clear ();
bool empty();
void set (XMLNode* node);
void add (XMLNode* node);
void clear_processors ();
};
bool operator==(const ProcessorSelection& a, const ProcessorSelection& b);
#endif /* __ardour_gtk_processor_selection_h__ */ #endif /* __ardour_gtk_processor_selection_h__ */

View file

@ -40,6 +40,8 @@
#include "pbd/statefuldestructible.h" #include "pbd/statefuldestructible.h"
#include "ardour/session_handle.h"
#include "canvas/fwd.h" #include "canvas/fwd.h"
#include "gtkmm2ext/actions.h" #include "gtkmm2ext/actions.h"
@ -47,6 +49,7 @@
#include "gtkmm2ext/tabbable.h" #include "gtkmm2ext/tabbable.h"
#include "gtkmm2ext/visibility_tracker.h" #include "gtkmm2ext/visibility_tracker.h"
#include "axis_provider.h"
#include "editing.h" #include "editing.h"
#include "selection.h" #include "selection.h"
@ -105,8 +108,8 @@ using ARDOUR::framecnt_t;
* of PublicEditor need not be recompiled if private methods or member variables * of PublicEditor need not be recompiled if private methods or member variables
* change. * change.
*/ */
class PublicEditor : public Gtkmm2ext::Tabbable { class PublicEditor : public Gtkmm2ext::Tabbable, public ARDOUR::SessionHandlePtr, public AxisViewProvider {
public: public:
PublicEditor (Gtk::Widget& content); PublicEditor (Gtk::Widget& content);
virtual ~PublicEditor (); virtual ~PublicEditor ();
@ -123,9 +126,6 @@ public:
*/ */
virtual void set_session (ARDOUR::Session* s) = 0; virtual void set_session (ARDOUR::Session* s) = 0;
/** @return The Session that we are editing, or 0 */
virtual ARDOUR::Session* session () const = 0;
/** Set the snap type. /** Set the snap type.
* @param t Snap type (defined in editing_syms.h) * @param t Snap type (defined in editing_syms.h)
*/ */
@ -353,6 +353,8 @@ public:
virtual RouteTimeAxisView* get_route_view_by_route_id (const PBD::ID& id) const = 0; virtual RouteTimeAxisView* get_route_view_by_route_id (const PBD::ID& id) const = 0;
virtual TimeAxisView* time_axis_view_from_stripable (boost::shared_ptr<ARDOUR::Stripable> s) const = 0;
virtual void get_equivalent_regions (RegionView* rv, std::vector<RegionView*>&, PBD::PropertyID) const = 0; virtual void get_equivalent_regions (RegionView* rv, std::vector<RegionView*>&, PBD::PropertyID) const = 0;
virtual RegionView* regionview_from_region (boost::shared_ptr<ARDOUR::Region>) const = 0; virtual RegionView* regionview_from_region (boost::shared_ptr<ARDOUR::Region>) const = 0;
virtual RouteTimeAxisView* rtav_from_route (boost::shared_ptr<ARDOUR::Route>) const = 0; virtual RouteTimeAxisView* rtav_from_route (boost::shared_ptr<ARDOUR::Route>) const = 0;
@ -422,15 +424,13 @@ public:
virtual ArdourCanvas::GtkCanvasViewport* get_track_canvas() const = 0; virtual ArdourCanvas::GtkCanvasViewport* get_track_canvas() const = 0;
virtual TimeAxisView* axis_view_from_stripable (boost::shared_ptr<ARDOUR::Stripable>) const = 0;
virtual void set_current_trimmable (boost::shared_ptr<ARDOUR::Trimmable>) = 0; virtual void set_current_trimmable (boost::shared_ptr<ARDOUR::Trimmable>) = 0;
virtual void set_current_movable (boost::shared_ptr<ARDOUR::Movable>) = 0; virtual void set_current_movable (boost::shared_ptr<ARDOUR::Movable>) = 0;
virtual void center_screen (framepos_t) = 0; virtual void center_screen (framepos_t) = 0;
virtual TrackViewList axis_views_from_routes (boost::shared_ptr<ARDOUR::RouteList>) const = 0; virtual TrackViewList axis_views_from_routes (boost::shared_ptr<ARDOUR::RouteList>) const = 0;
virtual TrackViewList const & get_track_views () = 0; virtual TrackViewList const & get_track_views () const = 0;
virtual DragManager* drags () const = 0; virtual DragManager* drags () const = 0;
virtual void maybe_autoscroll (bool, bool, bool from_headers) = 0; virtual void maybe_autoscroll (bool, bool, bool from_headers) = 0;

View file

@ -56,9 +56,9 @@ using namespace Gtk;
using namespace Gtkmm2ext; using namespace Gtkmm2ext;
RouteParams_UI::RouteParams_UI () RouteParams_UI::RouteParams_UI ()
: ArdourWindow (_("Tracks and Busses")), : ArdourWindow (_("Tracks and Busses"))
latency_apply_button (Stock::APPLY), , latency_apply_button (Stock::APPLY)
track_menu(0) , track_menu(0)
{ {
insert_box = 0; insert_box = 0;
_input_iosel = 0; _input_iosel = 0;
@ -235,7 +235,7 @@ RouteParams_UI::setup_processor_boxes()
cleanup_processor_boxes(); cleanup_processor_boxes();
// construct new redirect boxes // construct new redirect boxes
insert_box = new ProcessorBox (_session, boost::bind (&RouteParams_UI::plugin_selector, this), _rr_selection, 0); insert_box = new ProcessorBox (_session, boost::bind (&RouteParams_UI::plugin_selector, this), _p_selection, 0);
insert_box->set_route (_route); insert_box->set_route (_route);
boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack>(_route); boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack>(_route);

View file

@ -40,7 +40,7 @@
#include "ardour_window.h" #include "ardour_window.h"
#include "processor_box.h" #include "processor_box.h"
#include "route_processor_selection.h" #include "processor_selection.h"
#include "latency_gui.h" #include "latency_gui.h"
namespace ARDOUR { namespace ARDOUR {
@ -113,7 +113,7 @@ class RouteParams_UI : public ArdourWindow, public PBD::ScopedConnectionList
IOSelector * _output_iosel; IOSelector * _output_iosel;
PluginSelector *_plugin_selector; PluginSelector *_plugin_selector;
RouteProcessorSelection _rr_selection; ProcessorSelection _p_selection;
boost::shared_ptr<ARDOUR::Route> _route; boost::shared_ptr<ARDOUR::Route> _route;
PBD::ScopedConnection _route_processors_connection; PBD::ScopedConnection _route_processors_connection;

View file

@ -19,21 +19,27 @@
#include <algorithm> #include <algorithm>
#include <sigc++/bind.h> #include <sigc++/bind.h>
#include "pbd/error.h"
#include "pbd/error.h"
#include "pbd/i18n.h"
#include "ardour/selection.h"
#include "ardour/session.h"
#include "ardour/session_handle.h"
#include "axis_provider.h"
#include "gui_thread.h" #include "gui_thread.h"
#include "mixer_strip.h" #include "mixer_strip.h"
#include "mixer_ui.h"
#include "route_processor_selection.h" #include "route_processor_selection.h"
#include "route_ui.h" #include "route_ui.h"
#include "pbd/i18n.h"
using namespace std; using namespace std;
using namespace ARDOUR; using namespace ARDOUR;
using namespace PBD; using namespace PBD;
RouteProcessorSelection::RouteProcessorSelection (SessionHandlePtr& s, AxisViewProvider& ap)
RouteProcessorSelection::RouteProcessorSelection() : shp (s), avp (ap)
{ {
} }
@ -41,7 +47,7 @@ RouteProcessorSelection&
RouteProcessorSelection::operator= (const RouteProcessorSelection& other) RouteProcessorSelection::operator= (const RouteProcessorSelection& other)
{ {
if (&other != this) { if (&other != this) {
processors = other.processors; (*((ProcessorSelection*) this)) = (*((ProcessorSelection const *) &other));
axes = other.axes; axes = other.axes;
} }
return *this; return *this;
@ -61,47 +67,58 @@ RouteProcessorSelection::clear ()
clear_routes (); clear_routes ();
} }
void
RouteProcessorSelection::clear_processors ()
{
processors.clear ();
ProcessorsChanged ();
}
void void
RouteProcessorSelection::clear_routes () RouteProcessorSelection::clear_routes ()
{ {
PresentationInfo::ChangeSuspender cs; if (shp.session()) {
PresentationInfo::ChangeSuspender cs;
for (AxisViewSelection::iterator i = axes.begin(); i != axes.end(); ++i) { shp.session()->selection().clear_stripables ();
(*i)->set_selected (false);
} }
}
void
RouteProcessorSelection::presentation_info_changed (PropertyChange const & what_changed)
{
Session* s = shp.session();
if (!s) {
/* too early ... session handle provider doesn't know about the
session yet.
*/
return;
}
PropertyChange pc;
pc.add (Properties::selected);
CoreSelection::StripableAutomationControls sc;
s->selection().get_stripables (sc);
for (AxisViewSelection::iterator a = axes.begin(); a != axes.end(); ++a) {
(*a)->set_selected (false);
}
axes.clear (); axes.clear ();
drop_connections ();
}
void for (CoreSelection::StripableAutomationControls::const_iterator i = sc.begin(); i != sc.end(); ++i) {
RouteProcessorSelection::add (XMLNode* node) AxisView* av = avp.axis_view_by_stripable ((*i).stripable);
{ if (av) {
// XXX check for duplicate axes.insert (av);
processors.add (node); av->set_selected (true);
ProcessorsChanged(); }
} }
void
RouteProcessorSelection::set (XMLNode* node)
{
clear_processors ();
processors.set (node);
ProcessorsChanged ();
} }
void void
RouteProcessorSelection::add (AxisView* r) RouteProcessorSelection::add (AxisView* r)
{ {
if (!shp.session()) {
return;
}
if (axes.insert (r).second) { if (axes.insert (r).second) {
r->set_selected (true); shp.session()->selection().add (r->stripable(), boost::shared_ptr<AutomationControl>());
MixerStrip* ms = dynamic_cast<MixerStrip*> (r); MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
@ -114,23 +131,20 @@ RouteProcessorSelection::add (AxisView* r)
void void
RouteProcessorSelection::remove (AxisView* r) RouteProcessorSelection::remove (AxisView* r)
{ {
ENSURE_GUI_THREAD (*this, &RouteProcessorSelection::remove, r); if (!shp.session()) {
PresentationInfo::ChangeSuspender cs; return;
AxisViewSelection::iterator i;
if ((i = find (axes.begin(), axes.end(), r)) != axes.end()) {
AxisView* av = *i;
axes.erase (i);
av->set_selected (false);
} }
ENSURE_GUI_THREAD (*this, &RouteProcessorSelection::remove, r);
shp.session()->selection().remove (r->stripable(), boost::shared_ptr<AutomationControl>());
} }
void void
RouteProcessorSelection::set (AxisView* r) RouteProcessorSelection::set (AxisView* r)
{ {
PresentationInfo::ChangeSuspender cs; if (!shp.session()) {
clear_routes (); return;
add (r); }
shp.session()->selection().set (r->stripable(), boost::shared_ptr<AutomationControl>());
} }
bool bool

View file

@ -26,34 +26,36 @@
#include "processor_selection.h" #include "processor_selection.h"
#include "route_ui_selection.h" #include "route_ui_selection.h"
class RouteProcessorSelection : public PBD::ScopedConnectionList, public sigc::trackable namespace ARDOUR {
class SessionHandlePtr;
}
class AxisViewProvider;
class RouteProcessorSelection : public ProcessorSelection
{ {
public: public:
ProcessorSelection processors;
AxisViewSelection axes; AxisViewSelection axes;
RouteProcessorSelection(); RouteProcessorSelection (ARDOUR::SessionHandlePtr&, AxisViewProvider&);
RouteProcessorSelection& operator= (const RouteProcessorSelection& other); RouteProcessorSelection& operator= (const RouteProcessorSelection& other);
sigc::signal<void> ProcessorsChanged;
void clear (); void clear ();
bool empty(); bool empty();
void set (XMLNode* node);
void add (XMLNode* node);
void set (AxisView*); void set (AxisView*);
void add (AxisView*); void add (AxisView*);
void remove (AxisView*); void remove (AxisView*);
void clear_processors ();
void clear_routes ();
bool selected (AxisView*); bool selected (AxisView*);
void clear_routes ();
void presentation_info_changed (PBD::PropertyChange const & what_changed);
private: private:
ARDOUR::SessionHandlePtr& shp;
AxisViewProvider& avp;
void removed (AxisView*); void removed (AxisView*);
}; };

View file

@ -24,9 +24,10 @@
#include "pbd/stacktrace.h" #include "pbd/stacktrace.h"
#include "pbd/types_convert.h" #include "pbd/types_convert.h"
#include "ardour/evoral_types_convert.h"
#include "ardour/playlist.h" #include "ardour/playlist.h"
#include "ardour/rc_configuration.h" #include "ardour/rc_configuration.h"
#include "ardour/evoral_types_convert.h" #include "ardour/selection.h"
#include "control_protocol/control_protocol.h" #include "control_protocol/control_protocol.h"
@ -65,9 +66,6 @@ Selection::Selection (const PublicEditor* e)
/* we have disambiguate which remove() for the compiler */ /* we have disambiguate which remove() for the compiler */
void (Selection::*track_remove)(TimeAxisView*) = &Selection::remove;
TimeAxisView::CatchDeletion.connect (*this, MISSING_INVALIDATOR, boost::bind (track_remove, this, _1), gui_context());
void (Selection::*marker_remove)(ArdourMarker*) = &Selection::remove; void (Selection::*marker_remove)(ArdourMarker*) = &Selection::remove;
ArdourMarker::CatchDeletion.connect (*this, MISSING_INVALIDATOR, boost::bind (marker_remove, this, _1), gui_context()); ArdourMarker::CatchDeletion.connect (*this, MISSING_INVALIDATOR, boost::bind (marker_remove, this, _1), gui_context());
@ -130,20 +128,6 @@ Selection::clear_objects (bool with_signal)
clear_midi_regions (with_signal); clear_midi_regions (with_signal);
} }
void
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 ();
}
}
void void
Selection::clear_time (bool with_signal) Selection::clear_time (bool with_signal)
{ {
@ -271,38 +255,6 @@ Selection::toggle (boost::shared_ptr<Playlist> pl)
PlaylistsChanged (); PlaylistsChanged ();
} }
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()) {
tracks.push_back (track);
track->set_selected (true);
} else {
tracks.erase (i);
track->set_selected (false);
}
}
void void
Selection::toggle (const MidiNoteSelection& midi_note_list) Selection::toggle (const MidiNoteSelection& midi_note_list)
{ {
@ -405,10 +357,10 @@ Selection::toggle (framepos_t start, framepos_t end)
void void
Selection::add (boost::shared_ptr<Playlist> pl) Selection::add (boost::shared_ptr<Playlist> pl)
{ {
clear_time(); //enforce object/range exclusivity
clear_tracks(); //enforce object/track exclusivity
if (find (playlists.begin(), playlists.end(), pl) == playlists.end()) { if (find (playlists.begin(), playlists.end(), pl) == playlists.end()) {
clear_time(); //enforce object/range exclusivity
clear_tracks(); //enforce object/track exclusivity
pl->use (); pl->use ();
playlists.push_back(pl); playlists.push_back(pl);
PlaylistsChanged (); PlaylistsChanged ();
@ -418,9 +370,6 @@ Selection::add (boost::shared_ptr<Playlist> pl)
void void
Selection::add (const list<boost::shared_ptr<Playlist> >& pllist) Selection::add (const list<boost::shared_ptr<Playlist> >& pllist)
{ {
clear_time(); //enforce object/range exclusivity
clear_tracks(); //enforce object/track exclusivity
bool changed = false; bool changed = false;
for (list<boost::shared_ptr<Playlist> >::const_iterator i = pllist.begin(); i != pllist.end(); ++i) { for (list<boost::shared_ptr<Playlist> >::const_iterator i = pllist.begin(); i != pllist.end(); ++i) {
@ -432,51 +381,21 @@ Selection::add (const list<boost::shared_ptr<Playlist> >& pllist)
} }
if (changed) { if (changed) {
clear_time(); //enforce object/range exclusivity
clear_tracks(); //enforce object/track exclusivity
PlaylistsChanged (); PlaylistsChanged ();
} }
} }
void
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);
}
}
}
void
Selection::add (TimeAxisView* track)
{
if (dynamic_cast<VCATimeAxisView*> (track)) {
return;
}
TrackViewList tr;
tr.push_back (track);
add (tr);
}
void void
Selection::add (const MidiNoteSelection& midi_list) Selection::add (const MidiNoteSelection& midi_list)
{ {
clear_time(); //enforce object/range exclusivity
clear_tracks(); //enforce object/track exclusivity
const MidiNoteSelection::const_iterator b = midi_list.begin(); const MidiNoteSelection::const_iterator b = midi_list.begin();
const MidiNoteSelection::const_iterator e = midi_list.end(); const MidiNoteSelection::const_iterator e = midi_list.end();
if (!midi_list.empty()) { if (!midi_list.empty()) {
clear_time(); //enforce object/range exclusivity
clear_tracks(); //enforce object/track exclusivity
midi_notes.insert (midi_notes.end(), b, e); midi_notes.insert (midi_notes.end(), b, e);
MidiNotesChanged (); MidiNotesChanged ();
} }
@ -496,9 +415,6 @@ Selection::add (MidiCutBuffer* midi)
void void
Selection::add (vector<RegionView*>& v) Selection::add (vector<RegionView*>& v)
{ {
clear_time(); //enforce object/range exclusivity
clear_tracks(); //enforce object/track exclusivity
/* XXX This method or the add (const RegionSelection&) needs to go /* XXX This method or the add (const RegionSelection&) needs to go
*/ */
@ -511,6 +427,8 @@ Selection::add (vector<RegionView*>& v)
} }
if (changed) { if (changed) {
clear_time(); //enforce object/range exclusivity
clear_tracks(); //enforce object/track exclusivity
RegionsChanged (); RegionsChanged ();
} }
} }
@ -518,9 +436,6 @@ Selection::add (vector<RegionView*>& v)
void void
Selection::add (const RegionSelection& rs) Selection::add (const RegionSelection& rs)
{ {
clear_time(); //enforce object/range exclusivity
clear_tracks(); //enforce object/track exclusivity
/* XXX This method or the add (const vector<RegionView*>&) needs to go /* XXX This method or the add (const vector<RegionView*>&) needs to go
*/ */
@ -533,6 +448,8 @@ Selection::add (const RegionSelection& rs)
} }
if (changed) { if (changed) {
clear_time(); //enforce object/range exclusivity
clear_tracks(); //enforce object/track exclusivity
RegionsChanged (); RegionsChanged ();
} }
} }
@ -540,12 +457,11 @@ Selection::add (const RegionSelection& rs)
void void
Selection::add (RegionView* r) Selection::add (RegionView* r)
{ {
clear_time(); //enforce object/range exclusivity
clear_tracks(); //enforce object/track exclusivity
if (find (regions.begin(), regions.end(), r) == regions.end()) { if (find (regions.begin(), regions.end(), r) == regions.end()) {
bool changed = regions.add (r); bool changed = regions.add (r);
if (changed) { if (changed) {
clear_time(); //enforce object/range exclusivity
clear_tracks(); //enforce object/track exclusivity
RegionsChanged (); RegionsChanged ();
} }
} }
@ -624,16 +540,18 @@ Selection::replace (uint32_t sid, framepos_t start, framepos_t end)
void void
Selection::add (boost::shared_ptr<Evoral::ControlList> cl) Selection::add (boost::shared_ptr<Evoral::ControlList> cl)
{ {
clear_time(); //enforce object/range exclusivity boost::shared_ptr<ARDOUR::AutomationList> al = boost::dynamic_pointer_cast<ARDOUR::AutomationList>(cl);
clear_tracks(); //enforce object/track exclusivity
boost::shared_ptr<ARDOUR::AutomationList> al
= boost::dynamic_pointer_cast<ARDOUR::AutomationList>(cl);
if (!al) { if (!al) {
warning << "Programming error: Selected list is not an ARDOUR::AutomationList" << endmsg; warning << "Programming error: Selected list is not an ARDOUR::AutomationList" << endmsg;
return; return;
} }
if (!cl->empty()) {
clear_time(); //enforce object/range exclusivity
clear_tracks(); //enforce object/track exclusivity
}
/* The original may change so we must store a copy (not a pointer) here. /* The original may change so we must store a copy (not a pointer) here.
* e.g AutomationLine rewrites the list with gain mapping. * e.g AutomationLine rewrites the list with gain mapping.
* the downside is that we can't perfom duplicate checks. * the downside is that we can't perfom duplicate checks.
@ -643,38 +561,6 @@ Selection::add (boost::shared_ptr<Evoral::ControlList> cl)
LinesChanged(); LinesChanged();
} }
void
Selection::remove (TimeAxisView* track)
{
list<TimeAxisView*>::iterator i;
if ((i = find (tracks.begin(), tracks.end(), track)) != tracks.end()) {
/* erase first, because set_selected() will remove the track
from the selection, invalidating the iterator.
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)
{
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()) {
tracks.erase (x);
(*i)->set_selected (false);
}
}
}
void void
Selection::remove (ControlPoint* p) Selection::remove (ControlPoint* p)
{ {
@ -800,68 +686,13 @@ Selection::remove (boost::shared_ptr<ARDOUR::AutomationList> ac)
} }
} }
void
Selection::set (TimeAxisView* track)
{
if (dynamic_cast<VCATimeAxisView*> (track)) {
return;
}
clear_objects (); //enforce object/range exclusivity
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);
}
void
Selection::set (const TrackViewList& track_list)
{
clear_objects(); //enforce object/range exclusivity
TrackViewList to_be_added;
TrackViewList to_be_removed;
for (TrackViewList::const_iterator x = tracks.begin(); x != tracks.end(); ++x) {
if (find (track_list.begin(), track_list.end(), *x) == track_list.end()) {
to_be_removed.push_back (*x);
}
}
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()) {
to_be_added.push_back (*x);
}
}
PresentationInfo::ChangeSuspender cs;
remove (to_be_removed);
add (to_be_added);
}
void void
Selection::set (const MidiNoteSelection& midi_list) Selection::set (const MidiNoteSelection& midi_list)
{ {
clear_time (); //enforce region/object exclusivity if (!midi_list.empty()) {
clear_tracks(); //enforce object/track exclusivity clear_time (); //enforce region/object exclusivity
clear_tracks(); //enforce object/track exclusivity
}
clear_objects (); clear_objects ();
add (midi_list); add (midi_list);
} }
@ -869,8 +700,10 @@ Selection::set (const MidiNoteSelection& midi_list)
void void
Selection::set (boost::shared_ptr<Playlist> playlist) Selection::set (boost::shared_ptr<Playlist> playlist)
{ {
clear_time (); //enforce region/object exclusivity if (playlist) {
clear_tracks(); //enforce object/track exclusivity clear_time (); //enforce region/object exclusivity
clear_tracks(); //enforce object/track exclusivity
}
clear_objects (); clear_objects ();
add (playlist); add (playlist);
} }
@ -878,7 +711,9 @@ Selection::set (boost::shared_ptr<Playlist> playlist)
void void
Selection::set (const list<boost::shared_ptr<Playlist> >& pllist) Selection::set (const list<boost::shared_ptr<Playlist> >& pllist)
{ {
clear_time(); //enforce region/object exclusivity if (!pllist.empty()) {
clear_time(); //enforce region/object exclusivity
}
clear_objects (); clear_objects ();
add (pllist); add (pllist);
} }
@ -886,8 +721,10 @@ Selection::set (const list<boost::shared_ptr<Playlist> >& pllist)
void void
Selection::set (const RegionSelection& rs) Selection::set (const RegionSelection& rs)
{ {
clear_time(); //enforce region/object exclusivity if (!rs.empty()) {
clear_tracks(); //enforce object/track exclusivity clear_time(); //enforce region/object exclusivity
clear_tracks(); //enforce object/track exclusivity
}
clear_objects(); clear_objects();
regions = rs; regions = rs;
RegionsChanged(); /* EMIT SIGNAL */ RegionsChanged(); /* EMIT SIGNAL */
@ -896,8 +733,10 @@ Selection::set (const RegionSelection& rs)
void void
Selection::set (MidiRegionView* mrv) Selection::set (MidiRegionView* mrv)
{ {
clear_time(); //enforce region/object exclusivity if (mrv) {
clear_tracks(); //enforce object/track exclusivity clear_time(); //enforce region/object exclusivity
clear_tracks(); //enforce object/track exclusivity
}
clear_objects (); clear_objects ();
add (mrv); add (mrv);
} }
@ -905,8 +744,10 @@ Selection::set (MidiRegionView* mrv)
void void
Selection::set (RegionView* r, bool /*also_clear_tracks*/) Selection::set (RegionView* r, bool /*also_clear_tracks*/)
{ {
clear_time(); //enforce region/object exclusivity if (r) {
clear_tracks(); //enforce object/track exclusivity clear_time(); //enforce region/object exclusivity
clear_tracks(); //enforce object/track exclusivity
}
clear_objects (); clear_objects ();
add (r); add (r);
} }
@ -914,8 +755,11 @@ Selection::set (RegionView* r, bool /*also_clear_tracks*/)
void void
Selection::set (vector<RegionView*>& v) Selection::set (vector<RegionView*>& v)
{ {
clear_time(); //enforce region/object exclusivity if (!v.empty()) {
clear_tracks(); //enforce object/track exclusivity clear_time(); //enforce region/object exclusivity
clear_tracks(); //enforce object/track exclusivity
}
clear_objects(); clear_objects();
add (v); add (v);
@ -999,12 +843,6 @@ Selection::selected (ArdourMarker* m) const
return find (markers.begin(), markers.end(), m) != markers.end(); return find (markers.begin(), markers.end(), m) != markers.end();
} }
bool
Selection::selected (TimeAxisView* tv) const
{
return tv->selected ();
}
bool bool
Selection::selected (RegionView* rv) const Selection::selected (RegionView* rv) const
{ {
@ -1384,26 +1222,19 @@ Selection::set_state (XMLNode const & node, int)
clear_midi_notes (); clear_midi_notes ();
clear_points (); clear_points ();
clear_time (); clear_time ();
clear_tracks ();
clear_markers (); clear_markers ();
RegionSelection selected_regions; RegionSelection selected_regions;
/* NOTE: stripable/time-axis-view selection is saved/restored by
* ARDOUR::CoreSelection, not this Selection object
*/
PBD::ID id; PBD::ID id;
XMLNodeList children = node.children (); XMLNodeList children = node.children ();
for (XMLNodeList::const_iterator i = children.begin(); i != children.end(); ++i) { for (XMLNodeList::const_iterator i = children.begin(); i != children.end(); ++i) {
if ((*i)->name() == X_("RouteView")) { if ((*i)->name() == X_("Region")) {
if (!(*i)->get_property (X_("id"), id)) {
assert(false); // handle this more gracefully?
}
RouteTimeAxisView* rtv = editor->get_route_view_by_route_id (id);
if (rtv) {
add (rtv);
}
} else if ((*i)->name() == X_("Region")) {
if (!(*i)->get_property (X_("id"), id)) { if (!(*i)->get_property (X_("id"), id)) {
assert(false); assert(false);
@ -1594,3 +1425,252 @@ Selection::remove_regions (TimeAxisView* t)
i = tmp; i = tmp;
} }
} }
/* TIME AXIS VIEW ... proxy for Stripable/Controllable
*
* public methods just modify the CoreSelection; PresentationInfo::Changed will
* trigger Selection::core_selection_changed() and we will update our own data
* structures there.
*/
void
Selection::toggle (const TrackViewList& track_list)
{
TrackViewList t = add_grouped_tracks (track_list);
CoreSelection& selection (editor->session()->selection());
PresentationInfo::ChangeSuspender cs;
for (TrackSelection::const_iterator i = t.begin(); i != t.end(); ++i) {
boost::shared_ptr<Stripable> s = (*i)->stripable ();
boost::shared_ptr<AutomationControl> c = (*i)->control ();
selection.toggle (s, c);
}
}
void
Selection::toggle (TimeAxisView* track)
{
if (dynamic_cast<VCATimeAxisView*> (track)) {
return;
}
TrackViewList tr;
tr.push_back (track);
toggle (tr);
}
void
Selection::add (TrackViewList const & track_list)
{
TrackViewList t = add_grouped_tracks (track_list);
CoreSelection& selection (editor->session()->selection());
PresentationInfo::ChangeSuspender cs;
for (TrackSelection::const_iterator i = t.begin(); i != t.end(); ++i) {
boost::shared_ptr<Stripable> s = (*i)->stripable ();
boost::shared_ptr<AutomationControl> c = (*i)->control ();
selection.add (s, c);
}
}
void
Selection::add (TimeAxisView* track)
{
if (dynamic_cast<VCATimeAxisView*> (track)) {
return;
}
TrackViewList tr;
tr.push_back (track);
add (tr);
}
void
Selection::remove (TimeAxisView* track)
{
if (dynamic_cast<VCATimeAxisView*> (track)) {
return;
}
TrackViewList tvl;
tvl.push_back (track);
remove (tvl);
}
void
Selection::remove (const TrackViewList& t)
{
CoreSelection& selection (editor->session()->selection());
PresentationInfo::ChangeSuspender cs;
for (TrackSelection::const_iterator i = t.begin(); i != t.end(); ++i) {
boost::shared_ptr<Stripable> s = (*i)->stripable ();
boost::shared_ptr<AutomationControl> c = (*i)->control ();
selection.remove (s, c);
}
}
void
Selection::set (TimeAxisView* track)
{
if (dynamic_cast<VCATimeAxisView*> (track)) {
return;
}
TrackViewList tvl;
tvl.push_back (track);
set (tvl);
}
void
Selection::set (const TrackViewList& track_list)
{
TrackViewList t = add_grouped_tracks (track_list);
CoreSelection& selection (editor->session()->selection());
PresentationInfo::ChangeSuspender cs;
selection.clear_stripables ();
for (TrackSelection::const_iterator i = t.begin(); i != t.end(); ++i) {
boost::shared_ptr<Stripable> s = (*i)->stripable ();
boost::shared_ptr<AutomationControl> c = (*i)->control ();
selection.add (s, c);
}
}
void
Selection::clear_tracks (bool)
{
Session* s = editor->session();
if (s) {
CoreSelection& selection (s->selection());
selection.clear_stripables ();
}
}
bool
Selection::selected (TimeAxisView* tv) const
{
Session* session = editor->session();
if (!session) {
return false;
}
CoreSelection& selection (session->selection());
boost::shared_ptr<Stripable> s = tv->stripable ();
boost::shared_ptr<AutomationControl> c = tv->control ();
if (c) {
return selection.selected (c);
}
return selection.selected (s);
}
TrackViewList
Selection::add_grouped_tracks (TrackViewList const & t)
{
TrackViewList added;
for (TrackSelection::const_iterator i = t.begin(); i != t.end(); ++i) {
if (dynamic_cast<VCATimeAxisView*> (*i)) {
continue;
}
/* select anything in the same select-enabled route group */
ARDOUR::RouteGroup* rg = (*i)->route_group ();
if (rg && rg->is_active() && rg->is_select ()) {
TrackViewList tr = editor->axis_views_from_routes (rg->route_list ());
for (TrackViewList::iterator j = tr.begin(); j != tr.end(); ++j) {
/* Do not add the trackview passed in as an
* argument, because we want that to be on the
* end of the list.
*/
if (*j != *i) {
if (!added.contains (*j)) {
added.push_back (*j);
}
}
}
}
}
/* now add the the trackview's passed in as actual arguments */
added.insert (added.end(), t.begin(), t.end());
return added;
}
#if 0
static void dump_tracks (Selection const & s)
{
cerr << "--TRACKS [" << s.tracks.size() << ']' << ":\n";
for (TrackViewList::const_iterator x = s.tracks.begin(); x != s.tracks.end(); ++x) {
cerr << (*x)->name() << ' ' << (*x)->stripable() << " C = " << (*x)->control() << endl;
}
cerr << "///\n";
}
#endif
void
Selection::core_selection_changed (PropertyChange const & what_changed)
{
PropertyChange pc;
pc.add (Properties::selected);
if (!what_changed.contains (pc)) {
return;
}
CoreSelection& selection (editor->session()->selection());
if (selection.selected()) {
clear_objects(); // enforce object/range exclusivity
}
tracks.clear (); // clear stage for whatever tracks are now selected (maybe none)
TrackViewList const & tvl (editor->get_track_views ());
for (TrackViewList::const_iterator x = tvl.begin(); x != tvl.end(); ++x) {
boost::shared_ptr<Stripable> s = (*x)->stripable ();
boost::shared_ptr<AutomationControl> c = (*x)->control ();
if (!s) {
continue;
}
TimeAxisView* tav = editor->time_axis_view_from_stripable (s);
if (!tav) {
continue;
}
if ((c && selection.selected (c)) || selection.selected (s)) {
tracks.push_back (tav);
}
TimeAxisView::Children kids = tav->get_child_list ();
for (TimeAxisView::Children::iterator j = kids.begin(); j != kids.end(); ++j) {
s = (*j)->stripable ();
c = (*j)->control ();
if ((c && selection.selected (c)) || selection.selected (s)) {
tracks.push_back ((*j).get());
}
}
}
}

View file

@ -225,9 +225,13 @@ class Selection : public sigc::trackable, public PBD::ScopedConnectionList
std::list<std::pair<PBD::ID const, std::list<Evoral::event_id_t> > > pending_midi_note_selection; std::list<std::pair<PBD::ID const, std::list<Evoral::event_id_t> > > pending_midi_note_selection;
void core_selection_changed (PBD::PropertyChange const & pc);
private: private:
PublicEditor const * editor; PublicEditor const * editor;
uint32_t next_time_id; uint32_t next_time_id;
TrackViewList add_grouped_tracks (TrackViewList const & t);
}; };
bool operator==(const Selection& a, const Selection& b); bool operator==(const Selection& a, const Selection& b);

View file

@ -769,19 +769,9 @@ TimeAxisView::set_selected (bool yn)
time_axis_vbox.set_name (controls_base_unselected_name); time_axis_vbox.set_name (controls_base_unselected_name);
hide_selection (); hide_selection ();
/* children will be set for the yn=true case. but when deselecting
the editor only has a list of top-level trackviews, so we
have to do this here.
*/
for (Children::iterator i = children.begin(); i != children.end(); ++i) {
(*i)->set_selected (false);
}
} }
time_axis_frame.show(); time_axis_frame.show();
} }
void void

View file

@ -39,47 +39,3 @@ TrackSelection::~TrackSelection ()
{ {
} }
TrackViewList
TrackSelection::add (TrackViewList const & t)
{
TrackViewList added;
for (TrackSelection::const_iterator i = t.begin(); i != t.end(); ++i) {
if (dynamic_cast<VCATimeAxisView*> (*i)) {
continue;
}
/* select anything in the same select-enabled route group */
ARDOUR::RouteGroup* rg = (*i)->route_group ();
if (rg && rg->is_active() && rg->is_select ()) {
TrackViewList tr = _editor->axis_views_from_routes (rg->route_list ());
for (TrackViewList::iterator j = tr.begin(); j != tr.end(); ++j) {
/* Do not add the trackview passed in as an
* argument, because we want that to be on the
* end of the list.
*/
if (*j != *i) {
if (!contains (*j)) {
added.push_back (*j);
push_back (*j);
}
}
}
}
/* now add the the trackview's passed in as actual arguments */
if (!contains (*i)) {
added.push_back (*i);
push_back (*i);
}
}
return added;
}

View file

@ -35,8 +35,6 @@ public:
virtual ~TrackSelection (); virtual ~TrackSelection ();
TrackViewList add (TrackViewList const &);
template <typename Function> template <typename Function>
void foreach_time_axis (Function f) { void foreach_time_axis (Function f) {
for (iterator i = begin(); i != end(); ++i) { for (iterator i = begin(); i != end(); ++i) {

View file

@ -202,6 +202,7 @@ gtk2_ardour_sources = [
'port_matrix_labels.cc', 'port_matrix_labels.cc',
'port_matrix_row_labels.cc', 'port_matrix_row_labels.cc',
'processor_box.cc', 'processor_box.cc',
'processor_selection.cc',
'patch_change_dialog.cc', 'patch_change_dialog.cc',
'progress_reporter.cc', 'progress_reporter.cc',
'prompter.cc', 'prompter.cc',