rework set default transtion, nested proxy edl fixes, doubleclick proxy media fix...
[goodguy/history.git] / cinelerra-5.1 / cinelerra / transitionpopup.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 "bcdisplayinfo.h"
23 #include "clip.h"
24 #include "edit.h"
25 #include "edl.h"
26 #include "edlsession.h"
27 #include "language.h"
28 #include "mwindow.h"
29 #include "mwindowgui.h"
30 #include "plugin.h"
31 #include "transition.h"
32 #include "track.h"
33 #include "tracks.h"
34 #include "transitionpopup.h"
35
36
37 TransitionLengthThread::TransitionLengthThread(MWindow *mwindow)
38  : BC_DialogThread()
39 {
40         this->mwindow = mwindow;
41 }
42
43 TransitionLengthThread::~TransitionLengthThread()
44 {
45         close_window();
46 }
47
48 void TransitionLengthThread::start(Transition *transition,
49         double length)
50 {
51         this->transition = transition;
52         this->length = this->orig_length = length;
53         BC_DialogThread::start();
54 }
55
56 BC_Window* TransitionLengthThread::new_gui()
57 {
58         BC_DisplayInfo display_info;
59         int x = display_info.get_abs_cursor_x() - 150;
60         int y = display_info.get_abs_cursor_y() - 50;
61         TransitionLengthDialog *gui = new TransitionLengthDialog(mwindow,
62                 this,
63                 x,
64                 y);
65         gui->create_objects();
66         return gui;
67 }
68
69 void TransitionLengthThread::handle_close_event(int result)
70 {
71         if(!result)
72         {
73                 if(transition)
74                 {
75                         mwindow->set_transition_length(transition, length);
76                 }
77                 else
78                 {
79                         mwindow->set_transition_length(length);
80                 }
81         }
82 }
83
84
85
86
87
88
89
90
91
92 TransitionLengthDialog::TransitionLengthDialog(MWindow *mwindow,
93         TransitionLengthThread *thread,
94         int x,
95         int y)
96  : BC_Window(_(PROGRAM_NAME ": Transition length"),
97         x,
98         y,
99         300,
100         100,
101         -1,
102         -1,
103         0,
104         0,
105         1)
106 {
107         this->mwindow = mwindow;
108         this->thread = thread;
109 }
110
111 TransitionLengthDialog::~TransitionLengthDialog()
112 {
113 }
114
115
116 void TransitionLengthDialog::create_objects()
117 {
118         lock_window("TransitionLengthDialog::create_objects");
119         add_subwindow(new BC_Title(10, 10, _("Seconds:")));
120         text = new TransitionLengthText(mwindow, this, 100, 10);
121         text->create_objects();
122         add_subwindow(new BC_OKButton(this));
123         add_subwindow(new BC_CancelButton(this));
124         show_window();
125         unlock_window();
126 }
127
128 int TransitionLengthDialog::close_event()
129 {
130         set_done(0);
131         return 1;
132 }
133
134
135
136
137
138
139 TransitionLengthText::TransitionLengthText(MWindow *mwindow,
140         TransitionLengthDialog *gui,
141         int x,
142         int y)
143  : BC_TumbleTextBox(gui,
144         (float)gui->thread->length,
145         (float)0,
146         (float)100,
147         x,
148         y,
149         100)
150 {
151         this->mwindow = mwindow;
152         this->gui = gui;
153 }
154
155 int TransitionLengthText::handle_event()
156 {
157         double result = atof(get_text());
158         if(!EQUIV(result, gui->thread->length))
159         {
160                 gui->thread->length = result;
161                 mwindow->gui->lock_window();
162                 mwindow->gui->update(0, 1, 0, 0, 0, 0, 0);
163                 mwindow->gui->unlock_window();
164         }
165
166         return 1;
167 }
168
169
170
171
172
173
174
175
176
177
178
179 TransitionPopup::TransitionPopup(MWindow *mwindow, MWindowGUI *gui)
180  : BC_PopupMenu(0, 0, 0, "", 0)
181 {
182         this->mwindow = mwindow;
183         this->gui = gui;
184 }
185
186 TransitionPopup::~TransitionPopup()
187 {
188         delete length_thread;
189 //      delete dialog_thread;
190 }
191
192
193 void TransitionPopup::create_objects()
194 {
195         length_thread = new TransitionLengthThread(mwindow);
196 //      add_item(attach = new TransitionPopupAttach(mwindow, this));
197         add_item(show = new TransitionPopupShow(mwindow, this));
198         add_item(on = new TransitionPopupOn(mwindow, this));
199         add_item(length_item = new TransitionPopupLength(mwindow, this));
200         add_item(detach = new TransitionPopupDetach(mwindow, this));
201 }
202
203 int TransitionPopup::update(Transition *transition)
204 {
205         this->transition = transition;
206         this->length = transition->edit->track->from_units(transition->length);
207         show->set_checked(transition->show);
208         on->set_checked(transition->on);
209         char len_text[50];
210         sprintf(len_text, _("Length: %2.2f sec"), transition->track->from_units(transition->length));
211         length_item->set_text(len_text);
212         return 0;
213 }
214
215
216
217
218
219 TransitionPopupAttach::TransitionPopupAttach(MWindow *mwindow, TransitionPopup *popup)
220  : BC_MenuItem(_("Attach..."))
221 {
222         this->mwindow = mwindow;
223         this->popup = popup;
224 }
225
226 TransitionPopupAttach::~TransitionPopupAttach()
227 {
228 }
229
230 int TransitionPopupAttach::handle_event()
231 {
232 //      popup->dialog_thread->start();
233         return 1;
234 }
235
236
237
238
239
240
241
242 TransitionPopupDetach::TransitionPopupDetach(MWindow *mwindow, TransitionPopup *popup)
243  : BC_MenuItem(_("Detach"))
244 {
245         this->mwindow = mwindow;
246         this->popup = popup;
247 }
248
249 TransitionPopupDetach::~TransitionPopupDetach()
250 {
251 }
252
253 int TransitionPopupDetach::handle_event()
254 {
255         mwindow->detach_transition(popup->transition);
256         return 1;
257 }
258
259
260 TransitionPopupOn::TransitionPopupOn(MWindow *mwindow, TransitionPopup *popup)
261  : BC_MenuItem(_("On"))
262 {
263         this->mwindow = mwindow;
264         this->popup = popup;
265 }
266
267 TransitionPopupOn::~TransitionPopupOn()
268 {
269 }
270
271 int TransitionPopupOn::handle_event()
272 {
273         popup->transition->on = !get_checked();
274         mwindow->sync_parameters(CHANGE_EDL);
275         return 1;
276 }
277
278
279
280
281
282
283 TransitionPopupShow::TransitionPopupShow(MWindow *mwindow, TransitionPopup *popup)
284  : BC_MenuItem(_("Show"))
285 {
286         this->mwindow = mwindow;
287         this->popup = popup;
288 }
289
290 TransitionPopupShow::~TransitionPopupShow()
291 {
292 }
293
294 int TransitionPopupShow::handle_event()
295 {
296         mwindow->show_plugin(popup->transition);
297         return 1;
298 }
299
300
301
302
303
304
305
306
307 TransitionPopupLength::TransitionPopupLength(MWindow *mwindow, TransitionPopup *popup)
308  : BC_MenuItem(_("Length"))
309 {
310         this->mwindow = mwindow;
311         this->popup = popup;
312 }
313
314 TransitionPopupLength::~TransitionPopupLength()
315 {
316 }
317
318 int TransitionPopupLength::handle_event()
319 {
320         popup->length_thread->start(popup->transition,
321                 popup->length);
322         return 1;
323 }
324