4 * Copyright (C) 1997-2012 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "assetedit.h"
23 #include "assetpopup.h"
24 #include "assetremove.h"
26 #include "awindowgui.h"
27 #include "awindowmenu.h"
28 #include "bcsignals.h"
31 #include "cwindowgui.h"
34 #include "localsession.h"
35 #include "mainindexes.h"
36 #include "mainsession.h"
38 #include "mwindowgui.h"
41 #include "vwindowgui.h"
45 AssetPopup::AssetPopup(MWindow *mwindow, AWindowGUI *gui)
52 this->mwindow = mwindow;
56 AssetPopup::~AssetPopup()
60 void AssetPopup::create_objects()
62 add_item(info = new AssetPopupInfo(mwindow, this));
63 add_item(format = new AssetListFormat(mwindow));
64 add_item(new AssetPopupSort(mwindow, this));
65 add_item(index = new AssetPopupBuildIndex(mwindow, this));
66 add_item(view = new AssetPopupView(mwindow, this));
67 add_item(view_window = new AssetPopupViewWindow(mwindow, this));
68 add_item(new AssetPopupPaste(mwindow, this));
69 add_item(new AssetMatchSize(mwindow, this));
70 add_item(new AssetMatchRate(mwindow, this));
71 add_item(new AssetMatchAll(mwindow, this));
72 add_item(new AssetPopupProjectRemove(mwindow, this));
73 add_item(new AssetPopupDiskRemove(mwindow, this));
76 void AssetPopup::paste_assets()
78 // Collect items into the drag vectors for temporary storage
79 gui->lock_window("AssetPopup::paste_assets");
80 mwindow->gui->lock_window("AssetPopup::paste_assets");
81 mwindow->cwindow->gui->lock_window("AssetPopup::paste_assets");
83 gui->collect_assets();
84 mwindow->paste_assets(mwindow->edl->local_session->get_selectionstart(1),
85 mwindow->edl->tracks->first,
86 0); // do not overwrite
89 mwindow->gui->unlock_window();
90 mwindow->cwindow->gui->unlock_window();
93 void AssetPopup::match_size()
95 // Collect items into the drag vectors for temporary storage
96 gui->collect_assets();
97 mwindow->gui->lock_window("AssetPopup::match_size");
98 mwindow->asset_to_size();
99 mwindow->gui->unlock_window();
102 void AssetPopup::match_rate()
104 // Collect items into the drag vectors for temporary storage
105 gui->collect_assets();
106 mwindow->gui->lock_window("AssetPopup::match_rate");
107 mwindow->asset_to_rate();
108 mwindow->gui->unlock_window();
111 void AssetPopup::match_all()
113 // Collect items into the drag vectors for temporary storage
114 gui->collect_assets();
115 mwindow->gui->lock_window("AssetPopup::match_rate");
116 mwindow->asset_to_all();
117 mwindow->gui->unlock_window();
120 int AssetPopup::update()
123 gui->collect_assets();
135 AssetPopupInfo::AssetPopupInfo(MWindow *mwindow, AssetPopup *popup)
136 : BC_MenuItem(_("Info..."))
138 this->mwindow = mwindow;
142 AssetPopupInfo::~AssetPopupInfo()
146 int AssetPopupInfo::handle_event()
148 if(mwindow->session->drag_assets->total)
150 mwindow->awindow->asset_edit->edit_asset(
151 mwindow->session->drag_assets->values[0]);
154 if(mwindow->session->drag_clips->total)
156 popup->gui->awindow->clip_edit->edit_clip(
157 mwindow->session->drag_clips->values[0]);
167 AssetPopupBuildIndex::AssetPopupBuildIndex(MWindow *mwindow, AssetPopup *popup)
168 : BC_MenuItem(_("Rebuild index"))
170 this->mwindow = mwindow;
174 AssetPopupBuildIndex::~AssetPopupBuildIndex()
178 int AssetPopupBuildIndex::handle_event()
180 //printf("AssetPopupBuildIndex::handle_event 1\n");
181 mwindow->rebuild_indices();
191 AssetPopupSort::AssetPopupSort(MWindow *mwindow, AssetPopup *popup)
192 : BC_MenuItem(_("Sort items"))
194 this->mwindow = mwindow;
198 AssetPopupSort::~AssetPopupSort()
202 int AssetPopupSort::handle_event()
204 mwindow->awindow->gui->sort_assets();
214 AssetPopupView::AssetPopupView(MWindow *mwindow, AssetPopup *popup)
215 : BC_MenuItem(_("View"))
217 this->mwindow = mwindow;
221 AssetPopupView::~AssetPopupView()
225 int AssetPopupView::handle_event()
227 VWindow *vwindow = mwindow->get_viewer(1, DEFAULT_VWINDOW);
228 vwindow->gui->lock_window("AssetPopupView::handle_event");
230 if(mwindow->session->drag_assets->total)
231 vwindow->change_source(
232 mwindow->session->drag_assets->values[0]);
234 if(mwindow->session->drag_clips->total)
235 vwindow->change_source(
236 mwindow->session->drag_clips->values[0]);
238 vwindow->gui->unlock_window();
248 AssetPopupViewWindow::AssetPopupViewWindow(MWindow *mwindow, AssetPopup *popup)
249 : BC_MenuItem(_("View in new window"))
251 this->mwindow = mwindow;
255 AssetPopupViewWindow::~AssetPopupViewWindow()
259 int AssetPopupViewWindow::handle_event()
261 // Find window with nothing
262 VWindow *vwindow = mwindow->get_viewer(1);
264 // TODO: create new vwindow or change current vwindow
265 vwindow->gui->lock_window("AssetPopupView::handle_event");
267 if(mwindow->session->drag_assets->total)
268 vwindow->change_source(
269 mwindow->session->drag_assets->values[0]);
271 if(mwindow->session->drag_clips->total)
272 vwindow->change_source(
273 mwindow->session->drag_clips->values[0]);
275 vwindow->gui->unlock_window();
285 AssetPopupPaste::AssetPopupPaste(MWindow *mwindow, AssetPopup *popup)
286 : BC_MenuItem(_("Paste"))
288 this->mwindow = mwindow;
292 AssetPopupPaste::~AssetPopupPaste()
296 int AssetPopupPaste::handle_event()
298 popup->paste_assets();
309 AssetMatchSize::AssetMatchSize(MWindow *mwindow, AssetPopup *popup)
310 : BC_MenuItem(_("Match project size"))
312 this->mwindow = mwindow;
316 int AssetMatchSize::handle_event()
329 AssetMatchRate::AssetMatchRate(MWindow *mwindow, AssetPopup *popup)
330 : BC_MenuItem(_("Match frame rate"))
332 this->mwindow = mwindow;
336 int AssetMatchRate::handle_event()
349 AssetMatchAll::AssetMatchAll(MWindow *mwindow, AssetPopup *popup)
350 : BC_MenuItem(_("Match all"))
352 this->mwindow = mwindow;
356 int AssetMatchAll::handle_event()
375 AssetPopupProjectRemove::AssetPopupProjectRemove(MWindow *mwindow, AssetPopup *popup)
376 : BC_MenuItem(_("Remove from project"))
378 this->mwindow = mwindow;
384 AssetPopupProjectRemove::~AssetPopupProjectRemove()
388 int AssetPopupProjectRemove::handle_event()
390 mwindow->remove_assets_from_project(1,
392 mwindow->session->drag_assets,
393 mwindow->session->drag_clips);
400 AssetPopupDiskRemove::AssetPopupDiskRemove(MWindow *mwindow, AssetPopup *popup)
401 : BC_MenuItem(_("Remove from disk"))
403 this->mwindow = mwindow;
408 AssetPopupDiskRemove::~AssetPopupDiskRemove()
413 int AssetPopupDiskRemove::handle_event()
415 mwindow->awindow->asset_remove->start();