- if(mwindow->session->current_operation == DRAG_EDITHANDLE2 ||
- mwindow->session->current_operation == DRAG_PLUGINHANDLE2)
- {
-//printf("TrackCanvas::draw_drag_handle 1 %ld %ld\n", mwindow->session->drag_sample, mwindow->edl->local_session->view_start);
- int64_t pixel1 = Units::round(mwindow->session->drag_position *
- mwindow->edl->session->sample_rate /
- mwindow->edl->local_session->zoom_sample -
- mwindow->edl->local_session->view_start[pane->number]);
-//printf("TrackCanvas::draw_drag_handle 2 %d %jd\n", pane->number, pixel1);
- set_color(!snapped ? GREEN : (snapped=0, YELLOW));
- set_inverse();
-//printf("TrackCanvas::draw_drag_handle 3\n");
- draw_line(pixel1, 0, pixel1, get_h());
- set_opaque();
-//printf("TrackCanvas::draw_drag_handle 4\n");
+ if( mwindow->session->current_operation != DRAG_EDITHANDLE2 &&
+ mwindow->session->current_operation != DRAG_PLUGINHANDLE2 ) return;
+ int64_t pixel1 = Units::round(mwindow->session->drag_position *
+ mwindow->edl->session->sample_rate /
+ mwindow->edl->local_session->zoom_sample -
+ mwindow->edl->local_session->view_start[pane->number]);
+ set_color(!snapped ? GREEN : (snapped=0, YELLOW));
+ set_inverse();
+ draw_line(pixel1, 0, pixel1, get_h());
+ set_opaque();
+
+ if( mwindow->session->current_operation != DRAG_EDITHANDLE2 ) return;
+ if( !mwindow->session->drag_edit ) return;
+ int group_id = mwindow->session->drag_edit->group_id;
+ if( !group_id ) return;
+ int64_t dx, dy, dw, dh;
+ edit_dimensions(mwindow->session->drag_edit, dx, dy, dw, dh);
+ int drag_handle = mwindow->session->drag_handle;
+ int64_t pixel0 = !drag_handle ? dx : dx + dw;
+ int delta = pixel1 - pixel0;
+ set_color(LTPURPLE);
+ set_line_width(3);
+
+ for( Track *track=mwindow->edl->tracks->first; track; track=track->next ) {
+ if( track->is_hidden() ) continue;
+ Edit *left = 0, *right = 0;
+ double start = DBL_MAX, end = DBL_MIN;
+ for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
+ if( edit->group_id != group_id ) continue;
+ double edit_start = edit->track->from_units(edit->startproject);
+ if( edit_start < start ) { start = edit_start; left = edit; }
+ double edit_end = edit->track->from_units(edit->startproject+edit->length);
+ if( edit_end > end ) { end = edit_end; right = edit; }
+ }
+ Edit *edit = !drag_handle ? left : right;
+ if( !edit ) continue;
+ Indexable *idxbl = edit->asset;
+ if( !idxbl ) idxbl = edit->nested_edl;
+ int can_drag = idxbl ? 1 : 0;
+ if( drag_handle ) {
+ int64_t source_len = !idxbl ? -1 :
+ edit->track->data_type == TRACK_AUDIO ?
+ idxbl->get_audio_samples() :
+ edit->track->data_type == TRACK_VIDEO ?
+ idxbl->get_video_frames() : -1;
+ int64_t speed_start = edit->startproject;
+ int64_t speed_end = speed_start + edit->length;
+ int64_t speed_length = track->speed_length(speed_start, speed_end);
+ if( edit->startsource + speed_length >= source_len )
+ can_drag = 0;
+ }
+ else if( !edit->startsource )
+ can_drag = 0;
+ int64_t x, y, w, h;
+ edit_dimensions(edit, x, y, w, h);
+ if( y+h < 0 || y >= get_h() ) continue;
+ int edge_x = !drag_handle ? x : x + w;
+ int edge_y = y + h/2, xs10 = xS(10), ys10 = yS(10);
+ if( edge_x >= 0 && edge_x < get_w() ) {
+ if( !can_drag ) {
+ draw_line(edge_x-xs10,edge_y-ys10, edge_x+xs10,edge_y+ys10);
+ draw_line(edge_x-xs10,edge_y+ys10, edge_x+xs10,edge_y-ys10);
+ }
+ else if( !drag_handle ) {
+ draw_line(edge_x+xs10,edge_y-ys10, edge_x,edge_y);
+ draw_line(edge_x+xs10,edge_y+ys10, edge_x,edge_y);
+ }
+ else {
+ draw_line(edge_x,edge_y, edge_x-xs10,edge_y-ys10);
+ draw_line(edge_x,edge_y, edge_x-xs10,edge_y+ys10);
+ }
+ }
+ edge_x += delta;
+ if( edge_x >= 0 && edge_x < get_w() ) {
+ draw_line(edge_x, y, edge_x, y+h);
+ }