initial commit
[goodguy/history.git] / cinelerra-5.0 / cinelerra / menuveffects.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 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 "asset.h"
23 #include "bchash.h"
24 #include "edl.h"
25 #include "edlsession.h"
26 #include "file.h"
27 #include "mainmenu.h"
28 #include "mainsession.h"
29 #include "mwindow.h"
30 #include "mwindowgui.h"
31 #include "menuveffects.h"
32 #include "patchbay.h"
33 #include "quicktime.h"
34 #include "tracks.h"
35 #include "units.h"
36 #include "vpluginarray.h"
37
38
39 MenuVEffects::MenuVEffects(MWindow *mwindow)
40  : MenuEffects(mwindow)
41 {
42         thread = new MenuVEffectThread(mwindow, this);
43 }
44
45 MenuVEffects::~MenuVEffects()
46 {
47         delete thread;
48 }
49
50 MenuVEffectThread::MenuVEffectThread(MWindow *mwindow, MenuVEffects *menu_item)
51  : MenuEffectThread(mwindow, menu_item)
52 {
53 }
54
55 MenuVEffectThread::~MenuVEffectThread()
56 {
57 }
58
59 int MenuVEffectThread::get_recordable_tracks(Asset *asset)
60 {
61         asset->layers = mwindow->edl->tracks->recordable_video_tracks();
62         return asset->layers;
63 }
64
65 int MenuVEffectThread::get_derived_attributes(Asset *asset, BC_Hash *defaults)
66 {
67
68         asset->load_defaults(defaults, 
69                 "VEFFECT_",
70                 1, 
71                 1,
72                 1,
73                 0,
74                 0);
75
76
77
78
79 // Fix asset for video only
80         if(!File::supports_video(asset->format)) asset->format = FILE_MOV;
81         asset->audio_data = 0;
82         asset->video_data = 1;
83
84
85
86         return 0;
87 }
88
89 int MenuVEffectThread::save_derived_attributes(Asset *asset, BC_Hash *defaults)
90 {
91         asset->save_defaults(defaults,
92                 "VEFFECT_",
93                 1,
94                 1,
95                 1,
96                 0,
97                 0);
98
99
100         return 0;
101 }
102
103 PluginArray* MenuVEffectThread::create_plugin_array()
104 {
105         return new VPluginArray();
106 }
107
108 int64_t MenuVEffectThread::to_units(double position, int round)
109 {
110         if(round)
111                 return Units::round(position * mwindow->edl->session->frame_rate);
112         else
113                 return (int64_t)(position * mwindow->edl->session->frame_rate);
114                 
115         return 0;
116 }
117
118 int MenuVEffectThread::fix_menu(char *title)
119 {
120         mwindow->gui->mainmenu->add_veffect(title); 
121         return 0;
122 }
123
124 MenuVEffectItem::MenuVEffectItem(MenuVEffects *menueffect, char *string)
125  : MenuEffectItem(menueffect, string)
126 {
127 }