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,
62 0); // do not overwrite
65 mwindow->gui->unlock_window();
66 mwindow->cwindow->gui->unlock_window();
69 void AssetPopup::match_size()
71 // Collect items into the drag vectors for temporary storage
72 gui->collect_assets();
73 mwindow->gui->lock_window("AssetPopup::match_size");
74 mwindow->asset_to_size();
75 mwindow->gui->unlock_window();
78 void AssetPopup::match_rate()
80 // Collect items into the drag vectors for temporary storage
81 gui->collect_assets();
82 mwindow->gui->lock_window("AssetPopup::match_rate");
83 mwindow->asset_to_rate();
84 mwindow->gui->unlock_window();
87 int AssetPopup::update()
90 gui->collect_assets();
102 AssetPopupInfo::AssetPopupInfo(MWindow *mwindow, AssetPopup *popup)
103 : BC_MenuItem(_("Info..."))
105 this->mwindow = mwindow;
109 AssetPopupInfo::~AssetPopupInfo()
113 int AssetPopupInfo::handle_event()
115 if(mwindow->session->drag_assets.size())
117 if(mwindow->awindow->asset_edit->running() &&
118 mwindow->awindow->asset_edit->window)
120 mwindow->awindow->asset_edit->window->raise_window();
121 mwindow->awindow->asset_edit->window->flush();
125 mwindow->awindow->asset_edit->edit_asset(
126 mwindow->session->drag_assets[0]);
130 if(mwindow->session->drag_clips->total)
132 popup->gui->awindow->clip_edit->edit_clip(
133 mwindow->session->drag_clips->values[0]);
144 AssetPopupBuildIndex::AssetPopupBuildIndex(MWindow *mwindow, AssetPopup *popup)
145 : BC_MenuItem(_("Rebuild index"))
147 this->mwindow = mwindow;
151 AssetPopupBuildIndex::~AssetPopupBuildIndex()
155 int AssetPopupBuildIndex::handle_event()
157 //printf("AssetPopupBuildIndex::handle_event 1\n");
158 mwindow->rebuild_indices();
168 AssetPopupSort::AssetPopupSort(MWindow *mwindow, AssetPopup *popup)
169 : BC_MenuItem(_("Sort items"))
171 this->mwindow = mwindow;
175 AssetPopupSort::~AssetPopupSort()
179 int AssetPopupSort::handle_event()
181 mwindow->awindow->gui->sort_assets();
191 AssetPopupView::AssetPopupView(MWindow *mwindow, AssetPopup *popup)
192 : BC_MenuItem(_("View"))
194 this->mwindow = mwindow;
198 AssetPopupView::~AssetPopupView()
202 int AssetPopupView::handle_event()
204 mwindow->vwindow->gui->lock_window("AssetPopupView::handle_event");
206 if(mwindow->session->drag_assets.size())
207 mwindow->vwindow->change_source(
208 mwindow->session->drag_assets[0]);
210 if(mwindow->session->drag_clips->total)
211 mwindow->vwindow->change_source(
212 mwindow->session->drag_clips->values[0]);
214 mwindow->vwindow->gui->unlock_window();
224 AssetPopupPaste::AssetPopupPaste(MWindow *mwindow, AssetPopup *popup)
225 : BC_MenuItem(_("Paste"))
227 this->mwindow = mwindow;
231 AssetPopupPaste::~AssetPopupPaste()
235 int AssetPopupPaste::handle_event()
237 popup->paste_assets();
248 AssetMatchSize::AssetMatchSize(MWindow *mwindow, AssetPopup *popup)
249 : BC_MenuItem(_("Match project size"))
251 this->mwindow = mwindow;
255 int AssetMatchSize::handle_event()
268 AssetMatchRate::AssetMatchRate(MWindow *mwindow, AssetPopup *popup)
269 : BC_MenuItem(_("Match frame rate"))
271 this->mwindow = mwindow;
275 int AssetMatchRate::handle_event()
294 AssetPopupProjectRemove::AssetPopupProjectRemove(MWindow *mwindow, AssetPopup *popup)
295 : BC_MenuItem(_("Remove from project"))
297 this->mwindow = mwindow;
303 AssetPopupProjectRemove::~AssetPopupProjectRemove()
307 int AssetPopupProjectRemove::handle_event()
309 mwindow->remove_assets_from_project(1);
316 AssetPopupDiskRemove::AssetPopupDiskRemove(MWindow *mwindow, AssetPopup *popup)
317 : BC_MenuItem(_("Remove from disk"))
319 this->mwindow = mwindow;
324 AssetPopupDiskRemove::~AssetPopupDiskRemove()
329 int AssetPopupDiskRemove::handle_event()
331 mwindow->awindow->asset_remove->start();
341 // c-file-style: "linux"