do not sort MIDI regions by layer since they are all transparent
[ardour.git] / gtk2_ardour / editor_summary.cc
index a9cc524b1575c1ffe2e17237a26dd16bb9aa5391..6740ef92eb7385d21a8c138c496784dbacec8706 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2009 Paul Davis 
+    Copyright (C) 2009 Paul Davis
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -42,9 +42,9 @@ EditorSummary::EditorSummary (Editor* e)
          _move_dragging (false),
          _moved (false),
          _zoom_dragging (false)
-         
+
 {
-       
+
 }
 
 /** Connect to a session.
@@ -73,14 +73,18 @@ EditorSummary::on_expose_event (GdkEventExpose* event)
 {
        CairoWidget::on_expose_event (event);
 
+       if (_session == 0) {
+               return false;
+       }
+
        cairo_t* cr = gdk_cairo_create (get_window()->gobj());
 
        /* Render the view rectangle */
-       
+
        pair<double, double> x;
        pair<double, double> y;
        get_editor (&x, &y);
-       
+
        cairo_move_to (cr, x.first, y.first);
        cairo_line_to (cr, x.second, y.first);
        cairo_line_to (cr, x.second, y.second);
@@ -105,7 +109,7 @@ EditorSummary::on_expose_event (GdkEventExpose* event)
        _last_playhead = p;
 
        cairo_destroy (cr);
-       
+
        return true;
 }
 
@@ -115,18 +119,18 @@ EditorSummary::on_expose_event (GdkEventExpose* event)
 void
 EditorSummary::render (cairo_t* cr)
 {
-       if (_session == 0) {
-               return;
-       }
-
        /* background */
-       
+
        cairo_set_source_rgb (cr, 0, 0, 0);
        cairo_rectangle (cr, 0, 0, _width, _height);
        cairo_fill (cr);
 
+       if (_session == 0) {
+               return;
+       }
+
        /* compute total height of all tracks */
-       
+
        int h = 0;
        int max_height = 0;
        for (PublicEditor::TrackViewList::const_iterator i = _editor->track_views.begin(); i != _editor->track_views.end(); ++i) {
@@ -180,7 +184,7 @@ EditorSummary::render_region (RegionView* r, cairo_t* cr, nframes_t start, doubl
 {
        uint32_t const c = r->get_fill_color ();
        cairo_set_source_rgb (cr, UINT_RGBA_R (c) / 255.0, UINT_RGBA_G (c) / 255.0, UINT_RGBA_B (c) / 255.0);
-                       
+
        cairo_move_to (cr, (r->region()->position() - start) * _x_scale, y);
        cairo_line_to (cr, ((r->region()->position() - start + r->region()->length())) * _x_scale, y);
        cairo_stroke (cr);
@@ -215,7 +219,7 @@ EditorSummary::centre_on_click (GdkEventButton* ev)
 
        double const w = xr.second - xr.first;
        double const h = yr.second - yr.first;
-       
+
        xr.first = ev->x - w / 2;
        xr.second = ev->x + w / 2;
        yr.first = ev->y - h / 2;
@@ -248,63 +252,58 @@ EditorSummary::on_button_press_event (GdkEventButton* ev)
 {
        if (ev->button == 1) {
 
-               if (Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier)) {
+               pair<double, double> xr;
+               pair<double, double> yr;
+               get_editor (&xr, &yr);
+
+               _start_editor_x = xr;
+               _start_editor_y = yr;
+               _start_mouse_x = ev->x;
+               _start_mouse_y = ev->y;
+
+               if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
+
+                       /* primary-modifier-click: start a zoom drag */
+
+                       double const hx = (xr.first + xr.second) * 0.5;
+                       _zoom_left = ev->x < hx;
+                       _zoom_dragging = true;
+                       _editor->_dragging_playhead = true;
+
+
+                       /* In theory, we could support vertical dragging, which logically
+                          might scale track heights in order to make the editor reflect
+                          the dragged viewbox.  However, having tried this:
+                          a) it's hard to do
+                          b) it's quite slow
+                          c) it doesn't seem particularly useful, especially with the
+                          limited height of the summary
+
+                          So at the moment we don't support that...
+                       */
+
+
+               } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier)) {
 
                        /* secondary-modifier-click: locate playhead */
                        if (_session) {
                                _session->request_locate (ev->x / _x_scale + _session->current_start_frame());
                        }
 
+               } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
+
+                       centre_on_click (ev);
+
                } else {
-               
-                       pair<double, double> xr;
-                       pair<double, double> yr;
-                       get_editor (&xr, &yr);
-                       
-                       if (xr.first <= ev->x && ev->x <= xr.second && yr.first <= ev->y && ev->y <= yr.second) {
-                               
-                               _start_editor_x = xr;
-                               _start_editor_y = yr;
-                               _start_mouse_x = ev->x;
-                               _start_mouse_y = ev->y;
-                               
-                               if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
-                                       
-                                       /* modifier-click inside the view rectangle: start a zoom drag */
-                                       
-                                       double const hx = (xr.first + xr.second) * 0.5;
-                                       _zoom_left = ev->x < hx;
-                                       _zoom_dragging = true;
-                                       _editor->_dragging_playhead = true;
-                                       
-                                       /* In theory, we could support vertical dragging, which logically
-                                          might scale track heights in order to make the editor reflect
-                                          the dragged viewbox.  However, having tried this:
-                                          a) it's hard to do
-                                          b) it's quite slow
-                                          c) it doesn't seem particularly useful, especially with the
-                                          limited height of the summary
-                                          
-                                          So at the moment we don't support that...
-                                       */
-                                       
-                               } else {
-                                       
-                                       /* ordinary click inside the view rectangle: start a move drag */
-                                       
-                                       _move_dragging = true;
-                                       _moved = false;
-                                       _editor->_dragging_playhead = true;
-                               }
-                               
-                       } else {
-                       
-                               /* click outside the view rectangle: centre the view around the mouse click */
-                               centre_on_click (ev);
-                       }
+
+                       /* ordinary click: start a move drag */
+
+                       _move_dragging = true;
+                       _moved = false;
+                       _editor->_dragging_playhead = true;
                }
        }
