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()
48 void TransitionLengthThread::start(Transition *transition,
51 this->transition = transition;
52 this->length = this->orig_length = length;
53 BC_DialogThread::start();
56 BC_Window* TransitionLengthThread::new_gui()
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,
65 gui->create_objects();
69 void TransitionLengthThread::handle_close_event(int result)
75 mwindow->set_transition_length(transition, length);
79 mwindow->set_transition_length(length);
92 TransitionLengthDialog::TransitionLengthDialog(MWindow *mwindow,
93 TransitionLengthThread *thread,
96 : BC_Window(_(PROGRAM_NAME ": Transition length"),
107 this->mwindow = mwindow;
108 this->thread = thread;
111 TransitionLengthDialog::~TransitionLengthDialog()
116 void TransitionLengthDialog::create_objects()
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));
128 int TransitionLengthDialog::close_event()
139 TransitionLengthText::TransitionLengthText(MWindow *mwindow,
140 TransitionLengthDialog *gui,
143 : BC_TumbleTextBox(gui,
144 (float)gui->thread->length,
151 this->mwindow = mwindow;
155 int TransitionLengthText::handle_event()
157 double result = atof(get_text());
158 if(!EQUIV(result, gui->thread->length))
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();
179 TransitionPopup::TransitionPopup(MWindow *mwindow, MWindowGUI *gui)
180 : BC_PopupMenu(0, 0, 0, "", 0)
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);
210 sprintf(len_text, _("Length: %2.2f sec"), transition->track->from_units(transition->length));
211 length_item->set_text(len_text);
219 TransitionPopupAttach::TransitionPopupAttach(MWindow *mwindow, TransitionPopup *popup)
220 : BC_MenuItem(_("Attach..."))
222 this->mwindow = mwindow;
226 TransitionPopupAttach::~TransitionPopupAttach()
230 int TransitionPopupAttach::handle_event()
232 // popup->dialog_thread->start();
242 TransitionPopupDetach::TransitionPopupDetach(MWindow *mwindow, TransitionPopup *popup)
243 : BC_MenuItem(_("Detach"))
245 this->mwindow = mwindow;
249 TransitionPopupDetach::~TransitionPopupDetach()
253 int TransitionPopupDetach::handle_event()
255 mwindow->detach_transition(popup->transition);
260 TransitionPopupOn::TransitionPopupOn(MWindow *mwindow, TransitionPopup *popup)
261 : BC_MenuItem(_("On"))
263 this->mwindow = mwindow;
267 TransitionPopupOn::~TransitionPopupOn()
271 int TransitionPopupOn::handle_event()
273 popup->transition->on = !get_checked();
274 mwindow->sync_parameters(CHANGE_EDL);
283 TransitionPopupShow::TransitionPopupShow(MWindow *mwindow, TransitionPopup *popup)
284 : BC_MenuItem(_("Show"))
286 this->mwindow = mwindow;
290 TransitionPopupShow::~TransitionPopupShow()
294 int TransitionPopupShow::handle_event()
296 mwindow->show_plugin(popup->transition);
307 TransitionPopupLength::TransitionPopupLength(MWindow *mwindow, TransitionPopup *popup)
308 : BC_MenuItem(_("Length"))
310 this->mwindow = mwindow;
314 TransitionPopupLength::~TransitionPopupLength()
318 int TransitionPopupLength::handle_event()
320 popup->length_thread->start(popup->transition,