-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::PolyLine (group);
- // CAIROCANVAS
- // start_xfade_in->set_width_pixels (1);
- start_xfade_in->set_outline_color (ARDOUR_UI::config()->canvasvar_GainLine.get());
- }
-
- if (!start_xfade_out) {
- start_xfade_out = new ArdourCanvas::PolyLine (group);
- // CAIROCANVAS
- // start_xfade_out->set_width_pixels (1);
- uint32_t col = UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->canvasvar_GainLine.get(), 128);
- start_xfade_out->set_outline_color (col);
- }
-
- if (!start_xfade_rect) {
- start_xfade_rect = new ArdourCanvas::Rectangle (group);
- // CAIROCANVAS
- // start_xfade_rect->property_draw() = true;
- start_xfade_rect->set_fill (true);
- start_xfade_rect->set_fill_color (ARDOUR_UI::config()->canvasvar_ActiveCrossfade.get());
- start_xfade_rect->set_outline (false);
- start_xfade_rect->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);
- }
-
- ArdourCanvas::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) {
- ArdourCanvas::Duple &p ((*points)[pci++]);
- p.x = i;
- p.y = 1.0 + effective_height - (effective_height * vec.get()[i]);
- }
-
- start_xfade_rect->set (ArdourCanvas::Rect (((*points)[0]).x, 1.0, ((*points)[npoints-1]).x, effective_height));
- start_xfade_rect->show ();
-
- start_xfade_in->set (*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) {
- ArdourCanvas::Duple &p ((*points)[pci++]);
- p.x = i;
- p.y = 1.0 + effective_height - (effective_height * (1.0 - vec.get()[i]));
- }
-
- } else {
-
- inverse->curve().get_vector (0, inverse->back()->when, vec.get(), npoints);
-
- for (int i = 0, pci = 0; i < npoints; ++i) {
- ArdourCanvas::Duple &p ((*points)[pci++]);
- p.x = i;
- p.y = 1.0 + effective_height - (effective_height * vec.get()[i]);
- }
- }
-
- start_xfade_out->set (*points);
- start_xfade_out->show ();
- start_xfade_out->raise_to_top ();
-
- start_xfade_rect->raise_to_top (); //this needs to be topmost so the lines don't steal mouse focus
-
- show_start_xfade();
-
- delete points;
-}
-
-void
-AudioRegionView::redraw_end_xfade ()
-{
- boost::shared_ptr<AudioRegion> ar (audio_region());
-
- if (!ar->fade_out() || ar->fade_out()->empty()) {
- return;
- }
-
- show_end_xfade();
-
- redraw_end_xfade_to (ar, ar->fade_out()->back()->when);
-}
-
-void
-AudioRegionView::redraw_end_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 (!end_xfade_in) {
- end_xfade_in = new ArdourCanvas::PolyLine (group);
- // CAIROCANVAS
- // end_xfade_in->property_width_pixels() = 1;
- end_xfade_in->set_outline_color (ARDOUR_UI::config()->canvasvar_GainLine.get());
- }
-
- if (!end_xfade_out) {
- end_xfade_out = new ArdourCanvas::PolyLine (group);
- // CAIROCANVAS
- // end_xfade_out->property_width_pixels() = 1;
- uint32_t col UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->canvasvar_GainLine.get(), 128);
- end_xfade_out->set_outline_color (col);
- }
-
- if (!end_xfade_rect) {
- end_xfade_rect = new ArdourCanvas::Rectangle (group);
- // CAIROCANVAS
- // end_xfade_rect->property_draw() = true;
- end_xfade_rect->set_fill (true);
- end_xfade_rect->set_fill_color (ARDOUR_UI::config()->canvasvar_ActiveCrossfade.get());
- end_xfade_rect->set_outline (0);
- end_xfade_rect->Event.connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_end_xfade_event), end_xfade_rect, this));
- end_xfade_rect->set_data ("regionview", this);
- }
-
- Points* points = get_canvas_points ("xfade edit redraw", npoints);
- boost::scoped_array<float> vec (new float[npoints]);
-
- ar->fade_out()->curve().get_vector (0, ar->fade_out()->back()->when, vec.get(), npoints);
-
- double rend = trackview.editor().frame_to_pixel (_region->length() - len);
-
- double effective_height;
- if (_height >= NAME_HIGHLIGHT_THRESH) {
- effective_height = _height - NAME_HIGHLIGHT_SIZE - 2;
- } else {
- effective_height = _height - 2;
- }
-
- for (int i = 0, pci = 0; i < npoints; ++i) {
- ArdourCanvas::Duple &p ((*points)[pci++]);
- p.x = rend + i;
- p.y = 1.0 + effective_height - (effective_height * vec.get()[i]);
- }
-
- end_xfade_rect->set (ArdourCanvas::Rect (((*points)[0]).x, 1.0, ((*points)[npoints-1]).x, effective_height));
- end_xfade_rect->show ();
-
- end_xfade_in->set (*points);
- end_xfade_in->show ();
- end_xfade_in->raise_to_top ();
-
- /* fade in line */
-
- boost::shared_ptr<AutomationList> inverse = ar->inverse_fade_out ();
-
- if (!inverse) {
-
- for (int i = 0, pci = 0; i < npoints; ++i) {
- ArdourCanvas::Duple &p ((*points)[pci++]);
- p.x = rend + i;
- p.y = 1.0 + effective_height - (effective_height * (1.0 - vec.get()[i]));
- }
-
- } else {
-
- inverse->curve().get_vector (inverse->front()->when, inverse->back()->when, vec.get(), npoints);
-
- for (int i = 0, pci = 0; i < npoints; ++i) {
- ArdourCanvas::Duple &p ((*points)[pci++]);
- p.x = rend + i;
- p.y = 1.0 + effective_height - (effective_height * vec.get()[i]);
- }
- }
-
- end_xfade_out->set (*points);
- end_xfade_out->show ();
- end_xfade_out->raise_to_top ();
-
- end_xfade_rect->raise_to_top (); //this needs to be topmost so the lines don't steal mouse focus
-
- show_end_xfade();
-
- delete points;
-}
-
-void
-AudioRegionView::hide_xfades ()
-{
- hide_start_xfade ();
- hide_end_xfade ();
-}
-
-void
-AudioRegionView::hide_start_xfade ()
-{
- if (start_xfade_in) {
- start_xfade_in->hide();
- }
- if (start_xfade_out) {
- start_xfade_out->hide();
- }
- if (start_xfade_rect) {
- start_xfade_rect->hide ();
- }
-
- _start_xfade_visible = false;
-}
-
-void
-AudioRegionView::hide_end_xfade ()
-{
- if (end_xfade_in) {
- end_xfade_in->hide();
- }
- if (end_xfade_out) {
- end_xfade_out->hide();
- }
- if (end_xfade_rect) {
- end_xfade_rect->hide ();
- }
-
- _end_xfade_visible = false;
-}
-
-void
-AudioRegionView::show_start_xfade ()
-{
- if (start_xfade_in) {
- start_xfade_in->show();
- }
- if (start_xfade_out) {
- start_xfade_out->show();
- }
- if (start_xfade_rect) {
- start_xfade_rect->show ();
- }
-
- _start_xfade_visible = true;
-}
-
-void
-AudioRegionView::show_end_xfade ()
-{
- if (end_xfade_in) {
- end_xfade_in->show();
- }
- if (end_xfade_out) {
- end_xfade_out->show();
- }
- if (end_xfade_rect) {
- end_xfade_rect->show ();
- }
-
- _end_xfade_visible = true;
-}