Visual tweaks to Soundcloud panel
[ardour.git] / gtk2_ardour / streamview.cc
index 065f6b711c20c6651b0a1474698cb70e82f5e4c2..404b934562b60cf0d53d50db33247b8c24f843b4 100644 (file)
 #include "gui_thread.h"
 #include "utils.h"
 
+#include "i18n.h"
+
 using namespace std;
 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, ArdourCanvas::Group* canvas_group)
        : _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 ())
+       , _samples_per_pixel (_trackview.editor().get_current_zoom ())
        , rec_updating(false)
        , rec_active(false)
        , stream_base_color(0xFFFFFFFF)
        , _layers (1)
        , _layer_display (Overlaid)
-       , height(tv.height)
+       , height (tv.height)
        , last_rec_data_frame(0)
 {
-       CANVAS_DEBUG_NAME (_background_group, string_compose ("SV background group %1", _trackview.name()));
        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_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::BOTTOM);
        canvas_rect->set_outline_color (RGBA_TO_UINT (0, 0, 0, 255));
-
-       canvas_rect->Event.connect (sigc::bind (
-                       sigc::mem_fun (_trackview.editor(), &PublicEditor::canvas_stream_view_event),
-                       canvas_rect, &_trackview));
+       canvas_rect->set_fill (true);
+       canvas_rect->Event.connect (sigc::bind (sigc::mem_fun (_trackview.editor(), &PublicEditor::canvas_stream_view_event), canvas_rect, &_trackview));
 
        if (_trackview.is_track()) {
                _trackview.track()->DiskstreamChanged.connect (*this, invalidator (*this), boost::bind (&StreamView::diskstream_changed, this), gui_context());
@@ -99,14 +93,6 @@ StreamView::~StreamView ()
        undisplay_track ();
 
        delete canvas_rect;
-
-       if (owns_background_group) {
-               delete _background_group;
-       }
-
-       if (owns_canvas_group) {
-               delete _canvas_group;
-       }
 }
 
 void
@@ -144,7 +130,7 @@ StreamView::set_height (double h)
 }
 
 int
-StreamView::set_frames_per_pixel (double fpp)
+StreamView::set_samples_per_pixel (double fpp)
 {
        RegionViewList::iterator i;
 
@@ -152,17 +138,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);
@@ -426,15 +412,20 @@ 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;
+
+               default:
+                       fatal << string_compose (_("programming error: %1"), "illegal track mode") << endmsg;
+                       /*NOTREACHED*/
+                       return;
                }
 
                rect.rectangle->set_x0 (xstart);