delete 'big' 2d panner window, if panner changes to mono|stereo
[ardour.git] / gtk2_ardour / editor_summary.cc
index 7ce74f414b2b3216560e856bd96d66f8d4ba712d..1c30df4f3af17fe9ef19ed5e4ee4f2baebd699b1 100644 (file)
@@ -19,6 +19,8 @@
 
 #include "ardour/session.h"
 
+#include "canvas/debug.h"
+
 #include "time_axis_view.h"
 #include "streamview.h"
 #include "editor_summary.h"
@@ -55,6 +57,7 @@ EditorSummary::EditorSummary (Editor* e)
          _old_follow_playhead (false)
 {
        Region::RegionPropertyChanged.connect (region_property_connection, invalidator (*this), boost::bind (&CairoWidget::set_dirty, this), gui_context());
+       Route::RemoteControlIDChange.connect (route_ctrl_id_connection, invalidator (*this), boost::bind (&CairoWidget::set_dirty, this), gui_context());
        _editor->playhead_cursor->PositionChanged.connect (position_connection, invalidator (*this), boost::bind (&EditorSummary::playhead_position_changed, this, _1), gui_context());
 
        add_events (Gdk::POINTER_MOTION_MASK|Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK|Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK);
@@ -199,7 +202,7 @@ EditorSummary::render (cairo_t* cr)
        /* XXX: colour should be set from configuration file */
        cairo_set_source_rgba (cr, 1, 0, 0, 1);
 
-       const double ph= playhead_frame_to_position (_editor->playhead_cursor->current_frame);
+       const double ph= playhead_frame_to_position (_editor->playhead_cursor->current_frame());
        cairo_move_to (cr, ph, 0);
        cairo_line_to (cr, ph, get_height());
        cairo_stroke (cr);
@@ -315,7 +318,7 @@ EditorSummary::on_key_press_event (GdkEventKey* key)
                if (key->keyval == set_playhead_accel.accel_key && (int) key->state == set_playhead_accel.accel_mods) {
                        if (_session) {
                                get_pointer (x, y);
-                               _session->request_locate ((framepos_t) x / _x_scale, _session->transport_rolling());
+                               _session->request_locate (_start + (framepos_t) x / _x_scale, _session->transport_rolling());
                                return true;
                        }
                }
@@ -396,6 +399,8 @@ EditorSummary::on_button_press_event (GdkEventButton* ev)
                        _moved = false;
                        _editor->_dragging_playhead = true;
                        _editor->set_follow_playhead (false);
+
+                       ArdourCanvas::checkpoint ("sum", "------------------ summary move drag starts.\n");
                }
        }
 
@@ -431,11 +436,11 @@ EditorSummary::get_editor (pair<double, double>* x, pair<double, double>* y) con
 
                /* Otherwise query the editor for its actual position */
 
-               x->first = (_editor->leftmost_position () - _start) * _x_scale;
-               x->second = x->first + _editor->current_page_frames() * _x_scale;
+               x->first = (_editor->leftmost_sample () - _start) * _x_scale;
+               x->second = x->first + _editor->current_page_samples() * _x_scale;
                
                y->first = editor_y_to_summary (_editor->vertical_adjustment.get_value ());
-               y->second = editor_y_to_summary (_editor->vertical_adjustment.get_value () + _editor->canvas_height() - _editor->get_canvas_timebars_vsize());
+               y->second = editor_y_to_summary (_editor->vertical_adjustment.get_value () + _editor->visible_canvas_height());
        }
 }
 
@@ -562,7 +567,7 @@ EditorSummary::on_motion_notify_event (GdkEventMotion* ev)
                }
 
                set_editor (x, y);
