X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fautomation_line.cc;h=670083e0d482a917365101ab7d74eba8320a2f38;hb=237741d18722252abd4a6a20d3422315481ccffe;hp=a4d58cb53120fad787397f5e25f75385636b33e7;hpb=a1a3f6c8265264227ce19f731bf1863aff229a94;p=ardour.git diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc index a4d58cb531..670083e0d4 100644 --- a/gtk2_ardour/automation_line.cc +++ b/gtk2_ardour/automation_line.cc @@ -39,6 +39,7 @@ #include "ardour/automation_list.h" #include "ardour/dB.h" #include "ardour/debug.h" +#include "ardour/tempo.h" #include "evoral/Curve.hpp" @@ -105,6 +106,7 @@ AutomationLine::AutomationLine (const string& name, TimeAxisView& tv, ArdourCanv CANVAS_DEBUG_NAME (line, "region gain envelope line"); line->set_data ("line", this); line->set_outline_width (2.0); + line->set_covers_threshold (4.0); line->Event.connect (sigc::mem_fun (*this, &AutomationLine::event_handler)); @@ -137,7 +139,7 @@ AutomationLine::event_handler (GdkEvent* event) } void -AutomationLine::show () +AutomationLine::update_visibility () { if (_visible & Line) { /* Only show the line there are some points, otherwise we may show an out-of-date line @@ -149,32 +151,32 @@ AutomationLine::show () } else { line->hide (); } - } else { - line->hide(); - /* if the line is not visible, then no control points should be visible */ - for (vector::iterator i = control_points.begin(); i != control_points.end(); ++i) { - (*i)->hide (); - } - return; - } - if (_visible & ControlPoints) { - for (vector::iterator i = control_points.begin(); i != control_points.end(); ++i) { - (*i)->show (); - } - } else if (_visible & SelectedControlPoints) { - for (vector::iterator i = control_points.begin(); i != control_points.end(); ++i) { - if ((*i)->get_selected()) { + if (_visible & ControlPoints) { + for (vector::iterator i = control_points.begin(); i != control_points.end(); ++i) { (*i)->show (); - } else { + } + } else if (_visible & SelectedControlPoints) { + for (vector::iterator i = control_points.begin(); i != control_points.end(); ++i) { + if ((*i)->get_selected()) { + (*i)->show (); + } else { + (*i)->hide (); + } + } + } else { + for (vector::iterator i = control_points.begin(); i != control_points.end(); ++i) { (*i)->hide (); } } + } else { + line->hide (); for (vector::iterator i = control_points.begin(); i != control_points.end(); ++i) { (*i)->hide (); } } + } void @@ -519,11 +521,12 @@ AutomationLine::ContiguousControlPoints::ContiguousControlPoints (AutomationLine } void -AutomationLine::ContiguousControlPoints::compute_x_bounds () +AutomationLine::ContiguousControlPoints::compute_x_bounds (PublicEditor& e) { uint32_t sz = size(); if (sz > 0 && sz < line.npoints()) { + const TempoMap& map (e.session()->tempo_map()); /* determine the limits on x-axis motion for this contiguous range of control points @@ -531,14 +534,30 @@ AutomationLine::ContiguousControlPoints::compute_x_bounds () if (front()->view_index() > 0) { before_x = line.nth (front()->view_index() - 1)->get_x(); + + const framepos_t pos = e.pixel_to_sample(before_x); + const Meter& meter = map.meter_at (pos); + const framecnt_t len = ceil (meter.frames_per_bar (map.tempo_at (pos), e.session()->frame_rate()) + / (Timecode::BBT_Time::ticks_per_beat * meter.divisions_per_bar()) ); + const double one_tick_in_pixels = e.sample_to_pixel_unrounded (len); + + before_x += one_tick_in_pixels; } /* if our last point has a point after it in the line, we have an "after" bound */ - if (back()->view_index() < (line.npoints() - 2)) { + if (back()->view_index() < (line.npoints() - 1)) { after_x = line.nth (back()->view_index() + 1)->get_x(); + + const framepos_t pos = e.pixel_to_sample(after_x); + const Meter& meter = map.meter_at (pos); + const framecnt_t len = ceil (meter.frames_per_bar (map.tempo_at (pos), e.session()->frame_rate()) + / (Timecode::BBT_Time::ticks_per_beat * meter.divisions_per_bar())); + const double one_tick_in_pixels = e.sample_to_pixel_unrounded (len); + + after_x -= one_tick_in_pixels; } } } @@ -642,7 +661,7 @@ AutomationLine::drag_motion (double const x, float fraction, bool ignore_x, bool } for (vector::iterator ccp = contiguous_points.begin(); ccp != contiguous_points.end(); ++ccp) { - (*ccp)->compute_x_bounds (); + (*ccp)->compute_x_bounds (trackview.editor()); } } @@ -1006,9 +1025,7 @@ AutomationLine::reset_callback (const Evoral::ControlList& events) line->set (line_points); - if (_visible && alist->interpolation() != AutomationList::Discrete) { - line->show(); - } + update_visibility (); } set_selected_points (trackview.editor().get_selection().points); @@ -1081,7 +1098,7 @@ AutomationLine::add_visibility (VisibleAspects va) _visible = VisibleAspects (_visible | va); if (old != _visible) { - show (); + update_visibility (); } } @@ -1090,7 +1107,7 @@ AutomationLine::set_visibility (VisibleAspects va) { if (_visible != va) { _visible = va; - show (); + update_visibility (); } } @@ -1102,7 +1119,7 @@ AutomationLine::remove_visibility (VisibleAspects va) _visible = VisibleAspects (_visible & ~va); if (old != _visible) { - show (); + update_visibility (); } } @@ -1153,9 +1170,10 @@ AutomationLine::view_to_model_coord_y (double& y) const y = max (0.0, y); y = min (2.0, y); } else if (alist->parameter().type() == PanAzimuthAutomation || - alist->parameter().type() == PanElevationAutomation || - alist->parameter().type() == PanWidthAutomation) { + alist->parameter().type() == PanElevationAutomation) { y = 1.0 - y; + } else if (alist->parameter().type() == PanWidthAutomation) { + y = 2.0 * y - 1.0; } else if (alist->parameter().type() == PluginAutomation) { y = y * (double)(alist->get_max_y()- alist->get_min_y()) + alist->get_min_y(); } else { @@ -1171,10 +1189,10 @@ AutomationLine::model_to_view_coord (double& x, double& y) const alist->parameter().type() == EnvelopeAutomation) { y = gain_to_slider_position_with_max (y, Config->get_max_gain()); } else if (alist->parameter().type() == PanAzimuthAutomation || - alist->parameter().type() == PanElevationAutomation || - alist->parameter().type() == PanWidthAutomation) { - // vertical coordinate axis reversal + alist->parameter().type() == PanElevationAutomation) { y = 1.0 - y; + } else if (alist->parameter().type() == PanWidthAutomation) { + y = .5 + y * .5; } else if (alist->parameter().type() == PluginAutomation) { y = (y - alist->get_min_y()) / (double)(alist->get_max_y()- alist->get_min_y()); } else {