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"
30 #include "cwindowgui.h"
33 #include "localsession.h"
34 #include "mainindexes.h"
35 #include "mainsession.h"
37 #include "mwindowgui.h"
40 #include "vwindowgui.h"
44 AssetPopup::AssetPopup(MWindow *mwindow, AWindowGUI *gui)
51 this->mwindow = mwindow;
55 AssetPopup::~AssetPopup()
59 void AssetPopup::create_objects()
61 add_item(format = new AssetListFormat(mwindow));
62 add_item(info = new AssetPopupInfo(mwindow, this));
63 add_item(new AssetPopupSort(mwindow, this));
64 add_item(index = new AssetPopupBuildIndex(mwindow, this));
65 add_item(view = new AssetPopupView(mwindow, this));
66 add_item(view_window = new AssetPopupViewWindow(mwindow, this));
67 add_item(new AssetPopupPaste(mwindow, this));
68 add_item(new AssetMatchSize(mwindow, this));
69 add_item(new AssetMatchRate(mwindow, this));
70 add_item(new AssetMatchAll(mwindow, this));
71 add_item(new AssetPopupProjectRemove(mwindow, this));
72 add_item(new AssetPopupDiskRemove(mwindow, this));
75 void AssetPopup::paste_assets()
77 // Collect items into the drag vectors for temporary storage
78 gui->lock_window("AssetPopup::paste_assets");
79 mwindow->gui->lock_window("AssetPopup::paste_assets");
80 mwindow->cwindow->gui->lock_window("AssetPopup::paste_assets");
82 gui->collect_assets();
83 mwindow->paste_assets(mwindow->edl->local_session->get_selectionstart(1),
84 mwindow->edl->tracks->first);
87 mwindow->gui->unlock_window();
88 mwindow->cwindow->gui->unlock_window();
91 void AssetPopup::match_size()
93 // Collect items into the drag vectors for temporary storage
94 gui->collect_assets();
95 mwindow->gui->lock_window("AssetPopup::match_size");
96 mwindow->asset_to_size();
97 mwindow->gui->unlock_window();
100 void AssetPopup::match_rate()
102 // Collect items into the drag vectors for temporary storage
103 gui->collect_assets();
104 mwindow->gui->lock_window("AssetPopup::match_rate");
105 mwindow->asset_to_rate();
106 mwindow->gui->unlock_window();
109 void AssetPopup::match_all()
111 // Collect items into the drag vectors for temporary storage
112 gui->collect_assets();
113 mwindow->gui->lock_window("AssetPopup::match_rate");
114 mwindow->asset_to_all();
115 mwindow->gui->unlock_window();
118 int AssetPopup::update()
121 gui->collect_assets();
133 AssetPopupInfo::AssetPopupInfo(MWindow *mwindow, AssetPopup *popup)
134 : BC_MenuItem(_("Info..."))
136 this->mwindow = mwindow;
140 AssetPopupInfo::~AssetPopupInfo()
144 int AssetPopupInfo::handle_event()
146 if(mwindow->session->drag_assets->total)
148 if(mwindow->awindow->asset_edit->running() &&
149 mwindow->awindow->asset_edit->window)
151 mwindow->awindow->asset_edit->window->raise_window();
152 mwindow->awindow->asset_edit->window->flush();
156 mwindow->awindow->asset_edit->edit_asset(
157 mwindow->session->drag_assets->values[0]);
161 if(mwindow->session->drag_clips->total)
163 popup->gui->awindow->clip_edit->edit_clip(
164 mwindow->session->drag_clips->values[0]);
174 AssetPopupBuildIndex::AssetPopupBuildIndex(MWindow *mwindow, AssetPopup *popup)
175 : BC_MenuItem(_("Rebuild index"))
177 this->mwindow = mwindow;
181 AssetPopupBuildIndex::~AssetPopupBuildIndex()
185 int AssetPopupBuildIndex::handle_event()
187 //printf("AssetPopupBuildIndex::handle_event 1\n");
188 mwindow->rebuild_indices();
198 AssetPopupSort::AssetPopupSort(MWindow *mwindow, AssetPopup *popup)
199 : BC_MenuItem(_("Sort items"))
201 this->mwindow = mwindow;
205 AssetPopupSort::~AssetPopupSort()
209 int AssetPopupSort::handle_event()
211 mwindow->awindow->gui->sort_assets();
221 AssetPopupView::AssetPopupView(MWindow *mwindow, AssetPopup *popup)
222 : BC_MenuItem(_("View"))
224 this->mwindow = mwindow;
228 AssetPopupView::~AssetPopupView()
232 int AssetPopupView::handle_event()
234 VWindow *vwindow = mwindow->get_viewer(1, DEFAULT_VWINDOW);
235 vwindow->gui->lock_window("AssetPopupView::handle_event");
237 if(mwindow->session->drag_assets->total)
238 vwindow->change_source(
239 mwindow->session->drag_assets->values[0]);
241 if(mwindow->session->drag_clips->total)
242 vwindow->change_source(
243 mwindow->session->drag_clips->values[0]);
245 vwindow->gui->unlock_window();
255 AssetPopupViewWindow::AssetPopupViewWindow(MWindow *mwindow, AssetPopup *popup)
256 : BC_MenuItem(_("View in new window"))
258 this->mwindow = mwindow;
262 AssetPopupViewWindow::~AssetPopupViewWindow()
266 int AssetPopupViewWindow::handle_event()
268 // Find window with nothing
269 VWindow *vwindow = mwindow->get_viewer(1);
271 // TODO: create new vwindow or change current vwindow
272 vwindow->gui->lock_window("AssetPopupView::handle_event");
274 if(mwindow->session->drag_assets->total)
275 vwindow->change_source(
276 mwindow->session->drag_assets->values[0]);
278 if(mwindow->session->drag_clips->total)
279 vwindow->change_source(
280 mwindow->session->drag_clips->values[0]);
282 vwindow->gui->unlock_window();
292 AssetPopupPaste::AssetPopupPaste(MWindow *mwindow, AssetPopup *popup)
293 : BC_MenuItem(_("Paste"))
295 this->mwindow = mwindow;
299 AssetPopupPaste::~AssetPopupPaste()
303 int AssetPopupPaste::handle_event()
305 popup->paste_assets();
316 AssetMatchSize::AssetMatchSize(MWindow *mwindow, AssetPopup *popup)
317 : BC_MenuItem(_("Match project size"))
319 this->mwindow = mwindow;
323 int AssetMatchSize::handle_event()
336 AssetMatchRate::AssetMatchRate(MWindow *mwindow, AssetPopup *popup)
337 : BC_MenuItem(_("Match frame rate"))
339 this->mwindow = mwindow;
343 int AssetMatchRate::handle_event()
356 AssetMatchAll::AssetMatchAll(MWindow *mwindow, AssetPopup *popup)
357 : BC_MenuItem(_("Match all"))
359 this->mwindow = mwindow;
363 int AssetMatchAll::handle_event()
382 AssetPopupProjectRemove::AssetPopupProjectRemove(MWindow *mwindow, AssetPopup *popup)
383 : BC_MenuItem(_("Remove from project"))
385 this->mwindow = mwindow;
391 AssetPopupProjectRemove::~AssetPopupProjectRemove()
395 int AssetPopupProjectRemove::handle_event()
397 mwindow->remove_assets_from_project(1);
404 AssetPopupDiskRemove::AssetPopupDiskRemove(MWindow *mwindow, AssetPopup *popup)
405 : BC_MenuItem(_("Remove from disk"))
407 this->mwindow = mwindow;
412 AssetPopupDiskRemove::~AssetPopupDiskRemove()
417 int AssetPopupDiskRemove::handle_event()
419 mwindow->awindow->asset_remove->start();