rework android-rmt display, add a few buttons
[goodguy/history.git] / cinelerra-5.0 / 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
87         gui->unlock_window();
88         mwindow->gui->unlock_window();
89         mwindow->cwindow->gui->unlock_window();
90 }
91
92 void AssetPopup::match_size()
93 {
94 // Collect items into the drag vectors for temporary storage
95         gui->collect_assets();
96         mwindow->gui->lock_window("AssetPopup::match_size");
97         mwindow->asset_to_size();
98         mwindow->gui->unlock_window();
99 }
100
101 void AssetPopup::match_rate()
102 {
103 // Collect items into the drag vectors for temporary storage
104         gui->collect_assets();
105         mwindow->gui->lock_window("AssetPopup::match_rate");
106         mwindow->asset_to_rate();
107         mwindow->gui->unlock_window();
108 }
109
110 void AssetPopup::match_all()
111 {
112 // Collect items into the drag vectors for temporary storage
113         gui->collect_assets();
114         mwindow->gui->lock_window("AssetPopup::match_rate");
115         mwindow->asset_to_all();
116         mwindow->gui->unlock_window();
117 }
118
119 int AssetPopup::update()
120 {
121         format->update();
122         gui->collect_assets();
123         return 0;
124 }
125
126
127
128
129
130
131
132
133
134 AssetPopupInfo::AssetPopupInfo(MWindow *mwindow, AssetPopup *popup)
135  : BC_MenuItem(_("Info..."))
136 {
137         this->mwindow = mwindow;
138         this->popup = popup;
139 }
140
141 AssetPopupInfo::~AssetPopupInfo()
142 {
143 }
144
145 int AssetPopupInfo::handle_event()
146 {
147         if(mwindow->session->drag_assets->total)
148         {
149                 if(mwindow->awindow->asset_edit->running() && 
150                         mwindow->awindow->asset_edit->window)
151                 {
152                         mwindow->awindow->asset_edit->window->raise_window();
153                         mwindow->awindow->asset_edit->window->flush();
154                 }
155                 else
156                 {
157                         mwindow->awindow->asset_edit->edit_asset(
158                                 mwindow->session->drag_assets->values[0]);
159                 }
160         }
161         else
162         if(mwindow->session->drag_clips->total)
163         {
164                 popup->gui->awindow->clip_edit->edit_clip(
165                         mwindow->session->drag_clips->values[0]);
166         }
167         return 1;
168 }
169
170
171
172
173
174
175 AssetPopupBuildIndex::AssetPopupBuildIndex(MWindow *mwindow, AssetPopup *popup)
176  : BC_MenuItem(_("Rebuild index"))
177 {
178         this->mwindow = mwindow;
179         this->popup = popup;
180 }
181
182 AssetPopupBuildIndex::~AssetPopupBuildIndex()
183 {
184 }
185
186 int AssetPopupBuildIndex::handle_event()
187 {
188 //printf("AssetPopupBuildIndex::handle_event 1\n");
189         mwindow->rebuild_indices();
190         return 1;
191 }
192
193
194
195
196
197
198
199 AssetPopupSort::AssetPopupSort(MWindow *mwindow, AssetPopup *popup)
200  : BC_MenuItem(_("Sort items"))
201 {
202         this->mwindow = mwindow;
203         this->popup = popup;
204 }
205
206 AssetPopupSort::~AssetPopupSort()
207 {
208 }
209
210 int AssetPopupSort::handle_event()
211 {
212         mwindow->awindow->gui->sort_assets();
213         return 1;
214 }
215
216
217
218
219
220
221
222 AssetPopupView::AssetPopupView(MWindow *mwindow, AssetPopup *popup)
223  : BC_MenuItem(_("View"))
224 {
225         this->mwindow = mwindow;
226         this->popup = popup;
227 }
228
229 AssetPopupView::~AssetPopupView()
230 {
231 }
232
233 int AssetPopupView::handle_event()
234 {
235         VWindow *vwindow = mwindow->get_viewer(1, DEFAULT_VWINDOW);
236         vwindow->gui->lock_window("AssetPopupView::handle_event");
237
238         if(mwindow->session->drag_assets->total)
239                 vwindow->change_source(
240                         mwindow->session->drag_assets->values[0]);
241         else
242         if(mwindow->session->drag_clips->total)
243                 vwindow->change_source(
244                         mwindow->session->drag_clips->values[0]);
245
246         vwindow->gui->unlock_window();
247         return 1;
248 }
249
250
251
252
253
254
255
256 AssetPopupViewWindow::AssetPopupViewWindow(MWindow *mwindow, AssetPopup *popup)
257  : BC_MenuItem(_("View in new window"))
258 {
259         this->mwindow = mwindow;
260         this->popup = popup;
261 }
262
263 AssetPopupViewWindow::~AssetPopupViewWindow()
264 {
265 }
266
267 int AssetPopupViewWindow::handle_event()
268 {
269 // Find window with nothing
270         VWindow *vwindow = mwindow->get_viewer(1);
271
272 // TODO: create new vwindow or change current vwindow
273         vwindow->gui->lock_window("AssetPopupView::handle_event");
274
275         if(mwindow->session->drag_assets->total)
276                 vwindow->change_source(
277                         mwindow->session->drag_assets->values[0]);
278         else
279         if(mwindow->session->drag_clips->total)
280                 vwindow->change_source(
281                         mwindow->session->drag_clips->values[0]);
282
283         vwindow->gui->unlock_window();
284         return 1;
285 }
286
287
288
289
290
291
292
293 AssetPopupPaste::AssetPopupPaste(MWindow *mwindow, AssetPopup *popup)
294  : BC_MenuItem(_("Paste"))
295 {
296         this->mwindow = mwindow;
297         this->popup = popup;
298 }
299
300 AssetPopupPaste::~AssetPopupPaste()
301 {
302 }
303
304 int AssetPopupPaste::handle_event()
305 {
306         popup->paste_assets();
307         return 1;
308 }
309
310
311
312
313
314
315
316
317 AssetMatchSize::AssetMatchSize(MWindow *mwindow, AssetPopup *popup)
318  : BC_MenuItem(_("Match project size"))
319 {
320         this->mwindow = mwindow;
321         this->popup = popup;
322 }
323
324 int AssetMatchSize::handle_event()
325 {
326         popup->match_size();
327         return 1;
328 }
329
330
331
332
333
334
335
336
337 AssetMatchRate::AssetMatchRate(MWindow *mwindow, AssetPopup *popup)
338  : BC_MenuItem(_("Match frame rate"))
339 {
340         this->mwindow = mwindow;
341         this->popup = popup;
342 }
343
344 int AssetMatchRate::handle_event()
345 {
346         popup->match_rate();
347         return 1;
348 }
349
350
351
352
353
354
355
356
357 AssetMatchAll::AssetMatchAll(MWindow *mwindow, AssetPopup *popup)
358  : BC_MenuItem(_("Match all"))
359 {
360         this->mwindow = mwindow;
361         this->popup = popup;
362 }
363
364 int AssetMatchAll::handle_event()
365 {
366         popup->match_all();
367         return 1;
368 }
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383 AssetPopupProjectRemove::AssetPopupProjectRemove(MWindow *mwindow, AssetPopup *popup)
384  : BC_MenuItem(_("Remove from project"))
385 {
386         this->mwindow = mwindow;
387         this->popup = popup;
388 }
389
390
391
392 AssetPopupProjectRemove::~AssetPopupProjectRemove()
393 {
394 }
395
396 int AssetPopupProjectRemove::handle_event()
397 {
398         mwindow->remove_assets_from_project(1, 
399                 1, 
400                 mwindow->session->drag_assets,
401                 mwindow->session->drag_clips);
402         return 1;
403 }
404
405
406
407
408 AssetPopupDiskRemove::AssetPopupDiskRemove(MWindow *mwindow, AssetPopup *popup)
409  : BC_MenuItem(_("Remove from disk"))
410 {
411         this->mwindow = mwindow;
412         this->popup = popup;
413 }
414
415
416 AssetPopupDiskRemove::~AssetPopupDiskRemove()
417 {
418 }
419
420
421 int AssetPopupDiskRemove::handle_event()
422 {
423         mwindow->awindow->asset_remove->start();
424         return 1;
425 }
426
427
428
429