X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Faudio_region_view.cc;h=a511ff771fff27a28e56aff17624d0d18adcb85a;hb=c912bd61ae49cc79158f3322439c29b27ef51de8;hp=f0330077c1711000ab309e86a45007d958764328;hpb=266ac609419b7d659ac9ef01ae7f092298e9ab12;p=ardour.git diff --git a/gtk2_ardour/audio_region_view.cc b/gtk2_ardour/audio_region_view.cc index f0330077c1..a511ff771f 100644 --- a/gtk2_ardour/audio_region_view.cc +++ b/gtk2_ardour/audio_region_view.cc @@ -477,19 +477,23 @@ AudioRegionView::set_height (gdouble height) uint32_t wcnt = waves.size(); - for (uint32_t n = 0; n < wcnt; ++n) { - gdouble ht; + if (wcnt > 0) { - if (height < NAME_HIGHLIGHT_THRESH) { - ht = ((height - 2 * wcnt) / (double) wcnt); + gdouble ht; + + if (!ARDOUR_UI::config()->get_show_name_highlight() || (height < NAME_HIGHLIGHT_THRESH)) { + ht = height / (double) wcnt; } else { - ht = (((height - 2 * wcnt) - NAME_HIGHLIGHT_SIZE) / (double) wcnt); + ht = (height - NAME_HIGHLIGHT_SIZE) / (double) wcnt; + } + + for (uint32_t n = 0; n < wcnt; ++n) { + + gdouble yoff = floor (ht * n); + + waves[n]->set_height (ht); + waves[n]->set_y_position (yoff); } - - gdouble yoff = n * (ht + 1); - - waves[n]->set_height (ht); - waves[n]->set_y_position (yoff + 2); } if (gain_line) { @@ -554,7 +558,7 @@ AudioRegionView::reset_fade_in_shape_width (boost::shared_ptr ar, f width = std::max ((framecnt_t) 64, width); /* round here to prevent little visual glitches with sub-pixel placement */ - double const pwidth = rint (width / samples_per_pixel); + double const pwidth = floor (width / samples_per_pixel); double const handle_left = pwidth; /* Put the fade in handle so that its left side is at the end-of-fade line */ @@ -600,8 +604,8 @@ AudioRegionView::reset_fade_in_shape_width (boost::shared_ptr ar, f points.assign (list->size(), Duple()); for (x = list->begin(), pi = 0; x != list->end(); ++x, ++pi) { - points[pi].x = 1.0 + (pwidth * ((*x)->when/length)); - points[pi].y = effective_height - ((*x)->value * effective_height); + points[pi].x = (pwidth * ((*x)->when/length)); + points[pi].y = effective_height - ((*x)->value * (effective_height - 1.)); } /* draw the line */ @@ -633,7 +637,7 @@ AudioRegionView::reset_fade_out_shape_width (boost::shared_ptr ar, width = std::max ((framecnt_t) 64, width); - double const pwidth = rint(trackview.editor().sample_to_pixel (width)); + double const pwidth = floor(trackview.editor().sample_to_pixel (width)); /* the right edge should be right on the region frame is the pixel * width is zero. Hence the additional + 1.0 at the end. @@ -669,7 +673,7 @@ AudioRegionView::reset_fade_out_shape_width (boost::shared_ptr ar, double effective_height; - effective_height = _height - 1.0; + effective_height = _height; if (ARDOUR_UI::config()->get_show_name_highlight() && effective_height >= NAME_HIGHLIGHT_THRESH) { effective_height -= NAME_HIGHLIGHT_SIZE; @@ -687,7 +691,7 @@ AudioRegionView::reset_fade_out_shape_width (boost::shared_ptr ar, for (x = list->begin(), pi = 0; x != list->end(); ++x, ++pi) { points[pi].x = _pixel_width - pwidth + (pwidth * ((*x)->when/length)); - points[pi].y = 1.0 + effective_height - ((*x)->value * effective_height); + points[pi].y = effective_height - ((*x)->value * (effective_height - 1.)); } /* draw the line */ @@ -772,7 +776,7 @@ AudioRegionView::redraw_start_xfade_to (boost::shared_ptr ar, frame for (Points::size_type i = 0, pci = 0; i < npoints; ++i, ++pci) { ArdourCanvas::Duple &p (ipoints[pci]); /* leave x-axis alone but invert with respect to y-axis */ - p.y = 1.0 + effective_height - points[pci].y; + p.y = effective_height - points[pci].y; } } else { @@ -792,7 +796,7 @@ AudioRegionView::redraw_start_xfade_to (boost::shared_ptr ar, frame for (x = inverse->begin(), pi = 0; x != inverse->end(); ++x, ++pi) { ArdourCanvas::Duple& p (ipoints[pi]); p.x = (rect_width * ((*x)->when/length)); - p.y = 1.0 + effective_height - ((*x)->value * effective_height); + p.y = effective_height - ((*x)->value * (effective_height)); } } @@ -879,14 +883,13 @@ AudioRegionView::redraw_end_xfade_to (boost::shared_ptr ar, framecn const double rend = trackview.editor().sample_to_pixel (_region->length() - width); Evoral::ControlList::const_iterator x; - Points::size_type i; Points::size_type pi; double length = inverse->length(); - for (x = inverse->begin(), i = 0, pi = 0; x != inverse->end(); ++x, ++pi, ++i) { + for (x = inverse->begin(), pi = 0; x != inverse->end(); ++x, ++pi) { ArdourCanvas::Duple& p (ipoints[pi]); p.x = (rect_width * ((*x)->when/length)) + rend; - p.y = 1.0 + effective_height - ((*x)->value * effective_height); + p.y = effective_height - ((*x)->value * (effective_height)); } } @@ -1050,8 +1053,12 @@ AudioRegionView::update_envelope_visibility () return; } - if (ARDOUR_UI::config()->get_show_region_gain() || trackview.editor().current_mouse_mode() == Editing::MouseDraw || trackview.editor().current_mouse_mode() == Editing::MouseRange ) { + if (trackview.editor().current_mouse_mode() == Editing::MouseDraw || trackview.editor().current_mouse_mode() == Editing::MouseContent ) { gain_line->set_visibility (AutomationLine::VisibleAspects(AutomationLine::ControlPoints|AutomationLine::Line)); + gain_line->canvas_group().raise_to_top (); + } else if (ARDOUR_UI::config()->get_show_region_gain() || trackview.editor().current_mouse_mode() == Editing::MouseRange ) { + gain_line->set_visibility (AutomationLine::VisibleAspects(AutomationLine::Line)); + gain_line->canvas_group().raise_to_top (); } else { gain_line->set_visibility (AutomationLine::VisibleAspects(0)); } @@ -1123,12 +1130,18 @@ AudioRegionView::create_one_wave (uint32_t which, bool /*direct*/) uint32_t nwaves = std::min (nchans, audio_region()->n_channels()); gdouble ht; + /* reduce waveview height by 2.0 to account for our frame */ + if (trackview.current_height() < NAME_HIGHLIGHT_THRESH) { - ht = ((trackview.current_height()) / (double) nchans); + ht = ((trackview.current_height() - 2.0) / (double) nchans); } else { - ht = ((trackview.current_height() - NAME_HIGHLIGHT_SIZE) / (double) nchans); + ht = ((trackview.current_height() - NAME_HIGHLIGHT_SIZE - 2.0) / (double) nchans); } + /* first waveview starts at 1.0, not 0.0 since that will overlap the + * frame + */ + gdouble yoff = which * ht; WaveView *wave = new WaveView (group, audio_region ()); @@ -1339,6 +1352,13 @@ AudioRegionView::entered () fade_out_trim_handle->hide (); } } + } else { //this happens when we switch tools; if we switch away from Grab mode, hide all the fade handles + if (fade_in_handle) { fade_in_handle->hide(); } + if (fade_out_handle) { fade_out_handle->hide(); } + if (fade_in_trim_handle) { fade_in_trim_handle->hide(); } + if (fade_out_trim_handle) { fade_out_trim_handle->hide(); } + if (start_xfade_rect) { start_xfade_rect->set_outline (false); } + if (end_xfade_rect) { end_xfade_rect->set_outline (false); } } } @@ -1348,9 +1368,9 @@ AudioRegionView::exited () trackview.editor().set_current_trimmable (boost::shared_ptr()); trackview.editor().set_current_movable (boost::shared_ptr()); - if (gain_line) { - gain_line->remove_visibility (AutomationLine::ControlPoints); - } +// if (gain_line) { +// gain_line->remove_visibility (AutomationLine::ControlPoints); +// } if (fade_in_handle) { fade_in_handle->hide(); } if (fade_out_handle) { fade_out_handle->hide(); }