00001 #include "asset.h"
00002 #include "assetedit.h"
00003 #include "assetpopup.h"
00004 #include "assets.h"
00005 #include "awindowgui.h"
00006 #include "awindowgui.inc"
00007 #include "awindow.h"
00008 #include "awindowmenu.h"
00009 #include "bcsignals.h"
00010 #include "cache.h"
00011 #include "colormodels.h"
00012 #include "cursors.h"
00013 #include "cwindowgui.h"
00014 #include "cwindow.h"
00015 #include "edl.h"
00016 #include "edlsession.h"
00017 #include "file.h"
00018 #include "filesystem.h"
00019 #include "language.h"
00020 #include "labels.h"
00021 #include "labeledit.h"
00022 #include "localsession.h"
00023 #include "mainmenu.h"
00024 #include "mainsession.h"
00025 #include "mwindowgui.h"
00026 #include "mwindow.h"
00027 #include "newfolder.h"
00028 #include "preferences.h"
00029 #include "theme.h"
00030 #include "vframe.h"
00031 #include "vwindowgui.h"
00032 #include "vwindow.h"
00033
00034
00035
00036
00037 AssetPicon::AssetPicon(MWindow *mwindow,
00038 AWindowGUI *gui,
00039 Asset *asset)
00040 : BC_ListBoxItem()
00041 {
00042 reset();
00043 this->mwindow = mwindow;
00044 this->gui = gui;
00045 this->asset = asset;
00046 this->id = asset->id;
00047 }
00048
00049 AssetPicon::AssetPicon(MWindow *mwindow,
00050 AWindowGUI *gui,
00051 EDL *edl)
00052 : BC_ListBoxItem()
00053 {
00054 reset();
00055 this->mwindow = mwindow;
00056 this->gui = gui;
00057 this->edl = edl;
00058 this->id = edl->id;
00059 }
00060
00061 AssetPicon::AssetPicon(MWindow *mwindow,
00062 AWindowGUI *gui,
00063 char *folder)
00064 : BC_ListBoxItem(folder, gui->folder_icon)
00065 {
00066 reset();
00067 this->mwindow = mwindow;
00068 this->gui = gui;
00069 }
00070
00071 AssetPicon::AssetPicon(MWindow *mwindow,
00072 AWindowGUI *gui,
00073 PluginServer *plugin)
00074 : BC_ListBoxItem()
00075 {
00076 reset();
00077 this->mwindow = mwindow;
00078 this->gui = gui;
00079 this->plugin = plugin;
00080 asset = 0;
00081 icon = 0;
00082 id = 0;
00083 }
00084
00085 AssetPicon::AssetPicon(MWindow *mwindow,
00086 AWindowGUI *gui,
00087 Label *label)
00088 : BC_ListBoxItem()
00089 {
00090 reset();
00091 this->mwindow = mwindow;
00092 this->gui = gui;
00093 this->label = label;
00094 asset = 0;
00095 icon = 0;
00096 id = 0;
00097 }
00098
00099 AssetPicon::~AssetPicon()
00100 {
00101 if(icon)
00102 {
00103 if(icon != gui->file_icon &&
00104 icon != gui->audio_icon &&
00105 icon != gui->folder_icon &&
00106 icon != gui->clip_icon &&
00107 icon != gui->video_icon)
00108 {
00109 delete icon;
00110 delete icon_vframe;
00111 }
00112 }
00113 }
00114
00115 void AssetPicon::reset()
00116 {
00117 plugin = 0;
00118 label = 0;
00119 asset = 0;
00120 edl = 0;
00121 icon = 0;
00122 icon_vframe = 0;
00123 in_use = 1;
00124 id = 0;
00125 persistent = 0;
00126 }
00127
00128 void AssetPicon::create_objects()
00129 {
00130 FileSystem fs;
00131 char name[BCTEXTLEN];
00132 int pixmap_w, pixmap_h;
00133
00134
00135 pixmap_h = 50;
00136
00137 if(asset)
00138 {
00139 fs.extract_name(name, asset->path);
00140 set_text(name);
00141 if(asset->video_data)
00142 {
00143 if(mwindow->preferences->use_thumbnails)
00144 {
00145 File *file = mwindow->video_cache->check_out(asset, mwindow->edl);
00146
00147 if(file)
00148 {
00149 pixmap_w = pixmap_h * asset->width / asset->height;
00150
00151 file->set_layer(0);
00152 file->set_video_position(0, mwindow->edl->session->frame_rate);
00153
00154 if(gui->temp_picon &&
00155 (gui->temp_picon->get_w() != asset->width ||
00156 gui->temp_picon->get_h() != asset->height))
00157 {
00158 delete gui->temp_picon;
00159 gui->temp_picon = 0;
00160 }
00161
00162 if(!gui->temp_picon)
00163 {
00164 gui->temp_picon = new VFrame(0,
00165 asset->width,
00166 asset->height,
00167 BC_RGB888);
00168 }
00169
00170 file->read_frame(gui->temp_picon);
00171
00172 icon = new BC_Pixmap(gui, pixmap_w, pixmap_h);
00173 icon->draw_vframe(gui->temp_picon,
00174 0,
00175 0,
00176 pixmap_w,
00177 pixmap_h,
00178 0,
00179 0);
00180
00181 icon_vframe = new VFrame(0,
00182 pixmap_w,
00183 pixmap_h,
00184 BC_RGB888);
00185 cmodel_transfer(icon_vframe->get_rows(),
00186 gui->temp_picon->get_rows(),
00187 0,
00188 0,
00189 0,
00190 0,
00191 0,
00192 0,
00193 0,
00194 0,
00195 gui->temp_picon->get_w(),
00196 gui->temp_picon->get_h(),
00197 0,
00198 0,
00199 pixmap_w,
00200 pixmap_h,
00201 BC_RGB888,
00202 BC_RGB888,
00203 0,
00204 0,
00205 0);
00206
00207
00208 mwindow->video_cache->check_in(asset);
00209 }
00210 else
00211 {
00212 icon = gui->video_icon;
00213 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_FILM];
00214
00215 }
00216 }
00217 else
00218 {
00219 icon = gui->video_icon;
00220 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_FILM];
00221 }
00222 }
00223 else
00224 if(asset->audio_data)
00225 {
00226 icon = gui->audio_icon;
00227 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_SOUND];
00228 }
00229
00230
00231 set_icon(icon);
00232 set_icon_vframe(icon_vframe);
00233
00234 }
00235 else
00236 if(edl)
00237 {
00238
00239 strcpy(name, edl->local_session->clip_title);
00240 set_text(name);
00241 set_icon(gui->clip_icon);
00242 set_icon_vframe(mwindow->theme->get_image("clip_icon"));
00243 }
00244 else
00245 if(plugin)
00246 {
00247 strcpy(name, _(plugin->title));
00248 set_text(name);
00249 if(plugin->picon)
00250 {
00251 if(plugin->picon->get_color_model() == BC_RGB888)
00252 {
00253 icon = new BC_Pixmap(gui,
00254 plugin->picon->get_w(),
00255 plugin->picon->get_h());
00256 icon->draw_vframe(plugin->picon,
00257 0,
00258 0,
00259 plugin->picon->get_w(),
00260 plugin->picon->get_h(),
00261 0,
00262 0);
00263 }
00264 else
00265 {
00266 icon = new BC_Pixmap(gui,
00267 plugin->picon,
00268 PIXMAP_ALPHA);
00269 }
00270 icon_vframe = new VFrame (*plugin->picon);
00271 }
00272 else
00273 {
00274 icon = gui->file_icon;
00275 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN];
00276 }
00277 set_icon(icon);
00278 set_icon_vframe(icon_vframe);
00279 }
00280 else
00281 if(label)
00282 {
00283 Units::totext(name,
00284 label->position,
00285 mwindow->edl->session->time_format,
00286 mwindow->edl->session->sample_rate,
00287 mwindow->edl->session->frame_rate,
00288 mwindow->edl->session->frames_per_foot);
00289 set_text(name);
00290 icon = gui->file_icon;
00291 icon_vframe = BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN];
00292 set_icon(icon);
00293 set_icon_vframe(icon_vframe);
00294 }
00295
00296 }
00297
00298
00299
00300
00301
00302
00303 AWindowGUI::AWindowGUI(MWindow *mwindow, AWindow *awindow)
00304 : BC_Window(PROGRAM_NAME ": Resources",
00305 mwindow->session->awindow_x,
00306 mwindow->session->awindow_y,
00307 mwindow->session->awindow_w,
00308 mwindow->session->awindow_h,
00309 100,
00310 100,
00311 1,
00312 1,
00313 1)
00314 {
00315
00316
00317
00318
00319
00320 this->mwindow = mwindow;
00321 this->awindow = awindow;
00322 temp_picon = 0;
00323 allow_iconlisting = 1;
00324 }
00325
00326 AWindowGUI::~AWindowGUI()
00327 {
00328 assets.remove_all_objects();
00329 folders.remove_all_objects();
00330 aeffects.remove_all_objects();
00331 veffects.remove_all_objects();
00332 atransitions.remove_all_objects();
00333 vtransitions.remove_all_objects();
00334 labellist.remove_all_objects();
00335 displayed_assets[1].remove_all_objects();
00336 delete file_icon;
00337 delete audio_icon;
00338 delete folder_icon;
00339 delete clip_icon;
00340 delete newfolder_thread;
00341 delete asset_menu;
00342 delete label_menu;
00343 delete assetlist_menu;
00344 delete folderlist_menu;
00345 if(temp_picon) delete temp_picon;
00346 }
00347
00348 int AWindowGUI::create_objects()
00349 {
00350 int x, y;
00351 AssetPicon *picon;
00352
00353 SET_TRACE
00354
00355 asset_titles[0] = _("Title");
00356 asset_titles[1] = _("Comments");
00357
00358 SET_TRACE
00359
00360 set_icon(mwindow->theme->get_image("awindow_icon"));
00361 file_icon = new BC_Pixmap(this,
00362 BC_WindowBase::get_resources()->type_to_icon[ICON_UNKNOWN],
00363 PIXMAP_ALPHA);
00364
00365 folder_icon = new BC_Pixmap(this,
00366 BC_WindowBase::get_resources()->type_to_icon[ICON_FOLDER],
00367 PIXMAP_ALPHA);
00368
00369 audio_icon = new BC_Pixmap(this,
00370 BC_WindowBase::get_resources()->type_to_icon[ICON_SOUND],
00371 PIXMAP_ALPHA);
00372
00373 video_icon = new BC_Pixmap(this,
00374 BC_WindowBase::get_resources()->type_to_icon[ICON_FILM],
00375 PIXMAP_ALPHA);
00376
00377 SET_TRACE
00378
00379 clip_icon = new BC_Pixmap(this,
00380 mwindow->theme->get_image("clip_icon"),
00381 PIXMAP_ALPHA);
00382
00383 SET_TRACE
00384
00385
00386 folders.append(picon = new AssetPicon(mwindow,
00387 this,
00388 AEFFECT_FOLDER));
00389 picon->persistent = 1;
00390 folders.append(picon = new AssetPicon(mwindow,
00391 this,
00392 VEFFECT_FOLDER));
00393 picon->persistent = 1;
00394 folders.append(picon = new AssetPicon(mwindow,
00395 this,
00396 ATRANSITION_FOLDER));
00397 picon->persistent = 1;
00398 folders.append(picon = new AssetPicon(mwindow,
00399 this,
00400 VTRANSITION_FOLDER));
00401 picon->persistent = 1;
00402 folders.append(picon = new AssetPicon(mwindow,
00403 this,
00404 LABEL_FOLDER));
00405 picon->persistent = 1;
00406
00407 create_label_folder();
00408
00409 SET_TRACE
00410
00411 create_persistent_folder(&aeffects, 1, 0, 1, 0);
00412 create_persistent_folder(&veffects, 0, 1, 1, 0);
00413 create_persistent_folder(&atransitions, 1, 0, 0, 1);
00414 create_persistent_folder(&vtransitions, 0, 1, 0, 1);
00415
00416 SET_TRACE
00417
00418 mwindow->theme->get_awindow_sizes(this);
00419
00420 SET_TRACE
00421 add_subwindow(asset_list = new AWindowAssets(mwindow,
00422 this,
00423 mwindow->theme->alist_x,
00424 mwindow->theme->alist_y,
00425 mwindow->theme->alist_w,
00426 mwindow->theme->alist_h));
00427
00428 SET_TRACE
00429 add_subwindow(divider = new AWindowDivider(mwindow,
00430 this,
00431 mwindow->theme->adivider_x,
00432 mwindow->theme->adivider_y,
00433 mwindow->theme->adivider_w,
00434 mwindow->theme->adivider_h));
00435
00436 SET_TRACE
00437 divider->set_cursor(HSEPARATE_CURSOR);
00438
00439 SET_TRACE
00440 add_subwindow(folder_list = new AWindowFolders(mwindow,
00441 this,
00442 mwindow->theme->afolders_x,
00443 mwindow->theme->afolders_y,
00444 mwindow->theme->afolders_w,
00445 mwindow->theme->afolders_h));
00446
00447 SET_TRACE
00448
00449 x = mwindow->theme->abuttons_x;
00450 y = mwindow->theme->abuttons_y;
00451
00452 SET_TRACE
00453
00454 newfolder_thread = new NewFolderThread(mwindow, this);
00455
00456 add_subwindow(asset_menu = new AssetPopup(mwindow, this));
00457 asset_menu->create_objects();
00458
00459 add_subwindow(label_menu = new LabelPopup(mwindow, this));
00460 label_menu->create_objects();
00461
00462 SET_TRACE
00463
00464 add_subwindow(assetlist_menu = new AssetListMenu(mwindow, this));
00465
00466 SET_TRACE
00467 assetlist_menu->create_objects();
00468
00469 SET_TRACE
00470
00471 add_subwindow(folderlist_menu = new FolderListMenu(mwindow, this));
00472 folderlist_menu->create_objects();
00473
00474
00475 SET_TRACE
00476 create_custom_xatoms();
00477
00478 return 0;
00479 }
00480
00481 int AWindowGUI::resize_event(int w, int h)
00482 {
00483 mwindow->session->awindow_x = get_x();
00484 mwindow->session->awindow_y = get_y();
00485 mwindow->session->awindow_w = w;
00486 mwindow->session->awindow_h = h;
00487
00488 mwindow->theme->get_awindow_sizes(this);
00489 mwindow->theme->draw_awindow_bg(this);
00490
00491 reposition_objects();
00492
00493 int x = mwindow->theme->abuttons_x;
00494 int y = mwindow->theme->abuttons_y;
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516 BC_WindowBase::resize_event(w, h);
00517 return 1;
00518 }
00519
00520 int AWindowGUI::translation_event()
00521 {
00522 mwindow->session->awindow_x = get_x();
00523 mwindow->session->awindow_y = get_y();
00524 return 0;
00525 }
00526
00527 void AWindowGUI::reposition_objects()
00528 {
00529 int wmax = mwindow->session->awindow_w-mwindow->theme->adivider_w;
00530 int x = mwindow->theme->afolders_x;
00531 int w = mwindow->theme->afolders_w;
00532 if (w > wmax)
00533 w = wmax;
00534 if (w <= 0)
00535 w = 1;
00536 folder_list->reposition_window(x, mwindow->theme->afolders_y,
00537 w, mwindow->theme->afolders_h);
00538 x = mwindow->theme->adivider_x;
00539 if (x > wmax)
00540 x = wmax;
00541 if (x < 0)
00542 x = 0;
00543 divider->reposition_window(x,
00544 mwindow->theme->adivider_y,
00545 mwindow->theme->adivider_w,
00546 mwindow->theme->adivider_h);
00547 int x2 = mwindow->theme->alist_x;
00548 if (x2 < x+mwindow->theme->adivider_w)
00549 x2 = x+mwindow->theme->adivider_w;
00550 w = mwindow->theme->alist_w;
00551 if (w > wmax)
00552 w = wmax;
00553 if (w <= 0)
00554 w = 1;
00555 asset_list->reposition_window(x2, mwindow->theme->alist_y,
00556 w, mwindow->theme->alist_h);
00557 flush();
00558 }
00559
00560 int AWindowGUI::close_event()
00561 {
00562 hide_window();
00563 mwindow->session->show_awindow = 0;
00564 unlock_window();
00565
00566 mwindow->gui->lock_window("AWindowGUI::close_event");
00567 mwindow->gui->mainmenu->show_awindow->set_checked(0);
00568 mwindow->gui->unlock_window();
00569
00570 lock_window("AWindowGUI::close_event");
00571 mwindow->save_defaults();
00572 return 1;
00573 }
00574
00575
00576 int AWindowGUI::keypress_event()
00577 {
00578 switch(get_keypress())
00579 {
00580 case 'w':
00581 case 'W':
00582 if(ctrl_down())
00583 {
00584 close_event();
00585 return 1;
00586 }
00587 break;
00588 }
00589 return 0;
00590 }
00591
00592
00593
00594 int AWindowGUI::create_custom_xatoms()
00595 {
00596 UpdateAssetsXAtom = create_xatom("CWINDOWGUI_UPDATE_ASSETS");
00597 return 0;
00598 }
00599 int AWindowGUI::recieve_custom_xatoms(xatom_event *event)
00600 {
00601 if (event->message_type == UpdateAssetsXAtom)
00602 {
00603 update_assets();
00604 return 1;
00605 } else
00606 return 0;
00607 }
00608
00609 void AWindowGUI::async_update_assets()
00610 {
00611 xatom_event event;
00612 event.message_type = UpdateAssetsXAtom;
00613 send_custom_xatom(&event);
00614 }
00615
00616
00617
00618
00619
00620
00621
00622 void AWindowGUI::update_folder_list()
00623 {
00624
00625 for(int i = 0; i < folders.total; i++)
00626 {
00627 AssetPicon *picon = (AssetPicon*)folders.values[i];
00628 picon->in_use--;
00629 }
00630
00631
00632
00633 for(int i = 0; i < mwindow->edl->folders.total; i++)
00634 {
00635 char *folder = mwindow->edl->folders.values[i];
00636 int exists = 0;
00637
00638
00639 for(int j = 0; j < folders.total; j++)
00640 {
00641 AssetPicon *picon = (AssetPicon*)folders.values[j];
00642 if(!strcasecmp(picon->get_text(), folder))
00643 {
00644 exists = 1;
00645 picon->in_use = 1;
00646 break;
00647 }
00648 }
00649
00650 if(!exists)
00651 {
00652 AssetPicon *picon = new AssetPicon(mwindow, this, folder);
00653 picon->create_objects();
00654 folders.append(picon);
00655 }
00656
00657 }
00658
00659
00660
00661
00662
00663 for(int i = folders.total - 1; i >= 0; i--)
00664 {
00665 AssetPicon *picon = (AssetPicon*)folders.values[i];
00666 if(!picon->in_use && !picon->persistent)
00667 {
00668 delete picon;
00669 folders.remove_number(i);
00670 }
00671 }
00672
00673
00674
00675 }
00676
00677 void AWindowGUI::create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
00678 int do_audio,
00679 int do_video,
00680 int is_realtime,
00681 int is_transition)
00682 {
00683 ArrayList<PluginServer*> plugindb;
00684
00685
00686 mwindow->create_plugindb(do_audio,
00687 do_video,
00688 is_realtime,
00689 is_transition,
00690 0,
00691 plugindb);
00692
00693 for(int i = 0; i < plugindb.total; i++)
00694 {
00695 PluginServer *server = plugindb.values[i];
00696 int exists = 0;
00697
00698
00699 if(!exists)
00700 {
00701 AssetPicon *picon = new AssetPicon(mwindow, this, server);
00702 picon->create_objects();
00703 output->append(picon);
00704 }
00705 }
00706 }
00707
00708 void AWindowGUI::create_label_folder()
00709 {
00710 Label *current;
00711 for(current = mwindow->edl->labels->first; current; current = NEXT) {
00712 AssetPicon *picon = new AssetPicon(mwindow, this, current);
00713 picon->create_objects();
00714 labellist.append(picon);
00715 }
00716 }
00717
00718
00719 void AWindowGUI::update_asset_list()
00720 {
00721
00722 for(int i = 0; i < assets.total; i++)
00723 {
00724 AssetPicon *picon = (AssetPicon*)assets.values[i];
00725 picon->in_use--;
00726 }
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736 for(int i = 0; i < mwindow->edl->clips.total; i++)
00737 {
00738 int exists = 0;
00739
00740
00741 for(int j = 0; j < assets.total && !exists; j++)
00742 {
00743 AssetPicon *picon = (AssetPicon*)assets.values[j];
00744
00745 if(picon->id == mwindow->edl->clips.values[i]->id)
00746 {
00747 picon->edl = mwindow->edl->clips.values[i];
00748 picon->set_text(mwindow->edl->clips.values[i]->local_session->clip_title);
00749 exists = 1;
00750 picon->in_use = 1;
00751 }
00752 }
00753
00754
00755 if(!exists)
00756 {
00757 AssetPicon *picon = new AssetPicon(mwindow,
00758 this,
00759 mwindow->edl->clips.values[i]);
00760 picon->create_objects();
00761 assets.append(picon);
00762 }
00763 }
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773 for(Asset *current = mwindow->edl->assets->first;
00774 current;
00775 current = NEXT)
00776 {
00777 int exists = 0;
00778
00779
00780
00781 for(int j = 0; j < assets.total && !exists; j++)
00782 {
00783 AssetPicon *picon = (AssetPicon*)assets.values[j];
00784
00785 if(picon->id == current->id)
00786 {
00787
00788 picon->asset = current;
00789 exists = 1;
00790 picon->in_use = 1;
00791 break;
00792 }
00793 }
00794
00795
00796
00797 if(!exists)
00798 {
00799
00800 AssetPicon *picon = new AssetPicon(mwindow, this, current);
00801
00802 picon->create_objects();
00803
00804 assets.append(picon);
00805
00806 }
00807 }
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818 for(int i = assets.total - 1; i >= 0; i--)
00819 {
00820 AssetPicon *picon = (AssetPicon*)assets.values[i];
00821
00822 if(!picon->in_use)
00823 {
00824 delete picon;
00825 assets.remove_number(i);
00826 }
00827 }
00828
00829 }
00830
00831
00832
00833
00834
00835 void AWindowGUI::sort_assets()
00836 {
00837
00838 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER))
00839 sort_picons(&aeffects,
00840 0);
00841 else
00842 if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER))
00843 sort_picons(&veffects,
00844 0);
00845 else
00846 if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER))
00847 sort_picons(&atransitions,
00848 0);
00849 else
00850 if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
00851 sort_picons(&vtransitions,
00852 0);
00853 else
00854 if(!strcasecmp(mwindow->edl->session->current_folder, LABEL_FOLDER))
00855 ;
00856 else
00857 sort_picons(&assets,
00858 mwindow->edl->session->current_folder);
00859
00860 update_assets();
00861 }
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873 void AWindowGUI::collect_assets()
00874 {
00875 int i = 0;
00876 mwindow->session->drag_assets->remove_all();
00877 mwindow->session->drag_clips->remove_all();
00878 while(1)
00879 {
00880 AssetPicon *result = (AssetPicon*)asset_list->get_selection(0, i++);
00881 if(!result) break;
00882
00883 if(result->asset) mwindow->session->drag_assets->append(result->asset);
00884 if(result->edl) mwindow->session->drag_clips->append(result->edl);
00885 }
00886 }
00887
00888 void AWindowGUI::copy_picons(ArrayList<BC_ListBoxItem*> *dst,
00889 ArrayList<BC_ListBoxItem*> *src,
00890 char *folder)
00891 {
00892
00893 dst[0].remove_all();
00894 dst[1].remove_all_objects();
00895
00896
00897
00898 for(int i = 0; i < src->total; i++)
00899 {
00900 AssetPicon *picon = (AssetPicon*)src->values[i];
00901
00902 if(!folder ||
00903 (folder && picon->asset && !strcasecmp(picon->asset->folder, folder)) ||
00904 (folder && picon->edl && !strcasecmp(picon->edl->local_session->folder, folder)))
00905 {
00906 BC_ListBoxItem *item2, *item1;
00907 dst[0].append(item1 = picon);
00908 if(picon->edl)
00909 dst[1].append(item2 = new BC_ListBoxItem(picon->edl->local_session->clip_notes));
00910 else
00911 if(picon->label && picon->label->textstr)
00912 dst[1].append(item2 = new BC_ListBoxItem(picon->label->textstr));
00913 else
00914 dst[1].append(item2 = new BC_ListBoxItem(""));
00915 item1->set_autoplace_text(1);
00916 item2->set_autoplace_text(1);
00917
00918 }
00919 }
00920 }
00921
00922 void AWindowGUI::sort_picons(ArrayList<BC_ListBoxItem*> *src,
00923 char *folder)
00924 {
00925
00926 int done = 0;
00927 while(!done)
00928 {
00929 done = 1;
00930 for(int i = 0; i < src->total - 1; i++)
00931 {
00932 BC_ListBoxItem *item1 = src->values[i];
00933 BC_ListBoxItem *item2 = src->values[i + 1];
00934 item1->set_autoplace_icon(1);
00935 item2->set_autoplace_icon(1);
00936 item1->set_autoplace_text(1);
00937 item2->set_autoplace_text(1);
00938 if(strcmp(item1->get_text(), item2->get_text()) > 0)
00939 {
00940 src->values[i + 1] = item1;
00941 src->values[i] = item2;
00942 done = 0;
00943 }
00944 }
00945 }
00946 }
00947
00948
00949 void AWindowGUI::filter_displayed_assets()
00950 {
00951 allow_iconlisting = 1;
00952 asset_titles[0] = _("Title");
00953 asset_titles[1] = _("Comments");
00954 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER))
00955 copy_picons(displayed_assets,
00956 &aeffects,
00957 0);
00958 else
00959 if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER))
00960 copy_picons(displayed_assets,
00961 &veffects,
00962 0);
00963 else
00964 if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER))
00965 copy_picons(displayed_assets,
00966 &atransitions,
00967 0);
00968 else
00969 if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
00970 copy_picons(displayed_assets,
00971 &vtransitions,
00972 0);
00973 else
00974 if(!strcasecmp(mwindow->edl->session->current_folder, LABEL_FOLDER)) {
00975 copy_picons(displayed_assets,
00976 &labellist,
00977 0);
00978 asset_titles[0] = _("Time Stamps");
00979 asset_titles[1] = _("Title");
00980 allow_iconlisting = 0;
00981 }
00982 else
00983 copy_picons(displayed_assets,
00984 &assets,
00985 mwindow->edl->session->current_folder);
00986
00987 for(int i = 0; i < folders.total; i++)
00988 {
00989 if(!strcasecmp(mwindow->edl->session->current_folder, folders.values[i]->get_text()))
00990 folders.values[i]->set_selected(1);
00991 else
00992 folders.values[i]->set_selected(0);
00993 }
00994 }
00995
00996
00997 void AWindowGUI::update_assets()
00998 {
00999
01000 update_folder_list();
01001
01002 update_asset_list();
01003 labellist.remove_all_objects();
01004 create_label_folder();
01005
01006 filter_displayed_assets();
01007
01008
01009
01010
01011 if(mwindow->edl->session->folderlist_format != folder_list->get_format())
01012 folder_list->update_format(mwindow->edl->session->folderlist_format, 0);
01013 folder_list->update(&folders,
01014 0,
01015 0,
01016 1,
01017 folder_list->get_xposition(),
01018 folder_list->get_yposition(),
01019 -1);
01020
01021
01022 if(mwindow->edl->session->assetlist_format != asset_list->get_format())
01023 asset_list->update_format(mwindow->edl->session->assetlist_format, 0);
01024
01025
01026
01027 asset_list->update(displayed_assets,
01028 asset_titles,
01029 mwindow->edl->session->asset_columns,
01030 ASSET_COLUMNS,
01031 asset_list->get_xposition(),
01032 asset_list->get_yposition(),
01033 -1,
01034 0);
01035
01036
01037 flush();
01038
01039 return;
01040 }
01041
01042 int AWindowGUI::current_folder_number()
01043 {
01044 int result = -1;
01045 for(int i = 0; i < folders.total; i++)
01046 {
01047 if(!strcasecmp(folders.values[i]->get_text(), mwindow->edl->session->current_folder))
01048 {
01049 result = i;
01050 break;
01051 }
01052 }
01053 return result;
01054 }
01055
01056 int AWindowGUI::drag_motion()
01057 {
01058 if(get_hidden()) return 0;
01059
01060 int result = 0;
01061 return result;
01062 }
01063
01064 int AWindowGUI::drag_stop()
01065 {
01066 if(get_hidden()) return 0;
01067
01068 return 0;
01069 }
01070
01071 Asset* AWindowGUI::selected_asset()
01072 {
01073 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
01074 if(picon) return picon->asset;
01075 }
01076
01077 PluginServer* AWindowGUI::selected_plugin()
01078 {
01079 AssetPicon *picon = (AssetPicon*)asset_list->get_selection(0, 0);
01080 if(picon) return picon->plugin;
01081 }
01082
01083 AssetPicon* AWindowGUI::selected_folder()
01084 {
01085 AssetPicon *picon = (AssetPicon*)folder_list->get_selection(0, 0);
01086 return picon;
01087 }
01088
01089
01090
01091
01092
01093
01094
01095
01096
01097
01098 AWindowDivider::AWindowDivider(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
01099 : BC_SubWindow(x, y, w, h)
01100 {
01101 this->mwindow = mwindow;
01102 this->gui = gui;
01103 }
01104 AWindowDivider::~AWindowDivider()
01105 {
01106 }
01107
01108 int AWindowDivider::button_press_event()
01109 {
01110 if(is_event_win() && cursor_inside())
01111 {
01112 mwindow->session->current_operation = DRAG_PARTITION;
01113 return 1;
01114 }
01115 return 0;
01116 }
01117
01118 int AWindowDivider::cursor_motion_event()
01119 {
01120 if(mwindow->session->current_operation == DRAG_PARTITION)
01121 {
01122 mwindow->session->afolders_w = gui->get_relative_cursor_x();
01123 mwindow->theme->get_awindow_sizes(gui);
01124 gui->reposition_objects();
01125 }
01126 return 0;
01127 }
01128
01129 int AWindowDivider::button_release_event()
01130 {
01131 if(mwindow->session->current_operation == DRAG_PARTITION)
01132 {
01133 mwindow->session->current_operation = NO_OPERATION;
01134 return 1;
01135 }
01136 return 0;
01137 }
01138
01139
01140
01141
01142
01143
01144 AWindowFolders::AWindowFolders(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
01145 : BC_ListBox(x,
01146 y,
01147 w,
01148 h,
01149 mwindow->edl->session->folderlist_format == FOLDERS_ICONS ?
01150 LISTBOX_ICONS : LISTBOX_TEXT,
01151 &gui->folders,
01152 0,
01153 0,
01154 1,
01155 0,
01156 0,
01157 LISTBOX_SINGLE,
01158 ICON_TOP,
01159 1)
01160 {
01161 this->mwindow = mwindow;
01162 this->gui = gui;
01163 set_drag_scroll(0);
01164 }
01165
01166 AWindowFolders::~AWindowFolders()
01167 {
01168 }
01169
01170 int AWindowFolders::selection_changed()
01171 {
01172 AssetPicon *picon = (AssetPicon*)get_selection(0, 0);
01173 if(picon)
01174 {
01175 strcpy(mwindow->edl->session->current_folder, picon->get_text());
01176
01177 gui->asset_list->draw_background();
01178 gui->async_update_assets();
01179 }
01180 return 1;
01181 }
01182
01183 int AWindowFolders::button_press_event()
01184 {
01185 int result = 0;
01186
01187 result = BC_ListBox::button_press_event();
01188
01189 if(!result)
01190 {
01191 if(get_buttonpress() == 3 && is_event_win() && cursor_inside())
01192 {
01193 gui->folderlist_menu->update_titles();
01194 gui->folderlist_menu->activate_menu();
01195 result = 1;
01196 }
01197 }
01198
01199
01200 return result;
01201 }
01202
01203
01204
01205
01206
01207
01208
01209 AWindowAssets::AWindowAssets(MWindow *mwindow, AWindowGUI *gui, int x, int y, int w, int h)
01210 : BC_ListBox(x,
01211 y,
01212 w,
01213 h,
01214 (mwindow->edl->session->assetlist_format == ASSETS_ICONS && gui->allow_iconlisting ) ?
01215 LISTBOX_ICONS : LISTBOX_TEXT,
01216 &gui->assets,
01217 gui->asset_titles,
01218 mwindow->edl->session->asset_columns,
01219 1,
01220 0,
01221 0,
01222 LISTBOX_MULTIPLE,
01223 ICON_TOP,
01224 1)
01225 {
01226 this->mwindow = mwindow;
01227 this->gui = gui;
01228 set_drag_scroll(0);
01229 }
01230
01231 AWindowAssets::~AWindowAssets()
01232 {
01233 }
01234
01235 int AWindowAssets::button_press_event()
01236 {
01237 int result = 0;
01238
01239 result = BC_ListBox::button_press_event();
01240
01241 if(!result && get_buttonpress() == 3 && is_event_win() && cursor_inside())
01242 {
01243 BC_ListBox::deactivate_selection();
01244 gui->assetlist_menu->update_titles();
01245 gui->assetlist_menu->activate_menu();
01246 result = 1;
01247 }
01248
01249
01250 return result;
01251 }
01252
01253
01254 int AWindowAssets::handle_event()
01255 {
01256
01257 if(get_selection(0, 0))
01258 {
01259 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER))
01260 {
01261 }
01262 else
01263 if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER))
01264 {
01265 }
01266 else
01267 if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER))
01268 {
01269 }
01270 else
01271 if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
01272 {
01273 }
01274 else
01275 {
01276
01277 mwindow->vwindow->gui->lock_window("AWindowAssets::handle_event");
01278
01279 if(((AssetPicon*)get_selection(0, 0))->asset)
01280 mwindow->vwindow->change_source(((AssetPicon*)get_selection(0, 0))->asset);
01281 else
01282 if(((AssetPicon*)get_selection(0, 0))->edl)
01283 mwindow->vwindow->change_source(((AssetPicon*)get_selection(0, 0))->edl);
01284
01285 mwindow->vwindow->gui->unlock_window();
01286 }
01287 return 1;
01288 }
01289
01290 return 0;
01291 }
01292
01293 int AWindowAssets::selection_changed()
01294 {
01295
01296 if(get_button_down() && get_buttonpress() == 3 && get_selection(0, 0))
01297 {
01298 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER) ||
01299 !strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER) ||
01300 !strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER) ||
01301 !strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
01302 {
01303 gui->assetlist_menu->update_titles();
01304 gui->assetlist_menu->activate_menu();
01305 }
01306 else
01307 if (!strcasecmp(mwindow->edl->session->current_folder, LABEL_FOLDER))
01308 {
01309 if(((AssetPicon*)get_selection(0, 0))->label)
01310 gui->label_menu->activate_menu();
01311 }
01312 else
01313 {
01314 if(((AssetPicon*)get_selection(0, 0))->asset)
01315 gui->asset_menu->update();
01316 else
01317 if(((AssetPicon*)get_selection(0, 0))->edl)
01318 gui->asset_menu->update();
01319
01320
01321
01322 gui->asset_menu->activate_menu();
01323 }
01324
01325 BC_ListBox::deactivate_selection();
01326 return 1;
01327 }
01328 return 0;
01329 }
01330
01331 void AWindowAssets::draw_background()
01332 {
01333 BC_ListBox::draw_background();
01334 set_color(BC_WindowBase::get_resources()->audiovideo_color);
01335 set_font(LARGEFONT);
01336 draw_text(get_w() -
01337 get_text_width(LARGEFONT, mwindow->edl->session->current_folder) - 4,
01338 30,
01339 mwindow->edl->session->current_folder,
01340 -1,
01341 get_bg_surface());
01342 }
01343
01344 int AWindowAssets::drag_start_event()
01345 {
01346 int collect_pluginservers = 0;
01347 int collect_assets = 0;
01348
01349 if(BC_ListBox::drag_start_event())
01350 {
01351 if(!strcasecmp(mwindow->edl->session->current_folder, AEFFECT_FOLDER))
01352 {
01353 mwindow->session->current_operation = DRAG_AEFFECT;
01354 collect_pluginservers = 1;
01355 }
01356 else
01357 if(!strcasecmp(mwindow->edl->session->current_folder, VEFFECT_FOLDER))
01358 {
01359 mwindow->session->current_operation = DRAG_VEFFECT;
01360 collect_pluginservers = 1;
01361 }
01362 else
01363 if(!strcasecmp(mwindow->edl->session->current_folder, ATRANSITION_FOLDER))
01364 {
01365 mwindow->session->current_operation = DRAG_ATRANSITION;
01366 collect_pluginservers = 1;
01367 }
01368 else
01369 if(!strcasecmp(mwindow->edl->session->current_folder, VTRANSITION_FOLDER))
01370 {
01371 mwindow->session->current_operation = DRAG_VTRANSITION;
01372 collect_pluginservers = 1;
01373 }
01374 else
01375 if(!strcasecmp(mwindow->edl->session->current_folder, LABEL_FOLDER))
01376 {
01377
01378 }
01379 else
01380 {
01381 mwindow->session->current_operation = DRAG_ASSET;
01382 collect_assets = 1;
01383 }
01384
01385
01386 if(collect_pluginservers)
01387 {
01388 int i = 0;
01389 mwindow->session->drag_pluginservers->remove_all();
01390 while(1)
01391 {
01392 AssetPicon *result = (AssetPicon*)get_selection(0, i++);
01393 if(!result) break;
01394
01395 mwindow->session->drag_pluginservers->append(result->plugin);
01396 }
01397 }
01398
01399 if(collect_assets)
01400 {
01401 gui->collect_assets();
01402 }
01403
01404 return 1;
01405 }
01406 return 0;
01407 }
01408
01409 int AWindowAssets::drag_motion_event()
01410 {
01411 BC_ListBox::drag_motion_event();
01412
01413 mwindow->gui->lock_window("AWindowAssets::drag_motion_event");
01414 mwindow->gui->drag_motion();
01415 mwindow->gui->unlock_window();
01416
01417 mwindow->vwindow->gui->lock_window("AWindowAssets::drag_motion_event");
01418 mwindow->vwindow->gui->drag_motion();
01419 mwindow->vwindow->gui->unlock_window();
01420
01421 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_motion_event");
01422 mwindow->cwindow->gui->drag_motion();
01423 mwindow->cwindow->gui->unlock_window();
01424 return 0;
01425 }
01426
01427 int AWindowAssets::drag_stop_event()
01428 {
01429 int result = 0;
01430
01431 result = gui->drag_stop();
01432
01433
01434 if(!result)
01435 {
01436 mwindow->gui->lock_window("AWindowAssets::drag_stop_event");
01437 result = mwindow->gui->drag_stop();
01438 mwindow->gui->unlock_window();
01439 }
01440
01441 if(!result)
01442 {
01443 mwindow->vwindow->gui->lock_window("AWindowAssets::drag_stop_event");
01444 result = mwindow->vwindow->gui->drag_stop();
01445 mwindow->vwindow->gui->unlock_window();
01446 }
01447
01448 if(!result)
01449 {
01450 mwindow->cwindow->gui->lock_window("AWindowAssets::drag_stop_event");
01451 result = mwindow->cwindow->gui->drag_stop();
01452 mwindow->cwindow->gui->unlock_window();
01453 }
01454
01455
01456
01457 if(result) get_drag_popup()->set_animation(0);
01458
01459 BC_ListBox::drag_stop_event();
01460 mwindow->session->current_operation = ::NO_OPERATION;
01461 return 0;
01462 }
01463
01464 int AWindowAssets::column_resize_event()
01465 {
01466 mwindow->edl->session->asset_columns[0] = get_column_width(0);
01467 mwindow->edl->session->asset_columns[1] = get_column_width(1);
01468 return 1;
01469 }
01470
01471
01472
01473
01474
01475
01476
01477
01478
01479
01480
01481
01482 AWindowNewFolder::AWindowNewFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
01483 : BC_Button(x, y, mwindow->theme->newbin_data)
01484 {
01485 this->mwindow = mwindow;
01486 this->gui = gui;
01487 set_tooltip(_("New bin"));
01488 }
01489
01490 int AWindowNewFolder::handle_event()
01491 {
01492 gui->newfolder_thread->start_new_folder();
01493 return 1;
01494 }
01495
01496 AWindowDeleteFolder::AWindowDeleteFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
01497 : BC_Button(x, y, mwindow->theme->deletebin_data)
01498 {
01499 this->mwindow = mwindow;
01500 this->gui = gui;
01501 set_tooltip(_("Delete bin"));
01502 }
01503
01504 int AWindowDeleteFolder::handle_event()
01505 {
01506 if(gui->folder_list->get_selection(0, 0))
01507 {
01508 BC_ListBoxItem *folder = gui->folder_list->get_selection(0, 0);
01509 mwindow->delete_folder(folder->get_text());
01510 }
01511 return 1;
01512 }
01513
01514 AWindowRenameFolder::AWindowRenameFolder(MWindow *mwindow, AWindowGUI *gui, int x, int y)
01515 : BC_Button(x, y, mwindow->theme->renamebin_data)
01516 {
01517 this->mwindow = mwindow;
01518 this->gui = gui;
01519 set_tooltip(_("Rename bin"));
01520 }
01521
01522 int AWindowRenameFolder::handle_event()
01523 {
01524 return 1;
01525 }
01526
01527 AWindowDeleteDisk::AWindowDeleteDisk(MWindow *mwindow, AWindowGUI *gui, int x, int y)
01528 : BC_Button(x, y, mwindow->theme->deletedisk_data)
01529 {
01530 this->mwindow = mwindow;
01531 this->gui = gui;
01532 set_tooltip(_("Delete asset from disk"));
01533 }
01534
01535 int AWindowDeleteDisk::handle_event()
01536 {
01537 return 1;
01538 }
01539
01540 AWindowDeleteProject::AWindowDeleteProject(MWindow *mwindow, AWindowGUI *gui, int x, int y)
01541 : BC_Button(x, y, mwindow->theme->deleteproject_data)
01542 {
01543 this->mwindow = mwindow;
01544 this->gui = gui;
01545 set_tooltip(_("Delete asset from project"));
01546 }
01547
01548 int AWindowDeleteProject::handle_event()
01549 {
01550 return 1;
01551 }
01552
01553 AWindowInfo::AWindowInfo(MWindow *mwindow, AWindowGUI *gui, int x, int y)
01554 : BC_Button(x, y, mwindow->theme->infoasset_data)
01555 {
01556 this->mwindow = mwindow;
01557 this->gui = gui;
01558 set_tooltip(_("Edit information on asset"));
01559 }
01560
01561 int AWindowInfo::handle_event()
01562 {
01563 gui->awindow->asset_edit->edit_asset(gui->selected_asset());
01564 return 1;
01565 }
01566
01567 AWindowRedrawIndex::AWindowRedrawIndex(MWindow *mwindow, AWindowGUI *gui, int x, int y)
01568 : BC_Button(x, y, mwindow->theme->redrawindex_data)
01569 {
01570 this->mwindow = mwindow;
01571 this->gui = gui;
01572 set_tooltip(_("Redraw index"));
01573 }
01574
01575 int AWindowRedrawIndex::handle_event()
01576 {
01577 return 1;
01578 }
01579
01580 AWindowPaste::AWindowPaste(MWindow *mwindow, AWindowGUI *gui, int x, int y)
01581 : BC_Button(x, y, mwindow->theme->pasteasset_data)
01582 {
01583 this->mwindow = mwindow;
01584 this->gui = gui;
01585 set_tooltip(_("Paste asset on recordable tracks"));
01586 }
01587
01588 int AWindowPaste::handle_event()
01589 {
01590 return 1;
01591 }
01592
01593 AWindowAppend::AWindowAppend(MWindow *mwindow, AWindowGUI *gui, int x, int y)
01594 : BC_Button(x, y, mwindow->theme->appendasset_data)
01595 {
01596 this->mwindow = mwindow;
01597 this->gui = gui;
01598 set_tooltip(_("Append asset in new tracks"));
01599 }
01600
01601 int AWindowAppend::handle_event()
01602 {
01603 return 1;
01604 }
01605
01606 AWindowView::AWindowView(MWindow *mwindow, AWindowGUI *gui, int x, int y)
01607 : BC_Button(x, y, mwindow->theme->viewasset_data)
01608 {
01609 this->mwindow = mwindow;
01610 this->gui = gui;
01611 set_tooltip(_("View asset"));
01612 }
01613
01614 int AWindowView::handle_event()
01615 {
01616 return 1;
01617 }
01618
01619
01620
01621 LabelPopup::LabelPopup(MWindow *mwindow, AWindowGUI *gui)
01622 : BC_PopupMenu(0,
01623 0,
01624 0,
01625 "",
01626 0)
01627 {
01628 this->mwindow = mwindow;
01629 this->gui = gui;
01630 }
01631
01632 LabelPopup::~LabelPopup()
01633 {
01634 }
01635
01636 void LabelPopup::create_objects()
01637 {
01638 add_item(editlabel = new LabelPopupEdit(mwindow, this));
01639 }
01640
01641
01642
01643
01644 LabelPopupEdit::LabelPopupEdit(MWindow *mwindow, LabelPopup *popup)
01645 : BC_MenuItem(_("Edit..."))
01646 {
01647 this->mwindow = mwindow;
01648 this->popup = popup;
01649 }
01650
01651 LabelPopupEdit::~LabelPopupEdit()
01652 {
01653 }
01654
01655 int LabelPopupEdit::handle_event()
01656 {
01657 int i = 0;
01658 while(1)
01659 {
01660 AssetPicon *result = (AssetPicon*)mwindow->awindow->gui->asset_list->get_selection(0, i++);
01661 if(!result) break;
01662
01663 if(result->label) {
01664 mwindow->awindow->gui->awindow->label_edit->edit_label(result->label);
01665 break;
01666 }
01667 }
01668
01669 return 1;
01670 }