X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Faudio_region_view.cc;h=d8ec2abb3cbddda694ae89179f8fb1c4d91f04f6;hb=6fc1f270137a06115a79c6089004174c5cab5ed7;hp=73fa167e2f84b58ba1b4cb3e47570ed388f20d0e;hpb=9fb3247350ffbfe0dda0ec31f8562bf1afad2d34;p=ardour.git diff --git a/gtk2_ardour/audio_region_view.cc b/gtk2_ardour/audio_region_view.cc index 73fa167e2f..d8ec2abb3c 100644 --- a/gtk2_ardour/audio_region_view.cc +++ b/gtk2_ardour/audio_region_view.cc @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -159,12 +160,12 @@ AudioRegionView::init (Gdk::Color const & basic_color, bool wfd) create_waves (); - fade_in_shape = new ArdourCanvas::Curve (group); + fade_in_shape = new ArdourCanvas::PolyLine (group); CANVAS_DEBUG_NAME (fade_in_shape, string_compose ("fade in shape for %1", region()->name())); fade_in_shape->set_outline_color (fade_color); fade_in_shape->set_data ("regionview", this); - fade_out_shape = new ArdourCanvas::Curve (group); + fade_out_shape = new ArdourCanvas::PolyLine (group); CANVAS_DEBUG_NAME (fade_out_shape, string_compose ("fade out shape for %1", region()->name())); fade_out_shape->set_outline_color (fade_color); fade_out_shape->set_data ("regionview", this); @@ -448,7 +449,7 @@ void AudioRegionView::setup_fade_handle_positions() { /* position of fade handle offset from the top of the region view */ - double const handle_pos = 2; + double const handle_pos = 1.0; if (fade_in_handle) { fade_in_handle->set_y0 (handle_pos); @@ -503,8 +504,13 @@ AudioRegionView::set_height (gdouble height) float pos_x = trackview.editor().sample_to_pixel((*l).first); - (*l).second->set (ArdourCanvas::Duple (pos_x, 2.0), - ArdourCanvas::Duple (pos_x, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1)); + if (height >= NAME_HIGHLIGHT_THRESH) { + (*l).second->set (ArdourCanvas::Duple (pos_x, 2.0), + ArdourCanvas::Duple (pos_x, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1)); + } else { + (*l).second->set (ArdourCanvas::Duple (pos_x, 2.0), + ArdourCanvas::Duple (pos_x, _height - 1)); + } } if (name_text) { @@ -556,12 +562,12 @@ AudioRegionView::reset_fade_in_shape_width (boost::shared_ptr ar, f uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth); double effective_height; - float curve[npoints]; + std::vector curve(npoints); - audio_region()->fade_in()->curve().get_vector (0, audio_region()->fade_in()->back()->when, curve, npoints); + audio_region()->fade_in()->curve().get_vector (0, audio_region()->fade_in()->back()->when, &curve[0], npoints); if (_height >= NAME_HIGHLIGHT_THRESH) { - effective_height = _height - NAME_HIGHLIGHT_SIZE - 2; + effective_height = _height - NAME_HIGHLIGHT_SIZE - 1; } else { effective_height = _height - 2; } @@ -576,15 +582,15 @@ AudioRegionView::reset_fade_in_shape_width (boost::shared_ptr ar, f double xdelta = pwidth/npoints; for (pi = 0, pc = 0; pc < npoints; ++pc) { - points[pi].x = 1 + (pc * xdelta); - points[pi++].y = 2 + (effective_height - (curve[pc] * effective_height)); + points[pi].x = 1.0 + (pc * xdelta); + points[pi++].y = effective_height - (curve[pc] * effective_height); } /* draw the line */ - redraw_start_xfade_to (ar, width, points, effective_height); + redraw_start_xfade_to (ar, width, points, effective_height, handle_left); - fade_in_shape->set (points); + // fade_in_shape->set (points); /* ensure trim handle stays on top */ if (frame_handle_start) { @@ -634,35 +640,35 @@ AudioRegionView::reset_fade_out_shape_width (boost::shared_ptr ar, uint32_t npoints = std::min (gdk_screen_width(), (int) pwidth); double effective_height; - float curve[npoints]; + std::vector curve(npoints); - audio_region()->fade_out()->curve().get_vector (0, audio_region()->fade_out()->back()->when, curve, npoints); + audio_region()->fade_out()->curve().get_vector (0, audio_region()->fade_out()->back()->when, &curve[0], npoints); if (_height >= NAME_HIGHLIGHT_THRESH) { - effective_height = _height - NAME_HIGHLIGHT_SIZE - 2; + effective_height = _height - (NAME_HIGHLIGHT_SIZE + 1); /* skip the top pixel that shows the frame of this regionview */ } else { - effective_height = _height - 2; + effective_height = _height - 2; /* skip the top and bottom pixel that are the frame of this regionview */ } /* points *MUST* be in anti-clockwise order */ - + Points points; - + uint32_t pi, pc; double xdelta = pwidth/npoints; - + points.assign (npoints, Duple ()); - + for (pi = 0, pc = 0; pc < npoints; ++pc, ++pi) { - points[pi].x = _pixel_width - pwidth + (pc * xdelta); - points[pi].y = 2 + (effective_height - (curve[pc] * effective_height)); + points[pi].x = 1.0 + _pixel_width - pwidth + (pc * xdelta); + points[pi].y = effective_height - (curve[pc] * effective_height); } /* draw the line */ - redraw_end_xfade_to (ar, width, points, effective_height); + redraw_end_xfade_to (ar, width, points, effective_height, handle_right, pwidth-2); - fade_out_shape->set (points); + // fade_out_shape->set (points); /* ensure trim handle stays on top */ if (frame_handle_end) { @@ -698,21 +704,22 @@ AudioRegionView::redraw_start_xfade () } void -AudioRegionView::redraw_start_xfade_to (boost::shared_ptr ar, framecnt_t /*width*/, Points& points, double effective_height) +AudioRegionView::redraw_start_xfade_to (boost::shared_ptr ar, framecnt_t /*width*/, Points& points, double effective_height, + double rect_width) { if (points.size() < 3) { return; } if (!start_xfade_in) { - start_xfade_in = new ArdourCanvas::Curve (group); + start_xfade_in = new ArdourCanvas::PolyLine (group); CANVAS_DEBUG_NAME (start_xfade_in, string_compose ("xfade start in line for %1", region()->name())); start_xfade_in->set_outline_color (ARDOUR_UI::config()->get_canvasvar_CrossfadeLine()); start_xfade_in->set_outline_width (1.5); } if (!start_xfade_out) { - start_xfade_out = new ArdourCanvas::Curve (group); + start_xfade_out = new ArdourCanvas::PolyLine (group); CANVAS_DEBUG_NAME (start_xfade_out, string_compose ("xfade start out line for %1", region()->name())); uint32_t col = UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->get_canvasvar_CrossfadeLine(), 128); start_xfade_out->set_outline_color (col); @@ -729,7 +736,7 @@ AudioRegionView::redraw_start_xfade_to (boost::shared_ptr ar, frame start_xfade_rect->set_data ("regionview", this); } - start_xfade_rect->set (ArdourCanvas::Rect (points.front().x, 1.0, points.back().x, effective_height)); + start_xfade_rect->set (ArdourCanvas::Rect (1.0, 0.0, rect_width, effective_height)); start_xfade_rect->show (); start_xfade_in->set (points); @@ -745,21 +752,24 @@ AudioRegionView::redraw_start_xfade_to (boost::shared_ptr ar, frame if (!inverse) { + /* no inverse curve defined, show the inverse of the normal one */ + for (Points::size_type i = 0, pci = 0; i < npoints; ++i, ++pci) { ArdourCanvas::Duple &p (ipoints[pci]); - p.x = i; + p.x = 1.0 + i; + /* invert with respect to y-axis */ p.y = effective_height - points[pci].y; } } else { - float vec[npoints]; - inverse->curve().get_vector (0, inverse->back()->when, vec, npoints); + std::vector vec(npoints); + inverse->curve().get_vector (0, inverse->back()->when, &vec[0], npoints); for (Points::size_type i = 0, pci = 0; i < npoints; ++i, ++pci) { ArdourCanvas::Duple &p (ipoints[pci]); - p.x = i; - p.y = 1.0 + effective_height - (effective_height * vec[i]); + p.x = 1.0 + i; + p.y = effective_height - (effective_height * vec[i]); } } @@ -784,14 +794,15 @@ AudioRegionView::redraw_end_xfade () } void -AudioRegionView::redraw_end_xfade_to (boost::shared_ptr ar, framecnt_t width, Points& points, double effective_height) +AudioRegionView::redraw_end_xfade_to (boost::shared_ptr ar, framecnt_t width, Points& points, double effective_height, + double rect_edge, double rect_width) { if (points.size() < 3) { return; } if (!end_xfade_in) { - end_xfade_in = new ArdourCanvas::Curve (group); + end_xfade_in = new ArdourCanvas::PolyLine (group); CANVAS_DEBUG_NAME (end_xfade_in, string_compose ("xfade end in line for %1", region()->name())); uint32_t col UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->get_canvasvar_CrossfadeLine(), 128); end_xfade_in->set_outline_color (col); @@ -799,7 +810,7 @@ AudioRegionView::redraw_end_xfade_to (boost::shared_ptr ar, framecn } if (!end_xfade_out) { - end_xfade_out = new ArdourCanvas::Curve (group); + end_xfade_out = new ArdourCanvas::PolyLine (group); CANVAS_DEBUG_NAME (end_xfade_out, string_compose ("xfade end out line for %1", region()->name())); end_xfade_out->set_outline_color (ARDOUR_UI::config()->get_canvasvar_CrossfadeLine()); end_xfade_out->set_outline_width (2.0); @@ -815,7 +826,7 @@ AudioRegionView::redraw_end_xfade_to (boost::shared_ptr ar, framecn end_xfade_rect->set_data ("regionview", this); } - end_xfade_rect->set (ArdourCanvas::Rect (points.front().x, 1.0, points.back().x, effective_height)); + end_xfade_rect->set (ArdourCanvas::Rect (rect_edge, 1.0, rect_edge + rect_width, effective_height)); end_xfade_rect->show (); end_xfade_in->set (points); @@ -836,7 +847,7 @@ AudioRegionView::redraw_end_xfade_to (boost::shared_ptr ar, framecn for (Points::size_type i = 0, pci = 0; i < npoints; ++i, ++pci) { ArdourCanvas::Duple &p (ipoints[pci]); - p.x = rend + i; + p.x = 1.0 + rend + i; p.y = effective_height - points[pci].y; } @@ -851,8 +862,8 @@ AudioRegionView::redraw_end_xfade_to (boost::shared_ptr ar, framecn for (Points::size_type i = 0, pci = 0; i < npoints; ++i) { ArdourCanvas::Duple& p (ipoints[pci++]); - p.x = rend + i; - p.y = 1.0 + effective_height - (effective_height * vp[i]); + p.x = 1.0 + rend + i; + p.y = effective_height - (effective_height * vp[i]); } } @@ -1136,7 +1147,7 @@ AudioRegionView::create_one_wave (uint32_t which, bool /*direct*/) wave->set_y_position (yoff); wave->set_height (ht); wave->set_samples_per_pixel (samples_per_pixel); - wave->set_show_zero_line (true); + wave->set_show_zero_line (false); switch (Config->get_waveform_shape()) { case Rectified: @@ -1246,7 +1257,7 @@ AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev) } void -AudioRegionView::remove_gain_point_event (ArdourCanvas::Item *item, GdkEvent */*ev*/) +AudioRegionView::remove_gain_point_event (ArdourCanvas::Item *item, GdkEvent* /*ev*/) { ControlPoint *cp = reinterpret_cast (item->get_data ("control_point")); audio_region()->envelope()->erase (cp->model()); @@ -1323,7 +1334,8 @@ AudioRegionView::entered (bool internal_editing) trackview.editor().set_current_trimmable (_region); trackview.editor().set_current_movable (_region); - if (gain_line && trackview.editor().current_mouse_mode() == Editing::MouseGain) { + if (gain_line) { + /* these may or may not be visible depending on mouse mode */ gain_line->add_visibility (AutomationLine::ControlPoints); } @@ -1341,7 +1353,7 @@ AudioRegionView::exited () trackview.editor().set_current_trimmable (boost::shared_ptr()); trackview.editor().set_current_movable (boost::shared_ptr()); - if (gain_line && trackview.editor().current_mouse_mode() == Editing::MouseGain) { + if (gain_line) { gain_line->remove_visibility (AutomationLine::ControlPoints); } @@ -1514,12 +1526,6 @@ AudioRegionView::transients_changed () canvas_item->set (ArdourCanvas::Duple (-1.0, 2.0), ArdourCanvas::Duple (1.0, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1)); - 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 ();