add bluray dv, misc fixes
[goodguy/history.git] / cinelerra-5.1 / cinelerra / assetpopup.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 1997-2012 Adam Williams <broadcast at earthling dot net>
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #include "assetedit.h"
23 #include "assetpopup.h"
24 #include "assetremove.h"
25 #include "awindow.h"
26 #include "awindowgui.h"
27 #include "awindowmenu.h"
28 #include "bcsignals.h"
29 #include "clipedit.h"
30 #include "cwindow.h"
31 #include "cwindowgui.h"
32 #include "edl.h"
33 #include "language.h"
34 #include "localsession.h"
35 #include "mainindexes.h"
36 #include "mainsession.h"
37 #include "mwindow.h"
38 #include "mwindowgui.h"
39 #include "tracks.h"
40 #include "vwindow.h"
41 #include "vwindowgui.h"
42
43
44
45 AssetPopup::AssetPopup(MWindow *mwindow, AWindowGUI *gui)
46  : BC_PopupMenu(0,
47                 0,
48                 0,
49                 "",
50                 0)
51 {
52         this->mwindow = mwindow;
53         this->gui = gui;
54 }
55
56 AssetPopup::~AssetPopup()
57 {
58 }
59
60 void AssetPopup::create_objects()
61 {
62 //      add_item(format = new AssetListFormat(mwindow));
63         add_item(info = new AssetPopupInfo(mwindow, this));
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));
74 }
75
76 void AssetPopup::paste_assets()
77 {
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");
82
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
87
88         gui->unlock_window();
89         mwindow->gui->unlock_window();
90         mwindow->cwindow->gui->unlock_window();
91 }
92
93 void AssetPopup::match_size()
94 {
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();
100 }
101
102 void AssetPopup::match_rate()
103 {
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();
109 }
110
111 void AssetPopup::match_all()
112 {
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();
118 }
119
120 int AssetPopup::update()
121 {
122 //      format->update();
123         gui->collect_assets();
124         return 0;
125 }
126
127
128
129
130
131
132
133
134
135 AssetPopupInfo::AssetPopupInfo(MWindow *mwindow, AssetPopup *popup)
136  : BC_MenuItem(_("Info..."))
137 {
138         this->mwindow = mwindow;
139         this->popup = popup;
140 }
141
142 AssetPopupInfo::~AssetPopupInfo()
143 {
144 }
145
146 int AssetPopupInfo::handle_event()
147 {
148         if(mwindow->session->drag_assets->total)
149         {
150                 if(mwindow->awindow->asset_edit->running() &&
151                         mwindow->awindow->asset_edit->window)
152                 {
153                         mwindow->awindow->asset_edit->window->raise_window();
154                         mwindow->awindow->asset_edit->window->flush();
155                 }
156                 else
157                 {
158                         mwindow->awindow->asset_edit->edit_asset(
159                                 mwindow->session->drag_assets->values[0]);
160                 }
161         }
162         else
163         if(mwindow->session->drag_clips->total)
164         {
165                 popup->gui->awindow->clip_edit->edit_clip(
166                         mwindow->session->drag_clips->values[0]);
167         }
168         return 1;
169 }
170
171
172
173
174
175
176 AssetPopupBuildIndex::AssetPopupBuildIndex(MWindow *mwindow, AssetPopup *popup)
177  : BC_MenuItem(_("Rebuild index"))
178 {
179         this->mwindow = mwindow;
180         this->popup = popup;
181 }
182
183 AssetPopupBuildIndex::~AssetPopupBuildIndex()
184 {
185 }
186
187 int AssetPopupBuildIndex::handle_event()
188 {
189 //printf("AssetPopupBuildIndex::handle_event 1\n");
190         mwindow->rebuild_indices();
191         return 1;
192 }
193
194
195
196
197
198
199
200 AssetPopupSort::AssetPopupSort(MWindow *mwindow, AssetPopup *popup)
201  : BC_MenuItem(_("Sort items"))
202 {
203         this->mwindow = mwindow;
204         this->popup = popup;
205 }
206
207 AssetPopupSort::~AssetPopupSort()
208 {
209 }
210
211 int AssetPopupSort::handle_event()
212 {
213         mwindow->awindow->gui->sort_assets();
214         return 1;
215 }
216
217
218
219
220
221
222
223 AssetPopupView::AssetPopupView(MWindow *mwindow, AssetPopup *popup)
224  : BC_MenuItem(_("View"))
225 {
226         this->mwindow = mwindow;
227         this->popup = popup;
228 }
229
230 AssetPopupView::~AssetPopupView()
231 {
232 }
233
234 int AssetPopupView::handle_event()
235 {
236         VWindow *vwindow = mwindow->get_viewer(1, DEFAULT_VWINDOW);
237         vwindow->gui->lock_window("AssetPopupView::handle_event");
238
239         if(mwindow->session->drag_assets->total)
240                 vwindow->change_source(
241                         mwindow->session->drag_assets->values[0]);
242         else
243         if(mwindow->session->drag_clips->total)
244                 vwindow->change_source(
245                         mwindow->session->drag_clips->values[0]);
246
247         vwindow->gui->unlock_window();
248         return 1;
249 }
250
251
252
253
254
255
256
257 AssetPopupViewWindow::AssetPopupViewWindow(MWindow *mwindow, AssetPopup *popup)
258  : BC_MenuItem(_("View in new window"))
259 {
260         this->mwindow = mwindow;
261         this->popup = popup;
262 }
263
264 AssetPopupViewWindow::~AssetPopupViewWindow()
265 {
266 }
267
268 int AssetPopupViewWindow::handle_event()
269 {
270 // Find window with nothing
271         VWindow *vwindow = mwindow->get_viewer(1);
272
273 // TODO: create new vwindow or change current vwindow
274         vwindow->gui->lock_window("AssetPopupView::handle_event");
275
276         if(mwindow->session->drag_assets->total)
277                 vwindow->change_source(
278                         mwindow->session->drag_assets->values[0]);
279         else
280         if(mwindow->session->drag_clips->total)
281                 vwindow->change_source(
282                         mwindow->session->drag_clips->values[0]);
283
284         vwindow->gui->unlock_window();
285         return 1;
286 }
287
288
289
290
291
292
293
294 AssetPopupPaste::AssetPopupPaste(MWindow *mwindow, AssetPopup *popup)
295  : BC_MenuItem(_("Paste"))
296 {
297         this->mwindow = mwindow;
298         this->popup = popup;
299 }
300
301 AssetPopupPaste::~AssetPopupPaste()
302 {
303 }
304
305 int AssetPopupPaste::handle_event()
306 {
307         popup->paste_assets();
308         return 1;
309 }
310
311
312
313
314
315
316
317
318 AssetMatchSize::AssetMatchSize(MWindow *mwindow, AssetPopup *popup)
319  : BC_MenuItem(_("Match project size"))
320 {
321         this->mwindow = mwindow;
322         this->popup = popup;
323 }
324
325 int AssetMatchSize::handle_event()
326 {
327         popup->match_size();
328         return 1;
329 }
330
331
332
333
334
335
336
337
338 AssetMatchRate::AssetMatchRate(MWindow *mwindow, AssetPopup *popup)
339  : BC_MenuItem(_("Match frame rate"))
340 {
341         this->mwindow = mwindow;
342         this->popup = popup;
343 }
344
345 int AssetMatchRate::handle_event()
346 {
347         popup->match_rate();
348         return 1;
349 }
350
351
352
353
354
355
356
357
358 AssetMatchAll::AssetMatchAll(MWindow *mwindow, AssetPopup *popup)
359  : BC_MenuItem(_("Match all"))
360 {
361         this->mwindow = mwindow;
362         this->popup = popup;
363 }
364
365 int AssetMatchAll::handle_event()
366 {
367         popup->match_all();
368         return 1;
369 }
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384 AssetPopupProjectRemove::AssetPopupProjectRemove(MWindow *mwindow, AssetPopup *popup)
385  : BC_MenuItem(_("Remove from project"))
386 {
387         this->mwindow = mwindow;
388         this->popup = popup;
389 }
390
391
392
393 AssetPopupProjectRemove::~AssetPopupProjectRemove()
394 {
395 }
396
397 int AssetPopupProjectRemove::handle_event()
398 {
399         mwindow->remove_assets_from_project(1,
400                 1,
401                 mwindow->session->drag_assets,
402                 mwindow->session->drag_clips);
403         return 1;
404 }
405
406
407
408
409 AssetPopupDiskRemove::AssetPopupDiskRemove(MWindow *mwindow, AssetPopup *popup)
410  : BC_MenuItem(_("Remove from disk"))
411 {
412         this->mwindow = mwindow;
413         this->popup = popup;
414 }
415
416
417 AssetPopupDiskRemove::~AssetPopupDiskRemove()
418 {
419 }
420
421
422 int AssetPopupDiskRemove::handle_event()
423 {
424         mwindow->awindow->asset_remove->start();
425         return 1;
426 }
427
428
429
430