Merge branch 'ct' of git.pipapo.org:cinelerra-ct into ct
[cinelerra_cv/ct.git] / cinelerra / editpopup.C
blob4cbe0c3a84aa468c0245b5a52f2ada4519e22ccd
1 #include "edit.h"
2 #include "editpopup.h"
3 #include "language.h"
4 #include "mainsession.h"
5 #include "mwindow.h"
6 #include "mwindowgui.h"
7 #include "plugindialog.h"
8 #include "resizetrackthread.h"
9 #include "track.h"
10 #include "tracks.h"
11 #include "trackcanvas.h"
14 #include <string.h>
16 EditPopup::EditPopup(MWindow *mwindow, MWindowGUI *gui)
17  : BC_PopupMenu(0, 
18                 0, 
19                 0, 
20                 "", 
21                 0)
23         this->mwindow = mwindow;
24         this->gui = gui;
27 EditPopup::~EditPopup()
31 void EditPopup::create_objects()
33         add_item(new EditAttachEffect(mwindow, this));
34         add_item(new EditMoveTrackUp(mwindow, this));
35         add_item(new EditMoveTrackDown(mwindow, this));
36         add_item(new EditPopupDeleteTrack(mwindow, this));
37         add_item(new EditPopupAddTrack(mwindow, this));
38 //      add_item(new EditPopupTitle(mwindow, this));
39         resize_option = 0;
42 int EditPopup::update(Track *track, Edit *edit)
44         this->edit = edit;
45         this->track = track;
47         if(track->data_type == TRACK_VIDEO && !resize_option)
48         {
49                 add_item(resize_option = new EditPopupResize(mwindow, this));
50                 add_item(matchsize_option = new EditPopupMatchSize(mwindow, this));
51         }
52         else
53         if(track->data_type == TRACK_AUDIO && resize_option)
54         {
55                 remove_item(resize_option);
56                 remove_item(matchsize_option);
57                 resize_option = 0;
58                 matchsize_option = 0;
59         }
60         return 0;
71 EditAttachEffect::EditAttachEffect(MWindow *mwindow, EditPopup *popup)
72  : BC_MenuItem(_("Attach effect..."))
74         this->mwindow = mwindow;
75         this->popup = popup;
76         dialog_thread = new PluginDialogThread(mwindow);
79 EditAttachEffect::~EditAttachEffect()
81         delete dialog_thread;
84 int EditAttachEffect::handle_event()
86         dialog_thread->start_window(popup->track,
87                 0, 
88                 PROGRAM_NAME ": Attach Effect");
89         return 1;
93 EditMoveTrackUp::EditMoveTrackUp(MWindow *mwindow, EditPopup *popup)
94  : BC_MenuItem(_("Move up"))
96         this->mwindow = mwindow;
97         this->popup = popup;
99 EditMoveTrackUp::~EditMoveTrackUp()
102 int EditMoveTrackUp::handle_event()
104         mwindow->move_track_up(popup->track);
105         return 1;
110 EditMoveTrackDown::EditMoveTrackDown(MWindow *mwindow, EditPopup *popup)
111  : BC_MenuItem(_("Move down"))
113         this->mwindow = mwindow;
114         this->popup = popup;
116 EditMoveTrackDown::~EditMoveTrackDown()
119 int EditMoveTrackDown::handle_event()
121         mwindow->move_track_down(popup->track);
122         return 1;
128 EditPopupResize::EditPopupResize(MWindow *mwindow, EditPopup *popup)
129  : BC_MenuItem(_("Resize track..."))
131         this->mwindow = mwindow;
132         this->popup = popup;
133         dialog_thread = new ResizeTrackThread(mwindow, 
134                 popup->track->tracks->number_of(popup->track));
136 EditPopupResize::~EditPopupResize()
138         delete dialog_thread;
141 int EditPopupResize::handle_event()
143         dialog_thread->start_window(popup->track, popup->track->tracks->number_of(popup->track));
144         return 1;
152 EditPopupMatchSize::EditPopupMatchSize(MWindow *mwindow, EditPopup *popup)
153  : BC_MenuItem(_("Match output size"))
155         this->mwindow = mwindow;
156         this->popup = popup;
158 EditPopupMatchSize::~EditPopupMatchSize()
162 int EditPopupMatchSize::handle_event()
164         mwindow->match_output_size(popup->track);
165         return 1;
174 EditPopupDeleteTrack::EditPopupDeleteTrack(MWindow *mwindow, EditPopup *popup)
175  : BC_MenuItem(_("Delete track"))
177         this->mwindow = mwindow;
178         this->popup = popup;
180 int EditPopupDeleteTrack::handle_event()
182         mwindow->delete_track(popup->track);
183         return 1;
191 EditPopupAddTrack::EditPopupAddTrack(MWindow *mwindow, EditPopup *popup)
192  : BC_MenuItem(_("Add track"))
194         this->mwindow = mwindow;
195         this->popup = popup;
198 int EditPopupAddTrack::handle_event()
200         if(popup->track->data_type == TRACK_AUDIO)
201                 mwindow->add_audio_track_entry(1, popup->track);
202         else
203                 mwindow->add_video_track_entry(popup->track);
204         return 1;
212 EditPopupTitle::EditPopupTitle(MWindow *mwindow, EditPopup *popup)
213  : BC_MenuItem(_("User title..."))
215         this->mwindow = mwindow;
216         this->popup = popup;
217         window = 0;
220 EditPopupTitle::~EditPopupTitle()
222         delete popup;
225 int EditPopupTitle::handle_event()
227         int result;
229         Track *trc = mwindow->session->track_highlighted;
231         if (trc && trc->record)
232         {
233                 Edit *edt = mwindow->session->edit_highlighted;
234                 if(!edt) return 1;
236                 window = new EditPopupTitleWindow (mwindow, popup);
237                 window->create_objects();
238                 result = window->run_window();
241                 if(!result && edt)
242                 {
243                         strcpy(edt->user_title, window->title_text->get_text());
244                 }
246                 delete window;
247                 window = 0;
248         }
250         return 1;
254 EditPopupTitleWindow::EditPopupTitleWindow (MWindow *mwindow, EditPopup *popup)
255  : BC_Window (PROGRAM_NAME ": Set edit title",
256         mwindow->gui->get_abs_cursor_x(0) - 400 / 2,
257         mwindow->gui->get_abs_cursor_y(0) - 500 / 2,
258         300,
259         100,
260         300,
261         100,
262         0,
263         0,
264         1)
266         this->mwindow = mwindow;
267         this->popup = popup;
268         this->edt = this->mwindow->session->edit_highlighted;
269         if(this->edt)
270         {
271                 strcpy(new_text, this->edt->user_title);
272         }
275 EditPopupTitleWindow::~EditPopupTitleWindow()
279 int EditPopupTitleWindow::close_event()
281         set_done(1);
282         return 1;
285 int EditPopupTitleWindow::create_objects()
287         int x = 5;
288         int y = 10;
290         add_subwindow (new BC_Title (x, y, _("User title")));
291         add_subwindow (title_text = new EditPopupTitleText (this,
292                 mwindow, x, y + 20));
293         add_tool(new BC_OKButton(this));
294         add_tool(new BC_CancelButton(this));
297         show_window();
298         flush();
299         return 0;
303 EditPopupTitleText::EditPopupTitleText (EditPopupTitleWindow *window, 
304         MWindow *mwindow, int x, int y)
305  : BC_TextBox(x, y, 250, 1, (char*)(window->edt ? window->edt->user_title : ""))
307         this->window = window;
308         this->mwindow = mwindow;
311 EditPopupTitleText::~EditPopupTitleText() 
315 int EditPopupTitleText::handle_event()
317         return 1;
327 //      Local Variables:
328 //      mode: C++
329 //      c-file-style: "linux"
330 //      End: