X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fautomation_line.cc;h=98b87ee6e6c28d38858637d4d3665d1e26adab3c;hb=24d5f1a6249b08a8b21854ecf001be7e07e5bf23;hp=8137fc4b19a02f0b83084a5476d51f99a9b74e69;hpb=4dc63966f0872efe768dad61eb9b8785d06b92d1;p=ardour.git diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc index 8137fc4b19..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) { @@ -94,7 +94,7 @@ AutomationLine::AutomationLine (const string& name, } else { _our_time_converter = true; } - + _visible = Line; update_pending = false; @@ -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 (); @@ -203,7 +203,7 @@ AutomationLine::hide () /* leave control points setting unchanged, we are just hiding the overall line */ - + set_visibility (AutomationLine::VisibleAspects (_visible & ~Line)); } @@ -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); @@ -582,10 +591,10 @@ AutomationLine::ContiguousControlPoints::clamp_dx (double dx) /* get the maximum distance we can move any of these points along the x-axis */ - + double tx; /* possible position a point would move to, given dx */ ControlPoint* cp; - + if (dx > 0) { /* check the last point, since we're moving later in time */ cp = back(); @@ -649,15 +658,15 @@ AutomationLine::drag_motion (double const x, float fraction, bool ignore_x, bool no motion ever took place, but need to do before we handle motion. */ - + /* partition the points we are dragging into (potentially several) * set(s) of contiguous points. this will not happen with a normal * drag, but if the user does a discontiguous selection, it can. */ - + uint32_t expected_view_index = 0; CCP contig; - + for (list::iterator i = _drag_points.begin(); i != _drag_points.end(); ++i) { if (i == _drag_points.begin() || (*i)->view_index() != expected_view_index) { contig.reset (new ContiguousControlPoints (*this)); @@ -675,7 +684,7 @@ AutomationLine::drag_motion (double const x, float fraction, bool ignore_x, bool (*ccp)->compute_x_bounds (trackview.editor()); } _drag_had_movement = true; - } + } /* OK, now on to the stuff related to *this* motion event. First, for * each contiguous range, figure out the maximum x-axis motion we are @@ -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) { @@ -709,7 +717,7 @@ AutomationLine::drag_motion (double const x, float fraction, bool ignore_x, bool if (dx || dy) { /* and now move each section */ - + for (vector::iterator ccp = contiguous_points.begin(); ccp != contiguous_points.end(); ++ccp) { (*ccp)->move (dx, dy); } @@ -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,8 +891,9 @@ 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( new MementoCommand (memento_command_binder (), &before, &alist->get_state())); @@ -912,7 +921,7 @@ AutomationLine::get_selectables (framepos_t start, framepos_t end, double botfra /* model_when is relative to the start of the source, so we just need to add on the origin_b here (as it is the session frame position of the start of the source) */ - + framepos_t const session_frames_when = _time_converter->to (model_when) + _time_converter->origin_b (); if (session_frames_when >= start && session_frames_when <= end && (*i)->get_y() >= bot_track && (*i)->get_y() <= top_track) { @@ -993,7 +1002,7 @@ AutomationLine::reset_callback (const Evoral::ControlList& events) np = events.size(); Evoral::ControlList& e = const_cast (events); - + for (AutomationList::iterator ai = e.begin(); ai != e.end(); ++ai, ++pi) { double tx = (*ai)->when; @@ -1008,17 +1017,17 @@ AutomationLine::reset_callback (const Evoral::ControlList& events) _name) << endmsg; continue; } - + if (tx >= max_framepos || tx < 0 || tx >= _maximum_time) { continue; } - + /* convert x-coordinate to a canvas unit coordinate (this takes * zoom and scroll into account). */ - + tx = trackview.editor().sample_to_pixel_unrounded (tx); - + /* convert from canonical view height (0..1.0) to actual * height coordinates (using X11's top-left rooted system) */ @@ -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);