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 "proxypopup.h"
25 #include "awindowgui.h"
26 #include "bcsignals.h"
29 #include "cwindowgui.h"
35 #include "localsession.h"
36 #include "mainerror.h"
37 #include "mainsession.h"
39 #include "mwindowgui.h"
43 #include "vwindowgui.h"
47 ProxyPopup::ProxyPopup(MWindow *mwindow, AWindowGUI *gui)
48 : BC_PopupMenu(0, 0, 0, "", 0)
50 this->mwindow = mwindow;
54 ProxyPopup::~ProxyPopup()
58 void ProxyPopup::create_objects()
60 add_item(info = new ProxyPopupInfo(mwindow, this));
61 add_item(format = new AWindowListFormat(mwindow, gui));
62 add_item(new ProxyPopupSort(mwindow, this));
63 add_item(view = new ProxyPopupView(mwindow, this));
64 add_item(view_window = new ProxyPopupViewWindow(mwindow, this));
65 add_item(new ProxyPopupCopy(mwindow, this));
66 add_item(new ProxyPopupPaste(mwindow, this));
69 void ProxyPopup::paste_assets()
71 // Collect items into the drag vectors for temporary storage
72 gui->lock_window("ProxyPopup::paste_assets");
73 mwindow->gui->lock_window("ProxyPopup::paste_assets");
74 mwindow->cwindow->gui->lock_window("ProxyPopup::paste_assets");
76 gui->collect_assets(1);
77 mwindow->paste_assets(mwindow->edl->local_session->get_selectionstart(1),
78 mwindow->edl->tracks->first, 0); // do not overwrite
81 mwindow->gui->unlock_window();
82 mwindow->cwindow->gui->unlock_window();
85 int ProxyPopup::update()
88 gui->collect_assets(1);
93 ProxyPopupInfo::ProxyPopupInfo(MWindow *mwindow, ProxyPopup *popup)
94 : BC_MenuItem(_("Info..."))
96 this->mwindow = mwindow;
100 ProxyPopupInfo::~ProxyPopupInfo()
104 int ProxyPopupInfo::handle_event()
107 popup->gui->get_abs_cursor(cur_x, cur_y, 0);
109 if( mwindow->session->drag_assets->total ) {
110 AssetEdit *asset_edit = mwindow->awindow->get_asset_editor();
111 asset_edit->edit_asset(
112 mwindow->session->drag_assets->values[0], cur_x, cur_y);
115 if( mwindow->session->drag_clips->total ) {
116 popup->gui->awindow->clip_edit->edit_clip(
117 mwindow->session->drag_clips->values[0], cur_x, cur_y);
123 ProxyPopupSort::ProxyPopupSort(MWindow *mwindow, ProxyPopup *popup)
124 : BC_MenuItem(_("Sort items"))
126 this->mwindow = mwindow;
130 ProxyPopupSort::~ProxyPopupSort()
134 int ProxyPopupSort::handle_event()
136 mwindow->awindow->gui->sort_assets(0);
141 ProxyPopupView::ProxyPopupView(MWindow *mwindow, ProxyPopup *popup)
142 : BC_MenuItem(_("View"))
144 this->mwindow = mwindow;
148 ProxyPopupView::~ProxyPopupView()
152 int ProxyPopupView::handle_event()
154 VWindow *vwindow = mwindow->get_viewer(1, DEFAULT_VWINDOW);
156 if( mwindow->session->drag_assets->total )
157 vwindow->change_source(
158 mwindow->session->drag_assets->values[0]);
160 if( mwindow->session->drag_clips->total )
161 vwindow->change_source(
162 mwindow->session->drag_clips->values[0]);
168 ProxyPopupViewWindow::ProxyPopupViewWindow(MWindow *mwindow, ProxyPopup *popup)
169 : BC_MenuItem(_("View in new window"))
171 this->mwindow = mwindow;
175 ProxyPopupViewWindow::~ProxyPopupViewWindow()
179 int ProxyPopupViewWindow::handle_event()
181 for( int i=0; i<mwindow->session->drag_assets->size(); ++i ) {
182 VWindow *vwindow = mwindow->get_viewer(1);
183 vwindow->gui->lock_window("ProxyPopupView::handle_event 1");
184 vwindow->change_source(mwindow->session->drag_assets->get(i));
185 vwindow->gui->unlock_window();
187 for( int i=0; i<mwindow->session->drag_clips->size(); ++i ) {
188 VWindow *vwindow = mwindow->get_viewer(1);
189 vwindow->gui->lock_window("ProxyPopupView::handle_event 2");
190 vwindow->change_source(mwindow->session->drag_clips->get(i));
191 vwindow->gui->unlock_window();
197 ProxyPopupCopy::ProxyPopupCopy(MWindow *mwindow, ProxyPopup *popup)
198 : BC_MenuItem(_("Copy"))
200 this->mwindow = mwindow;
203 ProxyPopupCopy::~ProxyPopupCopy()
207 int ProxyPopupCopy::handle_event()
209 MWindowGUI *gui = mwindow->gui;
210 gui->lock_window("ProxyPopupCopy::handle_event");
211 if( mwindow->session->drag_clips->total > 0 ) {
212 EDL *edl = mwindow->session->drag_clips->values[0];
213 EDL *copy_edl = new EDL; // no parent or assets wont be copied
214 copy_edl->create_objects();
215 copy_edl->copy_all(edl);
217 double start = 0, end = edl->tracks->total_length();
218 copy_edl->copy(start, end, 1, &file, "", 1);
219 copy_edl->remove_user();
220 const char *file_string = file.string();
221 long file_length = strlen(file_string);
222 gui->to_clipboard(file_string, file_length, SECONDARY_SELECTION);
223 gui->to_clipboard(file_string, file_length, BC_PRIMARY_SELECTION);
225 gui->unlock_window();
230 ProxyPopupPaste::ProxyPopupPaste(MWindow *mwindow, ProxyPopup *popup)
231 : BC_MenuItem(_("Paste"))
233 this->mwindow = mwindow;
237 ProxyPopupPaste::~ProxyPopupPaste()
241 int ProxyPopupPaste::handle_event()
243 popup->paste_assets();
248 ProxyListMenu::ProxyListMenu(MWindow *mwindow, AWindowGUI *gui)
249 : BC_PopupMenu(0, 0, 0, "", 0)
251 this->mwindow = mwindow;
255 ProxyListMenu::~ProxyListMenu()
259 void ProxyListMenu::create_objects()
261 add_item(format = new AWindowListFormat(mwindow, gui));
262 add_item(new AWindowListSort(mwindow, gui));
266 void ProxyListMenu::update()