X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_selection.cc;h=b7b0019b892e184e3c377f2d3d839ec8691c8ecb;hb=24978033ef7b40ec5d408238421f42b3bc9821f3;hp=33685be2ff2cae571f949b871ea5b9dcd43ab9ce;hpb=c06c6c153db6b33b93515100d839f376dc805d5d;p=ardour.git diff --git a/gtk2_ardour/editor_selection.cc b/gtk2_ardour/editor_selection.cc index 33685be2ff..b7b0019b89 100644 --- a/gtk2_ardour/editor_selection.cc +++ b/gtk2_ardour/editor_selection.cc @@ -26,6 +26,7 @@ #include "ardour/playlist.h" #include "ardour/route_group.h" #include "ardour/profile.h" +#include "ardour/midi_region.h" #include "editor.h" #include "actions.h" @@ -35,6 +36,8 @@ #include "automation_line.h" #include "control_point.h" #include "editor_regions.h" +#include "editor_cursors.h" +#include "midi_region_view.h" #include "i18n.h" @@ -48,9 +51,9 @@ using namespace Editing; struct TrackViewByPositionSorter { - bool operator() (const TimeAxisView* a, const TimeAxisView *b) { - return a->y_position() < b->y_position(); - } + bool operator() (const TimeAxisView* a, const TimeAxisView *b) { + return a->y_position() < b->y_position(); + } }; bool @@ -174,12 +177,97 @@ Editor::select_all_tracks () * tracks, in which case nothing will happen unless `force' is true. */ void -Editor::set_selected_track_as_side_effect (bool force) +Editor::set_selected_track_as_side_effect (Selection::Operation op, bool /*force*/) { if (!clicked_axisview) { return; } +#if 1 + if (!clicked_routeview) { + return; + } + + bool had_tracks = !selection->tracks.empty(); + RouteGroup* group = clicked_routeview->route()->route_group(); + RouteGroup& arg (_session->all_route_group()); + + switch (op) { + case Selection::Toggle: + if (selection->selected (clicked_axisview)) { + if (arg.is_select() && arg.is_active()) { + for (TrackViewList::iterator i = track_views.begin(); i != track_views.end (); ++i) { + selection->remove(*i); + } + } else if (group && group->is_active()) { + for (TrackViewList::iterator i = track_views.begin(); i != track_views.end (); ++i) { + if ((*i)->route_group() == group) + selection->remove(*i); + } + } else { + selection->remove (clicked_axisview); + } + } else { + if (arg.is_select() && arg.is_active()) { + for (TrackViewList::iterator i = track_views.begin(); i != track_views.end (); ++i) { + selection->add(*i); + } + } else if (group && group->is_active()) { + for (TrackViewList::iterator i = track_views.begin(); i != track_views.end (); ++i) { + if ( (*i)->route_group() == group) + selection->add(*i); + } + } else { + selection->add (clicked_axisview); + } + } + break; + + case Selection::Add: + if (!had_tracks && arg.is_select() && arg.is_active()) { + /* nothing was selected already, and all group is active etc. so use + all tracks. + */ + for (TrackViewList::iterator i = track_views.begin(); i != track_views.end (); ++i) { + selection->add(*i); + } + } else if (group && group->is_active()) { + for (TrackViewList::iterator i = track_views.begin(); i != track_views.end (); ++i) { + if ((*i)->route_group() == group) + selection->add(*i); + } + } else { + selection->add (clicked_axisview); + } + break; + + case Selection::Set: + selection->clear(); + if (!had_tracks && arg.is_select() && arg.is_active()) { + /* nothing was selected already, and all group is active etc. so use + all tracks. + */ + for (TrackViewList::iterator i = track_views.begin(); i != track_views.end (); ++i) { + selection->add(*i); + } + } else if (group && group->is_active()) { + for (TrackViewList::iterator i = track_views.begin(); i != track_views.end (); ++i) { + if ((*i)->route_group() == group) + selection->add(*i); + } + } else { + selection->set (clicked_axisview); + } + break; + + case Selection::Extend: + selection->clear(); + cerr << ("Editor::set_selected_track_as_side_effect case Selection::Add not yet implemented\n"); + break; + } + +#else // the older version + if (!selection->tracks.empty()) { if (!selection->selected (clicked_axisview)) { selection->add (clicked_axisview); @@ -188,6 +276,7 @@ Editor::set_selected_track_as_side_effect (bool force) } else if (force) { selection->set (clicked_axisview); } +#endif } void @@ -241,46 +330,32 @@ Editor::set_selected_control_point_from_click (Selection::Operation op, bool /*n return false; } - if (clicked_control_point->selected()) { - /* the clicked control point is already selected; others may be as well, so - don't change the selection. - */ - return true; + switch (op) { + case Selection::Set: + selection->set (clicked_control_point); + break; + case Selection::Add: + selection->add (clicked_control_point); + break; + case Selection::Toggle: + selection->toggle (clicked_control_point); + break; + case Selection::Extend: + /* XXX */ + break; } - /* We know the ControlPoint that was clicked, but (as discussed in automation_selectable.h) - * selected automation data are described by areas on the AutomationLine. A ControlPoint - * represents any model points in the space that it takes up, so the AutomationSelectable - * needs to be the size of the ControlPoint. - */ - - double const size = clicked_control_point->size (); - AutomationLine& line = clicked_control_point->line (); - - nframes64_t const x1 = pixel_to_frame (clicked_control_point->get_x() - size / 2) + line.time_converter().origin_b (); - nframes64_t const x2 = pixel_to_frame (clicked_control_point->get_x() + size / 2) + line.time_converter().origin_b (); - double y1 = clicked_control_point->get_y() - size / 2; - double y2 = clicked_control_point->get_y() + size / 2; - - /* convert the y values to trackview space */ - double dummy = 0; - clicked_control_point->line().parent_group().i2w (dummy, y1); - clicked_control_point->line().parent_group().i2w (dummy, y2); - _trackview_group->w2i (dummy, y1); - _trackview_group->w2i (dummy, y2); - - /* and set up the selection */ - return select_all_within (x1, x2, y1, y2, selection->tracks, op); + return true; } void Editor::get_onscreen_tracks (TrackViewList& tvl) { - for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { - if ((*i)->y_position() < _canvas_height) { - tvl.push_back (*i); - } - } + for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { + if ((*i)->y_position() < _canvas_height) { + tvl.push_back (*i); + } + } } /** Call a slot for a given `basis' track and also for any track that is in the same @@ -320,7 +395,64 @@ Editor::mapover_tracks (sigc::slot sl, TimeA /* call the slots */ uint32_t const sz = tracks.size (); - + + for (set::iterator i = tracks.begin(); i != tracks.end(); ++i) { + sl (**i, sz); + } +} + +/** Call a slot for a given `basis' track and also for any track that is in the same + * active route group with a particular set of properties. + * + * @param sl Slot to call. + * @param basis Basis track. + * @param prop Properties that active edit groups must share to be included in the map. + */ + +void +Editor::mapover_tracks_with_unique_playlists (sigc::slot sl, TimeAxisView* basis, PBD::PropertyID prop) const +{ + RouteTimeAxisView* route_basis = dynamic_cast (basis); + set > playlists; + + if (route_basis == 0) { + return; + } + + set tracks; + tracks.insert (route_basis); + + RouteGroup* group = route_basis->route()->route_group(); // could be null, not a problem + + if (group && group->enabled_property(prop) && group->enabled_property (Properties::active.property_id) ) { + + /* the basis is a member of an active route group, with the appropriate + properties; find other members */ + + for (TrackViewList::const_iterator i = track_views.begin(); i != track_views.end(); ++i) { + RouteTimeAxisView* v = dynamic_cast (*i); + + if (v && v->route()->route_group() == group) { + + boost::shared_ptr t = v->track(); + if (t) { + if (playlists.insert (t->playlist()).second) { + /* haven't seen this playlist yet */ + tracks.insert (v); + } + } else { + /* not actually a "Track", but a timeaxis view that + we should mapover anyway. + */ + tracks.insert (v); + } + } + } + } + + /* call the slots */ + uint32_t const sz = tracks.size (); + for (set::iterator i = tracks.begin(); i != tracks.end(); ++i) { sl (**i, sz); } @@ -358,7 +490,7 @@ Editor::mapped_get_equivalent_regions (RouteTimeAxisView& tv, uint32_t, RegionVi void Editor::get_equivalent_regions (RegionView* basis, vector& equivalent_regions, PBD::PropertyID property) const { - mapover_tracks (sigc::bind (sigc::mem_fun (*this, &Editor::mapped_get_equivalent_regions), basis, &equivalent_regions), &basis->get_trackview(), property); + mapover_tracks_with_unique_playlists (sigc::bind (sigc::mem_fun (*this, &Editor::mapped_get_equivalent_regions), basis, &equivalent_regions), &basis->get_time_axis_view(), property); /* add clicked regionview since we skipped all other regions in the same track as the one it was in */ @@ -374,10 +506,9 @@ Editor::get_equivalent_regions (RegionSelection & basis, PBD::PropertyID prop) c vector eq; - mapover_tracks ( + mapover_tracks_with_unique_playlists ( sigc::bind (sigc::mem_fun (*this, &Editor::mapped_get_equivalent_regions), *i, &eq), - &(*i)->get_trackview(), prop - ); + &(*i)->get_time_axis_view(), prop); for (vector::iterator j = eq.begin(); j != eq.end(); ++j) { equivalent.add (*j); @@ -447,7 +578,6 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, switch (op) { case Selection::Toggle: - if (selection->selected (clicked_regionview)) { if (press) { @@ -458,7 +588,6 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, button_release_can_deselect = true; } else { - if (button_release_can_deselect) { /* just remove this one region, but only on a permitted button release */ @@ -514,14 +643,14 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, } else if (op == Selection::Extend) { list results; - nframes64_t last_frame; - nframes64_t first_frame; + framepos_t last_frame; + framepos_t first_frame; bool same_track = false; /* 1. find the last selected regionview in the track that was clicked in */ last_frame = 0; - first_frame = max_frames; + first_frame = max_framepos; for (RegionSelection::iterator x = selection->regions.begin(); x != selection->regions.end(); ++x) { if (&(*x)->get_time_axis_view() == &clicked_regionview->get_time_axis_view()) { @@ -589,8 +718,8 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, */ - first_frame = entered_regionview->region()->position(); - last_frame = entered_regionview->region()->last_frame(); + first_frame = clicked_regionview->region()->position(); + last_frame = clicked_regionview->region()->last_frame(); for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) { if ((*i)->region()->position() < first_frame) { @@ -612,7 +741,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, relevant_tracks.insert (r); } } - + set already_in_selection; if (relevant_tracks.empty()) { @@ -624,9 +753,9 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, any selected ones. */ - if (!selection->selected (entered_regionview)) { + if (!selection->selected (clicked_regionview)) { - RouteTimeAxisView* rtv = dynamic_cast (&entered_regionview->get_time_axis_view()); + RouteTimeAxisView* rtv = dynamic_cast (&clicked_regionview->get_time_axis_view()); if (rtv) { @@ -692,8 +821,8 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, */ if (find (already_in_selection.begin(), - already_in_selection.end(), - artv) == already_in_selection.end()) { + already_in_selection.end(), + artv) == already_in_selection.end()) { relevant_tracks.insert (artv); } @@ -706,7 +835,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, } /* 3. find all selectable objects (regionviews in this case) between that one and the end of the - one that was clicked. + one that was clicked. */ for (set::iterator t = relevant_tracks.begin(); t != relevant_tracks.end(); ++t) { @@ -731,7 +860,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, } } - out: +out: return commit; } @@ -802,7 +931,7 @@ Editor::set_selected_regionview_from_map_event (GdkEventAny* /*ev*/, StreamView* void Editor::track_selection_changed () { - switch (selection->tracks.size()){ + switch (selection->tracks.size()) { case 0: break; default: @@ -811,10 +940,22 @@ Editor::track_selection_changed () } for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { - if (find (selection->tracks.begin(), selection->tracks.end(), *i) != selection->tracks.end()) { - (*i)->set_selected (true); + + bool yn = (find (selection->tracks.begin(), selection->tracks.end(), *i) != selection->tracks.end()); + + (*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 && + ((mouse_mode == MouseRange) || + ((mouse_mode == MouseObject) && (_join_object_range_state == JOIN_OBJECT_RANGE_OBJECT)))) { + (*i)->reshow_selection (selection->time); } else { - (*i)->set_selected (false); + (*i)->hide_selection (); } } @@ -843,27 +984,258 @@ Editor::time_selection_changed () } } +/** Set all region actions to have a given sensitivity */ void -Editor::sensitize_the_right_region_actions (bool have_selected_regions) +Editor::sensitize_all_region_actions (bool s) { - for (vector >::iterator x = ActionManager::region_selection_sensitive_actions.begin(); - x != ActionManager::region_selection_sensitive_actions.end(); ++x) { + Glib::ListHandle > all = _region_actions->get_actions (); - string accel_path = (*x)->get_accel_path (); - AccelKey key; + for (Glib::ListHandle >::iterator i = all.begin(); i != all.end(); ++i) { + (*i)->set_sensitive (s); + } - /* if there is an accelerator, it should always be sensitive - to allow for keyboard ops on entered regions. - */ + _all_region_actions_sensitized = s; +} - bool known = ActionManager::lookup_entry (accel_path, key); +/** Sensitize region-based actions based on the selection ONLY, ignoring the entered_regionview. + * This method should be called just before displaying a Region menu. When a Region menu is not + * currently being shown, all region actions are sensitized so that hotkey-triggered actions + * on entered_regionviews work without having to check sensitivity every time the selection or + * entered_regionview changes. + * + * This method also sets up toggle action state as appropriate. + */ +void +Editor::sensitize_the_right_region_actions () +{ + if ((mouse_mode == MouseRange) || (mouse_mode != MouseObject && _join_object_range_state == JOIN_OBJECT_RANGE_RANGE)) { + sensitize_all_region_actions (false); + if (!selection->time.empty()) { + _region_actions->get_action("split-region")->set_sensitive (true); + } + return; + + } else if (mouse_mode != MouseObject) { + sensitize_all_region_actions (false); + return; + } + + /* We get here if we are in Object mode */ + + RegionSelection rs = get_regions_from_selection_and_entered (); + sensitize_all_region_actions (!rs.empty ()); + + _ignore_region_action = true; + + /* Look through the regions that are selected and make notes about what we have got */ + + bool have_audio = false; + bool have_multichannel_audio = false; + bool have_midi = false; + bool have_locked = false; + bool have_unlocked = false; + bool have_position_lock_style_audio = false; + bool have_position_lock_style_music = false; + bool have_muted = false; + bool have_unmuted = false; + bool have_opaque = false; + bool have_non_opaque = false; + bool have_not_at_natural_position = false; + bool have_envelope_visible = false; + bool have_envelope_invisible = false; + bool have_envelope_active = false; + bool have_envelope_inactive = false; + bool have_non_unity_scale_amplitude = false; + bool have_compound_regions = false; + + for (list::const_iterator i = rs.begin(); i != rs.end(); ++i) { + + boost::shared_ptr r = (*i)->region (); + boost::shared_ptr ar = boost::dynamic_pointer_cast (r); + + if (ar) { + have_audio = true; + if (ar->n_channels() > 1) { + have_multichannel_audio = true; + } + } - if (known && ((key.get_key() != GDK_VoidSymbol) && (key.get_key() != 0))) { - (*x)->set_sensitive (true); + if (boost::dynamic_pointer_cast (r)) { + have_midi = true; + } + + if (r->is_compound()) { + have_compound_regions = true; + } + + if (r->locked()) { + have_locked = true; + } else { + have_unlocked = true; + } + + if (r->position_lock_style() == MusicTime) { + have_position_lock_style_music = true; + } else { + have_position_lock_style_audio = true; + } + + if (r->muted()) { + have_muted = true; + } else { + have_unmuted = true; + } + + if (r->opaque()) { + have_opaque = true; + } else { + have_non_opaque = true; + } + + if (!r->at_natural_position()) { + have_not_at_natural_position = true; + } + + if (ar) { + /* its a bit unfortunate that "envelope visible" is a view-only + property. we have to find the regionview to able to check + its current setting. + */ + + have_envelope_invisible = false; + + if (*i) { + AudioRegionView* arv = dynamic_cast (*i); + if (arv) { + if (arv->envelope_visible()) { + have_envelope_visible = true; + } else { + have_envelope_invisible = true; + } + } + } + + if (ar->envelope_active()) { + have_envelope_active = true; + } else { + have_envelope_inactive = true; + } + + if (ar->scale_amplitude() != 1) { + have_non_unity_scale_amplitude = true; + } + } + } + + if (rs.size() > 1) { + _region_actions->get_action("show-region-list-editor")->set_sensitive (false); + _region_actions->get_action("show-region-properties")->set_sensitive (false); + _region_actions->get_action("rename-region")->set_sensitive (false); + if (have_audio) { + _region_actions->get_action("combine-regions")->set_sensitive (true); } else { - (*x)->set_sensitive (have_selected_regions); + _region_actions->get_action("combine-regions")->set_sensitive (false); } + } else if (rs.size() == 1) { + _region_actions->get_action("add-range-markers-from-region")->set_sensitive (false); + _region_actions->get_action("close-region-gaps")->set_sensitive (false); + _region_actions->get_action("combine-regions")->set_sensitive (false); } + + if (!have_multichannel_audio) { + _region_actions->get_action("split-multichannel-region")->set_sensitive (false); + } + + if (!have_midi) { + editor_actions->get_action("RegionMenuMIDI")->set_sensitive (false); + _region_actions->get_action("show-region-list-editor")->set_sensitive (false); + _region_actions->get_action("quantize-region")->set_sensitive (false); + _region_actions->get_action("fork-region")->set_sensitive (false); + _region_actions->get_action("insert-patch-change-context")->set_sensitive (false); + _region_actions->get_action("insert-patch-change")->set_sensitive (false); + _region_actions->get_action("transpose-region")->set_sensitive (false); + } else { + editor_actions->get_action("RegionMenuMIDI")->set_sensitive (true); + /* others were already marked sensitive */ + } + + if (_edit_point == EditAtMouse) { + _region_actions->get_action("set-region-sync-position")->set_sensitive (false); + _region_actions->get_action("trim-front")->set_sensitive (false); + _region_actions->get_action("trim-back")->set_sensitive (false); + _region_actions->get_action("split-region")->set_sensitive (false); + _region_actions->get_action("place-transient")->set_sensitive (false); + } + + if (have_compound_regions) { + _region_actions->get_action("uncombine-regions")->set_sensitive (true); + } else { + _region_actions->get_action("uncombine-regions")->set_sensitive (false); + } + + if (have_audio) { + + if (have_envelope_visible && !have_envelope_invisible) { + Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-gain-envelope-visible"))->set_active (); + } else if (have_envelope_visible && have_envelope_invisible) { + // _region_actions->get_action("toggle-region-gain-envelope-visible")->set_inconsistent (); + } + + if (have_envelope_active && !have_envelope_inactive) { + Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-gain-envelope-active"))->set_active (); + } else if (have_envelope_active && have_envelope_inactive) { + // _region_actions->get_action("toggle-region-gain-envelope-active")->set_inconsistent (); + } + + } else { + + _region_actions->get_action("analyze-region")->set_sensitive (false); + _region_actions->get_action("reset-region-gain-envelopes")->set_sensitive (false); + _region_actions->get_action("toggle-region-gain-envelope-visible")->set_sensitive (false); + _region_actions->get_action("toggle-region-gain-envelope-active")->set_sensitive (false); + _region_actions->get_action("pitch-shift-region")->set_sensitive (false); + + } + + if (!have_non_unity_scale_amplitude || !have_audio) { + _region_actions->get_action("reset-region-scale-amplitude")->set_sensitive (false); + } + + Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-lock"))->set_active (have_locked && !have_unlocked); + if (have_locked && have_unlocked) { + // _region_actions->get_action("toggle-region-lock")->set_inconsistent (); + } + + Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-lock-style"))->set_active (have_position_lock_style_music && !have_position_lock_style_audio); + + if (have_position_lock_style_music && have_position_lock_style_audio) { + // _region_actions->get_action("toggle-region-lock-style")->set_inconsistent (); + } + + Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-mute"))->set_active (have_muted && !have_unmuted); + if (have_muted && have_unmuted) { + // _region_actions->get_action("toggle-region-mute")->set_inconsistent (); + } + + Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-opaque-region"))->set_active (have_opaque && !have_non_opaque); + if (have_opaque && have_non_opaque) { + // _region_actions->get_action("toggle-opaque-region")->set_inconsistent (); + } + + if (!have_not_at_natural_position) { + _region_actions->get_action("naturalize-region")->set_sensitive (false); + } + + /* XXX: should also check that there is a track of the appropriate type for the selected region */ + if (_edit_point == EditAtMouse || _regions->get_single_selection() == 0 || selection->tracks.empty()) { + _region_actions->get_action("insert-region-from-region-list")->set_sensitive (false); + } else { + _region_actions->get_action("insert-region-from-region-list")->set_sensitive (true); + } + + _ignore_region_action = false; + + _all_region_actions_sensitized = false; } @@ -873,18 +1245,27 @@ Editor::region_selection_changed () _regions->block_change_connection (true); editor_regions_selection_changed_connection.block(true); - _regions->unselect_all (); + if (_region_selection_change_updates_region_list) { + _regions->unselect_all (); + } for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { (*i)->set_selected_regionviews (selection->regions); } - _regions->set_selected (selection->regions); - - sensitize_the_right_region_actions (!selection->regions.empty()); + if (_region_selection_change_updates_region_list) { + _regions->set_selected (selection->regions); + } _regions->block_change_connection (false); editor_regions_selection_changed_connection.block(false); + + if (!_all_region_actions_sensitized) { + /* This selection change might have changed what region actions + are allowed, so sensitize them all in case a key is pressed. + */ + sensitize_all_region_actions (true); + } } void @@ -904,7 +1285,7 @@ Editor::select_all_in_track (Selection::Operation op) return; } - clicked_routeview->get_selectables (0, max_frames, 0, DBL_MAX, touched); + clicked_routeview->get_selectables (0, max_framepos, 0, DBL_MAX, touched); switch (op) { case Selection::Toggle: @@ -922,16 +1303,32 @@ Editor::select_all_in_track (Selection::Operation op) } } +void +Editor::select_all_internal_edit (Selection::Operation) +{ + for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) { + MidiRegionView* mrv = dynamic_cast(*i); + if (mrv) { + mrv->select_all_notes (); + } + } +} + void Editor::select_all (Selection::Operation op) { list touched; + if (_internal_editing) { + select_all_internal_edit (op); + return; + } + for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) { if ((*iter)->hidden()) { continue; } - (*iter)->get_selectables (0, max_frames, 0, DBL_MAX, touched); + (*iter)->get_selectables (0, max_framepos, 0, DBL_MAX, touched); } begin_reversible_command (_("select all")); switch (op) { @@ -950,6 +1347,7 @@ Editor::select_all (Selection::Operation op) } commit_reversible_command (); } + void Editor::invert_selection_in_track () { @@ -968,6 +1366,16 @@ Editor::invert_selection () { list touched; + if (_internal_editing) { + for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) { + MidiRegionView* mrv = dynamic_cast(*i); + if (mrv) { + mrv->invert_selection (); + } + } + return; + } + for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) { if ((*iter)->hidden()) { continue; @@ -982,14 +1390,16 @@ Editor::invert_selection () * @param end End time in session frames. * @param top Top (lower) y limit in trackview coordinates (ie 0 at the top of the track view) * @param bottom Bottom (higher) y limit in trackview coordinates (ie 0 at the top of the track view) + * @param preserve_if_selected true to leave the current selection alone if we're adding to the selection and all of the selectables + * within the region are already selected. */ -bool -Editor::select_all_within (framepos_t start, framepos_t end, double top, double bot, const TrackViewList& tracklist, Selection::Operation op) +void +Editor::select_all_within (framepos_t start, framepos_t end, double top, double bot, const TrackViewList& tracklist, Selection::Operation op, bool preserve_if_selected) { list found; for (TrackViewList::const_iterator iter = tracklist.begin(); iter != tracklist.end(); ++iter) { - + if ((*iter)->hidden()) { continue; } @@ -998,7 +1408,18 @@ Editor::select_all_within (framepos_t start, framepos_t end, double top, double } if (found.empty()) { - return false; + return; + } + + if (preserve_if_selected && op != Selection::Toggle) { + list::iterator i = found.begin(); + while (i != found.end() && (*i)->get_selected()) { + ++i; + } + + if (i == found.end()) { + return; + } } begin_reversible_command (_("select all within")); @@ -1018,8 +1439,6 @@ Editor::select_all_within (framepos_t start, framepos_t end, double top, double } commit_reversible_command (); - - return !found.empty(); } void @@ -1079,8 +1498,8 @@ Editor::select_all_selectables_using_time_selection () return; } - nframes64_t start = selection->time[clicked_selection].start; - nframes64_t end = selection->time[clicked_selection].end; + framepos_t start = selection->time[clicked_selection].start; + framepos_t end = selection->time[clicked_selection].end; if (end - start < 1) { return; @@ -1172,17 +1591,15 @@ Editor::select_all_selectables_using_loop() void Editor::select_all_selectables_using_cursor (EditorCursor *cursor, bool after) { - nframes64_t start; - nframes64_t end; + framepos_t start; + framepos_t end; list touched; if (after) { - begin_reversible_command (_("select all after cursor")); - start = cursor->current_frame ; + start = cursor->current_frame; end = _session->current_end_frame(); } else { if (cursor->current_frame > 0) { - begin_reversible_command (_("select all before cursor")); start = 0; end = cursor->current_frame - 1; } else { @@ -1190,6 +1607,21 @@ Editor::select_all_selectables_using_cursor (EditorCursor *cursor, bool after) } } + if (_internal_editing) { + for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) { + MidiRegionView* mrv = dynamic_cast(*i); + if (mrv) { + mrv->select_range (start, end); + } + } + return; + } + + if (after) { + begin_reversible_command (_("select all after cursor")); + } else { + begin_reversible_command (_("select all before cursor")); + } TrackViewList* ts; @@ -1212,17 +1644,15 @@ Editor::select_all_selectables_using_cursor (EditorCursor *cursor, bool after) void Editor::select_all_selectables_using_edit (bool after) { - nframes64_t start; - nframes64_t end; + framepos_t start; + framepos_t end; list touched; if (after) { - begin_reversible_command (_("select all after edit")); start = get_preferred_edit_position(); end = _session->current_end_frame(); } else { if ((end = get_preferred_edit_position()) > 1) { - begin_reversible_command (_("select all before edit")); start = 0; end -= 1; } else { @@ -1230,6 +1660,19 @@ Editor::select_all_selectables_using_edit (bool after) } } + if (_internal_editing) { + for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) { + MidiRegionView* mrv = dynamic_cast(*i); + mrv->select_range (start, end); + } + return; + } + + if (after) { + begin_reversible_command (_("select all after edit")); + } else { + begin_reversible_command (_("select all before edit")); + } TrackViewList* ts; @@ -1252,14 +1695,22 @@ Editor::select_all_selectables_using_edit (bool after) void Editor::select_all_selectables_between (bool /*within*/) { - nframes64_t start; - nframes64_t end; + framepos_t start; + framepos_t end; list touched; if (!get_edit_op_range (start, end)) { return; } + if (_internal_editing) { + for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) { + MidiRegionView* mrv = dynamic_cast(*i); + mrv->select_range (start, end); + } + return; + } + TrackViewList* ts; if (selection->tracks.empty()) { @@ -1281,8 +1732,12 @@ Editor::select_all_selectables_between (bool /*within*/) void Editor::select_range_between () { - nframes64_t start; - nframes64_t end; + framepos_t start; + framepos_t end; + + if (mouse_mode == MouseRange && !selection->time.empty()) { + selection->clear_time (); + } if (!get_edit_op_range (start, end)) { return; @@ -1293,9 +1748,9 @@ Editor::select_range_between () } bool -Editor::get_edit_op_range (nframes64_t& start, nframes64_t& end) const +Editor::get_edit_op_range (framepos_t& start, framepos_t& end) const { - nframes64_t m; + framepos_t m; bool ignored; /* in range mode, use any existing selection */ @@ -1310,7 +1765,7 @@ Editor::get_edit_op_range (nframes64_t& start, nframes64_t& end) const if (!mouse_frame (m, ignored)) { /* mouse is not in a canvas, try playhead+selected marker. this is probably most true when using menus. - */ + */ if (selection->markers.empty()) { return false; @@ -1350,9 +1805,9 @@ Editor::get_edit_op_range (nframes64_t& start, nframes64_t& end) const if (selection->markers.empty()) { MessageDialog win (_("No edit range defined"), - false, - MESSAGE_INFO, - BUTTONS_OK); + false, + MESSAGE_INFO, + BUTTONS_OK); win.set_secondary_text ( _("the edit point is Selected Marker\nbut there is no selected marker.")); @@ -1399,9 +1854,9 @@ long Editor::select_range_around_region (RegionView* rv) { assert (rv); - + selection->set (&rv->get_time_axis_view()); - + selection->time.clear (); boost::shared_ptr r = rv->region (); return selection->set (r->position(), r->position() + r->length());