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
25 #include "awindowgui.h"
27 #include "editpopup.h"
29 #include "edlsession.h"
32 #include "localsession.h"
33 #include "mainerror.h"
34 #include "mainsession.h"
36 #include "mwindowgui.h"
37 #include "plugindialog.h"
38 #include "resizetrackthread.h"
41 #include "trackcanvas.h"
45 EditPopup::EditPopup(MWindow *mwindow, MWindowGUI *gui)
46 : BC_PopupMenu(0, 0, 0, "", 0)
48 this->mwindow = mwindow;
52 EditPopup::~EditPopup()
56 void EditPopup::create_objects()
58 add_item(new EditAttachEffect(mwindow, this));
59 add_item(new EditMoveTrackUp(mwindow, this));
60 add_item(new EditMoveTrackDown(mwindow, this));
61 add_item(new EditPopupDeleteTrack(mwindow, this));
62 add_item(new EditPopupAddTrack(mwindow, this));
63 // add_item(new EditPopupTitle(mwindow, this));
68 int EditPopup::update(Track *track, Edit *edit)
73 if(track->data_type == TRACK_VIDEO && !resize_option)
75 add_item(resize_option = new EditPopupResize(mwindow, this));
76 add_item(matchsize_option = new EditPopupMatchSize(mwindow, this));
79 if(track->data_type == TRACK_AUDIO && resize_option)
81 del_item(resize_option); resize_option = 0;
82 del_item(matchsize_option); matchsize_option = 0;
95 EditAttachEffect::EditAttachEffect(MWindow *mwindow, EditPopup *popup)
96 : BC_MenuItem(_("Attach effect..."))
98 this->mwindow = mwindow;
100 dialog_thread = new PluginDialogThread(mwindow);
103 EditAttachEffect::~EditAttachEffect()
105 delete dialog_thread;
108 int EditAttachEffect::handle_event()
110 dialog_thread->start_window(popup->track,
111 0, _(PROGRAM_NAME ": Attach Effect"),
112 0, popup->track->data_type);
117 EditMoveTrackUp::EditMoveTrackUp(MWindow *mwindow, EditPopup *popup)
118 : BC_MenuItem(_("Move up"))
120 this->mwindow = mwindow;
123 EditMoveTrackUp::~EditMoveTrackUp()
126 int EditMoveTrackUp::handle_event()
128 mwindow->move_track_up(popup->track);
134 EditMoveTrackDown::EditMoveTrackDown(MWindow *mwindow, EditPopup *popup)
135 : BC_MenuItem(_("Move down"))
137 this->mwindow = mwindow;
140 EditMoveTrackDown::~EditMoveTrackDown()
143 int EditMoveTrackDown::handle_event()
145 mwindow->move_track_down(popup->track);
150 EditPopupResize::EditPopupResize(MWindow *mwindow, EditPopup *popup)
151 : BC_MenuItem(_("Resize track..."))
153 this->mwindow = mwindow;
155 dialog_thread = new ResizeTrackThread(mwindow);
157 EditPopupResize::~EditPopupResize()
159 delete dialog_thread;
162 int EditPopupResize::handle_event()
164 dialog_thread->start_window(popup->track);
169 EditPopupMatchSize::EditPopupMatchSize(MWindow *mwindow, EditPopup *popup)
170 : BC_MenuItem(_("Match output size"))
172 this->mwindow = mwindow;
175 EditPopupMatchSize::~EditPopupMatchSize()
179 int EditPopupMatchSize::handle_event()
181 mwindow->match_output_size(popup->track);
186 EditPopupDeleteTrack::EditPopupDeleteTrack(MWindow *mwindow, EditPopup *popup)
187 : BC_MenuItem(_("Delete track"))
189 this->mwindow = mwindow;
192 int EditPopupDeleteTrack::handle_event()
194 mwindow->delete_track(popup->track);
199 EditPopupAddTrack::EditPopupAddTrack(MWindow *mwindow, EditPopup *popup)
200 : BC_MenuItem(_("Add track"))
202 this->mwindow = mwindow;
206 int EditPopupAddTrack::handle_event()
208 switch( popup->track->data_type ) {
210 mwindow->add_audio_track_entry(1, popup->track);
213 mwindow->add_video_track_entry(popup->track);
216 mwindow->add_subttl_track_entry(popup->track);
223 EditPopupTitle::EditPopupTitle(MWindow *mwindow, EditPopup *popup)
224 : BC_MenuItem(_("User title..."))
226 this->mwindow = mwindow;
231 EditPopupTitle::~EditPopupTitle()
236 int EditPopupTitle::handle_event()
240 Track *trc = mwindow->session->track_highlighted;
242 if (trc && trc->record)
244 Edit *edt = mwindow->session->edit_highlighted;
247 window = new EditPopupTitleWindow (mwindow, popup);
248 window->create_objects();
249 result = window->run_window();
254 strcpy(edt->user_title, window->title_text->get_text());
265 EditPopupTitleWindow::EditPopupTitleWindow (MWindow *mwindow, EditPopup *popup)
266 : BC_Window (_(PROGRAM_NAME ": Set edit title"),
267 mwindow->gui->get_abs_cursor_x(0) - 400 / 2,
268 mwindow->gui->get_abs_cursor_y(0) - 500 / 2,
277 this->mwindow = mwindow;
279 this->edt = this->mwindow->session->edit_highlighted;
282 strcpy(new_text, this->edt->user_title);
286 EditPopupTitleWindow::~EditPopupTitleWindow()
290 int EditPopupTitleWindow::close_event()
296 void EditPopupTitleWindow::create_objects()
301 add_subwindow (new BC_Title (x, y, _("User title")));
302 add_subwindow (title_text = new EditPopupTitleText (this,
303 mwindow, x, y + 20));
304 add_tool(new BC_OKButton(this));
305 add_tool(new BC_CancelButton(this));
313 EditPopupTitleText::EditPopupTitleText (EditPopupTitleWindow *window,
314 MWindow *mwindow, int x, int y)
315 : BC_TextBox(x, y, 250, 1, (char*)(window->edt ? window->edt->user_title : ""))
317 this->window = window;
318 this->mwindow = mwindow;
321 EditPopupTitleText::~EditPopupTitleText()
325 int EditPopupTitleText::handle_event()