+void AssetViewPopup::draw_vframe(VFrame *vframe)
+{
+ switch( draw_mode ) {
+ case ASSET_VIEW_MEDIA:
+ case ASSET_VIEW_ICON:
+ ViewPopup::draw_vframe(vframe);
+ case ASSET_VIEW_NONE:
+ default:
+ return;
+ case ASSET_VIEW_MEDIA_MAP:
+ case ASSET_VIEW_FULL:
+ break;
+ }
+ set_color(BLACK);
+ draw_box(0,0,get_w(),get_h());
+ 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 ) {
+ if( !track->is_armed() ) continue;
+ 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);
+ }
+ }
+ }
+}
+
+int AssetViewPopup::keypress_event()
+{
+ int result = 0;
+ AssetVIconThread *avt = (AssetVIconThread *)vt;
+ switch( avt->draw_mode ) {
+ case ASSET_VIEW_MEDIA_MAP:
+ switch( get_keypress() ) {
+ case 'f':
+ case 'F':
+ avt->draw_mode = ASSET_VIEW_FULL;
+ result = 1;
+ }
+ break;
+ case ASSET_VIEW_FULL:
+ avt->draw_mode = ASSET_VIEW_MEDIA_MAP;
+ result = 1;
+ }
+ if( result ) // zero change for refresh
+ avt->zoom_scale(0);
+ return ViewPopup::keypress_event();
+}
+
+
+AssetVIconThread::AssetVIconThread(AWindowGUI *gui, Preferences *preferences)
+ : VIconThread(gui->asset_list, preferences->vicon_size * 16/9, preferences->vicon_size,
+ 4*preferences->awindow_picon_h * 16/9, 4*preferences->awindow_picon_h)
+{
+ this->gui = gui;
+ draw_mode = ASSET_VIEW_NONE;
+ int vicon_cmodel = BC_RGB8;
+ switch( preferences->vicon_color_mode ) {
+ case VICON_COLOR_MODE_LOW: vicon_cmodel = BC_RGB8; break;
+ case VICON_COLOR_MODE_MED: vicon_cmodel = BC_RGB565; break;
+ case VICON_COLOR_MODE_HIGH: vicon_cmodel = BC_RGB888; break;
+ }
+ this->vicon_cmodel = vicon_cmodel;
+}
+
+AssetVIconThread::~AssetVIconThread()
+{
+}
+
+void AssetVIconThread::set_view_popup(AssetVIcon *v, int draw_mode)
+{
+ gui->stop_vicon_drawing();
+ this->draw_mode = draw_mode;
+ set_view_popup(v);
+ gui->start_vicon_drawing();
+}
+
+void AssetVIconThread::set_view_popup(AssetVIcon *v)
+{
+ if( !v ) draw_mode = ASSET_VIEW_NONE;
+ VIconThread::set_view_popup(v);
+}
+
+ViewPopup *AssetVIconThread::new_view_window(ViewPopup *vpopup)
+{
+ BC_WindowBase *parent = wdw->get_parent();
+ int rx = 0, ry = 0, rw = 0, rh = 0;
+ if( draw_mode != ASSET_VIEW_FULL ) {
+ 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(), vy = viewing->get_vy();
+ wdw->get_root_coordinates(vx, vy, &rx, &ry);
+ rx += (rx >= cx ? -view_w+viewing->w/4 : viewing->w-viewing->w/4);
+ ry += (ry >= cy ? -view_h+viewing->h/4 : viewing->h-viewing->h/4);
+ rw = view_w; rh = view_h;
+ }
+ else
+ parent->get_fullscreen_geometry(rx, ry, rw, rh);
+ AssetViewPopup *av_popup = (AssetViewPopup *)vpopup;
+ if( av_popup )
+ av_popup->reposition_window(rx, ry, rw, rh);
+ else
+ av_popup = new AssetViewPopup(this, draw_mode, rx, ry, rw, rh);
+ int playing_audio = gui->play_off ? -1 : 0;
+ if( !playing_audio ) {
+ switch( draw_mode ) {
+ case ASSET_VIEW_NONE:
+ case ASSET_VIEW_ICON:
+ case ASSET_VIEW_MEDIA_MAP:
+ case ASSET_VIEW_FULL:
+ playing_audio = -1;
+ break;
+ case ASSET_VIEW_MEDIA:
+ switch( gui->vicon_drawing ) {
+ case AVICON_SRC_TARGET:
+ case AVICON_NO_PLAY:
+ playing_audio = -1;
+ break;
+ }
+ }
+ }
+ vicon->playing_audio = playing_audio;
+ wdw->set_active_subwindow(av_popup);
+ return av_popup;
+}
+
+void AssetVIconThread::stop_vicon_drawing(int wait)
+{
+ stop_drawing();
+ gui->lock_window("AssetVIconThread::stop_vicon_drawing");
+ gui->unlock_window();
+}
+