X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fautomation_line.cc;h=98b87ee6e6c28d38858637d4d3665d1e26adab3c;hb=198ba51c3af256e23d525900b236df4b734c34e0;hp=d2a66a10276868235ae514c616e6e5e87db0efa9;hpb=22b07e0233a29d9633ffa825a79503befaf2e16e;p=ardour.git diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc index d2a66a1027..98b87ee6e6 100644 --- a/gtk2_ardour/automation_line.cc +++ b/gtk2_ardour/automation_line.cc @@ -30,7 +30,6 @@ #include #include -#include #include "boost/shared_ptr.hpp" @@ -64,7 +63,7 @@ #include "ardour/session.h" #include "ardour/value_as_string.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace std; using namespace ARDOUR; @@ -87,6 +86,7 @@ AutomationLine::AutomationLine (const string& name, , _parent_group (parent) , _offset (0) , _maximum_time (max_framepos) + , _fill (false) , _desc (desc) { if (converter) { @@ -172,7 +172,7 @@ AutomationLine::update_visibility () } } else if (_visible & SelectedControlPoints) { for (vector::iterator i = control_points.begin(); i != control_points.end(); ++i) { - if ((*i)->get_selected()) { + if ((*i)->selected()) { (*i)->show (); } else { (*i)->hide (); @@ -230,6 +230,11 @@ AutomationLine::set_height (guint32 h) (*i)->set_size (bsz); } + if (_fill) { + line->set_fill_y1 (_height); + } else { + line->set_fill_y1 (0); + } reset (); } } @@ -239,6 +244,10 @@ AutomationLine::set_line_color (uint32_t color) { _line_color = color; line->set_outline_color (color); + + ArdourCanvas::SVAModifier mod = UIConfiguration::instance().modifier ("automation line fill"); + + line->set_fill_color ((color & 0xffffff00) + mod.a()*255); } void @@ -471,9 +480,9 @@ AutomationLine::start_drag_single (ControlPoint* cp, double x, float fraction) _drag_points.clear (); _drag_points.push_back (cp); - if (cp->get_selected ()) { + if (cp->selected ()) { for (vector::iterator i = control_points.begin(); i != control_points.end(); ++i) { - if (*i != cp && (*i)->get_selected()) { + if (*i != cp && (*i)->selected()) { _drag_points.push_back (*i); } } @@ -547,8 +556,8 @@ AutomationLine::ContiguousControlPoints::compute_x_bounds (PublicEditor& e) 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()) + const Meter& meter = map.meter_at_frame (pos); + const framecnt_t len = ceil (meter.frames_per_bar (map.tempo_at_frame (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); @@ -563,8 +572,8 @@ AutomationLine::ContiguousControlPoints::compute_x_bounds (PublicEditor& e) 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()) + const Meter& meter = map.meter_at_frame (pos); + const framecnt_t len = ceil (meter.frames_per_bar (map.tempo_at_frame (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); @@ -695,7 +704,6 @@ AutomationLine::drag_motion (double const x, float fraction, bool ignore_x, bool } /* clamp y */ - for (list::iterator i = _drag_points.begin(); i != _drag_points.end(); ++i) { double const y = ((_height - (*i)->get_y()) / _height) + dy; if (y < 0) { @@ -731,13 +739,13 @@ AutomationLine::drag_motion (double const x, float fraction, bool ignore_x, bool line->set_steps (line_points, is_stepped()); } } - + double const result_frac = _last_drag_fraction + dy; _drag_distance += dx; _drag_x += dx; - _last_drag_fraction = fraction; + _last_drag_fraction = result_frac; did_push = with_push; - return pair (_drag_x + dx, _last_drag_fraction + dy); + return pair (_drag_x + dx, result_frac); } /** Should be called to indicate the end of a drag */ @@ -883,6 +891,7 @@ AutomationLine::remove_point (ControlPoint& cp) trackview.editor().begin_reversible_command (_("remove control point")); XMLNode &before = alist->get_state(); + trackview.editor ().get_selection ().clear_points (); alist->erase (cp.model()); trackview.editor().session()->add_command( @@ -1192,6 +1201,7 @@ AutomationLine::view_to_model_coord_y (double& y) const /* TODO: This should be more generic (use ParameterDescriptor) * or better yet: Controllable -> set_interface(); */ + if ( alist->parameter().type() == GainAutomation || alist->parameter().type() == EnvelopeAutomation || (_desc.logarithmic && _desc.lower == 0. && _desc.upper > _desc.lower)) { @@ -1208,8 +1218,12 @@ AutomationLine::view_to_model_coord_y (double& y) const } else if (alist->parameter().type() == PanAzimuthAutomation || alist->parameter().type() == PanElevationAutomation) { y = 1.0 - y; + y = max ((double) _desc.lower, y); + y = min ((double) _desc.upper, y); } else if (alist->parameter().type() == PanWidthAutomation) { y = 2.0 * y - 1.0; + y = max ((double) _desc.lower, y); + y = min ((double) _desc.upper, y); } else { y = y * (double)(alist->get_max_y() - alist->get_min_y()) + alist->get_min_y(); if (_desc.integer_step) { @@ -1217,6 +1231,8 @@ AutomationLine::view_to_model_coord_y (double& y) const } else if (_desc.toggled) { y = (y > 0.5) ? 1.0 : 0.0; } + y = max ((double) _desc.lower, y); + y = min ((double) _desc.upper, y); } } @@ -1227,7 +1243,7 @@ AutomationLine::model_to_view_coord_y (double& y) const if ( alist->parameter().type() == GainAutomation || alist->parameter().type() == EnvelopeAutomation || (_desc.logarithmic && _desc.lower == 0. && _desc.upper > _desc.lower)) { - y = gain_to_slider_position_with_max (y, Config->get_max_gain()); + y = gain_to_slider_position_with_max (y, _desc.upper); } else if (alist->parameter().type() == TrimAutomation || (_desc.logarithmic && _desc.lower * _desc.upper > 0 && _desc.upper > _desc.lower)) { const double lower_db = accurate_coefficient_to_dB (_desc.lower);