-               set_cursor (_start_position);
+               // set_cursor (_start_position);
 
        } else if (_zoom_dragging) {
 
@@ -622,45 +627,55 @@ EditorSummary::on_scroll_event (GdkEventScroll* ev)
        double x = xr.first;
        double y = yr.first;
 
-       double amount = 8;
-
-       if (Keyboard::modifier_state_contains (ev->state, Keyboard::SecondaryModifier)) {
-               amount = 64;
-       } else if (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier)) {
-               amount = 1;
-       }
-
-       if (Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier)) {
-
-               /* secondary-wheel == left-right scrolling */
-
-               if (ev->direction == GDK_SCROLL_UP) {
-                       x -= amount;
-               } else if (ev->direction == GDK_SCROLL_DOWN) {
-                       x += amount;
-               }
-
-       } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
-
-               /* primary-wheel == zoom */
-               
-               if (ev->direction == GDK_SCROLL_UP) {
-                       _editor->temporal_zoom_step (false);
-               } else {
-                       _editor->temporal_zoom_step (true);
-               }
-
-       } else {
-
-               if (ev->direction == GDK_SCROLL_DOWN) {
-                       y += amount;
-               } else if (ev->direction == GDK_SCROLL_UP) {
-                       y -= amount;
-               } else if (ev->direction == GDK_SCROLL_LEFT) {
-                       x -= amount;
-               } else if (ev->direction == GDK_SCROLL_RIGHT) {
-                       x += amount;
-               }
+       switch (ev->direction) {
+               case GDK_SCROLL_UP:
+                       if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollHorizontalModifier)) {
+                               x -= 64;
+                       } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollZoomHorizontalModifier)) {
+                               _editor->temporal_zoom_step (false);
+                       } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollZoomVerticalModifier)) {
+                               yr.first  += 4;
+                               yr.second -= 4;
+                               set_editor (xr, yr);
+                               return true;
+                       } else {
+                               y -= 8;
+                       }
+                       break;
+               case GDK_SCROLL_DOWN:
+                       if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollHorizontalModifier)) {
+                               x += 64;
+                       } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollZoomHorizontalModifier)) {
+                               _editor->temporal_zoom_step (true);
+                       } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::ScrollZoomVerticalModifier)) {
+                               yr.first  -= 4;
+                               yr.second += 4;
+                               set_editor (xr, yr);
+                               return true;
+                       } else {
+                               y += 8;
+                       }
+                       break;
+               case GDK_SCROLL_LEFT:
+                       if (Keyboard::modifier_state_contains (ev->state, Keyboard::SecondaryModifier)) {
+                               x -= 64;
+                       } else if (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier)) {
+                               x -= 1;
+                       } else {
+                               x -= 8;
+                       }
+                       break;
+               case GDK_SCROLL_RIGHT:
+                       if (Keyboard::modifier_state_contains (ev->state, Keyboard::SecondaryModifier)) {
+                               x += 64;
+                       } else if (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier)) {
+                               x += 1;
+                       } else {
+                               x += 8;
+                       }
+                       break;
+               default:
+                       break;
        }
 
        set_editor (x, y);
@@ -675,7 +690,7 @@ EditorSummary::on_scroll_event (GdkEventScroll* ev)
 void
 EditorSummary::set_editor (double const x, double const y)
 {
-       if (_editor->pending_visual_change.idle_handler_id >= 0) {
+       if (_editor->pending_visual_change.idle_handler_id >= 0 && _editor->pending_visual_change.being_handled == true) {
 
                /* As a side-effect, the Editor's visual change idle handler processes
                   pending GTK events.  Hence this motion notify handler can be called
@@ -687,7 +702,7 @@ EditorSummary::set_editor (double const x, double const y)
                   as it also means that we won't change these variables if an idle handler
                   is merely pending but not executing.  But c'est la vie.
                */
-
+               
                return;
        }
 
@@ -773,7 +788,7 @@ EditorSummary::set_editor_x (pair<double, double> x)
                
                double const nx = (
                        ((x.second - x.first) / _x_scale) /
-                       _editor->frame_to_unit (_editor->current_page_frames())
+                       _editor->sample_to_pixel (_editor->current_page_samples())
                        );
                
                if (nx != _editor->get_current_zoom ()) {
@@ -790,10 +805,10 @@ void
 EditorSummary::set_editor_y (double const y)
 {
        double y1 = summary_y_to_editor (y);
-       double const eh = _editor->canvas_height() - _editor->get_canvas_timebars_vsize ();
+       double const eh = _editor->visible_canvas_height();
        double y2 = y1 + eh;
 
-       double const full_editor_height = _editor->full_canvas_height - _editor->get_canvas_timebars_vsize();
+       double const full_editor_height = _editor->_full_canvas_height;
 
        if (y2 > full_editor_height) {
                y1 -= y2 - full_editor_height;
@@ -870,7 +885,7 @@ EditorSummary::set_editor_y (pair<double, double> const y)
        /* Height that we will use for scaling; use the whole editor height unless there are not
           enough tracks to fill it.
        */
-       double const ch = min (total_height, _editor->canvas_height() - _editor->get_canvas_timebars_vsize());
+       double const ch = min (total_height, _editor->visible_canvas_height());
 
        /* hence required scale factor of the complete tracks to fit the required y range;
           the amount of space they should take up divided by the amount they currently take up.
@@ -906,9 +921,9 @@ EditorSummary::playhead_position_changed (framepos_t p)
        int const o = int (_last_playhead);
        int const n = int (playhead_frame_to_position (p));
        if (_session && o != n) {
-               int a = min (o, n);
+               int a = max(2, min (o, n));
                int b = max (o, n);
-               set_overlays_dirty (a - 1, 0, b + 1, get_height ());
+               set_overlays_dirty (a - 2, 0, b + 2, get_height ());
        }
 }