play_off preview tweak, zoombar auto_color fix, deactivate popupmenu on click while...
[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  *
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 "keyframes.h"
27 #include "mainundo.h"
28 #include "mwindow.h"
29 #include "mwindowgui.h"
30 #include "patch.h"
31 #include "plugindialog.h"
32 #include "pluginset.h"
33 #include "mainsession.h"
34 #include "track.h"
35 #include "trackcanvas.h"
36 #include "tracks.h"
37 #include "transition.h"
38 #include "transitionpopup.h"
39 #include <string.h>
40
41
42 TransitionMenuItem::TransitionMenuItem(MWindow *mwindow, int audio, int video)
43  : BC_MenuItem(_("Paste Transition"))
44 {
45         this->audio = audio;
46         this->video = video;
47 }
48
49 TransitionMenuItem::~TransitionMenuItem()
50 {
51 }
52
53 int TransitionMenuItem::handle_event()
54 {
55         return 1;
56 }
57
58
59 PasteTransition::PasteTransition(MWindow *mwindow, int audio, int video)
60  : Thread()
61 {
62         this->mwindow = mwindow;
63         this->audio = audio;
64         this->video = video;
65 }
66
67 PasteTransition::~PasteTransition()
68 {
69 }
70
71 void PasteTransition::run()
72 {
73 }
74
75
76
77
78
79
80
81
82
83
84
85
86
87 Transition::Transition(EDL *edl, Edit *edit, const char *title, long unit_length)
88  : Plugin(edl, (PluginSet*)edit->edits, title)
89 {
90         this->edit = edit;
91         this->length = unit_length;
92 //printf("Transition::Transition %p %p %p %p\n", this, keyframes, keyframes->first, keyframes->last);
93 }
94
95 Transition::~Transition()
96 {
97 }
98
99 KeyFrame* Transition::get_keyframe()
100 {
101         return (KeyFrame*)keyframes->default_auto;
102 }
103
104 Transition& Transition::operator=(Transition &that)
105 {
106 //printf("Transition::operator= 1\n");
107         copy_from(&that);
108         return *this;
109 }
110
111 Plugin& Transition::operator=(Plugin &that)
112 {
113         copy_from((Transition*)&that);
114         return *this;
115 }
116
117 Edit& Transition::operator=(Edit &that)
118 {
119         copy_from((Transition*)&that);
120         return *this;
121 }
122
123
124 int Transition::operator==(Transition &that)
125 {
126         return identical(&that);
127 }
128
129 int Transition::operator==(Plugin &that)
130 {
131         return identical((Transition*)&that);
132 }
133
134 int Transition::operator==(Edit &that)
135 {
136         return identical((Transition*)&that);
137 }
138
139
140 void Transition::copy_from(Transition *that)
141 {
142         Plugin::copy_from(that);
143 }
144
145 int Transition::identical(Transition *that)
146 {
147         return this->length == that->length && Plugin::identical(that);
148 }
149
150
151 int Transition::reset_parameters()
152 {
153         return 0;
154 }
155
156 void Transition::save_xml(FileXML *file)
157 {
158         file->append_newline();
159         file->tag.set_title("TRANSITION");
160         file->tag.set_property("TITLE", title);
161         file->tag.set_property("LENGTH", length);
162         file->append_tag();
163         if(on)
164         {
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         int result = 0;
179         file->tag.get_property("TITLE", title);
180         Plugin::fix_plugin_title(title);
181         length = file->tag.get_property("LENGTH", length);
182         on = 0;
183
184         do{
185                 result = file->read_tag();
186                 if(!result)
187                 {
188                         if(file->tag.title_is("/TRANSITION"))
189                         {
190                                 result = 1;
191                         }
192                         else
193                         if(file->tag.title_is("ON"))
194                         {
195                                 on = 1;
196                         }
197                         else
198                         if(file->tag.title_is("KEYFRAME"))
199                         {
200                                 keyframes->default_auto->load(file);;
201                         }
202                 }
203         }while(!result);
204 }
205
206
207
208 int Transition::popup_transition(int x, int y)
209 {
210 //      if(mwindow->session->tracks_vertical)
211 //              mwindow->gui->transition_popup->activate_menu(this, PROGRAM_NAME ": Transition", y, x);
212 //      else
213 //              mwindow->gui->transition_popup->activate_menu(this, PROGRAM_NAME ": Transition", x, y);
214         return 0;
215 }
216
217 int Transition::update_derived()
218 {
219 // Redraw transition titles
220         return 0;
221 }
222
223 int Transition::update_display()
224 {
225 // Don't draw anything during loads.
226         return 0;
227 }
228
229 const char* Transition::default_title()
230 {
231         return _("Transition");
232 }
233
234 void Transition::dump(FILE *fp)
235 {
236         fprintf(fp,"       title: %s length: %jd\n", title, length);
237 }
238
239