+int AssetVIcon::popup_button_press(int x, int y)
+{
+ if( playing_audio >= 0 ) return 0;
+ VIconThread *vt = picon->gui->vicon_thread;
+ ViewPopup *view_win = vt->view_win;
+ if( !view_win || !view_win->is_event_win() ) return 0;
+ int view_w = view_win->get_w(), view_h = view_win->get_h();
+ MWindow *mwindow = picon->mwindow;
+ EDL *edl = mwindow->edl;
+ if( y < VIEW_POPUP_BAR_H ) {
+ Indexable *idxbl =
+ picon->indexable ? picon->indexable :
+ picon->edl ? picon->edl : 0;
+ if( !idxbl ) return 0;
+ double sample_rate = idxbl->get_sample_rate();
+ double audio_length = sample_rate > 0 && idxbl->have_audio() ?
+ idxbl->get_audio_samples() / sample_rate : 0;
+ double frame_rate = idxbl->get_frame_rate();
+ double video_length = frame_rate > 0 && idxbl->have_video() ?
+ idxbl->get_video_frames() / frame_rate : 0;
+ double idxbl_length = bmax(audio_length, video_length);
+ double pos = x * idxbl_length / view_w;
+ double start = 0, end = idxbl_length;
+ double lt = DBL_MAX, rt = DBL_MAX;
+ for( Track *track=edl->tracks->first; track!=0; track=track->next ) {
+ for( Edit *edit=track->edits->first; edit!=0; edit=edit->next ) {
+ Indexable *indexable = (Indexable *)edit->asset;
+ if( !indexable ) indexable = (Indexable *)edit->nested_edl;
+ if( !indexable ) continue;
+ if( indexable->id == idxbl->id ||
+ (!indexable->is_asset == !idxbl->is_asset &&
+ !strcmp(indexable->path, idxbl->path)) ) {
+ double start_pos = track->from_units(edit->startsource);
+ double end_pos = track->from_units(edit->startsource + edit->length);
+ double dlt = pos - start_pos, drt = end_pos - pos;
+ if( dlt >= 0 && dlt < lt ) { lt = dlt; start = start_pos; }
+ else if( dlt < 0 && -dlt < rt ) { rt = -dlt; end = start_pos; }
+ if( drt >= 0 && drt < rt ) { rt = drt; end = end_pos; }
+ else if( drt < 0 && -drt < lt ) { lt = -drt; start = end_pos; }
+ }
+ }
+ }
+ mwindow->gui->lock_window("AssetVIcon::popup_button_press");
+ VWindow *vwindow = mwindow->get_viewer(1, 0);
+ vwindow->change_source(idxbl);
+ mwindow->gui->unlock_window();
+ EDL *vedl = vwindow->get_edl();
+ vedl->set_inpoint(start);
+ vedl->set_outpoint(end);
+ vedl->local_session->set_selectionstart(start);
+ vedl->local_session->set_selectionend(end);
+ vwindow->update_position(CHANGE_NONE, 0, 1, 0);
+ return 1;
+ }
+ return y < view_h-VIEW_POPUP_BAR_H ? 0 : popup_cursor_motion(x, y);
+}
+
+int AssetVIcon::popup_cursor_motion(int x, int y)
+{
+ if( playing_audio >= 0 ) return 0;
+ VIconThread *vt = picon->gui->vicon_thread;
+ ViewPopup *view_win = (ViewPopup *)vt->view_win;
+ if( !view_win || !view_win->is_event_win() ||
+ !view_win->get_button_down() ) return 0;
+ int view_w = view_win->get_w(), view_h = view_win->get_h();
+ MWindow *mwindow = picon->mwindow;
+ EDL *edl = mwindow->edl;
+ if( y >= view_h-VIEW_POPUP_BAR_H ) {
+ double total_length = edl->tracks->total_length();
+ double pos = x * total_length / view_w;
+ mwindow->gui->lock_window("AssetVIcon::popup_cursor_motion");
+ mwindow->select_point(pos);
+ mwindow->zoom_sample(edl->local_session->zoom_sample);
+ mwindow->gui->unlock_window();
+ return 1;
+ }
+ return 0;
+}
+