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
24 #include "edlsession.h"
26 #include "mainsession.h"
27 #include "menuattachtransition.h"
29 #include "mwindowgui.h"
30 #include "plugindialog.h"
31 #include "pluginserver.h"
39 MenuAttachTransition::MenuAttachTransition(MWindow *mwindow, int data_type)
40 : BC_MenuItem(_("Attach Transition..."))
42 this->mwindow = mwindow;
43 this->data_type = data_type;
44 thread = new TransitionDialogThread(mwindow, data_type);
47 MenuAttachTransition::~MenuAttachTransition()
52 int MenuAttachTransition::handle_event()
59 TransitionDialogThread::TransitionDialogThread(MWindow *mwindow, int data_type)
62 this->mwindow = mwindow;
63 this->data_type = data_type;
66 void TransitionDialogThread::start()
68 if(!transition_names.total)
70 // Construct listbox names
71 ArrayList<PluginServer*> plugindb;
72 mwindow->search_plugindb(data_type == TRACK_AUDIO,
73 data_type == TRACK_VIDEO,
78 for(int i = 0; i < plugindb.total; i++)
79 transition_names.append(new BC_ListBoxItem(_(plugindb.values[i]->title)));
82 if(data_type == TRACK_AUDIO)
83 strcpy(transition_title, mwindow->edl->session->default_atransition);
85 strcpy(transition_title, mwindow->edl->session->default_vtransition);
87 mwindow->gui->unlock_window();
88 BC_DialogThread::start();
89 mwindow->gui->lock_window("TransitionDialogThread::start");
94 BC_Window* TransitionDialogThread::new_gui()
96 mwindow->gui->lock_window("TransitionDialogThread::new_gui");
97 int x = mwindow->gui->get_abs_cursor_x(0) -
98 mwindow->session->transitiondialog_w / 2;
99 int y = mwindow->gui->get_abs_cursor_y(0) -
100 mwindow->session->transitiondialog_h / 2;
101 TransitionDialog *window = new TransitionDialog(mwindow,
105 window->create_objects();
106 mwindow->gui->unlock_window();
110 void TransitionDialogThread::handle_close_event(int result)
114 mwindow->paste_transitions(data_type, transition_title);
120 TransitionDialog::TransitionDialog(MWindow *mwindow,
121 TransitionDialogThread *thread,
124 : BC_Window(_("Attach Transition"),
127 mwindow->session->transitiondialog_w,
128 mwindow->session->transitiondialog_h,
135 this->mwindow = mwindow;
136 this->thread = thread;
139 void TransitionDialog::create_objects()
144 lock_window("TransitionDialog::create_objects");
145 add_subwindow(name_title = new BC_Title(x, y, _("Select transition from list")));
146 y += name_title->get_h() + 5;
147 add_subwindow(name_list = new TransitionDialogName(thread,
148 &thread->transition_names,
152 get_h() - y - BC_OKButton::calculate_h() - 10));
153 add_subwindow(new BC_OKButton(this));
154 add_subwindow(new BC_CancelButton(this));
161 int TransitionDialog::resize_event(int w, int h)
166 name_title->reposition_window(x, y);
167 y += name_title->get_h() + 5;
168 name_list->reposition_window(x,
171 h - y - BC_OKButton::calculate_h() - 10);
178 TransitionDialogName::TransitionDialogName(TransitionDialogThread *thread,
179 ArrayList<BC_ListBoxItem*> *standalone_data,
191 this->thread = thread;
194 int TransitionDialogName::handle_event()
200 int TransitionDialogName::selection_changed()
202 int number = get_selection_number(0, 0);
203 strcpy(thread->transition_title,
204 thread->transition_names.values[number]->get_text());