+
+ if((agr = dynamic_cast<AudioGhostRegion*>(*i)) != 0) {
+ for (vector<WaveView*>::iterator w = agr->waves.begin(); w != agr->waves.end(); ++w) {
+ (*w)->property_data_src() = _region.get();
+ }
+ }
+ }
+
+}
+
+void
+AudioRegionView::color_handler ()
+{
+ //case cMutedWaveForm:
+ //case cWaveForm:
+ //case cWaveFormClip:
+ //case cZeroLine:
+ set_colors ();
+
+ //case cGainLineInactive:
+ //case cGainLine:
+ envelope_active_changed();
+
+}
+
+void
+AudioRegionView::set_frame_color ()
+{
+ if (!frame) {
+ return;
+ }
+
+ if (_region->opaque()) {
+ fill_opacity = 130;
+ } else {
+ fill_opacity = 0;
+ }
+
+ TimeAxisViewItem::set_frame_color ();
+
+ uint32_t wc;
+ uint32_t fc;
+
+ if (_selected) {
+ if (_region->muted()) {
+ wc = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_SelectedWaveForm.get(), MUTED_ALPHA);
+ } else {
+ wc = ARDOUR_UI::config()->canvasvar_SelectedWaveForm.get();
+ }
+ fc = ARDOUR_UI::config()->canvasvar_SelectedWaveFormFill.get();
+ } else {
+ if (_recregion) {
+ if (_region->muted()) {
+ wc = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_RecWaveForm.get(), MUTED_ALPHA);
+ } else {
+ wc = ARDOUR_UI::config()->canvasvar_RecWaveForm.get();
+ }
+ fc = ARDOUR_UI::config()->canvasvar_RecWaveFormFill.get();
+ } else {
+ if (_region->muted()) {
+ wc = UINT_RGBA_CHANGE_A(ARDOUR_UI::config()->canvasvar_WaveForm.get(), MUTED_ALPHA);
+ } else {
+ wc = ARDOUR_UI::config()->canvasvar_WaveForm.get();
+ }
+ fc = ARDOUR_UI::config()->canvasvar_WaveFormFill.get();
+ }
+ }
+
+ for (vector<ArdourCanvas::WaveView*>::iterator w = waves.begin(); w != waves.end(); ++w) {
+ if (_region->muted()) {
+ (*w)->property_wave_color() = wc;
+ } else {
+ (*w)->property_wave_color() = wc;
+ (*w)->property_fill_color() = fc;
+ }
+ }
+}
+
+void
+AudioRegionView::set_fade_visibility (bool yn)
+{
+ if (yn) {
+ if (fade_in_shape) {
+ fade_in_shape->show();
+ }
+ if (fade_out_shape) {
+ fade_out_shape->show ();
+ }
+ if (fade_in_handle) {
+ fade_in_handle->show ();
+ }
+ if (fade_out_handle) {
+ fade_out_handle->show ();
+ }
+ } else {
+ if (fade_in_shape) {
+ fade_in_shape->hide();
+ }
+ if (fade_out_shape) {
+ fade_out_shape->hide ();
+ }
+ if (fade_in_handle) {
+ fade_in_handle->hide ();
+ }
+ if (fade_out_handle) {
+ fade_out_handle->hide ();
+ }
+ }
+}
+
+void
+AudioRegionView::update_coverage_frames (LayerDisplay d)
+{
+ RegionView::update_coverage_frames (d);
+
+ if (fade_in_handle) {
+ fade_in_handle->raise_to_top ();
+ fade_out_handle->raise_to_top ();
+ }
+}
+
+void
+AudioRegionView::show_region_editor ()
+{
+ if (editor == 0) {
+ editor = new AudioRegionEditor (trackview.session(), audio_region());
+ }
+
+ editor->present ();
+ editor->show_all();
+}
+
+void
+AudioRegionView::transients_changed ()
+{
+ AnalysisFeatureList analysis_features = _region->transients();
+
+ while (feature_lines.size() < analysis_features.size()) {
+
+ ArdourCanvas::Line* canvas_item = new ArdourCanvas::Line(*group);
+
+ ArdourCanvas::Points points;
+
+ points.push_back(Gnome::Art::Point(-1.0, 2.0)); // first x-coord needs to be a non-normal value
+ points.push_back(Gnome::Art::Point(1.0, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1));
+
+ canvas_item->property_points() = points;
+ canvas_item->property_width_pixels() = 1;
+ canvas_item->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_ZeroLine.get();
+ canvas_item->property_first_arrowhead() = TRUE;
+ canvas_item->property_last_arrowhead() = TRUE;
+ canvas_item->property_arrow_shape_a() = 11.0;
+ canvas_item->property_arrow_shape_b() = 0.0;
+ canvas_item->property_arrow_shape_c() = 4.0;
+
+ canvas_item->raise_to_top ();
+ canvas_item->show ();
+
+ canvas_item->set_data ("regionview", this);
+ canvas_item->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_feature_line_event), canvas_item, this));
+
+ feature_lines.push_back (make_pair(0, canvas_item));
+ }
+
+ while (feature_lines.size() > analysis_features.size()) {
+ ArdourCanvas::Line* line = feature_lines.back().second;
+ feature_lines.pop_back ();
+ delete line;
+ }
+
+ AnalysisFeatureList::const_iterator i;
+ list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
+
+ for (i = analysis_features.begin(), l = feature_lines.begin(); i != analysis_features.end() && l != feature_lines.end(); ++i, ++l) {
+
+ ArdourCanvas::Points points;
+
+ float *pos = new float;
+ *pos = trackview.editor().frame_to_pixel (*i);
+
+ points.push_back(Gnome::Art::Point(*pos, 2.0)); // first x-coord needs to be a non-normal value
+ points.push_back(Gnome::Art::Point(*pos, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1));
+
+ (*l).second->property_points() = points;
+ (*l).second->set_data ("position", pos);
+
+ (*l).first = *i;
+ }
+}
+
+void
+AudioRegionView::update_transient(float /*old_pos*/, float new_pos)
+{
+ /* Find frame at old pos, calulate new frame then update region transients*/
+ list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
+
+ for (l = feature_lines.begin(); l != feature_lines.end(); ++l) {
+
+ /* Line has been updated in drag so we compare to new_pos */
+
+ float* pos = (float*) (*l).second->get_data ("position");
+
+ if (rint(new_pos) == rint(*pos)) {
+
+ framepos_t old_frame = (*l).first;
+ framepos_t new_frame = trackview.editor().pixel_to_frame (new_pos);
+
+ _region->update_transient (old_frame, new_frame);
+
+ break;
+ }
+ }
+}
+
+void
+AudioRegionView::remove_transient(float pos)
+{
+ /* Find frame at old pos, calulate new frame then update region transients*/
+ list<std::pair<framepos_t, ArdourCanvas::Line*> >::iterator l;
+
+ for (l = feature_lines.begin(); l != feature_lines.end(); ++l) {
+
+ /* Line has been updated in drag so we compare to new_pos */
+ float *line_pos = (float*) (*l).second->get_data ("position");
+
+ if (rint(pos) == rint(*line_pos)) {
+ _region->remove_transient ((*l).first);
+ break;
+ }
+ }
+}
+
+void
+AudioRegionView::thaw_after_trim ()
+{
+ RegionView::thaw_after_trim ();
+ unhide_envelope ();
+ drag_end ();
+}
+
+void
+AudioRegionView::redraw_start_xfade ()
+{
+ boost::shared_ptr<AudioRegion> ar (audio_region());
+
+ if (!ar->fade_in() || ar->fade_in()->empty()) {
+ return;
+ }
+
+ show_start_xfade();
+
+ redraw_start_xfade_to (ar, ar->fade_in()->back()->when);
+}
+
+void
+AudioRegionView::redraw_start_xfade_to (boost::shared_ptr<AudioRegion> ar, framecnt_t len)
+{
+ int32_t const npoints = trackview.editor().frame_to_pixel (len);
+
+ if (npoints < 3) {
+ return;
+ }
+
+ if (!start_xfade_in) {
+ start_xfade_in = new ArdourCanvas::Line (*group);
+ start_xfade_in->property_width_pixels() = 1;
+ start_xfade_in->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_GainLine.get();
+ }
+
+ if (!start_xfade_out) {
+ start_xfade_out = new ArdourCanvas::Line (*group);
+ start_xfade_out->property_width_pixels() = 1;
+ uint32_t col = UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->canvasvar_GainLine.get(), 128);
+ start_xfade_out->property_fill_color_rgba() = col;
+ }
+
+ if (!start_xfade_rect) {
+ start_xfade_rect = new ArdourCanvas::SimpleRect (*group);
+ start_xfade_rect->property_draw() = true;
+ start_xfade_rect->property_fill() = true;;
+ start_xfade_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_ActiveCrossfade.get();
+ start_xfade_rect->property_outline_pixels() = 0;
+ start_xfade_rect->signal_event().connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_start_xfade_event), start_xfade_rect, this));
+ start_xfade_rect->set_data ("regionview", this);
+ }
+
+ Points* points = get_canvas_points ("xfade edit redraw", npoints);
+ boost::scoped_array<float> vec (new float[npoints]);
+
+ double effective_height;
+ if (_height >= NAME_HIGHLIGHT_THRESH) {
+ effective_height = _height - NAME_HIGHLIGHT_SIZE - 2;
+ } else {
+ effective_height = _height - 2;
+ }
+
+ ar->fade_in()->curve().get_vector (0, ar->fade_in()->back()->when, vec.get(), npoints);
+
+ for (int i = 0, pci = 0; i < npoints; ++i) {
+ Gnome::Art::Point &p ((*points)[pci++]);
+ p.set_x (i);
+ p.set_y (1.0 + effective_height - (effective_height * vec.get()[i]));
+ }
+
+ start_xfade_rect->property_x1() = ((*points)[0]).get_x();
+ start_xfade_rect->property_y1() = 1.0;
+ start_xfade_rect->property_x2() = ((*points)[npoints-1]).get_x();
+ start_xfade_rect->property_y2() = effective_height;
+ start_xfade_rect->show ();
+
+ start_xfade_in->property_points() = *points;
+ start_xfade_in->show ();
+ start_xfade_in->raise_to_top ();
+
+ /* fade out line */
+
+ boost::shared_ptr<AutomationList> inverse = ar->inverse_fade_in();
+
+ if (!inverse) {
+
+ for (int i = 0, pci = 0; i < npoints; ++i) {
+ Gnome::Art::Point &p ((*points)[pci++]);
+ p.set_x (i);
+ p.set_y (1.0 + effective_height - (effective_height * (1.0 - vec.get()[i])));