thirdparty build changes for 10/12bit support
[goodguy/history.git] / cinelerra-5.1 / cinelerra / editpopup.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 "edit.h"
23 #include "editpopup.h"
24 #include "language.h"
25 #include "mainsession.h"
26 #include "mwindow.h"
27 #include "mwindowgui.h"
28 #include "plugindialog.h"
29 #include "resizetrackthread.h"
30 #include "track.h"
31 #include "tracks.h"
32 #include "trackcanvas.h"
33
34
35 #include <string.h>
36
37 EditPopup::EditPopup(MWindow *mwindow, MWindowGUI *gui)
38  : BC_PopupMenu(0, 
39                 0, 
40                 0, 
41                 "", 
42                 0)
43 {
44         this->mwindow = mwindow;
45         this->gui = gui;
46 }
47
48 EditPopup::~EditPopup()
49 {
50 }
51
52 void EditPopup::create_objects()
53 {
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));
60         resize_option = 0;
61 }
62
63 int EditPopup::update(Track *track, Edit *edit)
64 {
65         this->edit = edit;
66         this->track = track;
67
68         if(track->data_type == TRACK_VIDEO && !resize_option)
69         {
70                 add_item(resize_option = new EditPopupResize(mwindow, this));
71                 add_item(matchsize_option = new EditPopupMatchSize(mwindow, this));
72         }
73         else
74         if(track->data_type == TRACK_AUDIO && resize_option)
75         {
76                 del_item(resize_option);     resize_option = 0;
77                 del_item(matchsize_option);  matchsize_option = 0;
78         }
79         return 0;
80 }
81
82
83
84
85
86
87
88
89
90 EditAttachEffect::EditAttachEffect(MWindow *mwindow, EditPopup *popup)
91  : BC_MenuItem(_("Attach effect..."))
92 {
93         this->mwindow = mwindow;
94         this->popup = popup;
95         dialog_thread = new PluginDialogThread(mwindow);
96 }
97
98 EditAttachEffect::~EditAttachEffect()
99 {
100         delete dialog_thread;
101 }
102
103 int EditAttachEffect::handle_event()
104 {
105         dialog_thread->start_window(popup->track,
106                 0, 
107                 _(PROGRAM_NAME ": Attach Effect"),
108                 0,
109                 popup->track->data_type);
110         return 1;
111 }
112
113
114 EditMoveTrackUp::EditMoveTrackUp(MWindow *mwindow, EditPopup *popup)
115  : BC_MenuItem(_("Move up"))
116 {
117         this->mwindow = mwindow;
118         this->popup = popup;
119 }
120 EditMoveTrackUp::~EditMoveTrackUp()
121 {
122 }
123 int EditMoveTrackUp::handle_event()
124 {
125         mwindow->move_track_up(popup->track);
126         return 1;
127 }
128
129
130
131 EditMoveTrackDown::EditMoveTrackDown(MWindow *mwindow, EditPopup *popup)
132  : BC_MenuItem(_("Move down"))
133 {
134         this->mwindow = mwindow;
135         this->popup = popup;
136 }
137 EditMoveTrackDown::~EditMoveTrackDown()
138 {
139 }
140 int EditMoveTrackDown::handle_event()
141 {
142         mwindow->move_track_down(popup->track);
143         return 1;
144 }
145
146
147
148
149 EditPopupResize::EditPopupResize(MWindow *mwindow, EditPopup *popup)
150  : BC_MenuItem(_("Resize track..."))
151 {
152         this->mwindow = mwindow;
153         this->popup = popup;
154         dialog_thread = new ResizeTrackThread(mwindow);
155 }
156 EditPopupResize::~EditPopupResize()
157 {
158         delete dialog_thread;
159 }
160
161 int EditPopupResize::handle_event()
162 {
163         dialog_thread->start_window(popup->track);
164         return 1;
165 }
166
167
168
169
170
171
172 EditPopupMatchSize::EditPopupMatchSize(MWindow *mwindow, EditPopup *popup)
173  : BC_MenuItem(_("Match output size"))
174 {
175         this->mwindow = mwindow;
176         this->popup = popup;
177 }
178 EditPopupMatchSize::~EditPopupMatchSize()
179 {
180 }
181
182 int EditPopupMatchSize::handle_event()
183 {
184         mwindow->match_output_size(popup->track);
185         return 1;
186 }
187
188
189
190
191
192
193
194 EditPopupDeleteTrack::EditPopupDeleteTrack(MWindow *mwindow, EditPopup *popup)
195  : BC_MenuItem(_("Delete track"))
196 {
197         this->mwindow = mwindow;
198         this->popup = popup;
199 }
200 int EditPopupDeleteTrack::handle_event()
201 {
202         mwindow->delete_track(popup->track);
203         return 1;
204 }
205
206
207
208
209
210
211 EditPopupAddTrack::EditPopupAddTrack(MWindow *mwindow, EditPopup *popup)
212  : BC_MenuItem(_("Add track"))
213 {
214         this->mwindow = mwindow;
215         this->popup = popup;
216 }
217
218 int EditPopupAddTrack::handle_event()
219 {
220         switch( popup->track->data_type ) {
221         case TRACK_AUDIO:
222                 mwindow->add_audio_track_entry(1, popup->track);
223                 break;
224         case TRACK_VIDEO:
225                 mwindow->add_video_track_entry(popup->track);
226                 break;
227         case TRACK_SUBTITLE:
228                 mwindow->add_subttl_track_entry(popup->track);
229                 break;
230         }
231         return 1;
232 }
233
234
235
236
237
238
239 EditPopupTitle::EditPopupTitle(MWindow *mwindow, EditPopup *popup)
240  : BC_MenuItem(_("User title..."))
241 {
242         this->mwindow = mwindow;
243         this->popup = popup;
244         window = 0;
245 }
246
247 EditPopupTitle::~EditPopupTitle()
248 {
249         delete popup;
250 }
251
252 int EditPopupTitle::handle_event()
253 {
254         int result;
255
256         Track *trc = mwindow->session->track_highlighted;
257
258         if (trc && trc->record)
259         {
260                 Edit *edt = mwindow->session->edit_highlighted;
261                 if(!edt) return 1;
262
263                 window = new EditPopupTitleWindow (mwindow, popup);
264                 window->create_objects();
265                 result = window->run_window();
266
267
268                 if(!result && edt)
269                 {
270                         strcpy(edt->user_title, window->title_text->get_text());
271                 }
272
273                 delete window;
274                 window = 0;
275         }
276
277         return 1;
278 }
279
280
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,
285         300,
286         100,
287         300,
288         100,
289         0,
290         0,
291         1)
292 {
293         this->mwindow = mwindow;
294         this->popup = popup;
295         this->edt = this->mwindow->session->edit_highlighted;
296         if(this->edt)
297         {
298                 strcpy(new_text, this->edt->user_title);
299         }
300 }
301
302 EditPopupTitleWindow::~EditPopupTitleWindow()
303 {
304 }
305
306 int EditPopupTitleWindow::close_event()
307 {
308         set_done(1);
309         return 1;
310 }
311
312 void EditPopupTitleWindow::create_objects()
313 {
314         int x = 5;
315         int y = 10;
316
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));
322
323
324         show_window();
325         flush();
326 }
327
328
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 : ""))
332 {
333         this->window = window;
334         this->mwindow = mwindow;
335 }
336
337 EditPopupTitleText::~EditPopupTitleText() 
338
339 }
340  
341 int EditPopupTitleText::handle_event()
342 {
343         return 1;
344 }
345
346
347
348
349
350
351