remove incorrect calls to Editor::maybe_autoscroll() from specific Drag classes ...
[ardour.git] / gtk2_ardour / editor_canvas.cc
index d4d5f88c5293b67310e8f3a72f918a53dbbb181f..0c08af5c1143165eac86bea27cfddddfe51069aa 100644 (file)
@@ -30,6 +30,7 @@
 #include "canvas/canvas.h"
 #include "canvas/rectangle.h"
 #include "canvas/pixbuf.h"
+#include "canvas/scroll_group.h"
 #include "canvas/text.h"
 #include "canvas/debug.h"
 
@@ -60,19 +61,18 @@ using namespace Glib;
 using namespace Gtkmm2ext;
 using namespace Editing;
 
-/* XXX this is a hack. it ought to be the maximum value of an framepos_t */
-
-const double max_canvas_coordinate = (double) UINT32_MAX;
-
 void
 Editor::initialize_canvas ()
 {
        _track_canvas_viewport = new ArdourCanvas::GtkCanvasViewport (horizontal_adjustment, vertical_adjustment);
        _track_canvas = _track_canvas_viewport->canvas ();
+       _track_canvas->set_global_scroll (false);
+
+       hv_scroll_group = new ArdourCanvas::ScrollGroup (_track_canvas->root(), 
+                                                        ArdourCanvas::ScrollGroup::ScrollSensitivity (ArdourCanvas::ScrollGroup::ScrollsVertically|
+                                                                                                      ArdourCanvas::ScrollGroup::ScrollsHorizontally));
+       CANVAS_DEBUG_NAME (hv_scroll_group, "canvas hv scroll");
 
-       _time_bars_canvas_viewport = new ArdourCanvas::GtkCanvasViewport (horizontal_adjustment, unused_adjustment);
-       _time_bars_canvas = _time_bars_canvas_viewport->canvas ();
-       
        _verbose_cursor = new VerboseCursor (this);
 
        /* on the bottom, an image */
@@ -84,11 +84,11 @@ Editor::initialize_canvas ()
                // logo_item->property_width_in_pixels() = true;
                // logo_item->property_height_set() = true;
                // logo_item->property_width_set() = true;
-               logo_item->show ();
+               // logo_item->show ();
        }
-       
+
        /*a group to hold global rects like punch/loop indicators */
-       global_rect_group = new ArdourCanvas::Group (_track_canvas->root());
+       global_rect_group = new ArdourCanvas::Group (hv_scroll_group);
        CANVAS_DEBUG_NAME (global_rect_group, "global rect group");
 
         transport_loop_range_rect = new ArdourCanvas::Rectangle (global_rect_group, ArdourCanvas::Rect (0.0, 0.0, 0.0, ArdourCanvas::COORD_MAX));
@@ -100,14 +100,21 @@ Editor::initialize_canvas ()
        transport_punch_range_rect->hide();
 
        /*a group to hold time (measure) lines */
-       time_line_group = new ArdourCanvas::Group (_track_canvas->root());
+       time_line_group = new ArdourCanvas::Group (hv_scroll_group);
        CANVAS_DEBUG_NAME (time_line_group, "time line group");
 
-       _trackview_group = new ArdourCanvas::Group (_track_canvas->root());
+       _trackview_group = new ArdourCanvas::Group (hv_scroll_group);
+       //_trackview_group->set_scroll_sensitivity (ArdourCanvas::Group::ScrollSensitivity (ArdourCanvas::Group::ScrollsVertically|ArdourCanvas::Group::ScrollsHorizontally));  
        CANVAS_DEBUG_NAME (_trackview_group, "Canvas TrackViews");
+       
        _region_motion_group = new ArdourCanvas::Group (_trackview_group);
        CANVAS_DEBUG_NAME (_region_motion_group, "Canvas Region Motion");
 
+       /* TIME BAR CANVAS */
+       
+       _time_bars_canvas_viewport = new ArdourCanvas::GtkCanvasViewport (horizontal_adjustment, unused_adjustment);
+       _time_bars_canvas = _time_bars_canvas_viewport->canvas ();
+
        meter_bar_group = new ArdourCanvas::Group (_time_bars_canvas->root ());
        meter_bar = new ArdourCanvas::Rectangle (meter_bar_group, ArdourCanvas::Rect (0.0, 0.0, ArdourCanvas::COORD_MAX, timebar_height));
        CANVAS_DEBUG_NAME (meter_bar, "meter Bar");
@@ -175,14 +182,14 @@ Editor::initialize_canvas ()
        transport_bar_drag_rect->set_outline (false);
        transport_bar_drag_rect->hide ();
 
-       transport_punchin_line = new ArdourCanvas::Line (_track_canvas->root());
+       transport_punchin_line = new ArdourCanvas::Line (hv_scroll_group);
        transport_punchin_line->set_x0 (0);
        transport_punchin_line->set_y0 (0);
        transport_punchin_line->set_x1 (0);
        transport_punchin_line->set_y1 (ArdourCanvas::COORD_MAX);
        transport_punchin_line->hide ();
 
