remove implicit range. start-range and end-range work better. documentation changes...
[ardour.git] / gtk2_ardour / editor_selection.cc
index fbe46a1ae9656246af162de31b65662ac8923530..01d3d3e4182e083b006c54f5cd43dee45de06dee 100644 (file)
@@ -364,7 +364,7 @@ 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);
                }
        }
@@ -779,7 +779,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 (EditorSort);
+                                       int key = rtv->route()->order_key ();
 
                                        for (RegionSelection::iterator x = selection->regions.begin(); x != selection->regions.end(); ++x) {
 
@@ -794,7 +794,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 (EditorSort);
+                                                               int d = artv->route()->order_key ();
 
                                                                d -= key;
 
@@ -810,7 +810,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 (EditorSort);
+                                               int okey = closest->route()->order_key ();
 
                                                if (okey > key) {
                                                        swap (okey, key);
@@ -820,7 +820,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op)
                                                        RouteTimeAxisView* artv = dynamic_cast<RouteTimeAxisView*>(*x);
                                                        if (artv && artv != rtv) {
 
-                                                               int k = artv->route()->order_key (EditorSort);
+                                                               int k = artv->route()->order_key ();
 
                                                                if (k >= okey && k <= key) {
 
@@ -991,6 +991,15 @@ Editor::time_selection_changed ()
                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 ();
        }
@@ -1047,10 +1056,8 @@ Editor::sensitize_the_right_region_actions ()
        bool have_midi = false;
        bool have_locked = false;
        bool have_unlocked = false;
-#ifdef WITH_VIDEOTIMELINE
        bool have_video_locked = false;
        bool have_video_unlocked = false;
-#endif
        bool have_position_lock_style_audio = false;
        bool have_position_lock_style_music = false;
        bool have_muted = false;
@@ -1092,13 +1099,12 @@ Editor::sensitize_the_right_region_actions ()
                } else {
                        have_unlocked = true;
                }
-#ifdef WITH_VIDEOTIMELINE
+
                if (r->video_locked()) {
                        have_video_locked = true;
                } else {
                        have_video_unlocked = true;
                }
-#endif
 
                if (r->position_lock_style() == MusicTime) {
                        have_position_lock_style_music = true;
@@ -1223,13 +1229,11 @@ Editor::sensitize_the_right_region_actions ()
                // a->set_inconsistent ();
        }
 
-#ifdef WITH_VIDEOTIMELINE
        a = Glib::RefPtr<ToggleAction>::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 ();
        }
-#endif
 
        a = Glib::RefPtr<ToggleAction>::cast_dynamic (_region_actions->get_action("toggle-region-lock-style"));
        a->set_active (have_position_lock_style_music && !have_position_lock_style_audio);
@@ -1494,6 +1498,8 @@ Editor::select_all_within (framepos_t start, framepos_t end, double top, double
        }
 
        if (found.empty()) {
+               selection->clear_objects();
+               selection->clear_time ();
                return;
        }
 
@@ -1682,12 +1688,12 @@ Editor::select_all_selectables_using_cursor (EditorCursor *cursor, bool after)
        list<Selectable *> 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;
                }
@@ -1836,98 +1842,102 @@ Editor::select_range_between ()
 bool
 Editor::get_edit_op_range (framepos_t& start, framepos_t& end) const
 {
-       framepos_t m;
-       bool ignored;
+//     framepos_t m;
+//     bool ignored;
 
        /* if an explicit range exists, use it */
 
-       if (!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