Fixed some valgrind errors from using uninitialized variables in
[ardour.git] / gtk2_ardour / streamview.cc
index f6426836f1bb3a698a58633911543b9d88bb6d51..bceaf09f99a5e21063e34ea26b5e6bf1da836842 100644 (file)
@@ -275,7 +275,7 @@ StreamView::remove_rec_region (Region *r)
 {
        ENSURE_GUI_THREAD(bind (mem_fun (*this, &StreamView::remove_rec_region), r));
        
-       if (!Gtkmm2ext::UI::instance()->caller_is_gui_thread()) {
+       if (!Gtkmm2ext::UI::instance()->caller_is_ui_thread()) {
                fatal << "region deleted from non-GUI thread!" << endmsg;
                /*NOTREACHED*/
        } 
@@ -535,6 +535,7 @@ StreamView::set_selected_regionviews (AudioRegionSelection& regions)
 {
        bool selected;
 
+       // cerr << _trackview.name() << " (selected = " << regions.size() << ")" << endl;
        for (list<AudioRegionView*>::iterator i = region_views.begin(); i != region_views.end(); ++i) {
                
                selected = false;
@@ -545,6 +546,7 @@ StreamView::set_selected_regionviews (AudioRegionSelection& regions)
                        }
                }
                
+               // cerr << "\tregion " << (*i)->region.name() << " selected = " << selected << endl;
                (*i)->set_selected (selected, this);
        }
 }
@@ -616,11 +618,12 @@ StreamView::setup_rec_box ()
 
                // cerr << "\trolling\n";
 
-               if (!rec_active
-                   && _trackview.session().record_status() == Session::Recording
-                   && _trackview.get_diskstream()->record_enabled()) {
+               if (!rec_active && 
+                   _trackview.session().record_status() == Session::Recording && 
+                   _trackview.get_diskstream()->record_enabled()) {
+
+                       if (_trackview.audio_track()->mode() == Normal && use_rec_regions && rec_regions.size() == rec_rects.size()) {
 
-                       if (use_rec_regions && rec_regions.size() == rec_rects.size()) {
                                /* add a new region, but don't bother if they set use_rec_regions mid-record */
 
                                AudioRegion::SourceList sources;
@@ -662,7 +665,24 @@ StreamView::setup_rec_box ()
                        DiskStream& ds = at->disk_stream();
                        jack_nframes_t frame_pos = ds.current_capture_start ();
                        gdouble xstart = _trackview.editor.frame_to_pixel (frame_pos);
-                       gdouble xend = xstart;
+                       gdouble xend;
+                       uint32_t fill_color;
+
+                       switch (_trackview.audio_track()->mode()) {
+                       case Normal:
+                               xend = xstart;
+                               fill_color = color_map[cRecordingRectFill];
+                               break;
+
+                       case Destructive:
+                               xend = xstart + 2;
+                               fill_color = color_map[cRecordingRectFill];
+                               /* make the recording rect translucent to allow
+                                  the user to see the peak data coming in, etc.
+                               */
+                               fill_color = UINT_RGBA_CHANGE_A (fill_color, 120);
+                               break;
+                       }
                        
                        ArdourCanvas::SimpleRect * rec_rect = new Gnome::Canvas::SimpleRect (*canvas_group);
                        rec_rect->property_x1() = xstart;
@@ -670,7 +690,7 @@ StreamView::setup_rec_box ()
                        rec_rect->property_x2() = xend;
                        rec_rect->property_y2() = (double) _trackview.height - 1;
                        rec_rect->property_outline_color_rgba() = color_map[cRecordingRectOutline];
-                       rec_rect->property_fill_color_rgba() =  color_map[cRecordingRectFill];
+                       rec_rect->property_fill_color_rgba() = fill_color;
                        
                        RecBoxInfo recbox;
                        recbox.rectangle = rec_rect;
@@ -747,21 +767,32 @@ StreamView::setup_rec_box ()
 void
 StreamView::update_rec_box ()
 {
-       /* only update the last box */
        if (rec_active && rec_rects.size() > 0) {
+               /* only update the last box */
                RecBoxInfo & rect = rec_rects.back();
                jack_nframes_t at = _trackview.get_diskstream()->current_capture_end();
+               double xstart;
+               double xend;
+               
+               switch (_trackview.audio_track()->mode()) {
+               case Normal:
+                       rect.length = at - rect.start;
+                       xstart = _trackview.editor.frame_to_pixel (rect.start);
+                       xend = _trackview.editor.frame_to_pixel (at);
+                       break;
+                       
+               case Destructive:
+                       rect.length = 2;
+                       xstart = _trackview.editor.frame_to_pixel (_trackview.get_diskstream()->current_capture_start());
+                       xend = _trackview.editor.frame_to_pixel (at);
+                       break;
+               }
                
-               rect.length = at - rect.start;
-
-               gdouble xstart = _trackview.editor.frame_to_pixel ( rect.start );
-               gdouble xend = _trackview.editor.frame_to_pixel ( at );
-
                rect.rectangle->property_x1() = xstart;
                rect.rectangle->property_x2() = xend;
        }
 }
-
+       
 AudioRegionView*
 StreamView::find_view (const AudioRegion& region)
 {