fix message about markup elements by changing accel strings from <Mod> to Mod-
[ardour.git] / gtk2_ardour / audio_streamview.cc
index 1bf1855167d5d7f45be82f79fbdc75a8aa14d983..a69f398ef45d0ac96c14196c04d44cb4f0d55967 100644 (file)
@@ -61,7 +61,7 @@ using namespace Editing;
 AudioStreamView::AudioStreamView (AudioTimeAxisView& tv)
        : StreamView (tv)
 {
-       crossfades_visible = true;
+       crossfades_visible = tv.session()->config.get_xfades_visible ();
        color_handler ();
        _amplitude_above_axis = 1.0;
 
@@ -70,6 +70,9 @@ AudioStreamView::AudioStreamView (AudioTimeAxisView& tv)
 
 AudioStreamView::~AudioStreamView ()
 {
+       for (CrossfadeViewList::iterator xi = crossfade_views.begin(); xi != crossfade_views.end(); ++xi) {
+               delete xi->second;
+       }
 }
 
 int
@@ -121,7 +124,7 @@ AudioStreamView::create_region_view (boost::shared_ptr<Region> r, bool wait_for_
                if (recording) {
                        region_view = new AudioRegionView (_canvas_group, _trackview, region,
                                        _samples_per_unit, region_color, recording, TimeAxisViewItem::Visibility(
-                                                       TimeAxisViewItem::ShowFrame | 
+                                                       TimeAxisViewItem::ShowFrame |
                                                        TimeAxisViewItem::HideFrameRight |
                                                        TimeAxisViewItem::HideFrameLeft |
                                                        TimeAxisViewItem::HideFrameTB));
@@ -163,7 +166,7 @@ RegionView*
 AudioStreamView::add_region_view_internal (boost::shared_ptr<Region> r, bool wait_for_waves, bool recording)
 {
        RegionView *region_view = create_region_view (r, wait_for_waves, recording);
-       
+
        if (region_view == 0) {
                return 0;
        }
@@ -191,6 +194,12 @@ AudioStreamView::add_region_view_internal (boost::shared_ptr<Region> r, bool wai
 
        region_views.push_front (region_view);
 
+        if (_trackview.editor().internal_editing()) {
+                region_view->hide_rect ();
+        } else {
+                region_view->show_rect ();
+        }
+
        /* catch region going away */
 
        r->DropReferences.connect (*this, invalidator (*this), boost::bind (&AudioStreamView::remove_region_view, this, boost::weak_ptr<Region> (r)), gui_context());
@@ -329,7 +338,7 @@ AudioStreamView::add_crossfade (boost::weak_ptr<Crossfade> wc)
        cv->set_valid (true);
        crossfade->Invalidated.connect (*this, invalidator (*this), ui_bind (&AudioStreamView::remove_crossfade, this, _1), gui_context());
        crossfade_views[cv->crossfade] = cv;
-       if (!_trackview.session()->config.get_xfades_visible() || !crossfades_visible) {
+       if (!crossfades_visible) {
                cv->hide ();
        }
 
@@ -463,22 +472,22 @@ AudioStreamView::setup_rec_box ()
                                        if (src) {
                                                sources.push_back (src);
                                                src->PeakRangeReady.connect (rec_data_ready_connections,
-                                                                             invalidator (*this),
-                                                                            ui_bind (&AudioStreamView::rec_peak_range_ready, this, _1, _2, boost::weak_ptr<Source>(src)),
-                                                                            gui_context());
+                                                                            invalidator (*this),
+                                                                            ui_bind (&AudioStreamView::rec_peak_range_ready, this, _1, _2, boost::weak_ptr<Source>(src)),
+                                                                            gui_context());
                                        }
                                }
 
                                // handle multi
 
-                               nframes_t start = 0;
+                               framepos_t start = 0;
                                if (rec_regions.size() > 0) {
                                        start = rec_regions.back().first->start()
                                                        + _trackview.track()->get_captured_frames(rec_regions.size()-1);
                                }
 
-                               PropertyList plist; 
-                               
+                               PropertyList plist;
+
                                plist.add (Properties::start, start);
                                plist.add (Properties::length, 1);
                                plist.add (Properties::name, string());
@@ -488,8 +497,7 @@ AudioStreamView::setup_rec_box ()
                                        boost::dynamic_pointer_cast<AudioRegion>(RegionFactory::create (sources, plist, false)));
 
                                assert(region);
-                               region->block_property_changes ();
-                               region->set_position (_trackview.session()->transport_frame(), this);
+                               region->set_position (_trackview.session()->transport_frame());
                                rec_regions.push_back (make_pair(region, (RegionView*) 0));
                        }
 
@@ -498,7 +506,7 @@ AudioStreamView::setup_rec_box ()
                        boost::shared_ptr<AudioTrack> at;
 
                        at = _trackview.audio_track(); /* we know what it is already */
-                       nframes_t frame_pos = at->current_capture_start ();
+                       framepos_t const frame_pos = at->current_capture_start ();
                        gdouble xstart = _trackview.editor().frame_to_pixel (frame_pos);
                        gdouble xend;
                        uint32_t fill_color;
@@ -601,7 +609,7 @@ AudioStreamView::foreach_crossfadeview (void (CrossfadeView::*pmf)(void))
 }
 
 void
-AudioStreamView::rec_peak_range_ready (nframes_t start, nframes_t cnt, boost::weak_ptr<Source> weak_src)
+AudioStreamView::rec_peak_range_ready (framepos_t start, framecnt_t cnt, boost::weak_ptr<Source> weak_src)
 {
        ENSURE_GUI_THREAD (*this, &AudioStreamView::rec_peak_range_ready, start, cnt, weak_src)
 
@@ -620,74 +628,80 @@ AudioStreamView::rec_peak_range_ready (nframes_t start, nframes_t cnt, boost::we
        rec_data_ready_map[src] = true;
 
        if (rec_data_ready_map.size() == _trackview.track()->n_channels().n_audio()) {
-               this->update_rec_regions ();
+               update_rec_regions (start, cnt);
                rec_data_ready_map.clear();
        }
 }
 
 void
-AudioStreamView::update_rec_regions ()
+AudioStreamView::update_rec_regions (framepos_t start, framecnt_t cnt)
 {
-       if (Config->get_show_waveforms_while_recording ()) {
-               uint32_t n = 0;
+       if (!Config->get_show_waveforms_while_recording ()) {
+               return;
+       }
 
-               for (list<pair<boost::shared_ptr<Region>,RegionView*> >::iterator iter = rec_regions.begin();
-                               iter != rec_regions.end(); n++) {
+       uint32_t n = 0;
 
-                       list<pair<boost::shared_ptr<Region>,RegionView*> >::iterator tmp = iter;
-                       ++tmp;
+       for (list<pair<boost::shared_ptr<Region>,RegionView*> >::iterator iter = rec_regions.begin(); iter != rec_regions.end(); n++) {
 
-                       if (!canvas_item_visible (rec_rects[n].rectangle)) {
-                               /* rect already hidden, this region is done */
-                               iter = tmp;
-                               continue;
-                       }
+               list<pair<boost::shared_ptr<Region>,RegionView*> >::iterator tmp = iter;
+               ++tmp;
 
-                       boost::shared_ptr<AudioRegion> region = boost::dynamic_pointer_cast<AudioRegion>(iter->first);
-                       
-                       if (!region) {
-                               iter = tmp;
-                               continue;
-                       }
+               assert (n < rec_rects.size());
 
-                       nframes_t origlen = region->length();
+               if (!canvas_item_visible (rec_rects[n].rectangle)) {
+                       /* rect already hidden, this region is done */
+                       iter = tmp;
+                       continue;
+               }
 
-                       if (region == rec_regions.back().first && rec_active) {
+               boost::shared_ptr<AudioRegion> region = boost::dynamic_pointer_cast<AudioRegion>(iter->first);
 
-                               if (last_rec_data_frame > region->start()) {
+               if (!region) {
+                       iter = tmp;
+                       continue;
+               }
 
-                                       nframes_t nlen = last_rec_data_frame - region->start();
+               framecnt_t origlen = region->length();
 
-                                       if (nlen != region->length()) {
+               if (region == rec_regions.back().first && rec_active) {
 
-                                               region->suspend_property_changes ();
-                                               region->set_position (_trackview.track()->get_capture_start_frame(n), this);
-                                               region->set_length (nlen, this);
-                                               region->resume_property_changes ();
+                       if (last_rec_data_frame > region->start()) {
 
-                                               if (origlen == 1) {
-                                                       /* our special initial length */
-                                                       add_region_view_internal (region, false, true);
-                                               }
+                               framecnt_t nlen = last_rec_data_frame - region->start();
+
+                               if (nlen != region->length()) {
 
-                                               /* also update rect */
-                                               ArdourCanvas::SimpleRect * rect = rec_rects[n].rectangle;
-                                               gdouble xend = _trackview.editor().frame_to_pixel (region->position() + region->length());
-                                               rect->property_x2() = xend;
+                                       region->suspend_property_changes ();
+                                       region->set_position (_trackview.track()->get_capture_start_frame(n));
+                                       region->set_length (nlen);
+                                       region->resume_property_changes ();
+
+                                       if (origlen == 1) {
+                                               /* our special initial length */
+                                               add_region_view_internal (region, false, true);
+                                               setup_new_rec_layer_time (region);
                                        }
+
+                                       check_record_layers (region, (region->position() - region->start() + start + cnt));
+
+                                       /* also update rect */
+                                       ArdourCanvas::SimpleRect * rect = rec_rects[n].rectangle;
+                                       gdouble xend = _trackview.editor().frame_to_pixel (region->position() + region->length());
+                                       rect->property_x2() = xend;
                                }
 
                        } else {
 
-                               nframes_t nlen = _trackview.track()->get_captured_frames(n);
+                               framecnt_t nlen = _trackview.track()->get_captured_frames(n);
 
                                if (nlen != region->length()) {
 
                                        if (region->source_length(0) >= region->start() + nlen) {
 
                                                region->suspend_property_changes ();
-                                               region->set_position (_trackview.track()->get_capture_start_frame(n), this);
-                                               region->set_length (nlen, this);
+                                               region->set_position (_trackview.track()->get_capture_start_frame(n));
+                                               region->set_length (nlen);
                                                region->resume_property_changes ();
 
                                                if (origlen == 1) {
@@ -702,9 +716,9 @@ AudioStreamView::update_rec_regions ()
                                        }
                                }
                        }
-
-                       iter = tmp;
                }
+
+               iter = tmp;
        }
 }
 
@@ -795,8 +809,6 @@ AudioStreamView::update_contents_height ()
 void
 AudioStreamView::update_content_height (CrossfadeView* cv)
 {
-       cv->show ();
-
        if (_layer_display == Overlaid) {
 
                cv->set_y (0);
@@ -829,3 +841,14 @@ AudioStreamView::parameter_changed (string const & p)
                set_waveform_shape (Config->get_waveform_shape ());
        }
 }
+
+void
+AudioStreamView::horizontal_position_changed ()
+{
+       /* we only `draw' the bit of the curve that is visible, so we need to update here */
+
+       for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) {
+               i->second->horizontal_position_changed ();
+       }
+}
+