3 #include "automation.h"
5 #include "bezierauto.h"
6 #include "bezierautos.h"
12 #include "cwindowgui.h"
13 #include "edithandles.h"
14 #include "editpopup.h"
17 #include "edlsession.h"
18 #include "floatauto.h"
19 #include "floatautos.h"
22 #include "keyframepopup.h"
23 #include "keyframes.h"
25 #include "localsession.h"
26 #include "mainclock.h"
27 #include "maincursor.h"
29 #include "maskautos.h"
33 #include "mwindowgui.h"
37 #include "playbackengine.h"
38 #include "playtransport.h"
40 #include "pluginpopup.h"
41 #include "pluginset.h"
42 #include "pluginserver.h"
43 #include "preferences.h"
44 #include "resourcepixmap.h"
45 #include "mainsession.h"
46 #include "transitionhandles.h"
47 #include "transitionpopup.h"
48 #include "transportque.h"
52 #include "trackcanvas.h"
54 #include "transition.h"
56 #include "apatchgui.inc"
57 #include "vpatchgui.inc"
61 TrackCanvas::TrackCanvas(MWindow *mwindow, MWindowGUI *gui)
62 : BC_SubWindow(mwindow->theme->mcanvas_x,
63 mwindow->theme->mcanvas_y,
67 this->mwindow = mwindow;
70 selection_midpoint1 = selection_midpoint2 = 0;
75 translate_selected = 0;
84 TrackCanvas::~TrackCanvas()
86 for(int i = 0; i < resource_pixmaps.total; i++)
87 delete resource_pixmaps.values[i];
88 // delete transition_handles;
90 delete keyframe_pixmap;
91 delete camerakeyframe_pixmap;
92 delete modekeyframe_pixmap;
93 delete pankeyframe_pixmap;
94 delete projectorkeyframe_pixmap;
95 delete maskkeyframe_pixmap;
96 delete background_pixmap;
97 if(temp_picon) delete temp_picon;
100 int TrackCanvas::create_objects()
102 background_pixmap = new BC_Pixmap(this, get_w(), get_h());
103 // transition_handles = new TransitionHandles(mwindow, this);
104 edit_handles = new EditHandles(mwindow, this);
105 keyframe_pixmap = new BC_Pixmap(this, mwindow->theme->keyframe_data, PIXMAP_ALPHA);
106 camerakeyframe_pixmap = new BC_Pixmap(this, mwindow->theme->camerakeyframe_data, PIXMAP_ALPHA);
107 modekeyframe_pixmap = new BC_Pixmap(this, mwindow->theme->modekeyframe_data, PIXMAP_ALPHA);
108 pankeyframe_pixmap = new BC_Pixmap(this, mwindow->theme->pankeyframe_data, PIXMAP_ALPHA);
109 projectorkeyframe_pixmap = new BC_Pixmap(this, mwindow->theme->projectorkeyframe_data, PIXMAP_ALPHA);
110 maskkeyframe_pixmap = new BC_Pixmap(this, mwindow->theme->maskkeyframe_data, PIXMAP_ALPHA);
117 void TrackCanvas::resize_event()
119 //printf("TrackCanvas::resize_event 1\n");
122 //printf("TrackCanvas::resize_event 2\n");
125 int TrackCanvas::keypress_event()
129 switch(get_keypress())
134 mwindow->move_left();
141 mwindow->move_right();
149 mwindow->expand_sample();
162 mwindow->zoom_in_sample();
167 mwindow->zoom_in_y();
188 mwindow->move_down();
193 mwindow->zoom_in_t();
199 // since things under cursor have changed...
201 cursor_motion_event();
206 int TrackCanvas::drag_motion()
209 int cursor_x = get_relative_cursor_x();
210 int cursor_y = get_relative_cursor_y();
211 Track *over_track = 0;
213 PluginSet *over_pluginset = 0;
214 Plugin *over_plugin = 0;
220 drag_popup->cursor_motion_event();
226 if(get_cursor_over_window() &&
229 cursor_x < get_w() &&
232 // Find the edit and track the cursor is over
233 for(Track *track = mwindow->edl->tracks->first; track; track = track->next)
235 int64_t track_x, track_y, track_w, track_h;
236 track_dimensions(track, track_x, track_y, track_w, track_h);
238 if(cursor_y >= track_y &&
239 cursor_y < track_y + track_h)
242 for(Edit *edit = track->edits->first; edit; edit = edit->next)
244 int64_t edit_x, edit_y, edit_w, edit_h;
245 edit_dimensions(edit, edit_x, edit_y, edit_w, edit_h);
247 if(cursor_x >= edit_x &&
248 cursor_y >= edit_y &&
249 cursor_x < edit_x + edit_w &&
250 cursor_y < edit_y + edit_h)
257 for(int i = 0; i < track->plugin_set.total; i++)
259 PluginSet *pluginset = track->plugin_set.values[i];
263 for(Plugin *plugin = (Plugin*)pluginset->first;
265 plugin = (Plugin*)plugin->next)
267 int64_t plugin_x, plugin_y, plugin_w, plugin_h;
268 plugin_dimensions(plugin, plugin_x, plugin_y, plugin_w, plugin_h);
270 if(cursor_y >= plugin_y &&
271 cursor_y < plugin_y + plugin_h)
273 over_pluginset = plugin->plugin_set;
275 if(cursor_x >= plugin_x &&
276 cursor_x < plugin_x + plugin_w)
278 over_plugin = plugin;
289 if (!over_track) // check for pastes from patchbay
290 over_track = mwindow->gui->patchbay->is_over_track();
292 if(mwindow->session->track_highlighted != over_track)
294 mwindow->session->track_highlighted = over_track;
298 if(mwindow->session->edit_highlighted != over_edit)
300 mwindow->session->edit_highlighted = over_edit;
304 if(mwindow->session->pluginset_highlighted != over_pluginset)
306 mwindow->session->pluginset_highlighted = over_pluginset;
310 if(mwindow->session->plugin_highlighted != over_plugin)
312 mwindow->session->plugin_highlighted = over_plugin;
316 //printf("TrackCanvas::drag_motion 2 %p\n", mwindow->session->track_highlighted);
319 lock_window("TrackCanvas::drag_motion");
328 int TrackCanvas::drag_start_event()
333 int new_cursor, update_cursor;
335 if(mwindow->session->current_operation != NO_OPERATION) return 0;
339 if(test_plugins(get_drag_x(),
349 if(test_edits(get_drag_x(),
365 int TrackCanvas::drag_motion_event()
367 return drag_motion();
370 int TrackCanvas::cursor_leave_event()
372 // because drag motion calls get_cursor_over_window we can be sure that all highlights get deleted now
378 int TrackCanvas::drag_stop_event()
380 int result = drag_stop();
384 //printf("TrackCanvas::drag_stop_event 1 %p\n", drag_popup);
392 int TrackCanvas::drag_stop()
394 // In most cases the editing routine redraws and not the drag_stop
395 int result = 0, redraw = 0;
397 switch(mwindow->session->current_operation)
399 case DRAG_VTRANSITION:
400 case DRAG_ATRANSITION:
401 if(mwindow->session->edit_highlighted)
403 if((mwindow->session->current_operation == DRAG_ATRANSITION &&
404 mwindow->session->track_highlighted->data_type == TRACK_AUDIO) ||
405 (mwindow->session->current_operation == DRAG_VTRANSITION &&
406 mwindow->session->track_highlighted->data_type == TRACK_VIDEO))
408 mwindow->session->current_operation = NO_OPERATION;
409 mwindow->paste_transition();
419 // Behavior for dragged plugins is limited by the fact that a shared plugin
420 // can only refer to a standalone plugin that exists in the same position in
421 // time. Dragging a plugin from one point in time to another can't produce
422 // a shared plugin to the original plugin. In this case we relocate the
423 // plugin instead of sharing it.
424 case DRAG_AEFFECT_COPY:
425 case DRAG_VEFFECT_COPY:
426 if(mwindow->session->track_highlighted &&
427 ((mwindow->session->current_operation == DRAG_AEFFECT_COPY &&
428 mwindow->session->track_highlighted->data_type == TRACK_AUDIO) ||
429 (mwindow->session->current_operation == DRAG_VEFFECT_COPY &&
430 mwindow->session->track_highlighted->data_type == TRACK_VIDEO)))
432 mwindow->session->current_operation = NO_OPERATION;
434 // Insert shared plugin in source
435 if(mwindow->session->track_highlighted != mwindow->session->drag_plugin->track &&
436 !mwindow->session->plugin_highlighted &&
437 !mwindow->session->pluginset_highlighted)
439 // Move plugin if different startproject
440 mwindow->move_effect(mwindow->session->drag_plugin,
442 mwindow->session->track_highlighted,
447 // Move source to different location
448 if(mwindow->session->pluginset_highlighted)
450 //printf("TrackCanvas::drag_stop 6\n");
451 if(mwindow->session->plugin_highlighted)
453 mwindow->move_effect(mwindow->session->drag_plugin,
454 mwindow->session->plugin_highlighted->plugin_set,
456 mwindow->session->plugin_highlighted->startproject);
460 mwindow->move_effect(mwindow->session->drag_plugin,
461 mwindow->session->pluginset_highlighted,
463 mwindow->session->pluginset_highlighted->length());
468 // Move to a new plugin set between two edits
469 if(mwindow->session->edit_highlighted)
471 mwindow->move_effect(mwindow->session->drag_plugin,
473 mwindow->session->track_highlighted,
474 mwindow->session->edit_highlighted->startproject);
478 // Move to a new plugin set
479 if(mwindow->session->track_highlighted)
481 mwindow->move_effect(mwindow->session->drag_plugin,
483 mwindow->session->track_highlighted,
492 if(mwindow->session->track_highlighted &&
493 ((mwindow->session->current_operation == DRAG_AEFFECT &&
494 mwindow->session->track_highlighted->data_type == TRACK_AUDIO) ||
495 (mwindow->session->current_operation == DRAG_VEFFECT &&
496 mwindow->session->track_highlighted->data_type == TRACK_VIDEO)))
498 // Drop all the effects
499 PluginSet *plugin_set = mwindow->session->pluginset_highlighted;
500 Track *track = mwindow->session->track_highlighted;
502 double length = track->get_length();
504 if(mwindow->session->plugin_highlighted)
506 start = track->from_units(mwindow->session->plugin_highlighted->startproject);
507 length = track->from_units(mwindow->session->plugin_highlighted->length);
508 if(length <= 0) length = track->get_length();
511 if(mwindow->session->pluginset_highlighted)
513 start = track->from_units(plugin_set->length());
514 length = track->get_length() - start;
515 if(length <= 0) length = track->get_length();
518 if(mwindow->edl->local_session->get_selectionend() >
519 mwindow->edl->local_session->get_selectionstart())
521 start = mwindow->edl->local_session->get_selectionstart();
522 length = mwindow->edl->local_session->get_selectionend() -
523 mwindow->edl->local_session->get_selectionstart();
525 // Move to a point between two edits
527 if(mwindow->session->edit_highlighted)
529 start = mwindow->session->track_highlighted->from_units(
530 mwindow->session->edit_highlighted->startproject);
531 length = mwindow->session->track_highlighted->from_units(
532 mwindow->session->edit_highlighted->length);
535 mwindow->insert_effects_canvas(start, length);
538 if (mwindow->session->track_highlighted)
539 result = 1; // we have to cleanup
543 if(mwindow->session->track_highlighted)
545 int64_t position = mwindow->session->edit_highlighted ?
546 mwindow->session->edit_highlighted->startproject :
547 mwindow->session->track_highlighted->edits->length();
548 double position_f = mwindow->session->track_highlighted->from_units(position);
549 Track *track = mwindow->session->track_highlighted;
550 mwindow->paste_assets(position_f, track);
551 result = 1; // need to be one no matter what, since we have track highlited so we have to cleanup....
556 mwindow->session->current_operation = NO_OPERATION;
557 if(mwindow->session->track_highlighted)
559 if(mwindow->session->track_highlighted->data_type == mwindow->session->drag_edit->track->data_type)
561 int64_t position = mwindow->session->edit_highlighted ?
562 mwindow->session->edit_highlighted->startproject :
563 mwindow->session->track_highlighted->edits->length();
564 double position_f = mwindow->session->track_highlighted->from_units(position);
565 Track *track = mwindow->session->track_highlighted;
566 mwindow->move_edits(mwindow->session->drag_edits,
576 // since we don't have subwindows we have to terminate any drag operation
579 if (mwindow->session->track_highlighted
580 || mwindow->session->edit_highlighted
581 || mwindow->session->plugin_highlighted
582 || mwindow->session->pluginset_highlighted)
584 mwindow->session->track_highlighted = 0;
585 mwindow->session->edit_highlighted = 0;
586 mwindow->session->plugin_highlighted = 0;
587 mwindow->session->pluginset_highlighted = 0;
588 mwindow->session->current_operation = NO_OPERATION;
592 //printf("TrackCanvas::drag_stop %d %d\n", redraw, mwindow->session->current_operation);
595 mwindow->edl->tracks->update_y_pixels(mwindow->theme);
596 gui->get_scrollbars();
598 gui->patchbay->update();
599 gui->cursor->update();
608 void TrackCanvas::draw(int force, int hide_cursor)
610 // Swap pixmap layers
611 TRACE("TrackCanvas::draw 1")
612 if(get_w() != background_pixmap->get_w() ||
613 get_h() != background_pixmap->get_h())
615 delete background_pixmap;
616 background_pixmap = new BC_Pixmap(this, get_w(), get_h());
619 TRACE("TrackCanvas::draw 10")
620 // Cursor disappears after resize when this is called.
621 // Cursor doesn't redraw after editing when this isn't called.
622 if(gui->cursor && hide_cursor) gui->cursor->hide();
623 TRACE("TrackCanvas::draw 20")
624 draw_top_background(get_parent(), 0, 0, get_w(), get_h(), background_pixmap);
625 TRACE("TrackCanvas::draw 30")
626 draw_resources(force);
627 TRACE("TrackCanvas::draw 40")
632 void TrackCanvas::update_cursor()
634 switch(mwindow->edl->session->editing_mode)
636 case EDITING_ARROW: set_cursor(ARROW_CURSOR); break;
637 case EDITING_IBEAM: set_cursor(IBEAM_CURSOR); break;
642 void TrackCanvas::draw_indexes(Asset *asset)
644 // Don't redraw raw samples
645 if(asset->index_zoom > mwindow->edl->local_session->zoom_sample)
648 draw_resources(0, 1, asset);
656 void TrackCanvas::draw_resources(int force,
660 // Age resource pixmaps for deletion
662 for(int i = 0; i < resource_pixmaps.total; i++)
663 resource_pixmaps.values[i]->visible--;
666 resource_pixmaps.remove_all_objects();
668 //printf("TrackCanvas::draw_resources 1 %d %d\n", force, indexes_only);
671 for(Track *current = mwindow->edl->tracks->first;
675 //printf("TrackCanvas::draw_resources 2\n");
676 for(Edit *edit = current->edits->first; edit; edit = edit->next)
678 //printf("TrackCanvas::draw_resources 3\n");
679 if(!edit->asset) continue;
680 //printf("TrackCanvas::draw_resources 4\n");
683 if(edit->track->data_type != TRACK_AUDIO) continue;
684 if(!edit->asset->test_path(index_asset->path)) continue;
687 int64_t edit_x, edit_y, edit_w, edit_h;
688 edit_dimensions(edit, edit_x, edit_y, edit_w, edit_h);
689 //printf("TrackCanvas::draw_resources 10\n");
692 if(MWindowGUI::visible(edit_x, edit_x + edit_w, 0, get_w()) &&
693 MWindowGUI::visible(edit_y, edit_y + edit_h, 0, get_h()))
695 int64_t pixmap_x, pixmap_w, pixmap_h;
697 //printf("TrackCanvas::draw_resources 20\n");
698 // Search for existing pixmap containing edit
699 for(int i = 0; i < resource_pixmaps.total; i++)
701 ResourcePixmap* pixmap = resource_pixmaps.values[i];
702 //printf("TrackCanvas::draw_resources 30\n");
703 // Same pointer can be different edit if editing took place
704 if(pixmap->edit_id == edit->id)
706 //printf("TrackCanvas::draw_resources 40\n");
710 //printf("TrackCanvas::draw_resources 50\n");
713 // Get new size, offset of pixmap needed
714 get_pixmap_size(edit,
720 //printf("TrackCanvas::draw_resources 60\n");
723 if(pixmap_w && pixmap_h)
725 // Create pixmap if it doesn't exist
726 ResourcePixmap* pixmap = create_pixmap(edit,
731 //printf("TrackCanvas::draw_resources 70\n");
732 // Resize it if it's bigger
733 if(pixmap_w > pixmap->pixmap_w ||
734 pixmap_h > pixmap->pixmap_h)
735 pixmap->resize(pixmap_w, pixmap_h);
736 //printf("TrackCanvas::draw_resources 80\n");
737 pixmap->draw_data(edit,
745 //printf("TrackCanvas::draw_resources 90\n");
746 // Resize it if it's smaller
747 if(pixmap_w < pixmap->pixmap_w ||
748 pixmap_h < pixmap->pixmap_h)
749 pixmap->resize(pixmap_w, pixmap_h);
750 //printf("TrackCanvas::draw_resources 100\n");
751 // Copy pixmap to background canvas
752 background_pixmap->draw_pixmap(pixmap,
757 //printf("TrackCanvas::draw_resources 110\n");
762 //printf("TrackCanvas::draw_resources 200\n");
764 // Delete unused pixmaps
766 for(int i = resource_pixmaps.total - 1; i >= 0; i--)
767 if(resource_pixmaps.values[i]->visible < -5)
769 delete resource_pixmaps.values[i];
770 resource_pixmaps.remove(resource_pixmaps.values[i]);
774 ResourcePixmap* TrackCanvas::create_pixmap(Edit *edit,
780 ResourcePixmap *result = 0;
782 for(int i = 0; i < resource_pixmaps.total; i++)
784 //printf("TrackCanvas::create_pixmap 1 %d %d\n", edit->id, resource_pixmaps.values[i]->edit->id);
785 if(resource_pixmaps.values[i]->edit_id == edit->id)
787 result = resource_pixmaps.values[i];
794 //printf("TrackCanvas::create_pixmap 2\n");
795 result = new ResourcePixmap(mwindow,
800 resource_pixmaps.append(result);
803 // result->resize(pixmap_w, pixmap_h);
807 void TrackCanvas::get_pixmap_size(Edit *edit,
815 // Align x on frame boundaries
818 // switch(edit->edits->track->data_type)
830 if(pixmap_x + pixmap_w > get_w())
832 pixmap_w = get_w() - pixmap_x;
839 // int64_t picon_w = (int64_t)(edit->picon_w() + 0.5);
840 // int64_t frame_w = (int64_t)(edit->frame_w() + 0.5);
841 // int64_t pixel_increment = MAX(picon_w, frame_w);
842 // int64_t pixmap_x1 = edit_x;
843 // int64_t pixmap_x2 = edit_x + edit_w;
847 // pixmap_x1 = (int64_t)((double)-edit_x / pixel_increment) *
852 // if(pixmap_x2 > get_w())
854 // pixmap_x2 = (int64_t)((double)(get_w() - edit_x) / pixel_increment + 1) *
858 // pixmap_x = pixmap_x1;
859 // pixmap_w = pixmap_x2 - pixmap_x1;
864 pixmap_h = mwindow->edl->local_session->zoom_track;
865 if(mwindow->edl->session->show_titles) pixmap_h += mwindow->theme->title_bg_data->get_h();
866 //printf("get_pixmap_size %d %d %d %d\n", edit_x, edit_w, pixmap_x, pixmap_w);
869 void TrackCanvas::edit_dimensions(Edit *edit,
875 //printf("TrackCanvas::edit_dimensions 1 %p\n", edit->track);
876 w = Units::round(edit->track->from_units(edit->length) *
877 mwindow->edl->session->sample_rate /
878 mwindow->edl->local_session->zoom_sample);
879 //printf("TrackCanvas::edit_dimensions 1\n");
883 //printf("TrackCanvas::edit_dimensions 1\n");
884 x = Units::round(edit->track->from_units(edit->startproject) *
885 mwindow->edl->session->sample_rate /
886 mwindow->edl->local_session->zoom_sample -
887 mwindow->edl->local_session->view_start);
889 //printf("TrackCanvas::edit_dimensions 1\n");
890 y = edit->edits->track->y_pixel;
891 //printf("TrackCanvas::edit_dimensions 1\n");
893 if(mwindow->edl->session->show_titles)
894 h += mwindow->theme->title_bg_data->get_h();
895 //printf("TrackCanvas::edit_dimensions 2\n");
898 void TrackCanvas::track_dimensions(Track *track, int64_t &x, int64_t &y, int64_t &w, int64_t &h)
903 h = track->vertical_span(mwindow->theme);
907 void TrackCanvas::draw_paste_destination()
909 int current_atrack = 0;
910 int current_vtrack = 0;
911 int current_aedit = 0;
912 int current_vedit = 0;
917 //printf("TrackCanvas::draw_paste_destination 1\n");
918 if((mwindow->session->current_operation == DRAG_ASSET &&
919 (mwindow->session->drag_assets->total ||
920 mwindow->session->drag_clips->total)) ||
921 (mwindow->session->current_operation == DRAG_EDIT &&
922 mwindow->session->drag_edits->total))
924 //printf("TrackCanvas::draw_paste_destination 1\n");
929 if(mwindow->session->current_operation == DRAG_ASSET &&
930 mwindow->session->drag_assets->total)
931 asset = mwindow->session->drag_assets->values[0];
933 if(mwindow->session->current_operation == DRAG_ASSET &&
934 mwindow->session->drag_clips->total)
935 clip = mwindow->session->drag_clips->values[0];
937 // Get destination track
938 for(Track *dest = mwindow->session->track_highlighted;
944 // Get source width in pixels
948 // Use start of highlighted edit
949 if(mwindow->session->edit_highlighted)
950 position = mwindow->session->track_highlighted->from_units(
951 mwindow->session->edit_highlighted->startproject);
953 // Use end of highlighted track, disregarding effects
954 position = mwindow->session->track_highlighted->from_units(
955 mwindow->session->track_highlighted->edits->length());
957 // Get the x coordinate
958 x = Units::to_int64(position *
959 mwindow->edl->session->sample_rate /
960 mwindow->edl->local_session->zoom_sample) -
961 mwindow->edl->local_session->view_start;
963 if(dest->data_type == TRACK_AUDIO)
965 if(asset && current_atrack < asset->channels)
967 w = Units::to_int64((double)asset->audio_length /
969 mwindow->edl->session->sample_rate /
970 mwindow->edl->local_session->zoom_sample);
975 if(clip && current_atrack < clip->tracks->total_audio_tracks())
977 w = Units::to_int64((double)clip->tracks->total_length() *
978 mwindow->edl->session->sample_rate /
979 mwindow->edl->local_session->zoom_sample);
980 //printf("draw_paste_destination %d\n", x);
985 if(mwindow->session->current_operation == DRAG_EDIT &&
986 current_aedit < mwindow->session->drag_edits->total)
989 while(current_aedit < mwindow->session->drag_edits->total &&
990 mwindow->session->drag_edits->values[current_aedit]->track->data_type != TRACK_AUDIO)
993 if(current_aedit < mwindow->session->drag_edits->total)
995 edit = mwindow->session->drag_edits->values[current_aedit];
996 w = Units::to_int64(edit->length / mwindow->edl->local_session->zoom_sample);
1004 if(dest->data_type == TRACK_VIDEO)
1006 //printf("draw_paste_destination 1\n");
1007 if(asset && current_vtrack < asset->layers)
1009 w = Units::to_int64((double)asset->video_length /
1011 mwindow->edl->session->sample_rate /
1012 mwindow->edl->local_session->zoom_sample);
1017 if(clip && current_vtrack < clip->tracks->total_video_tracks())
1019 w = Units::to_int64(clip->tracks->total_length() *
1020 mwindow->edl->session->sample_rate /
1021 mwindow->edl->local_session->zoom_sample);
1026 if(mwindow->session->current_operation == DRAG_EDIT &&
1027 current_vedit < mwindow->session->drag_edits->total)
1029 //printf("draw_paste_destination 2\n");
1031 while(current_vedit < mwindow->session->drag_edits->total &&
1032 mwindow->session->drag_edits->values[current_vedit]->track->data_type != TRACK_VIDEO)
1035 if(current_vedit < mwindow->session->drag_edits->total)
1037 //printf("draw_paste_destination 3\n");
1038 edit = mwindow->session->drag_edits->values[current_vedit];
1039 w = Units::to_int64(edit->track->from_units(edit->length) *
1040 mwindow->edl->session->sample_rate /
1041 mwindow->edl->local_session->zoom_sample);
1051 int y = dest->y_pixel;
1052 int h = dest->vertical_span(mwindow->theme);
1055 //printf("TrackCanvas::draw_paste_destination 2 %d %d %d %d\n", x, y, w, h);
1056 if(x < -BC_INFINITY)
1058 w -= -BC_INFINITY - x;
1059 x += -BC_INFINITY - x;
1062 draw_highlight_rectangle(x, y, w, h);
1069 void TrackCanvas::plugin_dimensions(Plugin *plugin, int64_t &x, int64_t &y, int64_t &w, int64_t &h)
1071 x = Units::round(plugin->track->from_units(plugin->startproject) *
1072 mwindow->edl->session->sample_rate /
1073 mwindow->edl->local_session->zoom_sample -
1074 mwindow->edl->local_session->view_start);
1075 w = Units::round(plugin->track->from_units(plugin->length) *
1076 mwindow->edl->session->sample_rate /
1077 mwindow->edl->local_session->zoom_sample);
1078 y = plugin->track->y_pixel +
1079 mwindow->edl->local_session->zoom_track +
1080 plugin->plugin_set->get_number() *
1081 mwindow->theme->plugin_bg_data->get_h();
1082 if(mwindow->edl->session->show_titles)
1083 y += mwindow->theme->title_bg_data->get_h();
1084 h = mwindow->theme->plugin_bg_data->get_h();
1087 int TrackCanvas::resource_h()
1089 return mwindow->edl->local_session->zoom_track;
1092 void TrackCanvas::draw_highlight_rectangle(int x, int y, int w, int h)
1104 w = MIN(w, get_w() + 20);
1105 h = MIN(h, get_h() + 20);
1108 draw_rectangle(x, y, w, h);
1109 draw_rectangle(x + 1, y + 1, w - 2, h - 2);
1111 //printf("TrackCanvas::draw_highlight_rectangle %d %d %d %d\n", x, y, w, h);
1114 void TrackCanvas::draw_playback_cursor()
1116 // Called before playback_cursor exists
1117 // if(mwindow->playback_cursor && mwindow->playback_cursor->visible)
1119 // mwindow->playback_cursor->visible = 0;
1120 // mwindow->playback_cursor->draw();
1124 void TrackCanvas::get_handle_coords(Edit *edit, int64_t &x, int64_t &y, int64_t &w, int64_t &h, int side)
1126 int handle_w = mwindow->theme->edithandlein_data[0]->get_w();
1127 int handle_h = mwindow->theme->edithandlein_data[0]->get_h();
1129 edit_dimensions(edit, x, y, w, h);
1131 if(mwindow->edl->session->show_titles)
1133 y += mwindow->theme->title_bg_data->get_h();
1140 if(side == EDIT_OUT)
1149 void TrackCanvas::get_transition_coords(int64_t &x, int64_t &y, int64_t &w, int64_t &h)
1151 //printf("TrackCanvas::get_transition_coords 1\n");
1152 // int transition_w = mwindow->theme->transitionhandle_data[0]->get_w();
1153 // int transition_h = mwindow->theme->transitionhandle_data[0]->get_h();
1154 int transition_w = 30;
1155 int transition_h = 30;
1156 //printf("TrackCanvas::get_transition_coords 1\n");
1158 if(mwindow->edl->session->show_titles)
1159 y += mwindow->theme->title_bg_data->get_h();
1160 //printf("TrackCanvas::get_transition_coords 2\n");
1162 y += (h - mwindow->theme->title_bg_data->get_h()) / 2 - transition_h / 2;
1163 x -= transition_w / 2;
1169 void TrackCanvas::draw_highlighting()
1173 //printf("TrackCanvas::draw_highlighting 1 %p %d\n", mwindow->session->track_highlighted, mwindow->session->current_operation);
1177 switch(mwindow->session->current_operation)
1179 case DRAG_ATRANSITION:
1180 case DRAG_VTRANSITION:
1181 //printf("TrackCanvas::draw_highlighting 1 %p %p\n",
1182 // mwindow->session->track_highlighted, mwindow->session->edit_highlighted);
1183 if(mwindow->session->edit_highlighted)
1185 //printf("TrackCanvas::draw_highlighting 2\n");
1186 if((mwindow->session->current_operation == DRAG_ATRANSITION &&
1187 mwindow->session->track_highlighted->data_type == TRACK_AUDIO) ||
1188 (mwindow->session->current_operation == DRAG_VTRANSITION &&
1189 mwindow->session->track_highlighted->data_type == TRACK_VIDEO))
1191 //printf("TrackCanvas::draw_highlighting 2\n");
1192 edit_dimensions(mwindow->session->edit_highlighted, x, y, w, h);
1193 //printf("TrackCanvas::draw_highlighting 2\n");
1195 if(MWindowGUI::visible(x, x + w, 0, get_w()) &&
1196 MWindowGUI::visible(y, y + h, 0, get_h()))
1199 get_transition_coords(x, y, w, h);
1201 //printf("TrackCanvas::draw_highlighting 3\n");
1208 // Dragging a new effect from the Resource window
1211 if(mwindow->session->track_highlighted &&
1212 ((mwindow->session->current_operation == DRAG_AEFFECT && mwindow->session->track_highlighted->data_type == TRACK_AUDIO) ||
1213 (mwindow->session->current_operation == DRAG_VEFFECT && mwindow->session->track_highlighted->data_type == TRACK_VIDEO)))
1215 // Put it before another plugin
1216 if(mwindow->session->plugin_highlighted)
1218 plugin_dimensions(mwindow->session->plugin_highlighted,
1223 //printf("TrackCanvas::draw_highlighting 1 %d %d\n", x, w);
1226 // Put it after a plugin set
1227 if(mwindow->session->pluginset_highlighted &&
1228 mwindow->session->pluginset_highlighted->last)
1230 plugin_dimensions((Plugin*)mwindow->session->pluginset_highlighted->last,
1235 //printf("TrackCanvas::draw_highlighting 1 %d %d\n", x, w);
1236 int64_t track_x, track_y, track_w, track_h;
1237 track_dimensions(mwindow->session->track_highlighted,
1245 mwindow->session->track_highlighted->get_length() *
1246 mwindow->edl->session->sample_rate /
1247 mwindow->edl->local_session->zoom_sample -
1248 mwindow->edl->local_session->view_start) -
1250 //printf("TrackCanvas::draw_highlighting 2 %d\n", w);
1251 if(w <= 0) w = track_w;
1255 track_dimensions(mwindow->session->track_highlighted,
1261 //printf("TrackCanvas::draw_highlighting 1 %d %d %d %d\n", x, y, w, h);
1262 // Put it in a new plugin set determined by the selected range
1263 if(mwindow->edl->local_session->get_selectionend() >
1264 mwindow->edl->local_session->get_selectionstart())
1266 x = Units::to_int64(mwindow->edl->local_session->get_selectionstart() *
1267 mwindow->edl->session->sample_rate /
1268 mwindow->edl->local_session->zoom_sample -
1269 mwindow->edl->local_session->view_start);
1270 w = Units::to_int64((mwindow->edl->local_session->get_selectionend() -
1271 mwindow->edl->local_session->get_selectionstart()) *
1272 mwindow->edl->session->sample_rate /
1273 mwindow->edl->local_session->zoom_sample);
1275 // Put it in a new plugin set determined by an edit boundary
1277 if(mwindow->session->edit_highlighted)
1279 int64_t temp_y, temp_h;
1280 edit_dimensions(mwindow->session->edit_highlighted,
1286 // Put it at the beginning of the track in a new plugin set
1289 if(MWindowGUI::visible(x, x + w, 0, get_w()) &&
1290 MWindowGUI::visible(y, y + h, 0, get_h()))
1292 //printf("TrackCanvas::draw_highlighting 1\n");
1299 if(mwindow->session->track_highlighted)
1301 track_dimensions(mwindow->session->track_highlighted, x, y, w, h);
1303 if(MWindowGUI::visible(y, y + h, 0, get_h()))
1305 draw_paste_destination();
1310 // Dragging an effect from the timeline
1311 case DRAG_AEFFECT_COPY:
1312 case DRAG_VEFFECT_COPY:
1313 if((mwindow->session->plugin_highlighted || mwindow->session->track_highlighted) &&
1314 ((mwindow->session->current_operation == DRAG_AEFFECT_COPY && mwindow->session->track_highlighted->data_type == TRACK_AUDIO) ||
1315 (mwindow->session->current_operation == DRAG_VEFFECT_COPY && mwindow->session->track_highlighted->data_type == TRACK_VIDEO)))
1317 // Put it before another plugin
1318 if(mwindow->session->plugin_highlighted)
1319 plugin_dimensions(mwindow->session->plugin_highlighted, x, y, w, h);
1321 // Put it after a plugin set
1322 if(mwindow->session->pluginset_highlighted &&
1323 mwindow->session->pluginset_highlighted->last)
1325 plugin_dimensions((Plugin*)mwindow->session->pluginset_highlighted->last, x, y, w, h);
1329 if(mwindow->session->track_highlighted)
1331 track_dimensions(mwindow->session->track_highlighted, x, y, w, h);
1333 // Put it in a new plugin set determined by an edit boundary
1334 if(mwindow->session->edit_highlighted)
1336 int64_t temp_y, temp_h;
1337 edit_dimensions(mwindow->session->edit_highlighted,
1343 // Put it in a new plugin set at the start of the track
1346 // Calculate length of plugin based on data type of track and units
1347 if(mwindow->session->track_highlighted->data_type == TRACK_VIDEO)
1349 w = (int64_t)((double)mwindow->session->drag_plugin->length /
1350 mwindow->edl->session->frame_rate *
1351 mwindow->edl->session->sample_rate /
1352 mwindow->edl->local_session->zoom_sample);
1356 w = (int64_t)mwindow->session->drag_plugin->length /
1357 mwindow->edl->local_session->zoom_sample;
1360 if(MWindowGUI::visible(x, x + w, 0, get_w()) &&
1361 MWindowGUI::visible(y, y + h, 0, get_h()))
1370 //printf("TrackCanvas::draw_highlighting 1\n");
1371 if(mwindow->session->track_highlighted)
1373 track_dimensions(mwindow->session->track_highlighted, x, y, w, h);
1375 if(MWindowGUI::visible(y, y + h, 0, get_h()))
1377 draw_paste_destination();
1388 draw_highlight_rectangle(x, y, w, h);
1392 void TrackCanvas::draw_plugins()
1394 char string[BCTEXTLEN];
1396 for(Track *track = mwindow->edl->tracks->first;
1398 track = track->next)
1400 if(track->expand_view)
1402 for(int i = 0; i < track->plugin_set.total; i++)
1404 PluginSet *pluginset = track->plugin_set.values[i];
1406 for(Plugin *plugin = (Plugin*)pluginset->first; plugin; plugin = (Plugin*)plugin->next)
1408 int64_t total_x, y, total_w, h;
1409 plugin_dimensions(plugin, total_x, y, total_w, h);
1411 if(MWindowGUI::visible(total_x, total_x + total_w, 0, get_w()) &&
1412 MWindowGUI::visible(y, y + h, 0, get_h()) &&
1413 plugin->plugin_type != PLUGIN_NONE)
1415 int x = total_x, w = total_w, left_margin = 5;
1421 if(w + x > get_w()) w -= (w + x) - get_w();
1428 mwindow->theme->plugin_bg_data,
1431 set_font(MEDIUMFONT_3D);
1432 plugin->calculate_title(string, 0);
1434 // Truncate string to int64_test visible in background
1435 int len = strlen(string), j;
1436 for(j = len; j >= 0; j--)
1438 if(left_margin + get_text_width(MEDIUMFONT_3D, string) > w)
1446 // Justify the text on the left boundary of the edit if it is visible.
1447 // Otherwise justify it on the left side of the screen.
1448 int text_x = total_x + left_margin;
1449 text_x = MAX(left_margin, text_x);
1451 y + get_text_ascent(MEDIUMFONT_3D) + 2,
1463 void TrackCanvas::draw_inout_points()
1468 void TrackCanvas::draw_drag_handle()
1470 if(mwindow->session->current_operation == DRAG_EDITHANDLE2 ||
1471 mwindow->session->current_operation == DRAG_PLUGINHANDLE2)
1473 //printf("TrackCanvas::draw_drag_handle 1 %ld %ld\n", mwindow->session->drag_sample, mwindow->edl->local_session->view_start);
1474 int64_t pixel1 = Units::round(mwindow->session->drag_position *
1475 mwindow->edl->session->sample_rate /
1476 mwindow->edl->local_session->zoom_sample -
1477 mwindow->edl->local_session->view_start);
1478 //printf("TrackCanvas::draw_drag_handle 2 %d\n", pixel1);
1481 //printf("TrackCanvas::draw_drag_handle 3\n");
1482 draw_line(pixel1, 0, pixel1, get_h());
1484 //printf("TrackCanvas::draw_drag_handle 4\n");
1489 void TrackCanvas::draw_transitions()
1493 for(Track *track = mwindow->edl->tracks->first;
1495 track = track->next)
1497 for(Edit *edit = track->edits->first;
1501 if(edit->transition)
1503 int64_t strip_w, strip_x, strip_y;
1504 edit_dimensions(edit, x, y, w, h);
1507 if(mwindow->edl->session->show_titles)
1508 strip_y += mwindow->theme->title_bg_data->get_h();
1510 get_transition_coords(x, y, w, h);
1511 strip_w = Units::round(edit->track->from_units(edit->transition->length) *
1512 mwindow->edl->session->sample_rate /
1513 mwindow->edl->local_session->zoom_sample);
1515 if(MWindowGUI::visible(x, x + w, 0, get_w()) &&
1516 MWindowGUI::visible(y, y + h, 0, get_h()))
1518 PluginServer *server = mwindow->scan_plugindb(edit->transition->title,
1520 draw_vframe(server->picon,
1527 server->picon->get_w(),
1528 server->picon->get_h());
1530 if(MWindowGUI::visible(strip_x, strip_x + strip_w, 0, get_w()) &&
1531 MWindowGUI::visible(strip_y, strip_y + h, 0, get_h()))
1533 int x = strip_x, w = strip_w, left_margin = 5;
1539 if(w + x > get_w()) w -= (w + x) - get_w();
1547 mwindow->theme->plugin_bg_data,
1556 void TrackCanvas::draw_loop_points()
1558 //printf("TrackCanvas::draw_loop_points 1\n");
1559 if(mwindow->edl->local_session->loop_playback)
1561 //printf("TrackCanvas::draw_loop_points 2\n");
1562 int64_t x = Units::round(mwindow->edl->local_session->loop_start *
1563 mwindow->edl->session->sample_rate /
1564 mwindow->edl->local_session->zoom_sample -
1565 mwindow->edl->local_session->view_start);
1566 //printf("TrackCanvas::draw_loop_points 3\n");
1568 if(MWindowGUI::visible(x, x + 1, 0, get_w()))
1571 draw_line(x, 0, x, get_h());
1573 //printf("TrackCanvas::draw_loop_points 4\n");
1575 x = Units::round(mwindow->edl->local_session->loop_end *
1576 mwindow->edl->session->sample_rate /
1577 mwindow->edl->local_session->zoom_sample -
1578 mwindow->edl->local_session->view_start);
1579 //printf("TrackCanvas::draw_loop_points 5\n");
1581 if(MWindowGUI::visible(x, x + 1, 0, get_w()))
1584 draw_line(x, 0, x, get_h());
1586 //printf("TrackCanvas::draw_loop_points 6\n");
1588 //printf("TrackCanvas::draw_loop_points 7\n");
1591 void TrackCanvas::draw_brender_start()
1593 if(mwindow->preferences->use_brender)
1595 int64_t x = Units::round(mwindow->edl->session->brender_start *
1596 mwindow->edl->session->sample_rate /
1597 mwindow->edl->local_session->zoom_sample -
1598 mwindow->edl->local_session->view_start);
1600 if(MWindowGUI::visible(x, x + 1, 0, get_w()))
1603 draw_line(x, 0, x, get_h());
1608 int TrackCanvas::do_keyframes(int cursor_x,
1616 int current_tool = 0;
1618 EDLSession *session = mwindow->edl->session;
1620 for(Track *track = mwindow->edl->tracks->first;
1622 track = track->next)
1624 Automation *automation = track->automation;
1626 //printf("TrackCanvas::draw_keyframes 1\n");
1627 if(!result && session->auto_conf->fade)
1629 result = do_float_autos(track,
1630 automation->fade_autos,
1636 if(result && mwindow->session->current_operation == DRAG_FADE)
1640 if(result && buttonpress)
1642 synchronize_autos(0, track, (FloatAuto*)mwindow->session->drag_auto, 1);
1643 mwindow->session->current_operation = DRAG_FADE;
1644 update_drag_caption();
1648 //printf("TrackCanvas::draw_keyframes 1 %d\n", result);
1650 if(!result && session->auto_conf->czoom && automation->czoom_autos)
1652 result = do_float_autos(track,
1653 automation->czoom_autos,
1659 if(result && mwindow->session->current_operation == DRAG_CZOOM)
1663 if(result && buttonpress)
1665 mwindow->session->current_operation = DRAG_CZOOM;
1666 update_drag_caption();
1670 //printf("TrackCanvas::draw_keyframes 2 %d\n", result);
1671 if(!result && session->auto_conf->pzoom && automation->pzoom_autos)
1673 result = do_float_autos(track,
1674 automation->pzoom_autos,
1680 if(result && mwindow->session->current_operation == DRAG_PZOOM)
1684 if(result && buttonpress)
1686 mwindow->session->current_operation = DRAG_PZOOM;
1687 update_drag_caption();
1691 //printf("TrackCanvas::draw_keyframes 1 %d\n", result);
1692 if(!result && session->auto_conf->mute)
1694 result = do_toggle_autos(track,
1695 automation->mute_autos,
1701 if(result && mwindow->session->current_operation == DRAG_MUTE)
1705 if(result && buttonpress)
1707 mwindow->session->current_operation = DRAG_MUTE;
1708 update_drag_caption();
1712 //printf("TrackCanvas::draw_keyframes 1 %d\n", result);
1713 if(!result && session->auto_conf->camera && automation->camera_autos)
1715 result = do_autos(track,
1716 automation->camera_autos,
1721 camerakeyframe_pixmap);
1722 if(result && mwindow->session->current_operation == DRAG_CAMERA)
1726 if(result && buttonpress)
1728 mwindow->session->current_operation = DRAG_CAMERA_PRE;
1729 update_drag_caption();
1734 if(!result && session->auto_conf->mode && automation->mode_autos)
1736 result = do_autos(track,
1737 automation->mode_autos,
1742 modekeyframe_pixmap);
1743 if(result && mwindow->session->current_operation == DRAG_MODE)
1747 if(result && buttonpress)
1749 mwindow->session->current_operation = DRAG_MODE_PRE;
1750 update_drag_caption();
1755 //printf("TrackCanvas::draw_keyframes 1 %d\n", result);
1756 if(!result && session->auto_conf->projector && automation->projector_autos)
1758 result = do_autos(track,
1759 automation->projector_autos,
1764 projectorkeyframe_pixmap);
1765 if(result && mwindow->session->current_operation == DRAG_PROJECTOR)
1769 if(result && buttonpress)
1771 mwindow->session->current_operation = DRAG_PROJECTOR_PRE;
1772 update_drag_caption();
1777 if(!result && session->auto_conf->mask && automation->mask_autos)
1779 result = do_autos(track,
1780 automation->mask_autos,
1785 maskkeyframe_pixmap);
1786 if(result && mwindow->session->current_operation == DRAG_MASK)
1790 if(result && buttonpress)
1792 mwindow->session->current_operation = DRAG_MASK_PRE;
1793 update_drag_caption();
1798 //printf("TrackCanvas::draw_keyframes 1 %d\n", result);
1799 if(!result && session->auto_conf->pan && automation->pan_autos)
1801 result = do_autos(track,
1802 automation->pan_autos,
1807 pankeyframe_pixmap);
1808 if(result && mwindow->session->current_operation == DRAG_PAN)
1812 if(result && buttonpress)
1814 mwindow->session->current_operation = DRAG_PAN_PRE;
1815 update_drag_caption();
1820 //printf("TrackCanvas::draw_keyframes 1 %d\n", result);
1821 if(!result && session->auto_conf->plugins)
1825 result = do_plugin_autos(track,
1832 if(result && mwindow->session->current_operation == DRAG_PLUGINKEY)
1836 if(result && (buttonpress == 1))
1838 mwindow->session->current_operation = DRAG_PLUGINKEY_PRE;
1839 update_drag_caption();
1842 if (result && (buttonpress == 3))
1844 gui->keyframe_menu->update(plugin, keyframe);
1845 gui->keyframe_menu->activate_menu();
1846 rerender = 1; // the position changes
1849 if(result && (buttonpress == 3))
1851 gui->keyframe_menu->update(plugin, keyframe);
1852 gui->keyframe_menu->activate_menu();
1853 rerender = 1; // the position changes
1856 //printf("TrackCanvas::draw_keyframes 1 %d\n", result);
1859 if(mwindow->session->current_operation == DRAG_FADE ||
1860 mwindow->session->current_operation == DRAG_CZOOM ||
1861 mwindow->session->current_operation == DRAG_PZOOM ||
1862 mwindow->session->current_operation == DRAG_PLAY ||
1863 mwindow->session->current_operation == DRAG_MUTE ||
1864 mwindow->session->current_operation == DRAG_CAMERA ||
1865 mwindow->session->current_operation == DRAG_CAMERA_PRE ||
1866 mwindow->session->current_operation == DRAG_MASK ||
1867 mwindow->session->current_operation == DRAG_MASK_PRE ||
1868 mwindow->session->current_operation == DRAG_MODE ||
1869 mwindow->session->current_operation == DRAG_MODE_PRE ||
1870 mwindow->session->current_operation == DRAG_PAN ||
1871 mwindow->session->current_operation == DRAG_PAN_PRE ||
1872 mwindow->session->current_operation == DRAG_PLUGINKEY ||
1873 mwindow->session->current_operation == DRAG_PLUGINKEY_PRE ||
1874 mwindow->session->current_operation == DRAG_PROJECTOR ||
1875 mwindow->session->current_operation == DRAG_PROJECTOR_PRE)
1880 //printf("TrackCanvas::draw_keyframes 2 %d\n", result);
1884 new_cursor = UPRIGHT_ARROW_CURSOR;
1888 //printf("TrackCanvas::do_keyframes 3 %d\n", result);
1892 void TrackCanvas::draw_auto(Auto *current,
1900 char string[BCTEXTLEN];
1902 x1 = x - HANDLE_W / 2;
1903 x2 = x + HANDLE_W / 2;
1904 y1 = center_pixel + y - HANDLE_W / 2;
1905 y2 = center_pixel + y + HANDLE_W / 2;
1907 if(y1 < center_pixel + -zoom_track / 2) y1 = center_pixel + -zoom_track / 2;
1908 if(y2 > center_pixel + zoom_track / 2) y2 = center_pixel + zoom_track / 2;
1911 draw_box(x1 + 1, y1 + 1, x2 - x1, y2 - y1);
1913 draw_box(x1, y1, x2 - x1, y2 - y1);
1916 void TrackCanvas::draw_floatauto(Auto *current,
1928 int in_x1, in_y1, in_x2, in_y2;
1929 int out_x1, out_y1, out_x2, out_y2;
1930 char string[BCTEXTLEN];
1933 x1 = x - HANDLE_W / 2;
1934 x2 = x + HANDLE_W / 2;
1935 y1 = center_pixel + y - HANDLE_W / 2;
1936 y2 = center_pixel + y + HANDLE_W / 2;
1938 CLAMP(y1, center_pixel + -zoom_track / 2, center_pixel + zoom_track / 2);
1939 CLAMP(y2, center_pixel + -zoom_track / 2, center_pixel + zoom_track / 2);
1942 draw_box(x1 + 1, y1 + 1, x2 - x1, y2 - y1);
1944 draw_box(x1, y1, x2 - x1, y2 - y1);
1947 in_x1 = in_x - HANDLE_W / 2;
1948 in_x2 = in_x + HANDLE_W / 2;
1949 in_y1 = center_pixel + in_y - HANDLE_W / 2;
1950 in_y2 = center_pixel + in_y + HANDLE_W / 2;
1952 CLAMP(in_y1, center_pixel + -zoom_track / 2, center_pixel + zoom_track / 2);
1953 CLAMP(in_y2, center_pixel + -zoom_track / 2, center_pixel + zoom_track / 2);
1954 CLAMP(in_y, -zoom_track / 2, zoom_track / 2);
1957 draw_line(x + 1, center_pixel + y + 1, in_x + 1, center_pixel + in_y + 1);
1958 draw_box(in_x1 + 1, in_y1 + 1, in_x2 - in_x1, in_y2 - in_y1);
1960 draw_line(x, center_pixel + y, in_x, center_pixel + in_y);
1961 draw_box(in_x1, in_y1, in_x2 - in_x1, in_y2 - in_y1);
1966 out_x1 = out_x - HANDLE_W / 2;
1967 out_x2 = out_x + HANDLE_W / 2;
1968 out_y1 = center_pixel + out_y - HANDLE_W / 2;
1969 out_y2 = center_pixel + out_y + HANDLE_W / 2;
1971 CLAMP(out_y1, center_pixel + -zoom_track / 2, center_pixel + zoom_track / 2);
1972 CLAMP(out_y2, center_pixel + -zoom_track / 2, center_pixel + zoom_track / 2);
1973 CLAMP(out_y, -zoom_track / 2, zoom_track / 2);
1977 draw_line(x + 1, center_pixel + y + 1, out_x + 1, center_pixel + out_y + 1);
1978 draw_box(out_x1 + 1, out_y1 + 1, out_x2 - out_x1, out_y2 - out_y1);
1980 draw_line(x, center_pixel + y, out_x, center_pixel + out_y);
1981 draw_box(out_x1, out_y1, out_x2 - out_x1, out_y2 - out_y1);
1985 int TrackCanvas::test_auto(Auto *current,
1995 char string[BCTEXTLEN];
1998 x1 = x - HANDLE_W / 2;
1999 x2 = x + HANDLE_W / 2;
2000 y1 = center_pixel + y - HANDLE_W / 2;
2001 y2 = center_pixel + y + HANDLE_W / 2;
2003 if(y1 < center_pixel + -zoom_track / 2) y1 = center_pixel + -zoom_track / 2;
2004 if(y2 > center_pixel + zoom_track / 2) y2 = center_pixel + zoom_track / 2;
2005 //printf("test_auto 1 %d %d %d %d %d %d\n", cursor_x, cursor_y, x1, x2, y1, y2);
2007 if(cursor_x >= x1 && cursor_x < x2 && cursor_y >= y1 && cursor_y < y2)
2009 //printf("test_auto 2 %d\n", buttonpress);
2012 //printf("test_auto 3\n");
2013 mwindow->session->drag_auto = current;
2014 mwindow->session->drag_start_percentage = current->value_to_percentage();
2015 mwindow->session->drag_start_position = current->position;
2016 mwindow->session->drag_origin_x = cursor_x;
2017 mwindow->session->drag_origin_y = cursor_y;
2025 int TrackCanvas::test_floatauto(Auto *current,
2039 int in_x1, in_y1, in_x2, in_y2;
2040 int out_x1, out_y1, out_x2, out_y2;
2041 char string[BCTEXTLEN];
2044 x1 = x - HANDLE_W / 2;
2045 x2 = x + HANDLE_W / 2;
2046 y1 = center_pixel + y - HANDLE_W / 2;
2047 y2 = center_pixel + y + HANDLE_W / 2;
2049 if(y1 < center_pixel + -zoom_track / 2) y1 = center_pixel + -zoom_track / 2;
2050 if(y2 > center_pixel + zoom_track / 2) y2 = center_pixel + zoom_track / 2;
2052 in_x1 = in_x - HANDLE_W / 2;
2053 in_x2 = in_x + HANDLE_W / 2;
2054 in_y1 = center_pixel + in_y - HANDLE_W / 2;
2055 in_y2 = center_pixel + in_y + HANDLE_W / 2;
2057 if(in_y1 < center_pixel + -zoom_track / 2) in_y1 = center_pixel + -zoom_track / 2;
2058 if(in_y2 > center_pixel + zoom_track / 2) in_y2 = center_pixel + zoom_track / 2;
2060 out_x1 = out_x - HANDLE_W / 2;
2061 out_x2 = out_x + HANDLE_W / 2;
2062 out_y1 = center_pixel + out_y - HANDLE_W / 2;
2063 out_y2 = center_pixel + out_y + HANDLE_W / 2;
2065 if(out_y1 < center_pixel + -zoom_track / 2) out_y1 = center_pixel + -zoom_track / 2;
2066 if(out_y2 > center_pixel + zoom_track / 2) out_y2 = center_pixel + zoom_track / 2;
2070 //printf("TrackCanvas::test_floatauto %d %d %d %d %d %d\n", cursor_x, cursor_y, x1, x2, y1, y2);
2080 mwindow->session->drag_auto = current;
2081 mwindow->session->drag_start_percentage = current->value_to_percentage();
2082 mwindow->session->drag_start_position = current->position;
2083 mwindow->session->drag_origin_x = cursor_x;
2084 mwindow->session->drag_origin_y = cursor_y;
2085 mwindow->session->drag_handle = 0;
2092 cursor_x >= in_x1 &&
2094 cursor_y >= in_y1 &&
2096 current->position > 0)
2100 mwindow->session->drag_auto = current;
2101 mwindow->session->drag_start_percentage =
2102 current->invalue_to_percentage();
2103 mwindow->session->drag_start_position =
2104 ((FloatAuto*)current)->control_in_position;
2105 mwindow->session->drag_origin_x = cursor_x;
2106 mwindow->session->drag_origin_y = cursor_y;
2107 mwindow->session->drag_handle = 1;
2114 cursor_x >= out_x1 &&
2115 cursor_x < out_x2 &&
2116 cursor_y >= out_y1 &&
2121 mwindow->session->drag_auto = current;
2122 mwindow->session->drag_start_percentage =
2123 current->outvalue_to_percentage();
2124 mwindow->session->drag_start_position =
2125 ((FloatAuto*)current)->control_out_position;
2126 mwindow->session->drag_origin_x = cursor_x;
2127 mwindow->session->drag_origin_y = cursor_y;
2128 mwindow->session->drag_handle = 2;
2134 // printf("TrackCanvas::test_floatauto 2 drag_handle=%d ctrl_down=%d cursor_x=%d cursor_y=%d x1=%d x2=%d y1=%d y2=%d\n",
2135 // mwindow->session->drag_handle,
2144 void TrackCanvas::draw_floatline(int center_pixel,
2145 FloatAuto *previous,
2157 // Solve bezier equation for either every pixel or a certain large number of
2162 // Not using slope intercept
2169 // Call by reference fails for some reason here
2170 FloatAuto *previous1 = previous, *next1 = next;
2171 for(int x = x1; x < x2; x++)
2173 int64_t position = (int64_t)(unit_start + x * zoom_units);
2174 float value = autos->get_value(position, PLAY_FORWARD, previous1, next1);
2176 int y = (int)(center_pixel +
2177 (autos->value_to_percentage(value) - 0.5) * -yscale);
2182 draw_line(x - 1, prev_y + 1, x, y + 1);
2184 draw_line(x - 1, prev_y, x, y);
2191 // set_color(BLACK);
2192 // draw_line(x1, center_pixel + y1 + 1, x2, center_pixel + y2 + 1);
2193 // set_color(WHITE);
2194 // draw_line(x1, center_pixel + y1, x2, center_pixel + y2);
2202 void TrackCanvas::synchronize_autos(float change, Track *skip, FloatAuto *fauto, int fill_gangs)
2204 if (fill_gangs == 1 && skip->gang) // fill mwindow->session->drag_auto_gang
2206 for(Track *current = mwindow->edl->tracks->first;
2210 if(current->data_type == skip->data_type &&
2215 FloatAutos *fade_autos = current->automation->fade_autos;
2216 double position = skip->from_units(fauto->position);
2217 int tmp_cursor_on_frames = mwindow->edl->session->cursor_on_frames;
2218 mwindow->edl->session->cursor_on_frames = 0;
2219 FloatAuto *previous = 0, *next = 0;
2220 float init_value = fade_autos->get_value(fauto->position, PLAY_FORWARD, previous, next);
2222 int update_undo = !fade_autos->auto_exists_for_editing(position);
2224 FloatAuto *keyframe = (FloatAuto*)fade_autos->get_auto_for_editing(position);
2225 mwindow->edl->session->cursor_on_frames = tmp_cursor_on_frames;
2227 keyframe->value = init_value;
2229 keyframe->value += change;
2230 keyframe->position = fauto->position;
2231 keyframe->control_out_position = fauto->control_out_position;
2232 keyframe->control_in_position = fauto->control_in_position;
2233 keyframe->control_out_value = fauto->control_out_value;
2234 keyframe->control_in_value = fauto->control_in_value;
2236 mwindow->session->drag_auto_gang->append((Auto *)keyframe);
2240 if (fill_gangs == 0) // move the gangs
2244 for (int i = 0; i < mwindow->session->drag_auto_gang->total; i++)
2246 FloatAuto *keyframe = (FloatAuto *)mwindow->session->drag_auto_gang->values[i];
2248 keyframe->value += change;
2249 keyframe->position = fauto->position;
2250 if(skip->data_type == TRACK_AUDIO)
2251 CLAMP(keyframe->value, INFINITYGAIN, MAX_AUDIO_FADE);
2253 CLAMP(keyframe->value, 0, MAX_VIDEO_FADE);
2254 keyframe->control_out_position = fauto->control_out_position;
2255 keyframe->control_in_position = fauto->control_in_position;
2256 keyframe->control_out_value = fauto->control_out_value;
2257 keyframe->control_in_value = fauto->control_in_value;
2261 if (fill_gangs == -1) // remove the gangs
2263 for (int i = 0; i < mwindow->session->drag_auto_gang->total; i++)
2265 FloatAuto *keyframe = (FloatAuto *)mwindow->session->drag_auto_gang->values[i];
2266 keyframe->autos->remove_nonsequential(
2269 mwindow->session->drag_auto_gang->remove_all();
2274 int TrackCanvas::test_floatline(int center_pixel,
2288 int64_t position = (int64_t)(unit_start + cursor_x * zoom_units);
2289 // Call by reference fails for some reason here
2290 FloatAuto *previous = 0, *next = 0;
2291 float value = autos->get_value(position, PLAY_FORWARD, previous, next);
2292 int y = (int)(center_pixel +
2293 (autos->value_to_percentage(value) - 0.5) * -yscale);
2295 if(cursor_x >= x1 &&
2297 cursor_y >= y - HANDLE_W / 2 &&
2298 cursor_y < y + HANDLE_W / 2 &&
2306 mwindow->undo->update_undo_before(_("keyframe"), LOAD_AUTOMATION);
2310 current = mwindow->session->drag_auto = autos->insert_auto(position);
2311 ((FloatAuto*)current)->value = value;
2312 mwindow->session->drag_start_percentage = current->value_to_percentage();
2313 mwindow->session->drag_start_position = current->position;
2314 mwindow->session->drag_origin_x = cursor_x;
2315 mwindow->session->drag_origin_y = cursor_y;
2316 mwindow->session->drag_handle = 0;
2325 void TrackCanvas::draw_toggleline(int center_pixel,
2333 draw_line(x1, center_pixel + y1 + 1, x2, center_pixel + y1 + 1);
2335 draw_line(x1, center_pixel + y1, x2, center_pixel + y1);
2340 draw_line(x2 + 1, center_pixel + y1, x2 + 1, center_pixel + y2);
2342 draw_line(x2, center_pixel + y1, x2, center_pixel + y2);
2346 int TrackCanvas::test_toggleline(Autos *autos,
2357 if(cursor_x >= x1 && cursor_x < x2)
2359 int miny = center_pixel + y1 - HANDLE_W / 2;
2360 int maxy = center_pixel + y1 + HANDLE_W / 2;
2361 if(cursor_y >= miny && cursor_y < maxy)
2367 mwindow->undo->update_undo_before(_("keyframe"), LOAD_AUTOMATION);
2371 double position = (double)(cursor_x +
2372 mwindow->edl->local_session->view_start) *
2373 mwindow->edl->local_session->zoom_sample /
2374 mwindow->edl->session->sample_rate;
2375 int64_t unit_position = autos->track->to_units(position, 0);
2376 int new_value = (int)((IntAutos*)autos)->get_automation_constant(unit_position, unit_position);
2378 current = mwindow->session->drag_auto = autos->insert_auto(unit_position);
2379 ((IntAuto*)current)->value = new_value;
2380 mwindow->session->drag_start_percentage = current->value_to_percentage();
2381 mwindow->session->drag_start_position = current->position;
2382 mwindow->session->drag_origin_x = cursor_x;
2383 mwindow->session->drag_origin_y = cursor_y;
2391 void TrackCanvas::calculate_viewport(Track *track,
2392 double &view_start, // Seconds
2393 int64_t &unit_start,
2394 double &view_end, // Seconds
2398 double &zoom_sample,
2401 view_start = (double)mwindow->edl->local_session->view_start *
2402 mwindow->edl->local_session->zoom_sample /
2403 mwindow->edl->session->sample_rate;
2404 unit_start = track->to_units(view_start, 0);
2405 view_end = (double)(mwindow->edl->local_session->view_start +
2407 mwindow->edl->local_session->zoom_sample /
2408 mwindow->edl->session->sample_rate;
2409 unit_end = (int64_t)(track->to_units(view_end, 1));
2410 yscale = mwindow->edl->local_session->zoom_track;
2411 center_pixel = (int)(track->y_pixel + yscale / 2) +
2412 (mwindow->edl->session->show_titles ?
2413 mwindow->theme->title_bg_data->get_h() :
2415 zoom_sample = mwindow->edl->local_session->zoom_sample;
2417 zoom_units = track->to_doubleunits(zoom_sample / mwindow->edl->session->sample_rate);
2420 int TrackCanvas::do_float_autos(Track *track,
2438 double ax, ay, ax2, ay2;
2439 double in_x2, in_y2, out_x2, out_y2;
2444 calculate_viewport(track,
2456 // Get first auto before start
2459 for(current = autos->last;
2460 current && current->position >= unit_start;
2466 ax = (double)(current->position - unit_start) / zoom_units;
2467 ay = (((FloatAuto*)current)->value_to_percentage() - 0.5) * -yscale;
2472 current = autos->first ? autos->first : autos->default_auto;
2476 ay = (((FloatAuto*)current)->value_to_percentage() - 0.5) * -yscale;
2486 //printf("TrackCanvas::do_float_autos 1\n");
2497 ax2 = (double)(current->position - unit_start) / zoom_units;
2498 ay2 = (((FloatAuto*)current)->value_to_percentage() - 0.5) * -yscale;
2499 in_x2 = (double)(current->position +
2500 ((FloatAuto*)current)->control_in_position -
2503 in_y2 = (((FloatAuto*)current)->invalue_to_percentage() - 0.5) * -yscale;
2504 out_x2 = (double)(current->position +
2505 ((FloatAuto*)current)->control_out_position -
2508 out_y2 = (((FloatAuto*)current)->outvalue_to_percentage() - 0.5) * -yscale;
2517 slope = (ay2 - ay) / (ax2 - ax);
2523 ay2 = ay + slope * (get_w() - ax);
2528 ay = ay + slope * (0 - ax);
2546 if(current && !result)
2548 if(current != autos->default_auto)
2553 result = test_floatauto(current,
2568 draw_floatauto(current,
2585 // Draw joining line
2592 result = test_floatline(center_pixel,
2598 // Exclude auto coverage from the end of the line. The auto overlaps
2599 (int)ax2 - HANDLE_W / 2,
2607 draw_floatline(center_pixel,
2608 (FloatAuto*)previous,
2609 (FloatAuto*)current,
2637 current->position <= unit_end &&
2640 //printf("TrackCanvas::do_float_autos 100\n");
2649 if(ax < get_w() && !result)
2657 result = test_floatline(center_pixel,
2670 draw_floatline(center_pixel,
2671 (FloatAuto*)previous,
2672 (FloatAuto*)current,
2695 int TrackCanvas::do_toggle_autos(Track *track,
2712 double ax, ay, ax2, ay2;
2714 calculate_viewport(track,
2725 double high = -yscale * 0.8 / 2;
2726 double low = yscale * 0.8 / 2;
2728 // Get first auto before start
2730 for(current = autos->last; current && current->position >= unit_start; current = PREVIOUS)
2736 ay = ((IntAuto*)current)->value > 0 ? high : low;
2741 current = autos->first ? autos->first : autos->default_auto;
2745 ay = ((IntAuto*)current)->value > 0 ? high : low;
2758 ax2 = (double)(current->position - unit_start) / zoom_units;
2759 ay2 = ((IntAuto*)current)->value > 0 ? high : low;
2767 if(ax2 > get_w()) ax2 = get_w();
2769 if(current && !result)
2771 if(current != autos->default_auto)
2777 result = test_auto(current,
2805 result = test_toggleline(autos,
2818 draw_toggleline(center_pixel,
2827 }while(current && current->position <= unit_end && !result);
2829 if(ax < get_w() && !result)
2837 result = test_toggleline(autos,
2849 draw_toggleline(center_pixel,
2859 int TrackCanvas::do_autos(Track *track,
2878 calculate_viewport(track,
2890 for(current = autos->first; current && !result; current = NEXT)
2892 if(current->position >= unit_start && current->position < unit_end)
2895 x = (int64_t)((double)(current->position - unit_start) /
2896 zoom_units - (pixmap->get_w() / 2 + 0.5));
2897 y = center_pixel - pixmap->get_h() / 2;
2901 if(cursor_x >= x && cursor_y >= y &&
2902 cursor_x < x + pixmap->get_w() &&
2903 cursor_y < y + pixmap->get_h())
2909 mwindow->session->drag_auto = current;
2910 mwindow->session->drag_start_position = current->position;
2911 mwindow->session->drag_origin_x = cursor_x;
2912 mwindow->session->drag_origin_y = cursor_y;
2914 double position = autos->track->from_units(current->position);
2915 double center = (mwindow->edl->local_session->selectionstart +
2916 mwindow->edl->local_session->selectionend) /
2921 mwindow->edl->local_session->selectionstart = position;
2922 mwindow->edl->local_session->selectionend = position;
2925 if(position < center)
2927 mwindow->edl->local_session->selectionstart = position;
2930 mwindow->edl->local_session->selectionend = position;
2935 draw_pixmap(pixmap, x, y);
2941 // so this means it is always >0 when keyframe is found
2942 int TrackCanvas::do_plugin_autos(Track *track,
2947 Plugin* &keyframe_plugin,
2948 KeyFrame* &keyframe_instance)
2961 calculate_viewport(track,
2971 //printf("TrackCanvas::draw_plugin_autos 1 %d\n", track->plugin_set.total);
2972 for(int i = 0; i < track->plugin_set.total && !result; i++)
2974 PluginSet *plugin_set = track->plugin_set.values[i];
2975 int center_pixel = (int)(track->y_pixel +
2976 mwindow->edl->local_session->zoom_track +
2977 (i + 0.5) * mwindow->theme->plugin_bg_data->get_h() +
2978 (mwindow->edl->session->show_titles ? mwindow->theme->title_bg_data->get_h() : 0));
2980 //printf("TrackCanvas::draw_plugin_autos 2\n");
2981 for(Plugin *plugin = (Plugin*)plugin_set->first;
2983 plugin = (Plugin*)plugin->next)
2985 for(KeyFrame *keyframe = (KeyFrame*)plugin->keyframes->first;
2986 keyframe && !result;
2987 keyframe = (KeyFrame*)keyframe->next)
2989 //printf("TrackCanvas::draw_plugin_autos 3 %d\n", keyframe->position);
2990 if(keyframe->position >= unit_start && keyframe->position < unit_end)
2992 int64_t x = (int64_t)((keyframe->position - unit_start) / zoom_units);
2993 int y = center_pixel - keyframe_pixmap->get_h() / 2;
2995 //printf("TrackCanvas::draw_plugin_autos 4 %d %d\n", x, center_pixel);
2998 if(cursor_x >= x && cursor_y >= y &&
2999 cursor_x < x + keyframe_pixmap->get_w() &&
3000 cursor_y < y + keyframe_pixmap->get_h())
3003 keyframe_plugin = plugin;
3004 keyframe_instance = keyframe;
3008 mwindow->session->drag_auto = keyframe;
3009 mwindow->session->drag_start_position = keyframe->position;
3010 mwindow->session->drag_origin_x = cursor_x;
3011 mwindow->session->drag_origin_y = cursor_y;
3013 double position = track->from_units(keyframe->position);
3014 double center = (mwindow->edl->local_session->selectionstart +
3015 mwindow->edl->local_session->selectionend) /
3020 mwindow->edl->local_session->selectionstart = position;
3021 mwindow->edl->local_session->selectionend = position;
3024 if(position < center)
3026 mwindow->edl->local_session->selectionstart = position;
3029 mwindow->edl->local_session->selectionend = position;
3034 draw_pixmap(keyframe_pixmap,
3041 //printf("TrackCanvas::draw_plugin_autos 5\n");
3045 void TrackCanvas::draw_overlays()
3047 int new_cursor, update_cursor, rerender;
3048 TRACE("TrackCanvas::draw_overlays 1")
3050 // Move background pixmap to foreground pixmap
3051 draw_pixmap(background_pixmap,
3058 TRACE("TrackCanvas::draw_overlays 10")
3061 draw_inout_points();
3063 TRACE("TrackCanvas::draw_overlays 11");
3065 if(mwindow->edl->session->auto_conf->transitions) draw_transitions();
3067 TRACE("TrackCanvas::draw_overlays 12");
3071 TRACE("TrackCanvas::draw_overlays 13");
3074 draw_brender_start();
3076 TRACE("TrackCanvas::draw_overlays 14");
3077 // Highlighted areas
3078 draw_highlighting();
3080 TRACE("TrackCanvas::draw_overlays 15");
3090 TRACE("TrackCanvas::draw_overlays 16\n");
3092 if(gui->cursor) gui->cursor->restore();
3094 TRACE("TrackCanvas::draw_overlays 17\n");
3098 TRACE("TrackCanvas::draw_overlays 20");
3100 draw_playback_cursor();
3104 int TrackCanvas::activate()
3108 get_top_level()->deactivate();
3110 set_active_subwindow(this);
3111 gui->cursor->activate();
3116 int TrackCanvas::deactivate()
3121 gui->cursor->deactivate();
3127 void TrackCanvas::update_drag_handle()
3129 double new_position;
3132 (double)(get_cursor_x() + mwindow->edl->local_session->view_start) *
3133 mwindow->edl->local_session->zoom_sample /
3134 mwindow->edl->session->sample_rate;
3136 mwindow->edl->align_to_frame(new_position, 0);
3139 if(new_position != mwindow->session->drag_position)
3141 mwindow->session->drag_position = new_position;
3142 gui->mainclock->update(new_position);
3143 // Que the CWindow. Doesn't do anything if selectionstart and selection end
3145 // mwindow->cwindow->update(1, 0, 0);
3149 int TrackCanvas::update_drag_edit()
3158 #define UPDATE_DRAG_HEAD(do_clamp) \
3160 int x = cursor_x - mwindow->session->drag_origin_x; \
3161 int y = cursor_y - mwindow->session->drag_origin_y; \
3163 if(!current->autos->track->record) return 0; \
3164 double view_start; \
3165 int64_t unit_start; \
3170 double zoom_sample; \
3171 double zoom_units; \
3173 mwindow->undo->update_undo_before(_("tweek"), LOAD_AUTOMATION); \
3174 calculate_viewport(current->autos->track, \
3184 float percentage = (float)(mwindow->session->drag_origin_y - cursor_y) / \
3185 MAX(128, yscale) + \
3186 mwindow->session->drag_start_percentage; \
3187 if(do_clamp) CLAMP(percentage, 0, 1); \
3189 int64_t position = Units::to_int64(zoom_units * \
3190 (cursor_x - mwindow->session->drag_origin_x) + \
3191 mwindow->session->drag_start_position); \
3193 if((do_clamp) && position < 0) position = 0;
3203 int TrackCanvas::update_drag_floatauto(int cursor_x, int cursor_y)
3205 FloatAuto *current = (FloatAuto*)mwindow->session->drag_auto;
3207 UPDATE_DRAG_HEAD(mwindow->session->drag_handle == 0);
3210 //printf("TrackCanvas::update_drag_floatauto %ld %d\n",
3212 //mwindow->session->drag_handle);
3214 switch(mwindow->session->drag_handle)
3218 // Snap to nearby values
3225 value = ((FloatAuto*)current)->percentage_to_value(percentage);
3227 if(current->previous)
3229 value1 = ((FloatAuto*)current->previous)->value;
3230 distance1 = fabs(value - value1);
3231 current->value = value1;
3236 value2 = ((FloatAuto*)current->next)->value;
3237 distance2 = fabs(value - value2);
3238 if(!current->previous || distance2 < distance1)
3240 current->value = value2;
3244 if(!current->previous && !current->next)
3246 value = ((FloatAutos*)current->autos)->default_;
3248 value = current->value;
3251 value = ((FloatAuto*)current)->percentage_to_value(percentage);
3253 //printf("TrackCanvas::update_drag_floatauto 1 %f\n", value);
3254 if(value != current->value || position != current->position)
3257 float change = value - current->value;
3258 current->value = value;
3259 current->position = position;
3260 synchronize_autos(change, current->autos->track, current, 0);
3262 char string[BCTEXTLEN], string2[BCTEXTLEN];
3263 Units::totext(string2,
3264 current->autos->track->from_units(current->position),
3265 mwindow->edl->session->time_format,
3266 mwindow->edl->session->sample_rate,
3267 mwindow->edl->session->frame_rate,
3268 mwindow->edl->session->frames_per_foot);
3269 sprintf(string, "%s, %.2f", string2, current->value);
3270 gui->show_message(string);
3276 value = ((FloatAuto*)current)->percentage_to_invalue(percentage);
3277 position = MIN(0, position);
3278 if(value != current->control_in_value ||
3279 position != current->control_in_position)
3282 current->control_in_value = value;
3283 current->control_in_position = position;
3284 synchronize_autos(0, current->autos->track, current, 0);
3286 char string[BCTEXTLEN], string2[BCTEXTLEN];
3287 Units::totext(string2,
3288 current->autos->track->from_units(current->control_in_position),
3289 mwindow->edl->session->time_format,
3290 mwindow->edl->session->sample_rate,
3291 mwindow->edl->session->frame_rate,
3292 mwindow->edl->session->frames_per_foot);
3293 sprintf(string, "%s, %.2f", string2, current->control_in_value);
3294 gui->show_message(string);
3300 value = ((FloatAuto*)current)->percentage_to_outvalue(percentage);
3301 position = MAX(0, position);
3302 if(value != current->control_out_value ||
3303 position != current->control_out_position)
3306 current->control_out_value = value;
3307 current->control_out_position = position;
3308 synchronize_autos(0, current->autos->track, current, 0);
3310 char string[BCTEXTLEN], string2[BCTEXTLEN];
3311 Units::totext(string2,
3312 current->autos->track->from_units(
3313 ((FloatAuto*)current)->control_out_position),
3314 mwindow->edl->session->time_format,
3315 mwindow->edl->session->sample_rate,
3316 mwindow->edl->session->frame_rate,
3317 mwindow->edl->session->frames_per_foot);
3318 sprintf(string, "%s, %.2f",
3320 ((FloatAuto*)current)->control_out_value);
3321 gui->show_message(string);
3329 int TrackCanvas::update_drag_toggleauto(int cursor_x, int cursor_y)
3331 IntAuto *current = (IntAuto*)mwindow->session->drag_auto;
3333 UPDATE_DRAG_HEAD(1);
3335 int value = ((IntAuto*)current)->percentage_to_value(percentage);
3337 if(value != current->value || position != current->position)
3340 current->value = value;
3341 current->position = position;
3343 char string[BCTEXTLEN], string2[BCTEXTLEN];
3344 Units::totext(string2,
3345 current->autos->track->from_units(current->position),
3346 mwindow->edl->session->time_format,
3347 mwindow->edl->session->sample_rate,
3348 mwindow->edl->session->frame_rate,
3349 mwindow->edl->session->frames_per_foot);
3350 sprintf(string, "%s, %d", string2, current->value);
3351 gui->show_message(string);
3357 // Autos which can't change value through dragging.
3359 int TrackCanvas::update_drag_auto(int cursor_x, int cursor_y)
3361 Auto *current = (Auto*)mwindow->session->drag_auto;
3365 if(position != current->position)
3368 current->position = position;
3370 char string[BCTEXTLEN];
3371 Units::totext(string,
3372 current->autos->track->from_units(current->position),
3373 mwindow->edl->session->time_format,
3374 mwindow->edl->session->sample_rate,
3375 mwindow->edl->session->frame_rate,
3376 mwindow->edl->session->frames_per_foot);
3377 gui->show_message(string);
3379 double position_f = current->autos->track->from_units(current->position);
3380 double center_f = (mwindow->edl->local_session->selectionstart +
3381 mwindow->edl->local_session->selectionend) /
3385 mwindow->edl->local_session->selectionstart = position_f;
3386 mwindow->edl->local_session->selectionend = position_f;
3389 if(position_f < center_f)
3391 mwindow->edl->local_session->selectionstart = position_f;
3394 mwindow->edl->local_session->selectionend = position_f;
3401 void TrackCanvas::update_drag_caption()
3403 switch(mwindow->session->current_operation)
3413 int TrackCanvas::cursor_motion_event()
3415 int result, cursor_x, cursor_y;
3416 int update_clock = 0;
3417 int update_zoom = 0;
3418 int update_scroll = 0;
3419 int update_overlay = 0;
3420 int update_cursor = 0;
3423 double position = 0;
3424 //printf("TrackCanvas::cursor_motion_event 1\n");
3428 switch(mwindow->edl->session->editing_mode)
3430 case EDITING_ARROW: new_cursor = ARROW_CURSOR; break;
3431 case EDITING_IBEAM: new_cursor = IBEAM_CURSOR; break;
3434 switch(mwindow->session->current_operation)
3436 case DRAG_EDITHANDLE1:
3437 // Outside threshold. Upgrade status
3438 //printf("TrackCanvas::cursor_motion_event 1\n");
3439 if(labs(get_cursor_x() - mwindow->session->drag_origin_x) > HANDLE_W)
3441 //printf("TrackCanvas::cursor_motion_event 2\n");
3442 mwindow->session->current_operation = DRAG_EDITHANDLE2;
3447 case DRAG_EDITHANDLE2:
3448 update_drag_handle();
3452 case DRAG_PLUGINHANDLE1:
3453 if(labs(get_cursor_x() - mwindow->session->drag_origin_x) > HANDLE_W)
3455 //printf("TrackCanvas::cursor_motion_event 2\n");
3456 mwindow->session->current_operation = DRAG_PLUGINHANDLE2;
3461 case DRAG_PLUGINHANDLE2:
3462 update_drag_handle();
3466 // Rubber band curves
3468 rerender = update_overlay = update_drag_floatauto(get_cursor_x(), get_cursor_y());
3472 rerender = update_overlay = update_drag_floatauto(get_cursor_x(), get_cursor_y());
3476 rerender = update_overlay = update_drag_floatauto(get_cursor_x(), get_cursor_y());
3480 rerender = update_overlay = update_drag_toggleauto(get_cursor_x(), get_cursor_y());
3484 rerender = update_overlay = update_drag_toggleauto(get_cursor_x(), get_cursor_y());
3487 // Keyframe icons are sticky
3489 case DRAG_CAMERA_PRE:
3492 case DRAG_PROJECTOR_PRE:
3493 case DRAG_PLUGINKEY_PRE:
3494 if(labs(get_cursor_x() - mwindow->session->drag_origin_x) > HANDLE_W)
3496 //printf("TrackCanvas::cursor_motion_event 2\n");
3497 mwindow->session->current_operation++;
3506 case DRAG_PROJECTOR:
3507 case DRAG_PLUGINKEY:
3508 rerender = update_overlay =
3509 update_drag_auto(get_cursor_x(), get_cursor_y());
3514 cursor_x = get_cursor_x();
3515 cursor_y = get_cursor_y();
3516 position = (double)(cursor_x + mwindow->edl->local_session->view_start) *
3517 mwindow->edl->local_session->zoom_sample /
3518 mwindow->edl->session->sample_rate;
3520 position = mwindow->edl->align_to_frame(position, 0);
3521 position = MAX(position, 0);
3523 if(position < selection_midpoint1)
3525 mwindow->edl->local_session->selectionend = selection_midpoint1;
3526 mwindow->edl->local_session->selectionstart = position;
3528 mwindow->cwindow->update(1, 0, 0, 0, 1);
3529 // Update the faders
3530 mwindow->update_plugin_guis();
3531 gui->patchbay->update();
3535 mwindow->edl->local_session->selectionstart = selection_midpoint1;
3536 mwindow->edl->local_session->selectionend = position;
3537 // Don't que the CWindow
3539 //printf("TrackCanvas::cursor_motion_event 1 %f %f %f\n", position, mwindow->edl->local_session->selectionstart, mwindow->edl->local_session->selectionend);
3541 gui->cursor->hide();
3542 gui->cursor->draw();
3552 if(is_event_win() && cursor_inside())
3555 cursor_x = get_cursor_x();
3556 position = (double)cursor_x *
3557 (double)mwindow->edl->local_session->zoom_sample /
3558 (double)mwindow->edl->session->sample_rate +
3559 (double)mwindow->edl->local_session->view_start *
3560 (double)mwindow->edl->local_session->zoom_sample /
3561 (double)mwindow->edl->session->sample_rate;
3562 position = mwindow->edl->align_to_frame(position, 0);
3566 if(mwindow->edl->session->auto_conf->transitions &&
3567 test_transitions(get_cursor_x(),
3577 if(do_keyframes(get_cursor_x(),
3589 if(test_edit_handles(get_cursor_x(),
3598 // Plugin boundaries
3599 if(test_plugin_handles(get_cursor_x(),
3608 if(test_edits(get_cursor_x(),
3623 //printf("TrackCanvas::cursor_motion_event 1\n");
3624 if(update_cursor && new_cursor != get_cursor())
3626 set_cursor(new_cursor);
3629 //printf("TrackCanvas::cursor_motion_event 1 %d\n", rerender);
3632 mwindow->restart_brender();
3633 mwindow->sync_parameters(CHANGE_PARAMS);
3634 mwindow->update_plugin_guis();
3635 mwindow->cwindow->update(1, 0, 0, 0, 1);
3637 gui->patchbay->update();
3643 if(!mwindow->cwindow->playback_engine->is_playing_back)
3644 gui->mainclock->update(position);
3649 gui->zoombar->update();
3655 (cursor_x >= get_w() || cursor_x < 0 || cursor_y >= get_h() || cursor_y < 0))
3659 (cursor_x < get_w() && cursor_x >= 0 && cursor_y < get_h() && cursor_y >= 0))
3670 //printf("TrackCanvas::cursor_motion_event 100\n");
3674 void TrackCanvas::start_dragscroll()
3679 set_repeat(BC_WindowBase::get_resources()->scroll_repeat);
3680 //printf("TrackCanvas::start_dragscroll 1\n");
3684 void TrackCanvas::stop_dragscroll()
3689 unset_repeat(BC_WindowBase::get_resources()->scroll_repeat);
3690 //printf("TrackCanvas::stop_dragscroll 1\n");
3694 int TrackCanvas::repeat_event(int64_t duration)
3696 if(!drag_scroll) return 0;
3697 if(duration != BC_WindowBase::get_resources()->scroll_repeat) return 0;
3699 int sample_movement = 0;
3700 int track_movement = 0;
3701 int64_t x_distance = 0;
3702 int64_t y_distance = 0;
3703 double position = 0;
3706 switch(mwindow->session->current_operation)
3709 //printf("TrackCanvas::repeat_event 1 %d\n", mwindow->edl->local_session->view_start);
3710 if(get_cursor_x() > get_w())
3712 x_distance = get_cursor_x() - get_w();
3713 sample_movement = 1;
3716 if(get_cursor_x() < 0)
3718 x_distance = get_cursor_x();
3719 sample_movement = 1;
3722 if(get_cursor_y() > get_h())
3724 y_distance = get_cursor_y() - get_h();
3728 if(get_cursor_y() < 0)
3730 y_distance = get_cursor_y();
3740 position = (double)(get_cursor_x() +
3741 mwindow->edl->local_session->view_start +
3743 mwindow->edl->local_session->zoom_sample /
3744 mwindow->edl->session->sample_rate;
3745 position = mwindow->edl->align_to_frame(position, 0);
3746 position = MAX(position, 0);
3748 //printf("TrackCanvas::repeat_event 1 %f\n", position);
3749 switch(mwindow->session->current_operation)
3752 if(position < selection_midpoint1)
3754 mwindow->edl->local_session->selectionend = selection_midpoint1;
3755 mwindow->edl->local_session->selectionstart = position;
3757 mwindow->cwindow->update(1, 0, 0);
3758 // Update the faders
3759 mwindow->update_plugin_guis();
3760 gui->patchbay->update();
3764 mwindow->edl->local_session->selectionstart = selection_midpoint1;
3765 mwindow->edl->local_session->selectionend = position;
3766 // Don't que the CWindow
3771 mwindow->samplemovement(mwindow->edl->local_session->view_start +
3777 mwindow->trackmovement(mwindow->edl->local_session->track_start +
3784 int TrackCanvas::button_release_event()
3786 int redraw = 0, update_overlay = 0, result = 0;
3788 switch(mwindow->session->current_operation)
3790 case DRAG_EDITHANDLE2:
3791 mwindow->session->current_operation = NO_OPERATION;
3795 end_edithandle_selection();
3798 case DRAG_EDITHANDLE1:
3799 mwindow->session->current_operation = NO_OPERATION;
3804 case DRAG_PLUGINHANDLE2:
3805 mwindow->session->current_operation = NO_OPERATION;
3809 end_pluginhandle_selection();
3812 case DRAG_PLUGINHANDLE1:
3813 mwindow->session->current_operation = NO_OPERATION;
3819 synchronize_autos(0, 0, 0, -1); // delete the drag_auto_gang first and remove out of order keys
3828 case DRAG_PROJECTOR:
3829 case DRAG_PLUGINKEY:
3830 mwindow->session->current_operation = NO_OPERATION;
3831 mwindow->session->drag_handle = 0;
3832 // Remove any out-of-order keyframe
3833 if(mwindow->session->drag_auto)
3835 mwindow->session->drag_auto->autos->remove_nonsequential(
3836 mwindow->session->drag_auto);
3837 // mwindow->session->drag_auto->autos->optimize();
3840 mwindow->undo->update_undo_after();
3845 case DRAG_AEFFECT_COPY:
3846 case DRAG_VEFFECT_COPY:
3847 // Trap in drag stop
3853 if(mwindow->session->current_operation)
3855 mwindow->session->current_operation = NO_OPERATION;
3857 // Traps button release events
3863 cursor_motion_event();
3877 int TrackCanvas::test_edit_handles(int cursor_x,
3883 Edit *edit_result = 0;
3884 int handle_result = 0;
3887 for(Track *track = mwindow->edl->tracks->first;
3889 track = track->next)
3891 for(Edit *edit = track->edits->first;
3895 int64_t edit_x, edit_y, edit_w, edit_h;
3896 edit_dimensions(edit, edit_x, edit_y, edit_w, edit_h);
3898 if(cursor_x >= edit_x && cursor_x <= edit_x + edit_w &&
3899 cursor_y >= edit_y && cursor_y < edit_y + edit_h)
3901 if(cursor_x < edit_x + HANDLE_W)
3908 if(cursor_x >= edit_x + edit_w - HANDLE_W)
3926 if(handle_result == 0)
3928 position = edit_result->track->from_units(edit_result->startproject);
3929 new_cursor = LEFT_CURSOR;
3932 if(handle_result == 1)
3934 position = edit_result->track->from_units(edit_result->startproject + edit_result->length);
3935 new_cursor = RIGHT_CURSOR;
3938 // Reposition cursor
3941 mwindow->session->drag_edit = edit_result;
3942 mwindow->session->drag_handle = handle_result;
3943 mwindow->session->drag_button = get_buttonpress() - 1;
3944 mwindow->session->drag_position = position;
3945 mwindow->session->current_operation = DRAG_EDITHANDLE1;
3946 mwindow->session->drag_origin_x = get_cursor_x();
3947 mwindow->session->drag_origin_y = get_cursor_y();
3948 mwindow->session->drag_start = position;
3950 int rerender = start_selection(position);
3952 mwindow->cwindow->update(1, 0, 0);
3953 gui->timebar->update_highlights();
3954 gui->zoombar->update();
3955 gui->cursor->hide();
3956 gui->cursor->draw();
3966 int TrackCanvas::test_plugin_handles(int cursor_x,
3972 Plugin *plugin_result = 0;
3973 int handle_result = 0;
3976 for(Track *track = mwindow->edl->tracks->first;
3978 track = track->next)
3980 for(int i = 0; i < track->plugin_set.total && !result; i++)
3982 PluginSet *plugin_set = track->plugin_set.values[i];
3983 for(Plugin *plugin = (Plugin*)plugin_set->first;
3985 plugin = (Plugin*)plugin->next)
3987 int64_t plugin_x, plugin_y, plugin_w, plugin_h;
3988 plugin_dimensions(plugin, plugin_x, plugin_y, plugin_w, plugin_h);
3990 if(cursor_x >= plugin_x && cursor_x <= plugin_x + plugin_w &&
3991 cursor_y >= plugin_y && cursor_y < plugin_y + plugin_h)
3993 if(cursor_x < plugin_x + HANDLE_W)
3995 plugin_result = plugin;
4000 if(cursor_x >= plugin_x + plugin_w - HANDLE_W)
4002 plugin_result = plugin;
4011 //printf("TrackCanvas::test_plugin_handles %d %d %d\n", button_press, handle_result, result);
4016 if(handle_result == 0)
4018 position = plugin_result->track->from_units(plugin_result->startproject);
4019 new_cursor = LEFT_CURSOR;
4022 if(handle_result == 1)
4024 position = plugin_result->track->from_units(plugin_result->startproject + plugin_result->length);
4025 new_cursor = RIGHT_CURSOR;
4030 mwindow->session->drag_plugin = plugin_result;
4031 mwindow->session->drag_handle = handle_result;
4032 mwindow->session->drag_button = get_buttonpress() - 1;
4033 mwindow->session->drag_position = position;
4034 mwindow->session->current_operation = DRAG_PLUGINHANDLE1;
4035 mwindow->session->drag_origin_x = get_cursor_x();
4036 mwindow->session->drag_origin_y = get_cursor_y();
4037 mwindow->session->drag_start = position;
4039 int rerender = start_selection(position);
4040 if(rerender) mwindow->cwindow->update(1, 0, 0);
4041 gui->timebar->update_highlights();
4042 gui->zoombar->update();
4043 gui->cursor->hide();
4044 gui->cursor->draw();
4055 int TrackCanvas::test_tracks(int cursor_x,
4060 for(Track *track = mwindow->edl->tracks->first;
4062 track = track->next)
4064 int64_t track_x, track_y, track_w, track_h;
4065 track_dimensions(track, track_x, track_y, track_w, track_h);
4068 get_buttonpress() == 3 &&
4069 cursor_y >= track_y &&
4070 cursor_y < track_y + track_h)
4072 gui->edit_menu->update(track, 0);
4073 gui->edit_menu->activate_menu();
4080 int TrackCanvas::test_edits(int cursor_x,
4090 int over_edit_handle = 0;
4092 //printf("TrackCanvas::test_edits 1\n");
4093 for(Track *track = mwindow->edl->tracks->first;
4095 track = track->next)
4097 for(Edit *edit = track->edits->first;
4101 int64_t edit_x, edit_y, edit_w, edit_h;
4102 //printf("TrackCanvas::test_edits 1\n");
4103 edit_dimensions(edit, edit_x, edit_y, edit_w, edit_h);
4105 // Cursor inside a track
4106 // Cursor inside an edit
4107 if(cursor_x >= edit_x && cursor_x < edit_x + edit_w &&
4108 cursor_y >= edit_y && cursor_y < edit_y + edit_h)
4110 // Select duration of edit
4111 //printf("TrackCanvas::test_edits 2\n");
4114 if(get_double_click() && !drag_start)
4116 //printf("TrackCanvas::test_edits 3\n");
4117 mwindow->edl->local_session->selectionstart =
4118 edit->track->from_units(edit->startproject);
4119 mwindow->edl->local_session->selectionend =
4120 edit->track->from_units(edit->startproject) +
4121 edit->track->from_units(edit->length);
4122 if(mwindow->edl->session->cursor_on_frames)
4124 mwindow->edl->local_session->selectionstart =
4125 mwindow->edl->align_to_frame(mwindow->edl->local_session->selectionstart, 0);
4126 mwindow->edl->local_session->selectionend =
4127 mwindow->edl->align_to_frame(mwindow->edl->local_session->selectionend, 1);
4137 if(mwindow->edl->session->editing_mode == EDITING_ARROW)
4139 // Need to create drag window
4140 mwindow->session->current_operation = DRAG_EDIT;
4141 mwindow->session->drag_edit = edit;
4142 //printf("TrackCanvas::test_edits 2\n");
4144 // Drag only one edit
4147 mwindow->session->drag_edits->remove_all();
4148 mwindow->session->drag_edits->append(edit);
4151 // Construct list of all affected edits
4153 mwindow->edl->tracks->get_affected_edits(
4154 mwindow->session->drag_edits,
4155 edit->track->from_units(edit->startproject),
4158 mwindow->session->drag_origin_x = cursor_x;
4159 mwindow->session->drag_origin_y = cursor_y;
4161 drag_popup = new BC_DragWindow(gui,
4162 mwindow->theme->clip_icon,
4163 get_abs_cursor_x() - mwindow->theme->clip_icon->get_w() / 2,
4164 get_abs_cursor_y() - mwindow->theme->clip_icon->get_h() / 2);
4165 //printf("TrackCanvas::test_edits 3 %p\n", drag_popup);
4177 int TrackCanvas::test_resources(int cursor_x, int cursor_y)
4182 int TrackCanvas::test_plugins(int cursor_x,
4195 //printf("TrackCanvas::test_plugins 1\n");
4196 for(track = mwindow->edl->tracks->first;
4198 track = track->next)
4200 for(int i = 0; i < track->plugin_set.total && !done; i++)
4202 PluginSet *plugin_set = track->plugin_set.values[i];
4203 for(plugin = (Plugin*)plugin_set->first;
4205 plugin = (Plugin*)plugin->next)
4207 plugin_dimensions(plugin, x, y, w, h);
4208 if(MWindowGUI::visible(x, x + w, 0, get_w()) &&
4209 MWindowGUI::visible(y, y + h, 0, get_h()))
4211 if(cursor_x >= x && cursor_x < x + w &&
4212 cursor_y >= y && cursor_y < y + h)
4222 //printf("TrackCanvas::test_plugins 1\n");
4225 // Start plugin popup
4228 //printf("TrackCanvas::test_plugins 2\n");
4229 if(get_buttonpress() == 3)
4231 gui->plugin_menu->update(plugin);
4232 gui->plugin_menu->activate_menu();
4236 // Select range of plugin on doubleclick over plugin
4237 if (get_double_click() && !drag_start)
4239 mwindow->edl->local_session->selectionstart =
4240 plugin->track->from_units(plugin->startproject);
4241 mwindow->edl->local_session->selectionend =
4242 plugin->track->from_units(plugin->startproject) +
4243 plugin->track->from_units(plugin->length);
4244 if(mwindow->edl->session->cursor_on_frames)
4246 mwindow->edl->local_session->selectionstart =
4247 mwindow->edl->align_to_frame(mwindow->edl->local_session->selectionstart, 0);
4248 mwindow->edl->local_session->selectionend =
4249 mwindow->edl->align_to_frame(mwindow->edl->local_session->selectionend, 1);
4255 //printf("TrackCanvas::test_plugins 3\n");
4261 //printf("TrackCanvas::test_plugins 4\n");
4262 if(mwindow->edl->session->editing_mode == EDITING_ARROW)
4264 //printf("TrackCanvas::test_plugins 5\n");
4265 if(plugin->track->data_type == TRACK_AUDIO)
4266 mwindow->session->current_operation = DRAG_AEFFECT_COPY;
4268 if(plugin->track->data_type == TRACK_VIDEO)
4269 mwindow->session->current_operation = DRAG_VEFFECT_COPY;
4271 mwindow->session->drag_plugin = plugin;
4272 //printf("TrackCanvas::test_plugins 6\n");
4279 switch(plugin->plugin_type)
4281 case PLUGIN_STANDALONE:
4283 PluginServer *server = mwindow->scan_plugindb(plugin->title,
4285 VFrame *frame = server->picon;
4286 //printf("TrackCanvas::test_plugins 7\n");
4287 drag_popup = new BC_DragWindow(gui,
4289 get_abs_cursor_x() - frame->get_w() / 2,
4290 get_abs_cursor_y() - frame->get_h() / 2);
4294 case PLUGIN_SHAREDPLUGIN:
4295 case PLUGIN_SHAREDMODULE:
4296 drag_popup = new BC_DragWindow(gui,
4297 mwindow->theme->clip_icon,
4298 get_abs_cursor_x() - mwindow->theme->clip_icon->get_w() / 2,
4299 get_abs_cursor_y() - mwindow->theme->clip_icon->get_h() / 2);
4301 //printf("test plugins %d %p\n", mwindow->edl->session->editing_mode, mwindow->session->drag_plugin);
4304 //printf("TrackCanvas::test_plugins 9 %p\n");
4306 //printf("TrackCanvas::test_plugins 10\n");
4312 //printf("TrackCanvas::test_plugins 11\n");
4316 int TrackCanvas::test_transitions(int cursor_x,
4322 Transition *transition = 0;
4326 for(Track *track = mwindow->edl->tracks->first;
4328 track = track->next)
4330 for(Edit *edit = track->edits->first;
4334 if(edit->transition)
4336 edit_dimensions(edit, x, y, w, h);
4337 get_transition_coords(x, y, w, h);
4339 if(MWindowGUI::visible(x, x + w, 0, get_w()) &&
4340 MWindowGUI::visible(y, y + h, 0, get_h()))
4342 if(cursor_x >= x && cursor_x < x + w &&
4343 cursor_y >= y && cursor_y < y + h)
4345 transition = edit->transition;
4359 new_cursor = UPRIGHT_ARROW_CURSOR;
4362 if(get_buttonpress() == 3)
4364 gui->transition_menu->update(transition);
4365 gui->transition_menu->activate_menu();
4372 int TrackCanvas::button_press_event()
4375 int cursor_x, cursor_y;
4376 int new_cursor, update_cursor;
4378 //printf("TrackCanvas::button_press_event 1\n");
4379 cursor_x = get_cursor_x();
4380 cursor_y = get_cursor_y();
4382 if(is_event_win() && cursor_inside())
4389 if(get_buttonpress() == 1)
4391 gui->unlock_window();
4392 gui->mbuttons->transport->handle_transport(STOP, 1);
4393 gui->lock_window("TrackCanvas::button_press_event");
4396 int update_overlay = 0, update_cursor = 0, rerender = 0;
4398 if(get_buttonpress() == 4)
4400 //printf("TrackCanvas::button_press_event 1\n");
4401 mwindow->move_up(get_h() / 10);
4405 if(get_buttonpress() == 5)
4407 //printf("TrackCanvas::button_press_event 2\n");
4408 mwindow->move_down(get_h() / 10);
4412 switch(mwindow->edl->session->editing_mode)
4414 // Test handles and resource boundaries and highlight a track
4419 if(mwindow->edl->session->auto_conf->transitions &&
4420 test_transitions(cursor_x,
4429 if(do_keyframes(cursor_x,
4440 // Test edit boundaries
4441 if(test_edit_handles(cursor_x, cursor_y, 1, new_cursor, update_cursor))
4446 // Test plugin boundaries
4447 if(test_plugin_handles(cursor_x, cursor_y, 1, new_cursor, update_cursor))
4452 if(test_edits(cursor_x, cursor_y, 1, 0, update_cursor, rerender, new_cursor, update_cursor))
4457 if(test_plugins(cursor_x, cursor_y, 0, 1, update_cursor, rerender))
4462 if(test_resources(cursor_x, cursor_y))
4467 if(test_tracks(cursor_x, cursor_y, 1))
4474 // Test handles only and select a region
4477 double position = (double)cursor_x *
4478 mwindow->edl->local_session->zoom_sample /
4479 mwindow->edl->session->sample_rate +
4480 (double)mwindow->edl->local_session->view_start *
4481 mwindow->edl->local_session->zoom_sample /
4482 mwindow->edl->session->sample_rate;
4483 //printf("TrackCanvas::button_press_event %d\n", position);
4485 if(mwindow->edl->session->auto_conf->transitions &&
4486 test_transitions(cursor_x,
4495 if(do_keyframes(cursor_x,
4507 // Test edit boundaries
4508 if(test_edit_handles(cursor_x, cursor_y, 1, new_cursor, update_cursor))
4513 // Test plugin boundaries
4514 if(test_plugin_handles(cursor_x, cursor_y, 1, new_cursor, update_cursor))
4519 if(test_edits(cursor_x, cursor_y, 1, 0, update_cursor, rerender, new_cursor, update_cursor))
4524 if(test_plugins(cursor_x, cursor_y, 0, 1, update_cursor, rerender))
4529 if(test_tracks(cursor_x, cursor_y, 1))
4533 // Highlight selection
4536 rerender = start_selection(position);
4537 mwindow->session->current_operation = SELECT_REGION;
4548 mwindow->cwindow->update(1, 0, 0, 0, 1);
4550 mwindow->update_plugin_guis();
4551 gui->patchbay->update();
4562 gui->timebar->update_highlights();
4563 gui->cursor->hide();
4564 gui->cursor->show();
4565 gui->zoombar->update();
4576 int TrackCanvas::start_selection(double position)
4579 position = mwindow->edl->align_to_frame(position, 0);
4584 double midpoint = (mwindow->edl->local_session->selectionstart +
4585 mwindow->edl->local_session->selectionend) / 2;
4587 if(position < midpoint)
4589 mwindow->edl->local_session->selectionstart = position;
4590 selection_midpoint1 = mwindow->edl->local_session->selectionend;
4596 mwindow->edl->local_session->selectionend = position;
4597 selection_midpoint1 = mwindow->edl->local_session->selectionstart;
4598 // Don't que the CWindow for the end
4602 // Start a new selection
4604 //printf("TrackCanvas::start_selection %f\n", position);
4605 mwindow->edl->local_session->selectionstart =
4606 mwindow->edl->local_session->selectionend =
4608 selection_midpoint1 = position;
4616 void TrackCanvas::end_edithandle_selection()
4618 mwindow->modify_edithandles();
4621 void TrackCanvas::end_pluginhandle_selection()
4623 mwindow->modify_pluginhandles();
4627 double TrackCanvas::time_visible()
4629 return (double)get_w() *
4630 mwindow->edl->local_session->zoom_sample /
4631 mwindow->edl->session->sample_rate;
4674 void TrackCanvas::draw_automation()
4679 int TrackCanvas::set_index_file(int flash, Asset *asset)
4685 int TrackCanvas::button_release()
4691 int TrackCanvas::auto_reposition(int &cursor_x, int &cursor_y, int64_t cursor_position)
4697 int TrackCanvas::draw_floating_handle(int flash)
4702 int TrackCanvas::draw_loop_point(int64_t position, int flash)
4707 int TrackCanvas::draw_playback_cursor(int pixel, int flash)
4713 int TrackCanvas::update_handle_selection(int64_t cursor_position)
4718 int TrackCanvas::end_translation()