-       transport_punchout_line  = new ArdourCanvas::Line (_track_canvas->root());
+       transport_punchout_line  = new ArdourCanvas::Line (hv_scroll_group);
        transport_punchout_line->set_x0 (0);
        transport_punchout_line->set_y0 (0);
        transport_punchout_line->set_x1 (0);
@@ -190,12 +197,12 @@ Editor::initialize_canvas ()
        transport_punchout_line->hide();
 
        // used to show zoom mode active zooming
-       zoom_rect = new ArdourCanvas::Rectangle (_track_canvas->root(), ArdourCanvas::Rect (0.0, 0.0, 0.0, 0.0));
+       zoom_rect = new ArdourCanvas::Rectangle (hv_scroll_group, ArdourCanvas::Rect (0.0, 0.0, 0.0, 0.0));
        zoom_rect->hide();
        zoom_rect->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_zoom_rect_event), (ArdourCanvas::Item*) 0));
 
        // used as rubberband rect
-       rubberband_rect = new ArdourCanvas::Rectangle (_trackview_group, ArdourCanvas::Rect (0.0, 0.0, 0.0, 0.0));
+       rubberband_rect = new ArdourCanvas::Rectangle (hv_scroll_group, ArdourCanvas::Rect (0.0, 0.0, 0.0, 0.0));
        rubberband_rect->hide();
 
        tempo_bar->Event.connect (sigc::bind (sigc::mem_fun (*this, &Editor::canvas_tempo_bar_event), tempo_bar));
@@ -212,6 +219,13 @@ Editor::initialize_canvas ()
                logo_item->lower_to_bottom ();
        }
 
+
+       _canvas_bottom_rect = new ArdourCanvas::Rectangle (hv_scroll_group, ArdourCanvas::Rect (0.0, 0.0, ArdourCanvas::COORD_MAX, 20));
+       /* this thing is transparent */
+       _canvas_bottom_rect->set_fill (false);
+       _canvas_bottom_rect->set_outline (false);
+       _canvas_bottom_rect->Event.connect (sigc::mem_fun (*this, &Editor::canvas_bottom_rect_event));
+
        /* these signals will initially be delivered to the canvas itself, but if they end up remaining unhandled, they are passed to Editor-level
           handlers.
        */
@@ -255,10 +269,10 @@ void
 Editor::track_canvas_viewport_allocate (Gtk::Allocation alloc)
 {
        _canvas_viewport_allocation = alloc;
-       (void) track_canvas_viewport_size_allocated ();
+       track_canvas_viewport_size_allocated ();
 }
 
-bool
+void
 Editor::track_canvas_viewport_size_allocated ()
 {
        bool height_changed = _visible_canvas_height != _canvas_viewport_allocation.get_height();
@@ -289,8 +303,6 @@ Editor::track_canvas_viewport_size_allocated ()
        update_fixed_rulers();
        redisplay_tempo (false);
        _summary->set_overlays_dirty ();
-
-       return false;
 }
 
 void
@@ -318,12 +330,24 @@ Editor::reset_controls_layout_width ()
 void
 Editor::reset_controls_layout_height (int32_t h)
 {
+       /* ensure that the rect that represents the "bottom" of the canvas
+        * (the drag-n-drop zone) is, in fact, at the bottom.
+        */
+
+       _canvas_bottom_rect->set_position (ArdourCanvas::Duple (0, h));
+
+       /* track controls layout must span the full height of "h" (all tracks)
+        * plus the bottom rect.
+        */
+
+       h += _canvas_bottom_rect->height ();
+
         /* set the height of the scrollable area (i.e. the sum of all contained widgets)
+        * for the controls layout. The size request is set elsewhere.
          */
 
         controls_layout.property_height() = h;
 
-        /* size request is set elsewhere, see ::track_canvas_allocate() */
 }
 
 bool
@@ -463,7 +487,6 @@ Editor::maybe_autoscroll (bool allow_horiz, bool allow_vert, bool from_headers)
                return;
        }
 
-
        ArdourCanvas::Rect scrolling_boundary;
        Gtk::Allocation alloc;
        
@@ -572,8 +595,6 @@ Editor::autoscroll_canvas ()
 
                /* vertical */ 
                
-               new_pixel = vertical_pos;
-
                if (y < autoscroll_boundary.y0) {
 
                        /* scroll to make higher tracks visible */
@@ -912,7 +933,7 @@ Editor::get_time_bars_group () const
 ArdourCanvas::Group*
 Editor::get_track_canvas_group() const
 {
-       return _track_canvas->root();
+       return hv_scroll_group;
 }
 
 ArdourCanvas::GtkCanvasViewport*