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
23 #include "editpopup.h"
25 #include "mainsession.h"
27 #include "mwindowgui.h"
28 #include "plugindialog.h"
29 #include "resizetrackthread.h"
32 #include "trackcanvas.h"
37 EditPopup::EditPopup(MWindow *mwindow, MWindowGUI *gui)
44 this->mwindow = mwindow;
48 EditPopup::~EditPopup()
52 void EditPopup::create_objects()
54 add_item(new EditAttachEffect(mwindow, this));
55 add_item(new EditMoveTrackUp(mwindow, this));
56 add_item(new EditMoveTrackDown(mwindow, this));
57 add_item(new EditPopupDeleteTrack(mwindow, this));
58 add_item(new EditPopupAddTrack(mwindow, this));
59 // add_item(new EditPopupTitle(mwindow, this));
63 int EditPopup::update(Track *track, Edit *edit)
68 if(track->data_type == TRACK_VIDEO && !resize_option)
70 add_item(resize_option = new EditPopupResize(mwindow, this));
71 add_item(matchsize_option = new EditPopupMatchSize(mwindow, this));
74 if(track->data_type == TRACK_AUDIO && resize_option)
76 del_item(resize_option); resize_option = 0;
77 del_item(matchsize_option); matchsize_option = 0;
90 EditAttachEffect::EditAttachEffect(MWindow *mwindow, EditPopup *popup)
91 : BC_MenuItem(_("Attach effect..."))
93 this->mwindow = mwindow;
95 dialog_thread = new PluginDialogThread(mwindow);
98 EditAttachEffect::~EditAttachEffect()
100 delete dialog_thread;
103 int EditAttachEffect::handle_event()
105 dialog_thread->start_window(popup->track,
107 _(PROGRAM_NAME ": Attach Effect"),
109 popup->track->data_type);
114 EditMoveTrackUp::EditMoveTrackUp(MWindow *mwindow, EditPopup *popup)
115 : BC_MenuItem(_("Move up"))
117 this->mwindow = mwindow;
120 EditMoveTrackUp::~EditMoveTrackUp()
123 int EditMoveTrackUp::handle_event()
125 mwindow->move_track_up(popup->track);
131 EditMoveTrackDown::EditMoveTrackDown(MWindow *mwindow, EditPopup *popup)
132 : BC_MenuItem(_("Move down"))
134 this->mwindow = mwindow;
137 EditMoveTrackDown::~EditMoveTrackDown()
140 int EditMoveTrackDown::handle_event()
142 mwindow->move_track_down(popup->track);
149 EditPopupResize::EditPopupResize(MWindow *mwindow, EditPopup *popup)
150 : BC_MenuItem(_("Resize track..."))
152 this->mwindow = mwindow;
154 dialog_thread = new ResizeTrackThread(mwindow);
156 EditPopupResize::~EditPopupResize()
158 delete dialog_thread;
161 int EditPopupResize::handle_event()
163 dialog_thread->start_window(popup->track);
172 EditPopupMatchSize::EditPopupMatchSize(MWindow *mwindow, EditPopup *popup)
173 : BC_MenuItem(_("Match output size"))
175 this->mwindow = mwindow;
178 EditPopupMatchSize::~EditPopupMatchSize()
182 int EditPopupMatchSize::handle_event()
184 mwindow->match_output_size(popup->track);
194 EditPopupDeleteTrack::EditPopupDeleteTrack(MWindow *mwindow, EditPopup *popup)
195 : BC_MenuItem(_("Delete track"))
197 this->mwindow = mwindow;
200 int EditPopupDeleteTrack::handle_event()
202 mwindow->delete_track(popup->track);
211 EditPopupAddTrack::EditPopupAddTrack(MWindow *mwindow, EditPopup *popup)
212 : BC_MenuItem(_("Add track"))
214 this->mwindow = mwindow;
218 int EditPopupAddTrack::handle_event()
220 switch( popup->track->data_type ) {
222 mwindow->add_audio_track_entry(1, popup->track);
225 mwindow->add_video_track_entry(popup->track);
228 mwindow->add_subttl_track_entry(popup->track);
239 EditPopupTitle::EditPopupTitle(MWindow *mwindow, EditPopup *popup)
240 : BC_MenuItem(_("User title..."))
242 this->mwindow = mwindow;
247 EditPopupTitle::~EditPopupTitle()
252 int EditPopupTitle::handle_event()
256 Track *trc = mwindow->session->track_highlighted;
258 if (trc && trc->record)
260 Edit *edt = mwindow->session->edit_highlighted;
263 window = new EditPopupTitleWindow (mwindow, popup);
264 window->create_objects();
265 result = window->run_window();
270 strcpy(edt->user_title, window->title_text->get_text());
281 EditPopupTitleWindow::EditPopupTitleWindow (MWindow *mwindow, EditPopup *popup)
282 : BC_Window (_(PROGRAM_NAME ": Set edit title"),
283 mwindow->gui->get_abs_cursor_x(0) - 400 / 2,
284 mwindow->gui->get_abs_cursor_y(0) - 500 / 2,
293 this->mwindow = mwindow;
295 this->edt = this->mwindow->session->edit_highlighted;
298 strcpy(new_text, this->edt->user_title);
302 EditPopupTitleWindow::~EditPopupTitleWindow()
306 int EditPopupTitleWindow::close_event()
312 void EditPopupTitleWindow::create_objects()
317 add_subwindow (new BC_Title (x, y, _("User title")));
318 add_subwindow (title_text = new EditPopupTitleText (this,
319 mwindow, x, y + 20));
320 add_tool(new BC_OKButton(this));
321 add_tool(new BC_CancelButton(this));
329 EditPopupTitleText::EditPopupTitleText (EditPopupTitleWindow *window,
330 MWindow *mwindow, int x, int y)
331 : BC_TextBox(x, y, 250, 1, (char*)(window->edt ? window->edt->user_title : ""))
333 this->window = window;
334 this->mwindow = mwindow;
337 EditPopupTitleText::~EditPopupTitleText()
341 int EditPopupTitleText::handle_event()