+int TrackCanvas::do_transition_handles(int cursor_x, int cursor_y, int button_press,
+ int &rerender, int &update_overlay, int &new_cursor, int &update_cursor)
+{
+ if( !mwindow->edl->session->auto_conf->transitions )
+ return 0;
+ Transition *trans_result = 0;
+ int result = 0;
+
+ Track *track = mwindow->edl->tracks->first;
+ for( ; track && !result; track=track->next) {
+ if( track->is_hidden() ) continue;
+ Edit *edit = track->edits->first;
+ for( ; edit && !result; edit=edit->next ) {
+ Transition *trans = edit->transition;
+ if( !trans ) continue;
+ int64_t x, y, w, h;
+ edit_dimensions(edit, x, y, w, h);
+ int strip_x = x, edit_y = y;
+ get_transition_coords(edit, x, y, w, h);
+ VFrame *strip = mwindow->theme->get_image("plugin_bg_data");
+ int strip_y = y - strip->get_h();
+ if( track->show_assets() && track->show_titles() )
+ edit_y += mwindow->theme->get_image("title_bg_data")->get_h();
+ if( strip_y < edit_y ) strip_y = edit_y;
+ int strip_w = Units::round(edit->track->from_units(edit->transition->length) *
+ mwindow->edl->session->sample_rate / mwindow->edl->local_session->zoom_sample);
+ int x1 = strip_x + strip_w - HANDLE_W/2, x2 = x1 + HANDLE_W;
+ int y1 = strip_y + strip->get_h()/2 - HANDLE_H/2, y2 = y1 + HANDLE_W;
+ if( cursor_x >= x1 && cursor_x < x2 &&
+ cursor_y >= y1 && cursor_y < y2 ) {
+ trans_result = trans;
+ result = 1;
+ }
+ }
+ }
+
+ if( result ) {
+ if( button_press ) {
+ mwindow->session->drag_transition = trans_result;
+ mwindow->session->drag_handle = 1;
+ mwindow->session->drag_button = get_buttonpress() - 1;
+ int64_t trans_end = trans_result->edit->startproject + trans_result->length;
+ double position = trans_result->edit->track->from_units(trans_end);
+ mwindow->session->drag_position = position;
+ mwindow->session->drag_start = position;
+ mwindow->session->current_operation = DRAG_TRANSNHANDLE1;
+ mwindow->session->drag_origin_x = get_cursor_x();
+ mwindow->session->drag_origin_y = get_cursor_y();
+ update_cursor = 1;
+ }
+ new_cursor = RIGHT_CURSOR;
+ update_overlay = 1;
+ }
+
+ return result;
+}
+
+int TrackCanvas::drag_transition_handle(double position)
+{
+ Transition *transition = mwindow->session->drag_transition;
+ if( !transition ) return 1;
+ mwindow->session->drag_position = position;
+ mwindow->edl->local_session->set_selectionstart(position);
+ mwindow->edl->local_session->set_selectionend(position);
+ char string[BCSTRLEN];
+ int64_t length = transition->length;
+ Track *track = transition->edit->track;
+ int64_t start_pos = track->to_units(mwindow->session->drag_start, 0);
+ int64_t end_pos = track->to_units(mwindow->session->drag_position, 0);
+ length += end_pos - start_pos;
+ if( length < 0 ) length = 0;
+ double time = track->from_units(length);
+ Units::totext(string, time,
+ mwindow->edl->session->time_format,
+ mwindow->edl->session->sample_rate,
+ mwindow->edl->session->frame_rate,
+ mwindow->edl->session->frames_per_foot);
+ mwindow->gui->show_message(string);
+ if( mwindow->gui->transition_menu->length_thread->running() ) {
+ TransitionLengthDialog *dialog = (TransitionLengthDialog *)
+ mwindow->gui->transition_menu->length_thread->get_gui();
+ if( dialog ) {
+ dialog->lock_window("TrackCanvas::drag_transition_handle");
+ dialog->update_text(time);
+ dialog->thread->new_length = time;
+ dialog->unlock_window();
+ }
+ }
+ return 0;
+}
+