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 "edlsession.h"
31 #include "localsession.h"
32 #include "mainerror.h"
33 #include "mainsession.h"
35 #include "mwindowgui.h"
36 #include "plugindialog.h"
37 #include "resizetrackthread.h"
40 #include "trackpopup.h"
41 #include "trackcanvas.h"
45 TrackPopup::TrackPopup(MWindow *mwindow, MWindowGUI *gui)
46 : BC_PopupMenu(0, 0, 0, "", 0)
48 this->mwindow = mwindow;
57 TrackPopup::~TrackPopup()
61 void TrackPopup::create_objects()
63 add_item(new TrackAttachEffect(mwindow, this));
64 add_item(new TrackMoveUp(mwindow, this));
65 add_item(new TrackMoveDown(mwindow, this));
66 add_item(new TrackPopupDeleteTrack(mwindow, this));
67 add_item(new TrackPopupAddTrack(mwindow, this));
72 int TrackPopup::activate_menu(Track *track, Edit *edit,
73 PluginSet *pluginset, Plugin *plugin, double position)
77 this->pluginset = pluginset;
78 this->plugin = plugin;
79 this->position = position;
81 if( track->data_type == TRACK_VIDEO && !resize_option ) {
82 add_item(resize_option = new TrackPopupResize(mwindow, this));
83 add_item(matchsize_option = new TrackPopupMatchSize(mwindow, this));
85 else if( track->data_type == TRACK_AUDIO && resize_option ) {
86 del_item(resize_option); resize_option = 0;
87 del_item(matchsize_option); matchsize_option = 0;
90 return BC_PopupMenu::activate_menu();
94 TrackAttachEffect::TrackAttachEffect(MWindow *mwindow, TrackPopup *popup)
95 : BC_MenuItem(_("Attach effect..."))
97 this->mwindow = mwindow;
99 dialog_thread = new PluginDialogThread(mwindow);
102 TrackAttachEffect::~TrackAttachEffect()
104 delete dialog_thread;
107 int TrackAttachEffect::handle_event()
109 dialog_thread->start_window(popup->track,
110 0, _(PROGRAM_NAME ": Attach Effect"),
111 0, popup->track->data_type);
116 TrackMoveUp::TrackMoveUp(MWindow *mwindow, TrackPopup *popup)
117 : BC_MenuItem(_("Move up"))
119 this->mwindow = mwindow;
122 TrackMoveUp::~TrackMoveUp()
125 int TrackMoveUp::handle_event()
127 mwindow->move_track_up(popup->track);
133 TrackMoveDown::TrackMoveDown(MWindow *mwindow, TrackPopup *popup)
134 : BC_MenuItem(_("Move down"))
136 this->mwindow = mwindow;
139 TrackMoveDown::~TrackMoveDown()
142 int TrackMoveDown::handle_event()
144 mwindow->move_track_down(popup->track);
149 TrackPopupResize::TrackPopupResize(MWindow *mwindow, TrackPopup *popup)
150 : BC_MenuItem(_("Resize track..."))
152 this->mwindow = mwindow;
154 dialog_thread = new ResizeTrackThread(mwindow);
156 TrackPopupResize::~TrackPopupResize()
158 delete dialog_thread;
161 int TrackPopupResize::handle_event()
163 dialog_thread->start_window(popup->track);
168 TrackPopupMatchSize::TrackPopupMatchSize(MWindow *mwindow, TrackPopup *popup)
169 : BC_MenuItem(_("Match output size"))
171 this->mwindow = mwindow;
174 TrackPopupMatchSize::~TrackPopupMatchSize()
178 int TrackPopupMatchSize::handle_event()
180 mwindow->match_output_size(popup->track);
185 TrackPopupDeleteTrack::TrackPopupDeleteTrack(MWindow *mwindow, TrackPopup *popup)
186 : BC_MenuItem(_("Delete track"))
188 this->mwindow = mwindow;
191 int TrackPopupDeleteTrack::handle_event()
193 mwindow->delete_track(popup->track);
198 TrackPopupAddTrack::TrackPopupAddTrack(MWindow *mwindow, TrackPopup *popup)
199 : BC_MenuItem(_("Add track"))
201 this->mwindow = mwindow;
205 int TrackPopupAddTrack::handle_event()
207 switch( popup->track->data_type ) {
209 mwindow->add_audio_track_entry(1, popup->track);
212 mwindow->add_video_track_entry(popup->track);
215 mwindow->add_subttl_track_entry(popup->track);