-       
+
        return true;
 }
 
@@ -323,7 +322,7 @@ EditorSummary::on_motion_notify_event (GdkEventMotion* ev)
 {
        pair<double, double> xr = _start_editor_x;
        pair<double, double> yr = _start_editor_y;
-       
+
        if (_move_dragging) {
 
                _moved = true;
@@ -332,7 +331,7 @@ EditorSummary::on_motion_notify_event (GdkEventMotion* ev)
                xr.second += ev->x - _start_mouse_x;
                yr.first += ev->y - _start_mouse_y;
                yr.second += ev->y - _start_mouse_y;
-               
+
                set_editor (xr, yr);
 
        } else if (_zoom_dragging) {
@@ -347,17 +346,13 @@ EditorSummary::on_motion_notify_event (GdkEventMotion* ev)
 
                set_editor (xr, yr);
        }
-               
+
        return true;
 }
 
 bool
-EditorSummary::on_button_release_event (GdkEventButton* ev)
+EditorSummary::on_button_release_event (GdkEventButton*)
 {
-       if (_move_dragging && !_moved) {
-               centre_on_click (ev);
-       }
-
        _move_dragging = false;
        _zoom_dragging = false;
        _editor->_dragging_playhead = false;
@@ -368,15 +363,15 @@ bool
 EditorSummary::on_scroll_event (GdkEventScroll* ev)
 {
        /* mouse wheel */
-       
+
        pair<double, double> xr;
        pair<double, double> yr;
        get_editor (&xr, &yr);
 
        double const amount = 8;
-               
+
        if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
-               
+
                if (ev->direction == GDK_SCROLL_UP) {
                        xr.first += amount;
                        xr.second += amount;
@@ -386,7 +381,7 @@ EditorSummary::on_scroll_event (GdkEventScroll* ev)
                }
 
        } else {
-               
+
                if (ev->direction == GDK_SCROLL_DOWN) {
                        yr.first += amount;
                        yr.second += amount;
@@ -394,9 +389,9 @@ EditorSummary::on_scroll_event (GdkEventScroll* ev)
                        yr.first -= amount;
                        yr.second -= amount;
                }
-               
+
        }
-       
+
        set_editor (xr, yr);
        return true;
 }
@@ -439,4 +434,4 @@ EditorSummary::playhead_position_changed (nframes64_t p)
        }
 }
 
-       
+