Credit Andrew - fix vorbis audio which was scratchy and ensure aging plugin does...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / transition.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  * Copyright (C) 2003-2016 Cinelerra CV contributors
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  *
21  */
22
23 #include "edit.h"
24 #include "edits.h"
25 #include "errorbox.h"
26 #include "filexml.h"
27 #include "keyframes.h"
28 #include "mainundo.h"
29 #include "mwindow.h"
30 #include "mwindowgui.h"
31 #include "patch.h"
32 #include "plugindialog.h"
33 #include "pluginset.h"
34 #include "mainsession.h"
35 #include "track.h"
36 #include "trackcanvas.h"
37 #include "tracks.h"
38 #include "transition.h"
39 #include "transitionpopup.h"
40 #include <string.h>
41
42
43 TransitionMenuItem::TransitionMenuItem(MWindow *mwindow, int audio, int video)
44  : BC_MenuItem(_("Paste Transition"))
45 {
46         this->audio = audio;
47         this->video = video;
48 }
49
50 TransitionMenuItem::~TransitionMenuItem()
51 {
52 }
53
54 int TransitionMenuItem::handle_event()
55 {
56         return 1;
57 }
58
59
60 PasteTransition::PasteTransition(MWindow *mwindow, int audio, int video)
61  : Thread()
62 {
63         this->mwindow = mwindow;
64         this->audio = audio;
65         this->video = video;
66 }
67
68 PasteTransition::~PasteTransition()
69 {
70 }
71
72 void PasteTransition::run()
73 {
74 }
75
76
77
78
79
80
81
82
83
84
85
86
87
88 Transition::Transition(EDL *edl, Edit *edit, const char *title, long unit_length)
89  : Plugin(edl, (PluginSet*)edit->edits, title)
90 {
91         this->edit = edit;
92         this->length = unit_length;
93 //printf("Transition::Transition %p %p %p %p\n", this, keyframes, keyframes->first, keyframes->last);
94 }
95
96 Transition::~Transition()
97 {
98 }
99
100 KeyFrame* Transition::get_keyframe()
101 {
102         return (KeyFrame*)keyframes->default_auto;
103 }
104
105 Transition& Transition::operator=(Transition &that)
106 {
107 //printf("Transition::operator= 1\n");
108         copy_from(&that);
109         return *this;
110 }
111
112 Plugin& Transition::operator=(Plugin &that)
113 {
114         copy_from((Transition*)&that);
115         return *this;
116 }
117
118 Edit& Transition::operator=(Edit &that)
119 {
120         copy_from((Transition*)&that);
121         return *this;
122 }
123
124
125 int Transition::operator==(Transition &that)
126 {
127         return identical(&that);
128 }
129
130 int Transition::operator==(Plugin &that)
131 {
132         return identical((Transition*)&that);
133 }
134
135 int Transition::operator==(Edit &that)
136 {
137         return identical((Transition*)&that);
138 }
139
140
141 void Transition::copy_from(Transition *that)
142 {
143         Plugin::copy_from(that);
144 }
145
146 int Transition::identical(Transition *that)
147 {
148         return this->length == that->length && Plugin::identical(that);
149 }
150
151
152 int Transition::reset_parameters()
153 {
154         return 0;
155 }
156
157 void Transition::save_xml(FileXML *file)
158 {
159         file->append_newline();
160         file->tag.set_title("TRANSITION");
161         file->tag.set_property("TITLE", title);
162         file->tag.set_property("LENGTH", length);
163         file->append_tag();
164         if( on ) {
165                 file->tag.set_title("ON");
166                 file->append_tag();
167                 file->tag.set_title("/ON");
168                 file->append_tag();
169         }
170         keyframes->copy(0, 0, file, 1, 0);
171         file->tag.set_title("/TRANSITION");
172         file->append_tag();
173         file->append_newline();
174 }
175
176 void Transition::load_xml(FileXML *file)
177 {
178         file->tag.get_property("TITLE", title);
179         Plugin::fix_plugin_title(title);
180         length = file->tag.get_property("LENGTH", length);
181         on = 0;
182
183         while( !file->read_tag() ) {
184                 if( file->tag.title_is("/TRANSITION") ) break;
185                 if( file->tag.title_is("ON") ) { on = 1;  continue; }
186                 if( file->tag.title_is("KEYFRAME") )
187                         keyframes->default_auto->load(file);;
188         }
189 }
190
191
192 int Transition::popup_transition(int x, int y)
193 {
194 //      if(mwindow->session->tracks_vertical)
195 //              mwindow->gui->transition_popup->activate_menu(this, PROGRAM_NAME ": Transition", y, x);
196 //      else
197 //              mwindow->gui->transition_popup->activate_menu(this, PROGRAM_NAME ": Transition", x, y);
198         return 0;
199 }
200
201 int Transition::update_derived()
202 {
203 // Redraw transition titles
204         return 0;
205 }
206
207 int Transition::update_display()
208 {
209 // Don't draw anything during loads.
210         return 0;
211 }
212
213 const char* Transition::default_title()
214 {
215         return _("Transition");
216 }
217
218 void Transition::dump(FILE *fp)
219 {
220         fprintf(fp,"       title: %s length: %jd\n", title, length);
221 }
222
223