fader+meter: update numeric display bg on style change
[ardour.git] / gtk2_ardour / editor_drag.cc
index bf013c43527a75a117cbf03726fb243dacb2b7e2..eb130c5f294fedd86175379f13103e4bb6c603b8 100644 (file)
@@ -40,6 +40,7 @@
 #include "ardour/region_factory.h"
 #include "ardour/session.h"
 
+#include "canvas/canvas.h"
 #include "canvas/scroll_group.h"
 
 #include "editor.h"
@@ -4238,9 +4239,16 @@ SelectionDrag::motion (GdkEvent* event, bool first_move)
                        }
                }
                
+               //if user is selecting a range on an automation track, bail out here before we get to the grouped stuff, 
+               // because the grouped stuff will start working on tracks (routeTAVs), and end up removing this 
+               AutomationTimeAxisView *atest = dynamic_cast<AutomationTimeAxisView *>(_editor->clicked_axisview);
+               if (atest) {
+                       _editor->selection->add (atest);
+                       break; 
+               }
+               
                /* select all tracks within the rectangle that we've marked out so far */
-               TrackViewList to_be_added_to_selection;
-               TrackViewList to_be_removed_from_selection;
+               TrackViewList new_selection;
                TrackViewList& all_tracks (_editor->track_views);
 
                ArdourCanvas::Coord const top = grab_y();
@@ -4248,26 +4256,39 @@ SelectionDrag::motion (GdkEvent* event, bool first_move)
 
                if (top >= 0 && bottom >= 0) {
 
+                       //first, find the tracks that are covered in the y range selection
                        for (TrackViewList::const_iterator i = all_tracks.begin(); i != all_tracks.end(); ++i) {
-                       
                                if ((*i)->covered_by_y_range (top, bottom)) {
-                                       if (!(*i)->get_selected()) {
-                                               to_be_added_to_selection.push_back (*i);
-                                       }
-                               } else {
-                                       if ((*i)->get_selected()) {
-                                               to_be_removed_from_selection.push_back (*i);
-                                       }
+                                       new_selection.push_back (*i);
                                }
                        }
 
-                       if (!to_be_added_to_selection.empty()) {
-                               _editor->selection->add (to_be_added_to_selection);
-                       }
-                       
-                       if (!to_be_removed_from_selection.empty()) {
-                               _editor->selection->remove (to_be_removed_from_selection);
+                       //now find any tracks that are GROUPED with the tracks we selected
+                       TrackViewList grouped_add = new_selection;
+                       for (TrackViewList::const_iterator i = new_selection.begin(); i != new_selection.end(); ++i) {
+                               RouteTimeAxisView *n = dynamic_cast<RouteTimeAxisView *>(*i);
+                               if ( n && n->route()->route_group() && n->route()->route_group()->is_active() && n->route()->route_group()->enabled_property (ARDOUR::Properties::select.property_id) ) {
+                                       for (TrackViewList::const_iterator j = all_tracks.begin(); j != all_tracks.end(); ++j) {
+                                               RouteTimeAxisView *check = dynamic_cast<RouteTimeAxisView *>(*j);
+                                               if ( check && (n != check) && (check->route()->route_group() == n->route()->route_group()) )
+                                                       grouped_add.push_back (*j);
+                                       }
+                               }
                        }
+
+                       //now compare our list with the current selection, and add or remove as necessary
+                       //( NOTE: most mouse moves don't change the selection so we can't just SET it for every mouse move; it gets clunky )
+                       TrackViewList tracks_to_add;
+                       TrackViewList tracks_to_remove;
+                       for (TrackViewList::const_iterator i = grouped_add.begin(); i != grouped_add.end(); ++i)
+                               if ( !_editor->selection->tracks.contains ( *i ) )
+                                       tracks_to_add.push_back ( *i );
+                       for (TrackViewList::const_iterator i = _editor->selection->tracks.begin(); i != _editor->selection->tracks.end(); ++i)
+                               if ( !grouped_add.contains ( *i ) )
+                                       tracks_to_remove.push_back ( *i );
+                       _editor->selection->add(tracks_to_add);
+                       _editor->selection->remove(tracks_to_remove);
+
                }
        }
        break;
@@ -4978,8 +4999,8 @@ AutomationRangeDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
                                double const p = j->line->time_converter().from (i->start - j->line->time_converter().origin_b ());
                                double const q = j->line->time_converter().from (a - j->line->time_converter().origin_b ());
 
-                               the_list->add (p, the_list->eval (p));
-                               the_list->add (q, the_list->eval (q));
+                               the_list->editor_add (p, the_list->eval (p));
+                               the_list->editor_add (q, the_list->eval (q));
                        }
 
                        /* same thing for the end */
@@ -5004,8 +5025,8 @@ AutomationRangeDrag::start_grab (GdkEvent* event, Gdk::Cursor* cursor)
                                double const p = j->line->time_converter().from (b - j->line->time_converter().origin_b ());
                                double const q = j->line->time_converter().from (i->end - j->line->time_converter().origin_b ());
 
-                               the_list->add (p, the_list->eval (p));
-                               the_list->add (q, the_list->eval (q));
+                               the_list->editor_add (p, the_list->eval (p));
+                               the_list->editor_add (q, the_list->eval (q));
                        }
                }
 
@@ -5465,21 +5486,28 @@ RegionCutDrag::~RegionCutDrag ()
 void
 RegionCutDrag::motion (GdkEvent*, bool)
 {
-       line->set_position (_drags->current_pointer_frame());
+       framepos_t where = _drags->current_pointer_frame();
+       _editor->snap_to (where);
+
+       line->set_position (where);
 }
 
 void
 RegionCutDrag::finished (GdkEvent*, bool)
 {
+       _editor->get_track_canvas()->canvas()->re_enter();
+
+       framepos_t pos = _drags->current_pointer_frame();
+       
        line->hide ();
 
-       RegionSelection rs = _editor->get_regions_from_selection_and_mouse ();
+       RegionSelection rs = _editor->get_regions_from_selection_and_mouse (pos);
 
        if (rs.empty()) {
                return;
        }
 
-       _editor->split_regions_at (_drags->current_pointer_frame(), rs);
+       _editor->split_regions_at (pos, rs);
 }
 
 void