start-range and finish-range should graphically show the range being created. also...
[ardour.git] / gtk2_ardour / editor_selection.cc
index 1089381a151794779989d1b35977609ea599c623..203df9f32281a3b2dea26317bd300d929481255f 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,6 +1056,8 @@ Editor::sensitize_the_right_region_actions ()
        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;
@@ -1089,6 +1100,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 {
@@ -1212,6 +1229,12 @@ Editor::sensitize_the_right_region_actions ()
                // a->set_inconsistent ();
        }
 
+       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 ();
+       }
+
        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);
 
@@ -1355,17 +1378,7 @@ Editor::select_all (Selection::Operation op)
 {
        list<Selectable *> touched;
 
-       TrackViewList ts;
-
-       if (selection->tracks.empty()) {
-               if (entered_track) {
-                       ts.push_back (entered_track);
-               } else {
-                       ts = track_views;
-               }
-       } else {
-               ts = selection->tracks;
-       }
+       TrackViewList ts  = track_views;
 
        if (_internal_editing) {
 
@@ -1395,8 +1408,10 @@ Editor::select_all (Selection::Operation op)
                        continue;
                }
                (*iter)->get_selectables (0, max_framepos, 0, DBL_MAX, touched);
+               selection->add (*iter);
        }
 
+
        begin_reversible_command (_("select all"));
        switch (op) {
        case Selection::Add:
@@ -1475,6 +1490,8 @@ Editor::select_all_within (framepos_t start, framepos_t end, double top, double
        }
 
        if (found.empty()) {
+               selection->clear_objects();
+               selection->clear_time ();
                return;
        }
 
@@ -1663,12 +1680,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;
                }
@@ -1817,98 +1834,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