make middle-click on piano roll track header more usefully select/unselect notes
[ardour.git] / gtk2_ardour / streamview.cc
index db6f60f3b0187fa38bd78c0ba0df9ec5489dbeaa..8239bca2f4a84e0a92e17f87cf2c103ef0510c59 100644 (file)
@@ -28,6 +28,8 @@
 #include "ardour/track.h"
 #include "ardour/session.h"
 
+#include "pbd/compose.h"
+
 #include "canvas/rectangle.h"
 #include "canvas/debug.h"
 
@@ -48,13 +50,10 @@ using namespace ARDOUR;
 using namespace PBD;
 using namespace Editing;
 
-StreamView::StreamView (RouteTimeAxisView& tv, ArdourCanvas::Group* background_group, ArdourCanvas::Group* canvas_group)
+StreamView::StreamView (RouteTimeAxisView& tv)
        : _trackview (tv)
-       , owns_background_group (background_group == 0)
-       , owns_canvas_group (canvas_group == 0)
-       , _background_group (background_group ? background_group : new ArdourCanvas::Group (_trackview.canvas_background()))
-       , _canvas_group (canvas_group ? canvas_group : new ArdourCanvas::Group (_trackview.canvas_display()))
-       , _frames_per_pixel (_trackview.editor().get_current_zoom ())
+       , _canvas_group (new ArdourCanvas::Group (_trackview.canvas_display()))
+       , _samples_per_pixel (_trackview.editor().get_current_zoom ())
        , rec_updating(false)
        , rec_active(false)
        , stream_base_color(0xFFFFFFFF)
@@ -63,18 +62,19 @@ StreamView::StreamView (RouteTimeAxisView& tv, ArdourCanvas::Group* background_g
        , height(tv.height)
        , last_rec_data_frame(0)
 {
-       CANVAS_DEBUG_NAME (_background_group, "SV background group");
-       CANVAS_DEBUG_NAME (_canvas_group, "SV canvas group");
+       CANVAS_DEBUG_NAME (_canvas_group, string_compose ("SV canvas group %1", _trackview.name()));
        
        /* set_position() will position the group */
 
-       canvas_rect = new ArdourCanvas::Rectangle (_background_group);
-       CANVAS_DEBUG_NAME (canvas_rect, "SV canvas rectangle");
+       canvas_rect = new ArdourCanvas::Rectangle (_canvas_group);
+       CANVAS_DEBUG_NAME (canvas_rect, string_compose ("SV canvas rectangle %1", _trackview.name()));
        canvas_rect->set (ArdourCanvas::Rect (0, 0, ArdourCanvas::COORD_MAX, tv.current_height ()));
        canvas_rect->raise(1); // raise above tempo lines
 
-       canvas_rect->set_outline_what (0x2 | 0x8);
+       canvas_rect->set_outline_what (ArdourCanvas::Rectangle::What (ArdourCanvas::Rectangle::TOP | ArdourCanvas::Rectangle::BOTTOM));
        canvas_rect->set_outline_color (RGBA_TO_UINT (0, 0, 0, 255));
+       canvas_rect->set_fill_color (RGBA_TO_UINT (1.0, 0, 0, 255));
+       canvas_rect->set_fill (true);
 
        canvas_rect->Event.connect (sigc::bind (
                        sigc::mem_fun (_trackview.editor(), &PublicEditor::canvas_stream_view_event),
@@ -97,14 +97,6 @@ StreamView::~StreamView ()
        undisplay_track ();
 
        delete canvas_rect;
-
-       if (owns_background_group) {
-               delete _background_group;
-       }
-
-       if (owns_canvas_group) {
-               delete _canvas_group;
-       }
 }
 
 void
@@ -142,7 +134,7 @@ StreamView::set_height (double h)
 }
 
 int
-StreamView::set_frames_per_pixel (double fpp)
+StreamView::set_samples_per_pixel (double fpp)
 {
        RegionViewList::iterator i;
 
@@ -150,17 +142,17 @@ StreamView::set_frames_per_pixel (double fpp)
                return -1;
        }
 
-       _frames_per_pixel = fpp;
+       _samples_per_pixel = fpp;
 
        for (i = region_views.begin(); i != region_views.end(); ++i) {
-               (*i)->set_frames_per_pixel (fpp);
+               (*i)->set_samples_per_pixel (fpp);
        }
 
        for (vector<RecBoxInfo>::iterator xi = rec_rects.begin(); xi != rec_rects.end(); ++xi) {
                RecBoxInfo &recbox = (*xi);
 
-               ArdourCanvas::Coord const xstart = _trackview.editor().frame_to_pixel (recbox.start);
-               ArdourCanvas::Coord const xend = _trackview.editor().frame_to_pixel (recbox.start + recbox.length);
+               ArdourCanvas::Coord const xstart = _trackview.editor().sample_to_pixel (recbox.start);
+               ArdourCanvas::Coord const xend = _trackview.editor().sample_to_pixel (recbox.start + recbox.length);
 
                recbox.rectangle->set_x0 (xstart);
                recbox.rectangle->set_x1 (xend);
@@ -424,14 +416,14 @@ StreamView::update_rec_box ()
                case NonLayered:
                case Normal:
                        rect.length = at - rect.start;
-                       xstart = _trackview.editor().frame_to_pixel (rect.start);
-                       xend = _trackview.editor().frame_to_pixel (at);
+                       xstart = _trackview.editor().sample_to_pixel (rect.start);
+                       xend = _trackview.editor().sample_to_pixel (at);
                        break;
 
                case Destructive:
                        rect.length = 2;
-                       xstart = _trackview.editor().frame_to_pixel (_trackview.track()->current_capture_start());
-                       xend = _trackview.editor().frame_to_pixel (at);
+                       xstart = _trackview.editor().sample_to_pixel (_trackview.track()->current_capture_start());
+                       xend = _trackview.editor().sample_to_pixel (at);
                        break;
                }
 
@@ -609,7 +601,7 @@ StreamView::update_contents_height ()
                case Expanded:
                        /* In stacked displays, the recregion is always at the top */
                        i->rectangle->set_y0 (0);
-                       i->rectangle->set_y1 (h)
+                       i->rectangle->set_y1 (h);
                        break;
                }
        }