X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_selection.cc;h=b5a0be1c7869aa3e19c71a5a83c8ef282ac08bdb;hb=24df2b559464f981e2c6a91719e3cfe2a76a197c;hp=c598116bade542f3d6acf01f20d831cd7d62062e;hpb=782c9383fc95533a358510292ad06267c66c5af4;p=ardour.git diff --git a/gtk2_ardour/editor_selection.cc b/gtk2_ardour/editor_selection.cc index c598116bad..b5a0be1c78 100644 --- a/gtk2_ardour/editor_selection.cc +++ b/gtk2_ardour/editor_selection.cc @@ -21,14 +21,20 @@ #include #include "pbd/stacktrace.h" +#include "pbd/unwind.h" -#include "ardour/session.h" +#include "ardour/control_protocol_manager.h" +#include "ardour/midi_region.h" #include "ardour/playlist.h" -#include "ardour/route_group.h" #include "ardour/profile.h" -#include "ardour/midi_region.h" +#include "ardour/route_group.h" +#include "ardour/selection.h" +#include "ardour/session.h" +#include "ardour/vca.h" #include "editor.h" +#include "editor_drag.h" +#include "editor_routes.h" #include "actions.h" #include "audio_time_axis.h" #include "audio_region_view.h" @@ -38,8 +44,9 @@ #include "editor_regions.h" #include "editor_cursors.h" #include "midi_region_view.h" +#include "sfdb_ui.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace std; using namespace ARDOUR; @@ -84,10 +91,6 @@ Editor::extend_selection_to_track (TimeAxisView& view) sorted.sort (cmp); - if (!selection->selected (&view)) { - to_be_added.push_back (&view); - } - /* figure out if we should go forward or backwards */ for (TrackViewList::iterator i = sorted.begin(); i != sorted.end(); ++i) { @@ -153,6 +156,10 @@ Editor::extend_selection_to_track (TimeAxisView& view) } } + if (!selection->selected (&view)) { + to_be_added.push_back (&view); + } + if (!to_be_added.empty()) { selection->add (to_be_added); return true; @@ -170,6 +177,7 @@ Editor::select_all_tracks () visible_views.push_back (*i); } } + PBD::Unwinder uw (_track_selection_change_without_scroll, true); selection->set (visible_views); } @@ -177,45 +185,35 @@ Editor::select_all_tracks () * tracks, in which case nothing will happen unless `force' is true. */ void -Editor::set_selected_track_as_side_effect (Selection::Operation op, bool /*force*/) +Editor::set_selected_track_as_side_effect (Selection::Operation op) { if (!clicked_axisview) { return; } -#if 1 - if (!clicked_routeview) { - return; + RouteGroup* group = NULL; + if (clicked_routeview) { + group = clicked_routeview->route()->route_group(); } - 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()) { + if (group && group->is_active()) { for (TrackViewList::iterator i = track_views.begin(); i != track_views.end (); ++i) { - if ((*i)->route_group() == group) + if ((*i)->route_group() == group) { selection->remove(*i); + } } } else { selection->remove (clicked_axisview); } } else { - if (arg.is_select() && arg.is_active()) { + if (group && group->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) + if ((*i)->route_group() == group) { selection->add(*i); + } } } else { selection->add (clicked_axisview); @@ -224,17 +222,11 @@ Editor::set_selected_track_as_side_effect (Selection::Operation op, bool /*force 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()) { + if (group && group->is_active()) { for (TrackViewList::iterator i = track_views.begin(); i != track_views.end (); ++i) { - if ((*i)->route_group() == group) + if ((*i)->route_group() == group) { selection->add(*i); + } } } else { selection->add (clicked_axisview); @@ -243,17 +235,11 @@ Editor::set_selected_track_as_side_effect (Selection::Operation op, bool /*force 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()) { + if (group && group->is_active()) { for (TrackViewList::iterator i = track_views.begin(); i != track_views.end (); ++i) { - if ((*i)->route_group() == group) + if ((*i)->route_group() == group) { selection->add(*i); + } } } else { selection->set (clicked_axisview); @@ -262,26 +248,15 @@ Editor::set_selected_track_as_side_effect (Selection::Operation op, bool /*force 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); - } - - } else if (force) { - selection->set (clicked_axisview); - } -#endif } void Editor::set_selected_track (TimeAxisView& view, Selection::Operation op, bool no_remove) { + begin_reversible_selection_op (X_("Set Selected Track")); + switch (op) { case Selection::Toggle: if (selection->selected (&view)) { @@ -294,9 +269,7 @@ Editor::set_selected_track (TimeAxisView& view, Selection::Operation op, bool no break; case Selection::Add: - if (!selection->selected (&view)) { - selection->add (&view); - } + selection->add (&view); break; case Selection::Set: @@ -307,6 +280,8 @@ Editor::set_selected_track (TimeAxisView& view, Selection::Operation op, bool no extend_selection_to_track (view); break; } + + commit_reversible_selection_op (); } void @@ -324,35 +299,77 @@ Editor::set_selected_track_from_click (bool press, Selection::Operation op, bool } bool -Editor::set_selected_control_point_from_click (Selection::Operation op, bool /*no_remove*/) +Editor::set_selected_control_point_from_click (bool press, Selection::Operation op) { if (!clicked_control_point) { return false; } + bool ret = false; + switch (op) { case Selection::Set: - selection->set (clicked_control_point); + if (!selection->selected (clicked_control_point)) { + selection->set (clicked_control_point); + ret = true; + } else { + /* clicked on an already selected point */ + if (press) { + break; + } else { + if (selection->points.size() > 1) { + selection->set (clicked_control_point); + ret = true; + } + } + } break; + case Selection::Add: - selection->add (clicked_control_point); + if (press) { + selection->add (clicked_control_point); + ret = true; + } break; case Selection::Toggle: - selection->toggle (clicked_control_point); + + /* This is a bit of a hack; if we Primary-Click-Drag a control + point (for push drag) we want the point we clicked on to be + selected, otherwise we end up confusingly dragging an + unselected point. So here we ensure that the point is selected + after the press, and if we subsequently get a release (meaning no + drag occurred) we set things up so that the toggle has happened. + */ + if (press && !selection->selected (clicked_control_point)) { + /* This is the button press, and the control point is not selected; make it so, + in case this press leads to a drag. Also note that having done this, we don't + need to toggle again on release. + */ + selection->toggle (clicked_control_point); + _control_point_toggled_on_press = true; + ret = true; + } else if (!press && !_control_point_toggled_on_press) { + /* This is the release, and the point wasn't toggled on the press, so do it now */ + selection->toggle (clicked_control_point); + ret = true; + } else { + /* Reset our flag */ + _control_point_toggled_on_press = false; + } break; case Selection::Extend: /* XXX */ break; } - return true; + return ret; } 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) { + if ((*i)->y_position() < _visible_canvas_height) { tvl.push_back (*i); } } @@ -401,6 +418,63 @@ Editor::mapover_tracks (sigc::slot sl, TimeA } } +/** 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); + } +} + void Editor::mapped_get_equivalent_regions (RouteTimeAxisView& tv, uint32_t, RegionView * basis, vector* all_equivs) const { @@ -433,7 +507,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_time_axis_view(), 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 */ @@ -449,7 +523,7 @@ 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_time_axis_view(), prop); @@ -463,7 +537,6 @@ Editor::get_equivalent_regions (RegionSelection & basis, PBD::PropertyID prop) c return equivalent; } - int Editor::get_regionview_count_from_region_list (boost::shared_ptr region) { @@ -503,7 +576,7 @@ Editor::get_regionview_count_from_region_list (boost::shared_ptr region) bool -Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, bool /*no_track_remove*/) +Editor::set_selected_regionview_from_click (bool press, Selection::Operation op) { vector all_equivalent_regions; bool commit = false; @@ -518,7 +591,6 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, if (op == Selection::Toggle || op == Selection::Set) { - switch (op) { case Selection::Toggle: if (selection->selected (clicked_regionview)) { @@ -551,7 +623,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, if (press) { if (selection->selected (clicked_routeview)) { - get_equivalent_regions (clicked_regionview, all_equivalent_regions, ARDOUR::Properties::select.property_id); + get_equivalent_regions (clicked_regionview, all_equivalent_regions, ARDOUR::Properties::group_select.property_id); } else { all_equivalent_regions.push_back (clicked_regionview); } @@ -569,12 +641,21 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, case Selection::Set: if (!selection->selected (clicked_regionview)) { - get_equivalent_regions (clicked_regionview, all_equivalent_regions, ARDOUR::Properties::select.property_id); + get_equivalent_regions (clicked_regionview, all_equivalent_regions, ARDOUR::Properties::group_select.property_id); selection->set (all_equivalent_regions); commit = true; } else { - /* no commit necessary: clicked on an already selected region */ - goto out; + /* clicked on an already selected region */ + if (press) + goto out; + else { + if (selection->regions.size() > 1) { + /* collapse region selection down to just this one region (and its equivalents) */ + get_equivalent_regions(clicked_regionview, all_equivalent_regions, ARDOUR::Properties::group_select.property_id); + selection->set(all_equivalent_regions); + commit = true; + } + } } break; @@ -615,7 +696,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, /* 2. figure out the boundaries for our search for new objects */ switch (clicked_regionview->region()->coverage (first_frame, last_frame)) { - case OverlapNone: + case Evoral::OverlapNone: if (last_frame < clicked_regionview->region()->first_frame()) { first_frame = last_frame; last_frame = clicked_regionview->region()->last_frame(); @@ -625,7 +706,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, } break; - case OverlapExternal: + case Evoral::OverlapExternal: if (last_frame < clicked_regionview->region()->first_frame()) { first_frame = last_frame; last_frame = clicked_regionview->region()->last_frame(); @@ -635,7 +716,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, } break; - case OverlapInternal: + case Evoral::OverlapInternal: if (last_frame < clicked_regionview->region()->first_frame()) { first_frame = last_frame; last_frame = clicked_regionview->region()->last_frame(); @@ -645,8 +726,8 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, } break; - case OverlapStart: - case OverlapEnd: + case Evoral::OverlapStart: + case Evoral::OverlapEnd: /* nothing to do except add clicked region to selection, since it overlaps with the existing selection in this track. */ @@ -712,7 +793,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, RouteTimeAxisView* closest = 0; int distance = INT_MAX; - int key = rtv->route()->order_key ("editor"); + int key = rtv->route()->presentation_info().order (); for (RegionSelection::iterator x = selection->regions.begin(); x != selection->regions.end(); ++x) { @@ -727,7 +808,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, if (result.second) { /* newly added to already_in_selection */ - int d = artv->route()->order_key ("editor"); + int d = artv->route()->presentation_info().order (); d -= key; @@ -743,7 +824,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, /* now add all tracks between that one and this one */ - int okey = closest->route()->order_key ("editor"); + int okey = closest->route()->presentation_info().order (); if (okey > key) { swap (okey, key); @@ -753,7 +834,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, RouteTimeAxisView* artv = dynamic_cast(*x); if (artv && artv != rtv) { - int k = artv->route()->order_key ("editor"); + int k = artv->route()->presentation_info().order (); if (k >= okey && k <= key) { @@ -800,26 +881,55 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, if (!regions.empty()) { selection->add (regions); commit = true; + } else if (selection->regions.empty() && !selection->selected (clicked_regionview)) { + /* ensure that at least the clicked regionview is selected. */ + selection->set (clicked_regionview); + commit = true; } + } out: return commit; } +void +Editor::set_selection (std::list s, Selection::Operation op) +{ + if (s.empty()) { + return; + } + begin_reversible_selection_op (X_("set selection")); + switch (op) { + case Selection::Toggle: + selection->toggle (s); + break; + case Selection::Set: + selection->set (s); + break; + case Selection::Extend: + selection->add (s); + break; + case Selection::Add: + selection->add (s); + break; + } + + commit_reversible_selection_op () ; +} void Editor::set_selected_regionview_from_region_list (boost::shared_ptr region, Selection::Operation op) { vector all_equivalent_regions; - get_regions_corresponding_to (region, all_equivalent_regions); + get_regions_corresponding_to (region, all_equivalent_regions, region->whole_file()); if (all_equivalent_regions.empty()) { return; } - begin_reversible_command (_("set selected regions")); + begin_reversible_selection_op (X_("set selected regions")); switch (op) { case Selection::Toggle: @@ -837,7 +947,7 @@ Editor::set_selected_regionview_from_region_list (boost::shared_ptr regi break; } - commit_reversible_command () ; + commit_reversible_selection_op () ; } bool @@ -862,55 +972,198 @@ Editor::set_selected_regionview_from_map_event (GdkEventAny* /*ev*/, StreamView* return true; } - begin_reversible_command (_("set selected regions")); + begin_reversible_selection_op (X_("set selected regions")); selection->set (rv); - commit_reversible_command () ; + commit_reversible_selection_op () ; return true; } +struct SelectionOrderSorter { + bool operator() (TimeAxisView const * const a, TimeAxisView const * const b) const { + boost::shared_ptr sa = a->stripable (); + boost::shared_ptr sb = b->stripable (); + if (!sa && !sb) { + return a < b; + } + if (!sa) { + return false; + } + if (!sb) { + return true; + } + return sa->presentation_info().selection_cnt() < sb->presentation_info().selection_cnt(); + } +}; + void -Editor::track_selection_changed () +Editor::presentation_info_changed (PropertyChange const & what_changed) { - switch (selection->tracks.size()) { - case 0: - break; - default: - set_selected_mixer_strip (*(selection->tracks.front())); - break; + uint32_t n_tracks = 0; + uint32_t n_busses = 0; + uint32_t n_vcas = 0; + uint32_t n_routes = 0; + uint32_t n_stripables = 0; + + /* We cannot ensure ordering of the handlers for + * PresentationInfo::Changed, so we have to do everything in order + * here, as a single handler. + */ + + if (what_changed.contains (Properties::selected)) { + for (TrackViewList::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) { + (*i)->set_selected (false); + (*i)->hide_selection (); + } } - for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { + /* STEP 1: set the GUI selection state (in which TimeAxisViews for the + * currently selected stripable/controllable duples are found and added + */ + + 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); + if (what_changed.contains (Properties::selected)) { - 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()); + 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; } - if (yn && - ((mouse_mode == MouseRange) || - ((mouse_mode == MouseObject) && (_join_object_range_state == JOIN_OBJECT_RANGE_OBJECT)))) { - (*i)->reshow_selection (selection->time); - } else { - (*i)->hide_selection (); + CoreSelection::StripableAutomationControls sc; + _session->selection().get_stripables (sc); + + for (CoreSelection::StripableAutomationControls::const_iterator i = sc.begin(); i != sc.end(); ++i) { + + AxisView* av = axis_view_by_stripable ((*i).stripable); + + if (!av) { + continue; + } + + n_stripables++; + + if (boost::dynamic_pointer_cast ((*i).stripable)) { + n_tracks++; + n_routes++; + } else if (boost::dynamic_pointer_cast ((*i).stripable)) { + n_busses++; + n_routes++; + } else if (boost::dynamic_pointer_cast ((*i).stripable)) { + n_vcas++; + } + + TimeAxisView* tav = dynamic_cast (av); + + if (!tav) { + assert (0); + continue; /* impossible */ + } + + if (!(*i).controllable) { + + /* "parent" track selected */ + tav->set_selected (true); + tav->reshow_selection (selection->time); + + } else { + + /* possibly a child */ + + TimeAxisView::Children c = tav->get_child_list (); + + for (TimeAxisView::Children::iterator j = c.begin(); j != c.end(); ++j) { + + boost::shared_ptr 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::stripable_selection_sensitive_actions, (n_stripables > 0)); + ActionManager::set_sensitive (ActionManager::track_selection_sensitive_actions, (n_tracks > 0)); + ActionManager::set_sensitive (ActionManager::bus_selection_sensitive_actions, (n_busses > 0)); + ActionManager::set_sensitive (ActionManager::route_selection_sensitive_actions, (n_routes > 0)); + ActionManager::set_sensitive (ActionManager::vca_selection_sensitive_actions, (n_vcas > 0)); + + sensitize_the_right_region_actions (false); + + /* STEP 4: notify control protocols */ + + ControlProtocolManager::instance().stripable_selection_changed (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(*x); + + if (atv) { + if (atv->is_audio_track()) { + audio_track_cnt++; + } + + } else { + MidiTimeAxisView* mtv = dynamic_cast(*x); + + if (mtv) { + if (mtv->is_midi_track()) { + midi_track_cnt++; + } + } + } + } + + sfbrowser->reset (audio_track_cnt, midi_track_cnt); } } - ActionManager::set_sensitive (ActionManager::track_selection_sensitive_actions, !selection->tracks.empty()); + /* 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); + } } void Editor::time_selection_changed () { - if (Profile->get_sae()) { - return; - } + /* XXX this is superficially inefficient. Hide the selection in all + * tracks, then show it in all selected tracks. + * + * However, if you investigate what this actually does, it isn't + * anywhere nearly as bad as it may appear. Remember: nothing is + * redrawn or even recomputed during these two loops - that only + * happens when we next render ... + */ for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { (*i)->hide_selection (); @@ -925,6 +1178,19 @@ Editor::time_selection_changed () } else { ActionManager::set_sensitive (ActionManager::time_selection_sensitive_actions, true); } + + /* propagate into backend, but only when there is no drag or we are at + * the end of a drag, otherwise this is too expensive (could case a + * locate per mouse motion event. + */ + + if (_session && !_drags->active()) { + if (selection->time.length() != 0) { + _session->set_range_selection (selection->time.start(), selection->time.end_frame()); + } else { + _session->clear_range_selection (); + } + } } /** Set all region actions to have a given sensitivity */ @@ -940,42 +1206,96 @@ Editor::sensitize_all_region_actions (bool s) _all_region_actions_sensitized = s; } -/** 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. +/** Sensitize region-based actions. * - * This method also sets up toggle action state as appropriate. + * This method is called from whenever we leave the canvas, either by moving + * the pointer out of it, or by popping up a context menu. See + * Editor::{entered,left}_track_canvas() for details there. */ void -Editor::sensitize_the_right_region_actions () +Editor::sensitize_the_right_region_actions (bool because_canvas_crossing) { - 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; + bool have_selection = false; + bool have_entered = false; + bool have_edit_point = false; + RegionSelection rs; - } else if (mouse_mode != MouseObject) { - sensitize_all_region_actions (false); - return; + // std::cerr << "STRRA: crossing ? " << because_canvas_crossing << " within ? " << within_track_canvas + // << std::endl; + + if (!selection->regions.empty()) { + have_selection = true; + rs = selection->regions; + } + + if (entered_regionview) { + have_entered = true; + rs.add (entered_regionview); + } + + if (rs.empty() && !selection->tracks.empty()) { + + /* no selected regions, but some selected tracks. + */ + + if (_edit_point == EditAtMouse) { + if (!within_track_canvas) { + /* pointer is not in canvas, so edit point is meaningless */ + have_edit_point = false; + } else { + /* inside canvas. we don't know where the edit + point will be when an action is invoked, but + assume it could intersect with a region. + */ + have_edit_point = true; + } + } else { + RegionSelection at_edit_point; + framepos_t const where = get_preferred_edit_position (Editing::EDIT_IGNORE_NONE, false, !within_track_canvas); + get_regions_at (at_edit_point, where, selection->tracks); + if (!at_edit_point.empty()) { + have_edit_point = true; + } + if (rs.empty()) { + rs.insert (rs.end(), at_edit_point.begin(), at_edit_point.end()); + } + } } - /* We get here if we are in Object mode */ + //std::cerr << "\tfinal have selection: " << have_selection + // << " have entered " << have_entered + // << " have edit point " << have_edit_point + // << " EP = " << enum_2_string (_edit_point) + // << std::endl; - RegionSelection rs = get_regions_from_selection_and_entered (); - sensitize_all_region_actions (!rs.empty ()); + typedef std::map RegionActionMap; _ignore_region_action = true; + for (RegionActionMap::iterator x = region_action_map.begin(); x != region_action_map.end(); ++x) { + RegionActionTarget tgt = x->second.target; + bool sensitive = false; + + if ((tgt & SelectedRegions) && have_selection) { + sensitive = true; + } else if ((tgt & EnteredRegions) && have_entered) { + sensitive = true; + } else if ((tgt & EditPointRegions) && have_edit_point) { + sensitive = true; + } + + x->second.action->set_sensitive (sensitive); + } + /* 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_video_locked = false; + bool have_video_unlocked = false; bool have_position_lock_style_audio = false; bool have_position_lock_style_music = false; bool have_muted = false; @@ -983,12 +1303,15 @@ Editor::sensitize_the_right_region_actions () 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; + bool have_inactive_fade_in = false; + bool have_inactive_fade_out = false; + bool have_active_fade_in = false; + bool have_active_fade_out = false; + bool have_transients = false; for (list::const_iterator i = rs.begin(); i != rs.end(); ++i) { @@ -997,6 +1320,9 @@ Editor::sensitize_the_right_region_actions () if (ar) { have_audio = true; + if (ar->n_channels() > 1) { + have_multichannel_audio = true; + } } if (boost::dynamic_pointer_cast (r)) { @@ -1013,6 +1339,12 @@ Editor::sensitize_the_right_region_actions () have_unlocked = true; } + if (r->video_locked()) { + have_video_locked = true; + } else { + have_video_unlocked = true; + } + if (r->position_lock_style() == MusicTime) { have_position_lock_style_music = true; } else { @@ -1035,21 +1367,11 @@ Editor::sensitize_the_right_region_actions () 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 = true; - - if (*i) { - AudioRegionView* arv = dynamic_cast (*i); - if (arv && arv->envelope_visible()) { - have_envelope_visible = true; - } - } + if (r->has_transients ()){ + have_transients = true; + } + if (ar) { if (ar->envelope_active()) { have_envelope_active = true; } else { @@ -1059,14 +1381,31 @@ Editor::sensitize_the_right_region_actions () if (ar->scale_amplitude() != 1) { have_non_unity_scale_amplitude = true; } + + if (ar->fade_in_active ()) { + have_active_fade_in = true; + } else { + have_inactive_fade_in = true; + } + + if (ar->fade_out_active ()) { + have_active_fade_out = true; + } else { + have_inactive_fade_out = true; + } } } + _region_actions->get_action("split-region-at-transients")->set_sensitive (have_transients); + 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) { + /* XXX need to check whether there is than 1 per + playlist, because otherwise this makes no sense. + */ _region_actions->get_action("combine-regions")->set_sensitive (true); } else { _region_actions->get_action("combine-regions")->set_sensitive (false); @@ -1077,20 +1416,27 @@ Editor::sensitize_the_right_region_actions () _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_menu_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("legatize-region")->set_sensitive (false); + _region_actions->get_action("remove-overlap")->set_sensitive (false); + _region_actions->get_action("transform-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_menu_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); - } + /* ok, moving along... */ if (have_compound_regions) { _region_actions->get_action("uncombine-regions")->set_sensitive (true); @@ -1100,25 +1446,21 @@ Editor::sensitize_the_right_region_actions () 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 (); + // Glib::RefPtr::cast_dynamic (_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("loudness-analyze-region")->set_sensitive (false); + _region_actions->get_action("spectral-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); + _region_actions->get_action("strip-region-silence")->set_sensitive (false); + _region_actions->get_action("show-rhythm-ferret")->set_sensitive (false); } @@ -1126,25 +1468,39 @@ Editor::sensitize_the_right_region_actions () _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); + Glib::RefPtr a = Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-lock")); + a->set_active (have_locked && !have_unlocked); if (have_locked && have_unlocked) { - // _region_actions->get_action("toggle-region-lock")->set_inconsistent (); + // a->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); + a = Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-video-lock")); + a->set_active (have_video_locked && !have_video_unlocked); + if (have_video_locked && have_video_unlocked) { + // a->set_inconsistent (); + } - if (have_position_lock_style_music && have_position_lock_style_audio) { - // _region_actions->get_action("toggle-region-lock-style")->set_inconsistent (); + a = Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-lock-style")); + a->set_active (have_position_lock_style_music && !have_position_lock_style_audio); + + vector proxies = a->get_proxies(); + for (vector::iterator p = proxies.begin(); p != proxies.end(); ++p) { + Gtk::CheckMenuItem* cmi = dynamic_cast (*p); + if (cmi) { + cmi->set_inconsistent (have_position_lock_style_music && have_position_lock_style_audio); + } } - Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-mute"))->set_active (have_muted && !have_unmuted); + a = Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-mute")); + a->set_active (have_muted && !have_unmuted); if (have_muted && have_unmuted) { - // _region_actions->get_action("toggle-region-mute")->set_inconsistent (); + // a->set_inconsistent (); } - Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-opaque-region"))->set_active (have_opaque && !have_non_opaque); + a = Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-opaque-region")); + a->set_active (have_opaque && !have_non_opaque); if (have_opaque && have_non_opaque) { - // _region_actions->get_action("toggle-opaque-region")->set_inconsistent (); + // a->set_inconsistent (); } if (!have_not_at_natural_position) { @@ -1158,12 +1514,34 @@ Editor::sensitize_the_right_region_actions () _region_actions->get_action("insert-region-from-region-list")->set_sensitive (true); } + a = Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-fade-in")); + a->set_active (have_active_fade_in && !have_inactive_fade_in); + if (have_active_fade_in && have_inactive_fade_in) { + // a->set_inconsistent (); + } + + a = Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-fade-out")); + a->set_active (have_active_fade_out && !have_inactive_fade_out); + + if (have_active_fade_out && have_inactive_fade_out) { + // a->set_inconsistent (); + } + + bool const have_active_fade = have_active_fade_in || have_active_fade_out; + bool const have_inactive_fade = have_inactive_fade_in || have_inactive_fade_out; + + a = Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-fades")); + a->set_active (have_active_fade && !have_inactive_fade); + + if (have_active_fade && have_inactive_fade) { + // a->set_inconsistent (); + } + _ignore_region_action = false; _all_region_actions_sensitized = false; } - void Editor::region_selection_changed () { @@ -1185,12 +1563,18 @@ Editor::region_selection_changed () _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); + sensitize_the_right_region_actions (false); + + /* propagate into backend */ + + if (_session) { + if (!selection->regions.empty()) { + _session->set_object_selection (selection->regions.start(), selection->regions.end_frame()); + } else { + _session->clear_object_selection (); + } } + } void @@ -1210,6 +1594,8 @@ Editor::select_all_in_track (Selection::Operation op) return; } + begin_reversible_selection_op (X_("Select All in Track")); + clicked_routeview->get_selectables (0, max_framepos, 0, DBL_MAX, touched); switch (op) { @@ -1226,42 +1612,63 @@ Editor::select_all_in_track (Selection::Operation op) selection->add (touched); break; } + + commit_reversible_selection_op (); } -void +bool Editor::select_all_internal_edit (Selection::Operation) { + bool selected = false; + for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) { MidiRegionView* mrv = dynamic_cast(*i); if (mrv) { mrv->select_all_notes (); + selected = true; } } + + MidiRegionView* mrv = dynamic_cast(entered_regionview); + if (mrv) { + mrv->select_all_notes (); + selected = true; + } + + return selected; } void -Editor::select_all (Selection::Operation op) +Editor::select_all_objects (Selection::Operation op) { list touched; - if (_internal_editing) { - select_all_internal_edit (op); - return; + if (internal_editing() && select_all_internal_edit(op)) { + return; // Selected notes } - for (TrackViewList::iterator iter = track_views.begin(); iter != track_views.end(); ++iter) { + TrackViewList ts; + + if (selection->tracks.empty()) { + ts = track_views; + } else { + ts = selection->tracks; + } + + for (TrackViewList::iterator iter = ts.begin(); iter != ts.end(); ++iter) { if ((*iter)->hidden()) { continue; } (*iter)->get_selectables (0, max_framepos, 0, DBL_MAX, touched); } - begin_reversible_command (_("select all")); + + begin_reversible_selection_op (X_("select all")); switch (op) { case Selection::Add: selection->add (touched); break; case Selection::Toggle: - selection->add (touched); + selection->toggle (touched); break; case Selection::Set: selection->set (touched); @@ -1270,7 +1677,7 @@ Editor::select_all (Selection::Operation op) /* meaningless, because we're selecting everything */ break; } - commit_reversible_command (); + commit_reversible_selection_op (); } void @@ -1282,8 +1689,10 @@ Editor::invert_selection_in_track () return; } + begin_reversible_selection_op (X_("Invert Selection in Track")); clicked_routeview->get_inverted_selectables (*selection, touched); selection->set (touched); + commit_reversible_selection_op (); } void @@ -1291,7 +1700,7 @@ Editor::invert_selection () { list touched; - if (_internal_editing) { + if (internal_editing()) { for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) { MidiRegionView* mrv = dynamic_cast(*i); if (mrv) { @@ -1308,7 +1717,9 @@ Editor::invert_selection () (*iter)->get_inverted_selectables (*selection, touched); } + begin_reversible_selection_op (X_("Invert Selection")); selection->set (touched); + commit_reversible_selection_op (); } /** @param start Start time in session frames. @@ -1333,12 +1744,14 @@ Editor::select_all_within (framepos_t start, framepos_t end, double top, double } if (found.empty()) { + selection->clear_objects(); + selection->clear_time (); return; } if (preserve_if_selected && op != Selection::Toggle) { list::iterator i = found.begin(); - while (i != found.end() && (*i)->get_selected()) { + while (i != found.end() && (*i)->selected()) { ++i; } @@ -1347,7 +1760,7 @@ Editor::select_all_within (framepos_t start, framepos_t end, double top, double } } - begin_reversible_command (_("select all within")); + begin_reversible_selection_op (X_("select all within")); switch (op) { case Selection::Add: selection->add (found); @@ -1363,7 +1776,7 @@ Editor::select_all_within (framepos_t start, framepos_t end, double top, double break; } - commit_reversible_command (); + commit_reversible_selection_op (); } void @@ -1373,8 +1786,26 @@ Editor::set_selection_from_region () return; } + /* find all the tracks that have selected regions */ + + set tracks; + + for (RegionSelection::const_iterator r = selection->regions.begin(); r != selection->regions.end(); ++r) { + tracks.insert (&(*r)->get_time_axis_view()); + } + + TrackViewList tvl; + tvl.insert (tvl.end(), tracks.begin(), tracks.end()); + + /* select range (this will clear the region selection) */ + selection->set (selection->regions.start(), selection->regions.end_frame()); - if (!Profile->get_sae()) { + + /* and select the tracks */ + + selection->set (tvl); + + if (!get_smart_mode () || !mouse_mode == Editing::MouseObject) { set_mouse_mode (Editing::MouseRange, false); } } @@ -1405,12 +1836,12 @@ Editor::set_selection_from_loop() void Editor::set_selection_from_range (Location& loc) { - begin_reversible_command (_("set selection from range")); + begin_reversible_selection_op (X_("set selection from range")); selection->set (loc.start(), loc.end()); - commit_reversible_command (); + commit_reversible_selection_op (); - if (!Profile->get_sae()) { - set_mouse_mode (Editing::MouseRange, false); + if (!get_smart_mode () || mouse_mode != Editing::MouseObject) { + set_mouse_mode (MouseRange, false); } } @@ -1445,9 +1876,9 @@ Editor::select_all_selectables_using_time_selection () (*iter)->get_selectables (start, end - 1, 0, DBL_MAX, touched); } - begin_reversible_command (_("select all from range")); + begin_reversible_selection_op (X_("select all from range")); selection->set (touched); - commit_reversible_command (); + commit_reversible_selection_op (); } @@ -1476,9 +1907,9 @@ Editor::select_all_selectables_using_punch() } (*iter)->get_selectables (location->start(), location->end() - 1, 0, DBL_MAX, touched); } - begin_reversible_command (_("select all from punch")); + begin_reversible_selection_op (X_("select all from punch")); selection->set (touched); - commit_reversible_command (); + commit_reversible_selection_op (); } @@ -1507,9 +1938,9 @@ Editor::select_all_selectables_using_loop() } (*iter)->get_selectables (location->start(), location->end() - 1, 0, DBL_MAX, touched); } - begin_reversible_command (_("select all from loop")); + begin_reversible_selection_op (X_("select all from loop")); selection->set (touched); - commit_reversible_command (); + commit_reversible_selection_op (); } @@ -1521,18 +1952,18 @@ Editor::select_all_selectables_using_cursor (EditorCursor *cursor, bool after) list touched; if (after) { - start = cursor->current_frame; + start = cursor->current_frame(); end = _session->current_end_frame(); } else { - if (cursor->current_frame > 0) { + if (cursor->current_frame() > 0) { start = 0; - end = cursor->current_frame - 1; + end = cursor->current_frame() - 1; } else { return; } } - if (_internal_editing) { + if (internal_editing()) { for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) { MidiRegionView* mrv = dynamic_cast(*i); if (mrv) { @@ -1543,9 +1974,9 @@ Editor::select_all_selectables_using_cursor (EditorCursor *cursor, bool after) } if (after) { - begin_reversible_command (_("select all after cursor")); + begin_reversible_selection_op (X_("select all after cursor")); } else { - begin_reversible_command (_("select all before cursor")); + begin_reversible_selection_op (X_("select all before cursor")); } TrackViewList* ts; @@ -1563,21 +1994,21 @@ Editor::select_all_selectables_using_cursor (EditorCursor *cursor, bool after) (*iter)->get_selectables (start, end, 0, DBL_MAX, touched); } selection->set (touched); - commit_reversible_command (); + commit_reversible_selection_op (); } void -Editor::select_all_selectables_using_edit (bool after) +Editor::select_all_selectables_using_edit (bool after, bool from_context_menu) { framepos_t start; framepos_t end; list touched; if (after) { - start = get_preferred_edit_position(); + start = get_preferred_edit_position(EDIT_IGNORE_NONE, from_context_menu); end = _session->current_end_frame(); } else { - if ((end = get_preferred_edit_position()) > 1) { + if ((end = get_preferred_edit_position(EDIT_IGNORE_NONE, from_context_menu)) > 1) { start = 0; end -= 1; } else { @@ -1585,7 +2016,7 @@ Editor::select_all_selectables_using_edit (bool after) } } - if (_internal_editing) { + 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); @@ -1594,9 +2025,9 @@ Editor::select_all_selectables_using_edit (bool after) } if (after) { - begin_reversible_command (_("select all after edit")); + begin_reversible_selection_op (X_("select all after edit")); } else { - begin_reversible_command (_("select all before edit")); + begin_reversible_selection_op (X_("select all before edit")); } TrackViewList* ts; @@ -1614,11 +2045,11 @@ Editor::select_all_selectables_using_edit (bool after) (*iter)->get_selectables (start, end, 0, DBL_MAX, touched); } selection->set (touched); - commit_reversible_command (); + commit_reversible_selection_op (); } void -Editor::select_all_selectables_between (bool /*within*/) +Editor::select_all_selectables_between (bool within) { framepos_t start; framepos_t end; @@ -1628,7 +2059,7 @@ Editor::select_all_selectables_between (bool /*within*/) return; } - if (_internal_editing) { + 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); @@ -1648,10 +2079,12 @@ Editor::select_all_selectables_between (bool /*within*/) if ((*iter)->hidden()) { continue; } - (*iter)->get_selectables (start, end, 0, DBL_MAX, touched); + (*iter)->get_selectables (start, end, 0, DBL_MAX, touched, within); } + begin_reversible_selection_op (X_("Select all Selectables Between")); selection->set (touched); + commit_reversible_selection_op (); } void @@ -1660,7 +2093,7 @@ Editor::select_range_between () framepos_t start; framepos_t end; - if (mouse_mode == MouseRange && !selection->time.empty()) { + if ( !selection->time.empty() ) { selection->clear_time (); } @@ -1668,121 +2101,131 @@ Editor::select_range_between () return; } - set_mouse_mode (MouseRange); + if (!get_smart_mode () || mouse_mode != Editing::MouseObject) { + set_mouse_mode (MouseRange, false); + } + + begin_reversible_selection_op (X_("Select Range Between")); selection->set (start, end); + commit_reversible_selection_op (); } bool Editor::get_edit_op_range (framepos_t& start, framepos_t& end) const { - framepos_t m; - bool ignored; +// framepos_t m; +// bool ignored; - /* in range mode, use any existing selection */ + /* if an explicit range exists, use it */ - if (mouse_mode == MouseRange && !selection->time.empty()) { + if ( (mouse_mode == MouseRange || get_smart_mode() ) && !selection->time.empty()) { /* we know that these are ordered */ start = selection->time.start(); end = selection->time.end_frame(); return true; - } - - 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; - } - - start = selection->markers.front()->position(); - end = _session->audible_frame(); - } else { - - switch (_edit_point) { - case EditAtPlayhead: - if (selection->markers.empty()) { - /* use mouse + playhead */ - start = m; - end = _session->audible_frame(); - } else { - /* use playhead + selected marker */ - start = _session->audible_frame(); - end = selection->markers.front()->position(); - } - break; - - case EditAtMouse: - /* use mouse + selected marker */ - if (selection->markers.empty()) { - start = m; - end = _session->audible_frame(); - } else { - start = selection->markers.front()->position(); - end = m; - } - break; - - case EditAtSelectedMarker: - /* use mouse + selected marker */ - if (selection->markers.empty()) { - - MessageDialog win (_("No edit range defined"), - false, - MESSAGE_INFO, - BUTTONS_OK); - - win.set_secondary_text ( - _("the edit point is Selected Marker\nbut there is no selected marker.")); - - - win.set_default_response (RESPONSE_CLOSE); - win.set_position (Gtk::WIN_POS_MOUSE); - win.show_all(); - - win.run (); - - return false; // NO RANGE - } - start = selection->markers.front()->position(); - end = m; - break; - } - } - - if (start == end) { + start = 0; + end = 0; return false; } - if (start > end) { - swap (start, end); - } +// 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; +// } + +// start = selection->markers.front()->position(); +// end = _session->audible_frame(); + +// } else { + +// switch (_edit_point) { +// case EditAtPlayhead: +// if (selection->markers.empty()) { +// /* use mouse + playhead */ +// start = m; +// end = _session->audible_frame(); +// } else { +// /* use playhead + selected marker */ +// start = _session->audible_frame(); +// end = selection->markers.front()->position(); +// } +// break; + +// case EditAtMouse: +// /* use mouse + selected marker */ +// if (selection->markers.empty()) { +// start = m; +// end = _session->audible_frame(); +// } else { +// start = selection->markers.front()->position(); +// end = m; +// } +// break; + +// case EditAtSelectedMarker: +// /* use mouse + selected marker */ +// if (selection->markers.empty()) { + +// MessageDialog win (_("No edit range defined"), +// false, +// MESSAGE_INFO, +// BUTTONS_OK); + +// win.set_secondary_text ( +// _("the edit point is Selected Marker\nbut there is no selected marker.")); + + +// win.set_default_response (RESPONSE_CLOSE); +// win.set_position (Gtk::WIN_POS_MOUSE); +// win.show_all(); + +// win.run (); + +// return false; // NO RANGE +// } +// start = selection->markers.front()->position(); +// end = m; +// break; +// } +// } + +// if (start == end) { +// return false; +// } + +// if (start > end) { +// swap (start, end); +// } /* turn range into one delimited by start...end, not start...end-1 */ - end++; +// end++; - return true; +// return true; } void Editor::deselect_all () { + begin_reversible_selection_op (X_("Deselect All")); selection->clear (); + commit_reversible_selection_op (); } long -Editor::select_range_around_region (RegionView* rv) +Editor::select_range (framepos_t s, framepos_t e) { - assert (rv); - - selection->set (&rv->get_time_axis_view()); - + begin_reversible_selection_op (X_("Select Range")); + selection->add (clicked_axisview); selection->time.clear (); - boost::shared_ptr r = rv->region (); - return selection->set (r->position(), r->position() + r->length()); + long ret = selection->set (s, e); + commit_reversible_selection_op (); + return ret; }