X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fautomation_line.cc;h=a72916191173a202609b0e388837dc3b450c006d;hb=1315ee3dff1e4966ab28bd47e81b5f003cac6e40;hp=4978a1ef68e14cde3752b87268450eb98c7cbad3;hpb=d6ef740e9002c7112bc47cb2d9d8d4b8609aa089;p=ardour.git diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc index 4978a1ef68..a729161911 100644 --- a/gtk2_ardour/automation_line.cc +++ b/gtk2_ardour/automation_line.cc @@ -232,6 +232,7 @@ AutomationLine::AutomationLine (const string & name, TimeAxisView& tv, ArdourCan no_draw = false; _visible = true; terminal_points_can_slide = true; + _y_position = 0; _height = 0; group = new ArdourCanvas::Group (parent); @@ -307,17 +308,27 @@ AutomationLine::control_point_box_size () } void -AutomationLine::set_height (guint32 h) +AutomationLine::set_y_position_and_height (guint32 y, guint32 h) { + bool changed = false; + + if (y != _y_position) { + _y_position = y; + changed = true; + } + if (h != _height) { _height = h; - double bsz = control_point_box_size(); + double const bsz = control_point_box_size(); for (vector::iterator i = control_points.begin(); i != control_points.end(); ++i) { (*i)->set_size (bsz); } + changed = true; + } + if (changed) { reset (); } } @@ -365,7 +376,7 @@ AutomationLine::modify_view_point (ControlPoint& cp, double x, double y, bool wi y = max (0.0, y); y = min (1.0, y); - y = _height - (y * _height); + y = _y_position + _height - (y * _height); if (cp.can_slide) { @@ -494,7 +505,7 @@ AutomationLine::model_representation (ControlPoint& cp, ModelRepresentation& mr) */ mr.xval = (nframes_t) floor (cp.get_x()); - mr.yval = 1.0 - (cp.get_y() / _height); + mr.yval = 1.0 - ( (cp.get_y() - _y_position) / _height); /* if xval has not changed, set it directly from the model to avoid rounding errors */ @@ -831,7 +842,7 @@ AutomationLine::point_drag (ControlPoint& cp, nframes_t x, float fraction, bool void AutomationLine::line_drag (uint32_t i1, uint32_t i2, float fraction, bool with_push) { - double ydelta = fraction - last_drag_fraction; + double const ydelta = fraction - last_drag_fraction; did_push = with_push; @@ -844,7 +855,7 @@ AutomationLine::line_drag (uint32_t i1, uint32_t i2, float fraction, bool with_p for (uint32_t i = i1 ; i <= i2; i++) { cp = nth (i); - modify_view_point (*cp, trackview.editor.unit_to_frame (cp->get_x()), ((_height - cp->get_y()) /_height) + ydelta, with_push); + modify_view_point (*cp, trackview.editor.unit_to_frame (cp->get_x()), ((_height - cp->get_y() + _y_position) /_height) + ydelta, with_push); } if (line_points.size() > 1) { @@ -1041,8 +1052,8 @@ AutomationLine::get_selectables (nframes_t& start, nframes_t& end, /* Curse X11 and its inverted coordinate system! */ - bot = (1.0 - topfrac) * _height; - top = (1.0 - botfrac) * _height; + bot = _y_position + (1.0 - topfrac) * _height; + top = _y_position + (1.0 - botfrac) * _height; nstart = max_frames; nend = 0; @@ -1108,8 +1119,8 @@ AutomationLine::set_selected_points (PointSelection& points) /* Curse X11 and its inverted coordinate system! */ - bot = (1.0 - (*r).high_fract) * _height; - top = (1.0 - (*r).low_fract) * _height; + bot = _y_position + (1.0 - (*r).high_fract) * _height; + top = _y_position + (1.0 - (*r).low_fract) * _height; for (vector::iterator i = control_points.begin(); i != control_points.end(); ++i) { @@ -1136,6 +1147,13 @@ AutomationLine::set_selected_points (PointSelection& points) } +void AutomationLine::set_colors() { + set_line_color( color_map[cAutomationLine] ); + for (vector::iterator i = control_points.begin(); i != control_points.end(); ++i) { + (*i)->show_color (false, !points_visible); + } +} + void AutomationLine::show_selection () { @@ -1196,7 +1214,7 @@ AutomationLine::reset_callback (const AutomationList& events) model_to_view_y (translated_y); tmp_points.push_back (ALPoint (trackview.editor.frame_to_unit ((*ai)->when), - _height - (translated_y * _height))); + _y_position + _height - (translated_y * _height))); } determine_visible_control_points (tmp_points);