2 #include "assetpopup.h"
3 #include "assetremove.h"
5 #include "awindowgui.h"
6 #include "awindowmenu.h"
9 #include "cwindowgui.h"
12 #include "localsession.h"
13 #include "mainindexes.h"
14 #include "mainsession.h"
16 #include "mwindowgui.h"
19 #include "vwindowgui.h"
23 AssetPopup::AssetPopup(MWindow *mwindow, AWindowGUI *gui)
30 this->mwindow = mwindow;
34 AssetPopup::~AssetPopup()
38 void AssetPopup::create_objects()
40 add_item(format = new AssetListFormat(mwindow));
41 add_item(info = new AssetPopupInfo(mwindow, this));
42 add_item(new AssetPopupSort(mwindow, this));
43 add_item(index = new AssetPopupBuildIndex(mwindow, this));
44 add_item(view = new AssetPopupView(mwindow, this));
45 add_item(new AssetPopupPaste(mwindow, this));
46 add_item(new AssetMatchSize(mwindow, this));
47 add_item(new AssetMatchRate(mwindow, this));
48 add_item(new AssetPopupProjectRemove(mwindow, this));
49 add_item(new AssetPopupDiskRemove(mwindow, this));
52 void AssetPopup::paste_assets()
54 // Collect items into the drag vectors for temporary storage
55 gui->lock_window("AssetPopup::paste_assets");
56 mwindow->gui->lock_window("AssetPopup::paste_assets");
57 mwindow->cwindow->gui->lock_window("AssetPopup::paste_assets");
59 gui->collect_assets();
60 mwindow->paste_assets(mwindow->edl->local_session->get_selectionstart(1),
61 mwindow->edl->tracks->first);
64 mwindow->gui->unlock_window();
65 mwindow->cwindow->gui->unlock_window();
68 void AssetPopup::match_size()
70 // Collect items into the drag vectors for temporary storage
71 gui->collect_assets();
72 mwindow->gui->lock_window("AssetPopup::match_size");
73 mwindow->asset_to_size();
74 mwindow->gui->unlock_window();
77 void AssetPopup::match_rate()
79 // Collect items into the drag vectors for temporary storage
80 gui->collect_assets();
81 mwindow->gui->lock_window("AssetPopup::match_rate");
82 mwindow->asset_to_rate();
83 mwindow->gui->unlock_window();
86 int AssetPopup::update()
89 gui->collect_assets();
101 AssetPopupInfo::AssetPopupInfo(MWindow *mwindow, AssetPopup *popup)
102 : BC_MenuItem(_("Info..."))
104 this->mwindow = mwindow;
108 AssetPopupInfo::~AssetPopupInfo()
112 int AssetPopupInfo::handle_event()
114 if(mwindow->session->drag_assets->total)
116 if(mwindow->awindow->asset_edit->running() &&
117 mwindow->awindow->asset_edit->window)
119 mwindow->awindow->asset_edit->window->raise_window();
120 mwindow->awindow->asset_edit->window->flush();
124 mwindow->awindow->asset_edit->edit_asset(
125 mwindow->session->drag_assets->values[0]);
129 if(mwindow->session->drag_clips->total)
131 popup->gui->awindow->clip_edit->edit_clip(
132 mwindow->session->drag_clips->values[0]);
143 AssetPopupBuildIndex::AssetPopupBuildIndex(MWindow *mwindow, AssetPopup *popup)
144 : BC_MenuItem(_("Rebuild index"))
146 this->mwindow = mwindow;
150 AssetPopupBuildIndex::~AssetPopupBuildIndex()
154 int AssetPopupBuildIndex::handle_event()
156 //printf("AssetPopupBuildIndex::handle_event 1\n");
157 mwindow->rebuild_indices();
167 AssetPopupSort::AssetPopupSort(MWindow *mwindow, AssetPopup *popup)
168 : BC_MenuItem(_("Sort items"))
170 this->mwindow = mwindow;
174 AssetPopupSort::~AssetPopupSort()
178 int AssetPopupSort::handle_event()
180 mwindow->awindow->gui->sort_assets();
190 AssetPopupView::AssetPopupView(MWindow *mwindow, AssetPopup *popup)
191 : BC_MenuItem(_("View"))
193 this->mwindow = mwindow;
197 AssetPopupView::~AssetPopupView()
201 int AssetPopupView::handle_event()
203 mwindow->vwindow->gui->lock_window("AssetPopupView::handle_event");
205 if(mwindow->session->drag_assets->total)
206 mwindow->vwindow->change_source(
207 mwindow->session->drag_assets->values[0]);
209 if(mwindow->session->drag_clips->total)
210 mwindow->vwindow->change_source(
211 mwindow->session->drag_clips->values[0]);
213 mwindow->vwindow->gui->unlock_window();
223 AssetPopupPaste::AssetPopupPaste(MWindow *mwindow, AssetPopup *popup)
224 : BC_MenuItem(_("Paste"))
226 this->mwindow = mwindow;
230 AssetPopupPaste::~AssetPopupPaste()
234 int AssetPopupPaste::handle_event()
236 popup->paste_assets();
247 AssetMatchSize::AssetMatchSize(MWindow *mwindow, AssetPopup *popup)
248 : BC_MenuItem(_("Match project size"))
250 this->mwindow = mwindow;
254 int AssetMatchSize::handle_event()
267 AssetMatchRate::AssetMatchRate(MWindow *mwindow, AssetPopup *popup)
268 : BC_MenuItem(_("Match frame rate"))
270 this->mwindow = mwindow;
274 int AssetMatchRate::handle_event()
293 AssetPopupProjectRemove::AssetPopupProjectRemove(MWindow *mwindow, AssetPopup *popup)
294 : BC_MenuItem(_("Remove from project"))
296 this->mwindow = mwindow;
302 AssetPopupProjectRemove::~AssetPopupProjectRemove()
306 int AssetPopupProjectRemove::handle_event()
308 mwindow->remove_assets_from_project(1);
315 AssetPopupDiskRemove::AssetPopupDiskRemove(MWindow *mwindow, AssetPopup *popup)
316 : BC_MenuItem(_("Remove from disk"))
318 this->mwindow = mwindow;
323 AssetPopupDiskRemove::~AssetPopupDiskRemove()
328 int AssetPopupDiskRemove::handle_event()
330 mwindow->awindow->asset_remove->start();