diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2017-02-14 16:09:32 +0100 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2017-02-15 20:07:49 +0100 |
commit | 0a41daa932a0f742c7dc7a14c02ae93baa12903a (patch) | |
tree | 75d6585d78fcc5b2d47f0ec90f25289ac9174265 /gtk2_ardour/editor_selection.cc | |
parent | 2cc94f88801fa98e7b06d782903ab48446d08287 (diff) |
classify all region actions based on how they get a list of regions to operate on; use this in Editor::sensitize_the_right_region_actions()
There are still problems because actions like trim_front()
that use the edit point get the edit point with different
results than the code that sensitizes actions
Diffstat (limited to 'gtk2_ardour/editor_selection.cc')
-rw-r--r-- | gtk2_ardour/editor_selection.cc | 109 |
1 files changed, 42 insertions, 67 deletions
diff --git a/gtk2_ardour/editor_selection.cc b/gtk2_ardour/editor_selection.cc index 2bcc8f1f2f..563b904279 100644 --- a/gtk2_ardour/editor_selection.cc +++ b/gtk2_ardour/editor_selection.cc @@ -1098,13 +1098,52 @@ Editor::sensitize_all_region_actions (bool s) void Editor::sensitize_the_right_region_actions (bool from_context_menu, bool from_outside_canvas) { - PBD::stacktrace (cerr, 20); - RegionSelection rs = get_regions_from_selection_and_edit_point (Editing::EDIT_IGNORE_NONE, from_context_menu, from_outside_canvas); + bool have_selection = false; + bool have_entered = false; + bool have_edit_point = false; + RegionSelection rs; - sensitize_all_region_actions (!rs.empty ()); + if (!selection->regions.empty()) { + have_selection = true; + rs = selection->regions; + } + + if (entered_regionview) { + have_entered = true; + rs.add (entered_regionview); + } + + if (!selection->tracks.empty()) { + RegionSelection at_edit_point; + framepos_t const where = get_preferred_edit_position (Editing::EDIT_IGNORE_NONE, from_context_menu, from_outside_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()); + } + } + + typedef std::map<std::string,RegionAction> 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; @@ -1254,70 +1293,6 @@ Editor::sensitize_the_right_region_actions (bool from_context_menu, bool from_ou /* others were already marked sensitive */ } - /* these actions all require a single location, taken from the edit - * point. - */ - - vector<string> edit_point_actions; - edit_point_actions.push_back ("set-region-sync-position"); - edit_point_actions.push_back ("trim-front"); - edit_point_actions.push_back ("trim-back"); - edit_point_actions.push_back ("place-transient"); - edit_point_actions.push_back ("align-regions-start"); - edit_point_actions.push_back ("align-regions-start-relative"); - edit_point_actions.push_back ("align-regions-end"); - edit_point_actions.push_back ("align-regions-end-relative"); - edit_point_actions.push_back ("align-regions-sync"); - edit_point_actions.push_back ("align-regions-sync-relative"); - - /* They all use Editor::get_regions_from_selection_and_edit_point(), - * which is the same method used at the start of this to determine if - * any regions are eligible/valid for editing. - * - * there are two possible reasons why these actions should still - * be sensitive. - * - * 1. regions are selected - * 2. the edit point is inside some regions on selected tracks - * - * the first condition is satisfied if selection->regions is not empty. - * the second condition is satisfied if selection->regions is empty, - * but @param rs (set above by the call to get_regions_from_selection_and_edit_point() - * is not empty. - * - * if the mouse is the edit point, then whether get_regions_from_selection_and_edit_point() - * will have identified any regions will depend on the edit point setting. - * - * Editing::EditIgnoreOption that we passed to it, which in turn will - * depend on whether or not the pointer is still inside the track - * canvas. If it was, then the pointer position will determine whether - * or not any non-selected regions are considered eligible. If it - * wasn't, then we will ignore the pointer position and fallback on a - * secondary edit point (at this writing, that will likely be the - * playhead but see get_regions_from_selection_and_edit_point() to see - * how this works). - * - * if the edit point is not the mouse, then - * get_regions_from_selection_and_edit_point() will just do the right - * thing. - * - * However, the implementation of the actions will still use the edit - * point, ... - * - */ - - bool sensitivity; - - if (!selection->regions.empty() || !rs.empty()) { /* conditions 1 and 2 above */ - sensitivity = true; - } else { - sensitivity = false; - } - - for (vector<string>::const_iterator a = edit_point_actions.begin(); a != edit_point_actions.end(); ++a) { - _region_actions->get_action (*a)->set_sensitive (sensitivity); - } - /* ok, moving along... */ if (have_compound_regions) { |