Use automation line's frame of reference for y position.
- removes the need for 'pixel hunting' wrt NAME_HIGHLIGHT_SIZE. - new control points generated by clicking on a line are placed where the verbose canvas cursor says they are.
This commit is contained in:
parent
6d98ccf901
commit
5e7c7e52bd
@ -1309,18 +1309,32 @@ AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev, b
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double x, y;
|
uint32_t before_p, after_p;
|
||||||
|
double mx = ev->button.x;
|
||||||
|
double my = ev->button.y;
|
||||||
|
|
||||||
|
item->canvas_to_item (mx, my);
|
||||||
|
|
||||||
|
framecnt_t const frame_within_region = (framecnt_t) floor (mx * samples_per_pixel);
|
||||||
|
|
||||||
|
if (!gain_line->control_points_adjacent (frame_within_region, before_p, after_p)) {
|
||||||
|
/* no adjacent points */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*y is in item frame */
|
||||||
|
double const bx = gain_line->nth (before_p)->get_x();
|
||||||
|
double const ax = gain_line->nth (after_p)->get_x();
|
||||||
|
double const click_ratio = (ax - mx) / (ax - bx);
|
||||||
|
|
||||||
|
double y = ((gain_line->nth (before_p)->get_y() * click_ratio) + (gain_line->nth (after_p)->get_y() * (1 - click_ratio)));
|
||||||
|
|
||||||
/* don't create points that can't be seen */
|
/* don't create points that can't be seen */
|
||||||
|
|
||||||
update_envelope_visibility ();
|
update_envelope_visibility ();
|
||||||
|
|
||||||
x = ev->button.x;
|
|
||||||
y = ev->button.y;
|
|
||||||
|
|
||||||
item->canvas_to_item (x, y);
|
|
||||||
framepos_t rpos = region ()->position ();
|
framepos_t rpos = region ()->position ();
|
||||||
framepos_t fx = trackview.editor().pixel_to_sample (x) + rpos;
|
framepos_t fx = trackview.editor().pixel_to_sample (mx) + rpos;
|
||||||
trackview.editor ().snap_to_with_modifier (fx, ev);
|
trackview.editor ().snap_to_with_modifier (fx, ev);
|
||||||
fx -= rpos;
|
fx -= rpos;
|
||||||
|
|
||||||
@ -1330,11 +1344,11 @@ AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev, b
|
|||||||
|
|
||||||
/* compute vertical fractional position */
|
/* compute vertical fractional position */
|
||||||
|
|
||||||
y = 1.0 - (y / (_height - NAME_HIGHLIGHT_SIZE));
|
y = 1.0 - (y / (gain_line->height()));
|
||||||
|
|
||||||
/* map using gain line */
|
/* map using gain line */
|
||||||
|
|
||||||
gain_line->view_to_model_coord (x, y);
|
gain_line->view_to_model_coord (mx, y);
|
||||||
|
|
||||||
/* XXX STATEFUL: can't convert to stateful diff until we
|
/* XXX STATEFUL: can't convert to stateful diff until we
|
||||||
can represent automation data with it.
|
can represent automation data with it.
|
||||||
|
@ -628,11 +628,11 @@ AutomationTimeAxisView::add_automation_event (GdkEvent* event, framepos_t when,
|
|||||||
|
|
||||||
double x = 0;
|
double x = 0;
|
||||||
|
|
||||||
_canvas_display->canvas_to_item (x, y);
|
_line->grab_item().canvas_to_item (x, y);
|
||||||
|
|
||||||
/* compute vertical fractional position */
|
/* compute vertical fractional position */
|
||||||
|
|
||||||
y = 1.0 - (y / height);
|
y = 1.0 - (y / _line->height());
|
||||||
|
|
||||||
/* map using line */
|
/* map using line */
|
||||||
|
|
||||||
|
@ -4319,7 +4319,7 @@ LineDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*cursor*/)
|
|||||||
double mx = event->button.x;
|
double mx = event->button.x;
|
||||||
double my = event->button.y;
|
double my = event->button.y;
|
||||||
|
|
||||||
_line->parent_group().canvas_to_item (mx, my);
|
_line->grab_item().canvas_to_item (mx, my);
|
||||||
|
|
||||||
framecnt_t const frame_within_region = (framecnt_t) floor (mx * _editor->samples_per_pixel);
|
framecnt_t const frame_within_region = (framecnt_t) floor (mx * _editor->samples_per_pixel);
|
||||||
|
|
||||||
@ -4330,7 +4330,7 @@ LineDrag::start_grab (GdkEvent* event, Gdk::Cursor* /*cursor*/)
|
|||||||
|
|
||||||
Drag::start_grab (event, _editor->cursors()->fader);
|
Drag::start_grab (event, _editor->cursors()->fader);
|
||||||
|
|
||||||
/* store grab start in parent frame */
|
/* store grab start in item frame */
|
||||||
double const bx = _line->nth (_before)->get_x();
|
double const bx = _line->nth (_before)->get_x();
|
||||||
double const ax = _line->nth (_after)->get_x();
|
double const ax = _line->nth (_after)->get_x();
|
||||||
double const click_ratio = (ax - mx) / (ax - bx);
|
double const click_ratio = (ax - mx) / (ax - bx);
|
||||||
@ -4391,14 +4391,19 @@ LineDrag::finished (GdkEvent* event, bool movement_occured)
|
|||||||
AutomationTimeAxisView* atv;
|
AutomationTimeAxisView* atv;
|
||||||
|
|
||||||
if ((atv = dynamic_cast<AutomationTimeAxisView*>(_editor->clicked_axisview)) != 0) {
|
if ((atv = dynamic_cast<AutomationTimeAxisView*>(_editor->clicked_axisview)) != 0) {
|
||||||
framepos_t where = _editor->canvas_event_sample (event, 0, 0);
|
framepos_t where = grab_frame ();
|
||||||
|
|
||||||
atv->add_automation_event (event, where, event->button.y, false);
|
double cx = 0;
|
||||||
|
double cy = _fixed_grab_y;
|
||||||
|
|
||||||
|
_line->grab_item().item_to_canvas (cx, cy);
|
||||||
|
|
||||||
|
atv->add_automation_event (event, where, cy, false);
|
||||||
} else if (dynamic_cast<AudioTimeAxisView*>(_editor->clicked_axisview) != 0) {
|
} else if (dynamic_cast<AudioTimeAxisView*>(_editor->clicked_axisview) != 0) {
|
||||||
AudioRegionView* arv;
|
AudioRegionView* arv;
|
||||||
|
|
||||||
if ((arv = dynamic_cast<AudioRegionView*>(_editor->clicked_regionview)) != 0) {
|
if ((arv = dynamic_cast<AudioRegionView*>(_editor->clicked_regionview)) != 0) {
|
||||||
arv->add_gain_point_event (arv->get_canvas_group (), event, false);
|
arv->add_gain_point_event (&arv->get_gain_line()->grab_item(), event, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user