4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
22 #include "bcdisplayinfo.h"
26 #include "edlsession.h"
29 #include "mwindowgui.h"
31 #include "transition.h"
34 #include "transitionpopup.h"
37 TransitionLengthThread::TransitionLengthThread(MWindow *mwindow)
40 this->mwindow = mwindow;
43 TransitionLengthThread::~TransitionLengthThread()
47 void TransitionLengthThread::start(Transition *transition,
50 this->transition = transition;
51 this->length = this->orig_length = length;
52 BC_DialogThread::start();
55 BC_Window* TransitionLengthThread::new_gui()
57 BC_DisplayInfo display_info;
58 int x = display_info.get_abs_cursor_x() - 150;
59 int y = display_info.get_abs_cursor_y() - 50;
60 TransitionLengthDialog *gui = new TransitionLengthDialog(mwindow,
64 gui->create_objects();
68 void TransitionLengthThread::handle_close_event(int result)
74 mwindow->set_transition_length(transition, length);
78 mwindow->set_transition_length(length);
91 TransitionLengthDialog::TransitionLengthDialog(MWindow *mwindow,
92 TransitionLengthThread *thread,
95 : BC_Window(PROGRAM_NAME ": Transition length",
106 this->mwindow = mwindow;
107 this->thread = thread;
110 TransitionLengthDialog::~TransitionLengthDialog()
115 void TransitionLengthDialog::create_objects()
117 lock_window("TransitionLengthDialog::create_objects");
118 add_subwindow(new BC_Title(10, 10, _("Seconds:")));
119 text = new TransitionLengthText(mwindow, this, 100, 10);
120 text->create_objects();
121 add_subwindow(new BC_OKButton(this));
122 add_subwindow(new BC_CancelButton(this));
127 int TransitionLengthDialog::close_event()
138 TransitionLengthText::TransitionLengthText(MWindow *mwindow,
139 TransitionLengthDialog *gui,
142 : BC_TumbleTextBox(gui,
143 (float)gui->thread->length,
150 this->mwindow = mwindow;
154 int TransitionLengthText::handle_event()
156 double result = atof(get_text());
157 if(!EQUIV(result, gui->thread->length))
159 gui->thread->length = result;
175 TransitionPopup::TransitionPopup(MWindow *mwindow, MWindowGUI *gui)
182 this->mwindow = mwindow;
186 TransitionPopup::~TransitionPopup()
188 delete length_thread;
189 // delete dialog_thread;
193 void TransitionPopup::create_objects()
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));
203 int TransitionPopup::update(Transition *transition)
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);
216 TransitionPopupAttach::TransitionPopupAttach(MWindow *mwindow, TransitionPopup *popup)
217 : BC_MenuItem(_("Attach..."))
219 this->mwindow = mwindow;
223 TransitionPopupAttach::~TransitionPopupAttach()
227 int TransitionPopupAttach::handle_event()
229 // popup->dialog_thread->start();
239 TransitionPopupDetach::TransitionPopupDetach(MWindow *mwindow, TransitionPopup *popup)
240 : BC_MenuItem(_("Detach"))
242 this->mwindow = mwindow;
246 TransitionPopupDetach::~TransitionPopupDetach()
250 int TransitionPopupDetach::handle_event()
252 mwindow->detach_transition(popup->transition);
257 TransitionPopupOn::TransitionPopupOn(MWindow *mwindow, TransitionPopup *popup)
258 : BC_MenuItem(_("On"))
260 this->mwindow = mwindow;
264 TransitionPopupOn::~TransitionPopupOn()
268 int TransitionPopupOn::handle_event()
270 popup->transition->on = !get_checked();
271 mwindow->sync_parameters(CHANGE_EDL);
280 TransitionPopupShow::TransitionPopupShow(MWindow *mwindow, TransitionPopup *popup)
281 : BC_MenuItem(_("Show"))
283 this->mwindow = mwindow;
287 TransitionPopupShow::~TransitionPopupShow()
291 int TransitionPopupShow::handle_event()
293 mwindow->show_plugin(popup->transition);
304 TransitionPopupLength::TransitionPopupLength(MWindow *mwindow, TransitionPopup *popup)
305 : BC_MenuItem(_("Length"))
307 this->mwindow = mwindow;
311 TransitionPopupLength::~TransitionPopupLength()
315 int TransitionPopupLength::handle_event()
317 popup->length_thread->start(popup->transition,