+void AssetViewPopup::draw_vframe(VFrame *vframe)
+{
+ if( draw_mode == ASSET_DRAW_IMAGE ) {
+ ViewPopup::draw_vframe(vframe);
+ return;
+ }
+ set_color(BLACK);
+ draw_box(0,0,get_w(),get_h());
+ if( draw_mode != ASSET_DRAW_MEDIA_MAP )
+ return;
+ int y1 = bar_h;
+ int y2 = get_h()-bar_h;
+ BC_WindowBase::draw_vframe(vframe, 0,y1, get_w(),y2-y1);
+ AssetVIconThread *avt = (AssetVIconThread *)vt;
+ AssetVIcon *vicon = (AssetVIcon *)avt->vicon;
+ AssetPicon *picon = (AssetPicon *)vicon->picon;
+ Indexable *idxbl =
+ picon->indexable ? picon->indexable :
+ picon->edl ? picon->edl : 0;
+ if( !idxbl ) return;
+ 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);
+ if( !idxbl_length ) idxbl_length = 1;
+
+ EDL *edl = picon->mwindow->edl;
+ double total_length = edl->tracks->total_length();
+ if( !total_length ) total_length = 1;
+ 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 pos1 = track->from_units(edit->startsource);
+ double pos2 = track->from_units(edit->startsource + edit->length);
+ double xscale = get_w() / idxbl_length;
+ int ex1 = pos1 * xscale, ex2 = pos2 * xscale;
+ set_color(WHITE);
+ draw_box(ex1,0, ex2-ex1,y1);
+ set_color(BLACK);
+ draw_line(ex1,0, ex1,y1);
+ draw_line(ex2,0, ex2,y1);
+ pos1 = track->from_units(edit->startproject);
+ pos2 = track->from_units(edit->startproject + edit->length);
+ xscale = get_w() / total_length;
+ int px1 = pos1 * xscale, px2 = pos2 * xscale;
+ set_color(RED);
+ draw_box(px1,y2, px2-px1,get_h()-y2);
+ set_color(BLACK);
+ draw_line(px1,y2, px1,get_h()-1);
+ draw_line(px2,y2, px2,get_h()-1);
+
+ set_color(YELLOW);
+ draw_line(ex1,y1, px1,y2);
+ draw_line(ex2,y1, px2,y2);
+ }
+ }
+ }
+}
+
+
+AssetVIconThread::AssetVIconThread(AWindowAssets *asset_list)
+ : VIconThread(asset_list,
+ asset_list->mwindow->preferences->awindow_picon_h * 16/9,
+ asset_list->mwindow->preferences->awindow_picon_h,
+ 4 * asset_list->mwindow->preferences->awindow_picon_h * 16/9,
+ 4 * asset_list->mwindow->preferences->awindow_picon_h)
+{
+ draw_mode = ASSET_DRAW_IMAGE;
+}
+
+AssetVIconThread::~AssetVIconThread()
+{
+}
+
+void AssetVIconThread::set_view_popup(AssetVIcon *vicon, int draw_mode)
+{
+ if( draw_mode >= 0 )
+ this->draw_mode = draw_mode;
+ VIconThread::set_view_popup(vicon);
+}
+
+ViewPopup *AssetVIconThread::new_view_window(VFrame *frame)
+{
+ BC_WindowBase *parent = wdw->get_parent();
+ XineramaScreenInfo *info = parent->get_xinerama_info(-1);
+ int cx = info ? info->x_org + info->width/2 : parent->get_root_w(0)/2;
+ int cy = info ? info->y_org + info->height/2 : parent->get_root_h(0)/2;
+ int vx = viewing->get_vx(), rx = 0;
+ int vy = viewing->get_vy(), ry = 0;
+ wdw->get_root_coordinates(vx, vy, &rx, &ry);
+ rx += (rx >= cx ? -view_w : viewing->vw);
+ ry += (ry >= cy ? -view_h : viewing->vh);
+ AssetViewPopup *popup = new AssetViewPopup(this, draw_mode,
+ frame, rx, ry, view_w, view_h);
+ if( draw_mode == ASSET_DRAW_MEDIA_MAP )
+ vicon->playing_audio = -1;
+ wdw->set_active_subwindow(popup);
+ return popup;
+}
+