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