fix for selected_to_clipboard unpacked copy
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / trackpopup.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #include "asset.h"
23 #include "assets.h"
24 #include "awindow.h"
25 #include "awindowgui.h"
26 #include "edl.h"
27 #include "edlsession.h"
28 #include "file.h"
29 #include "keys.h"
30 #include "language.h"
31 #include "localsession.h"
32 #include "mainerror.h"
33 #include "mainsession.h"
34 #include "mwindow.h"
35 #include "mwindowgui.h"
36 #include "plugindialog.h"
37 #include "resizetrackthread.h"
38 #include "track.h"
39 #include "tracks.h"
40 #include "trackpopup.h"
41 #include "trackcanvas.h"
42
43 #include <string.h>
44
45 TrackPopup::TrackPopup(MWindow *mwindow, MWindowGUI *gui)
46  : BC_PopupMenu(0, 0, 0, "", 0)
47 {
48         this->mwindow = mwindow;
49         this->gui = gui;
50         track = 0;
51         edit = 0;
52         pluginset = 0;
53         plugin = 0;
54         position = 0;
55 }
56
57 TrackPopup::~TrackPopup()
58 {
59 }
60
61 void TrackPopup::create_objects()
62 {
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));
68         resize_option = 0;
69         matchsize_option = 0;
70 }
71
72 int TrackPopup::activate_menu(Track *track, Edit *edit,
73                 PluginSet *pluginset, Plugin *plugin, double position)
74 {
75         this->track = track;
76         this->edit = edit;
77         this->pluginset = pluginset;
78         this->plugin = plugin;
79         this->position = position;
80
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));
84         }
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;
88         }
89
90         return BC_PopupMenu::activate_menu();
91 }
92
93
94 TrackAttachEffect::TrackAttachEffect(MWindow *mwindow, TrackPopup *popup)
95  : BC_MenuItem(_("Attach effect..."))
96 {
97         this->mwindow = mwindow;
98         this->popup = popup;
99         dialog_thread = new PluginDialogThread(mwindow);
100 }
101
102 TrackAttachEffect::~TrackAttachEffect()
103 {
104         delete dialog_thread;
105 }
106
107 int TrackAttachEffect::handle_event()
108 {
109         dialog_thread->start_window(popup->track,
110                 0, _(PROGRAM_NAME ": Attach Effect"),
111                 0, popup->track->data_type);
112         return 1;
113 }
114
115
116 TrackMoveUp::TrackMoveUp(MWindow *mwindow, TrackPopup *popup)
117  : BC_MenuItem(_("Move up"))
118 {
119         this->mwindow = mwindow;
120         this->popup = popup;
121 }
122 TrackMoveUp::~TrackMoveUp()
123 {
124 }
125 int TrackMoveUp::handle_event()
126 {
127         mwindow->move_track_up(popup->track);
128         return 1;
129 }
130
131
132
133 TrackMoveDown::TrackMoveDown(MWindow *mwindow, TrackPopup *popup)
134  : BC_MenuItem(_("Move down"))
135 {
136         this->mwindow = mwindow;
137         this->popup = popup;
138 }
139 TrackMoveDown::~TrackMoveDown()
140 {
141 }
142 int TrackMoveDown::handle_event()
143 {
144         mwindow->move_track_down(popup->track);
145         return 1;
146 }
147
148
149 TrackPopupResize::TrackPopupResize(MWindow *mwindow, TrackPopup *popup)
150  : BC_MenuItem(_("Resize track..."))
151 {
152         this->mwindow = mwindow;
153         this->popup = popup;
154         dialog_thread = new ResizeTrackThread(mwindow);
155 }
156 TrackPopupResize::~TrackPopupResize()
157 {
158         delete dialog_thread;
159 }
160
161 int TrackPopupResize::handle_event()
162 {
163         dialog_thread->start_window(popup->track);
164         return 1;
165 }
166
167
168 TrackPopupMatchSize::TrackPopupMatchSize(MWindow *mwindow, TrackPopup *popup)
169  : BC_MenuItem(_("Match output size"))
170 {
171         this->mwindow = mwindow;
172         this->popup = popup;
173 }
174 TrackPopupMatchSize::~TrackPopupMatchSize()
175 {
176 }
177
178 int TrackPopupMatchSize::handle_event()
179 {
180         mwindow->match_output_size(popup->track);
181         return 1;
182 }
183
184
185 TrackPopupDeleteTrack::TrackPopupDeleteTrack(MWindow *mwindow, TrackPopup *popup)
186  : BC_MenuItem(_("Delete track"))
187 {
188         this->mwindow = mwindow;
189         this->popup = popup;
190 }
191 int TrackPopupDeleteTrack::handle_event()
192 {
193         mwindow->delete_track(popup->track);
194         return 1;
195 }
196
197
198 TrackPopupAddTrack::TrackPopupAddTrack(MWindow *mwindow, TrackPopup *popup)
199  : BC_MenuItem(_("Add track"))
200 {
201         this->mwindow = mwindow;
202         this->popup = popup;
203 }
204
205 int TrackPopupAddTrack::handle_event()
206 {
207         switch( popup->track->data_type ) {
208         case TRACK_AUDIO:
209                 mwindow->add_audio_track_entry(1, popup->track);
210                 break;
211         case TRACK_VIDEO:
212                 mwindow->add_video_track_entry(popup->track);
213                 break;
214         case TRACK_SUBTITLE:
215                 mwindow->add_subttl_track_entry(popup->track);
216                 break;
217         }
218         return 1;
219 }
220