initial commit
[goodguy/history.git] / cinelerra-5.0 / cinelerra / transition.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 "edit.h"
23 #include "edits.h"
24 #include "errorbox.h"
25 #include "filexml.h"
26 #include "format.inc"
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 0;
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         {
166                 file->tag.set_title("ON");
167                 file->append_tag();
168         }
169         keyframes->copy(0, 0, file, 1, 0);
170         file->tag.set_title("/TRANSITION");
171         file->append_tag();
172         file->append_newline();
173 }
174
175 void Transition::load_xml(FileXML *file)
176 {
177         int result = 0;
178         file->tag.get_property("TITLE", title);
179         length = file->tag.get_property("LENGTH", length);
180         on = 0;
181         
182         do{
183                 result = file->read_tag();
184                 if(!result)
185                 {
186                         if(file->tag.title_is("/TRANSITION"))
187                         {
188                                 result = 1;
189                         }
190                         else
191                         if(file->tag.title_is("ON"))
192                         {
193                                 on = 1;
194                         }
195                         else
196                         if(file->tag.title_is("KEYFRAME"))
197                         {
198                                 keyframes->default_auto->load(file);;
199                         }
200                 }
201         }while(!result);
202 }
203
204
205
206 int Transition::popup_transition(int x, int y)
207 {
208 //      if(mwindow->session->tracks_vertical)
209 //              mwindow->gui->transition_popup->activate_menu(this, PROGRAM_NAME ": Transition", y, x);
210 //      else
211 //              mwindow->gui->transition_popup->activate_menu(this, PROGRAM_NAME ": Transition", x, y);
212         return 0;
213 }
214
215 int Transition::update_derived()
216 {
217 // Redraw transition titles
218         return 0;
219 }
220
221 int Transition::update_display()
222 {
223 // Don't draw anything during loads.
224         return 0;
225 }
226
227 const char* Transition::default_title()
228 {
229         return "Transition";
230 }
231
232 void Transition::dump(FILE *fp)
233 {
234         fprintf(fp,"       title: %s length: " _LD "\n", title, length);
235 }
236
237