X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_selection.cc;h=305ad7790275640a481ccf7380812653898e1d4d;hb=3705a2d6307cf443acbf8419b0e0f560591f2016;hp=6cd022cce185f53f9d8b73e88bdf7f52fe3a3a8e;hpb=8aa9508c82f32efcf9c7c00e2c9e76268d4dddce;p=ardour.git diff --git a/gtk2_ardour/editor_selection.cc b/gtk2_ardour/editor_selection.cc index 6cd022cce1..305ad77902 100644 --- a/gtk2_ardour/editor_selection.cc +++ b/gtk2_ardour/editor_selection.cc @@ -18,13 +18,14 @@ */ #include -#include +#include #include #include #include #include +#include #include "editor.h" #include "actions.h" @@ -48,7 +49,7 @@ using namespace Editing; struct TrackViewByPositionSorter { bool operator() (const TimeAxisView* a, const TimeAxisView *b) { - return a->y_position < b->y_position; + return a->y_position() < b->y_position(); } }; @@ -160,7 +161,13 @@ Editor::extend_selection_to_track (TimeAxisView& view) void Editor::select_all_tracks () { - selection->set (track_views); + TrackViewList visible_views; + for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { + if ((*i)->marked_for_display()) { + visible_views.push_back (*i); + } + } + selection->set (visible_views); } void @@ -201,21 +208,7 @@ Editor::set_selected_track (TimeAxisView& view, Selection::Operation op, bool no break; case Selection::Set: - if (selection->selected (&view) && selection->tracks.size() > 1) { - - /* reset track selection if there is only 1 other track - selected OR if no_remove is not set (its there to - prevent deselecting a multi-track selection - when clicking on an already selected track - for some reason. - */ - - if (selection->tracks.empty()) { - selection->set (&view); - } else if (selection->tracks.size() == 1 || !no_remove) { - selection->set (&view); - } - } + selection->set (&view); break; case Selection::Extend: @@ -248,7 +241,7 @@ Editor::set_selected_control_point_from_click (Selection::Operation op, bool no_ /* select this point and any others that it represents */ double y1, y2; - nframes_t x1, x2; + nframes64_t x1, x2; x1 = pixel_to_frame (clicked_control_point->get_x() - 10); x2 = pixel_to_frame (clicked_control_point->get_x() + 10); @@ -375,6 +368,44 @@ Editor::get_equivalent_regions (RegionView* basis, vector& equivale equivalent_regions.push_back (basis); } +int +Editor::get_regionview_count_from_region_list (boost::shared_ptr region) +{ + int region_count = 0; + + for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { + + RouteTimeAxisView* tatv; + + if ((tatv = dynamic_cast (*i)) != 0) { + + boost::shared_ptr pl; + vector > results; + RegionView* marv; + boost::shared_ptr ds; + + if ((ds = tatv->get_diskstream()) == 0) { + /* bus */ + continue; + } + + if ((pl = (ds->playlist())) != 0) { + pl->get_region_list_equivalent_regions (region, results); + } + + for (vector >::iterator ir = results.begin(); ir != results.end(); ++ir) { + if ((marv = tatv->view()->find_view (*ir)) != 0) { + region_count++; + } + } + + } + } + + return region_count; +} + + bool Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, bool no_track_remove) { @@ -462,8 +493,8 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op, } else if (op == Selection::Extend) { list results; - nframes_t last_frame; - nframes_t first_frame; + nframes64_t last_frame; + nframes64_t first_frame; bool same_track = false; /* 1. find the last selected regionview in the track that was clicked in */ @@ -761,11 +792,17 @@ Editor::track_selection_changed () (*i)->set_selected (false); } } + + ActionManager::set_sensitive (ActionManager::track_selection_sensitive_actions, !selection->tracks.empty()); } void Editor::time_selection_changed () { + if (Profile->get_sae()) { + return; + } + for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { (*i)->hide_selection (); } @@ -788,14 +825,51 @@ Editor::time_selection_changed () } +void +Editor::sensitize_the_right_region_actions (bool have_selected_regions) +{ + for (vector >::iterator x = ActionManager::region_selection_sensitive_actions.begin(); + x != ActionManager::region_selection_sensitive_actions.end(); ++x) { + + string accel_path = (*x)->get_accel_path (); + AccelKey key; + + /* if there is an accelerator, it should always be sensitive + to allow for keyboard ops on entered regions. + */ + + bool known = ActionManager::lookup_entry (accel_path, key); + + if (known && ((key.get_key() != GDK_VoidSymbol) && (key.get_key() != 0))) { + (*x)->set_sensitive (true); + } else { + (*x)->set_sensitive (have_selected_regions); + } + } +} + + void Editor::region_selection_changed () { + region_list_change_connection.block(true); + editor_regions_selection_changed_connection.block(true); + + region_list_display.get_selection()->unselect_all(); + for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { + (*i)->set_selected_regionviews (selection->regions); + set_selected_in_region_list(selection->regions); + } + sensitize_the_right_region_actions (!selection->regions.empty()); + zoomed_to_region = false; + + region_list_change_connection.block(false); + editor_regions_selection_changed_connection.block(false); } void @@ -890,7 +964,7 @@ Editor::invert_selection () } bool -Editor::select_all_within (nframes_t start, nframes_t end, double top, double bot, const TrackViewList& tracklist, Selection::Operation op) +Editor::select_all_within (nframes64_t start, nframes64_t end, double top, double bot, const TrackViewList& tracklist, Selection::Operation op) { list touched; list::size_type n = 0; @@ -961,7 +1035,9 @@ Editor::set_selection_from_region () } selection->set (0, selection->regions.start(), selection->regions.end_frame()); - set_mouse_mode (Editing::MouseRange, false); + if (!Profile->get_sae()) { + set_mouse_mode (Editing::MouseRange, false); + } } void @@ -994,7 +1070,9 @@ Editor::set_selection_from_range (Location& loc) selection->set (0, loc.start(), loc.end()); commit_reversible_command (); - set_mouse_mode (Editing::MouseRange, false); + if (!Profile->get_sae()) { + set_mouse_mode (Editing::MouseRange, false); + } } void @@ -1006,8 +1084,8 @@ Editor::select_all_selectables_using_time_selection () return; } - nframes_t start = selection->time[clicked_selection].start; - nframes_t end = selection->time[clicked_selection].end; + nframes64_t start = selection->time[clicked_selection].start; + nframes64_t end = selection->time[clicked_selection].end; if (end - start < 1) { return; @@ -1099,8 +1177,8 @@ Editor::select_all_selectables_using_loop() void Editor::select_all_selectables_using_cursor (Cursor *cursor, bool after) { - nframes_t start; - nframes_t end; + nframes64_t start; + nframes64_t end; list touched; if (after) { @@ -1139,8 +1217,8 @@ Editor::select_all_selectables_using_cursor (Cursor *cursor, bool after) void Editor::select_all_selectables_using_edit (bool after) { - nframes_t start; - nframes_t end; + nframes64_t start; + nframes64_t end; list touched; if (after) { @@ -1307,6 +1385,12 @@ Editor::get_edit_op_range (nframes64_t& start, nframes64_t& end) const swap (start, end); } + /* turn range into one delimited by start...end, + not start...end-1 + */ + + end++; + return true; }