Credit Andrew - improve in-tree documentation
[goodguy/cinelerra.git] / 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 "asset.h"
23 #include "assets.h"
24 #include "awindow.h"
25 #include "awindowgui.h"
26 #include "edit.h"
27 #include "edits.h"
28 #include "editpopup.h"
29 #include "edl.h"
30 #include "edlsession.h"
31 #include "file.h"
32 #include "keys.h"
33 #include "language.h"
34 #include "localsession.h"
35 #include "mainerror.h"
36 #include "mainsession.h"
37 #include "mwindow.h"
38 #include "mwindowgui.h"
39 #include "plugindialog.h"
40 #include "resizetrackthread.h"
41 #include "track.h"
42 #include "tracks.h"
43 #include "trackcanvas.h"
44
45 #include <string.h>
46
47 EditPopup::EditPopup(MWindow *mwindow, MWindowGUI *gui)
48  : BC_PopupMenu(0, 0, 0, "", 0)
49 {
50         this->mwindow = mwindow;
51         this->gui = gui;
52
53         track = 0;
54         edit = 0;
55         plugin = 0;
56         pluginset = 0;
57         position = 0;
58 }
59
60 EditPopup::~EditPopup()
61 {
62 }
63
64 void EditPopup::create_objects()
65 {
66         add_item(new EditPopupClearSelect(mwindow, this));
67         add_item(new EditPopupCopy(mwindow, this));
68         add_item(new EditPopupCut(mwindow, this));
69         add_item(new EditPopupMute(mwindow, this));
70         add_item(new EditPopupCopyPack(mwindow, this));
71         add_item(new EditPopupCutPack(mwindow, this));
72         add_item(new EditPopupMutePack(mwindow, this));
73         add_item(new EditPopupPaste(mwindow, this));
74         add_item(new EditPopupOverwrite(mwindow, this));
75         add_item(new EditPopupOverwritePlugins(mwindow, this));
76 }
77
78 int EditPopup::activate_menu(Track *track, Edit *edit,
79                 PluginSet *pluginset, Plugin *plugin, double position)
80 {
81         this->track = track;
82         this->edit = edit;
83         this->pluginset = pluginset;
84         this->plugin = plugin;
85         this->position = position;
86         return BC_PopupMenu::activate_menu();
87 }
88
89 EditPopupClearSelect::EditPopupClearSelect(MWindow *mwindow, EditPopup *popup)
90  : BC_MenuItem(_("Clear Select"),_("Ctrl-Shift-A"),'A')
91 {
92         this->mwindow = mwindow;
93         this->popup = popup;
94         set_ctrl(1);
95         set_shift(1);
96 }
97
98 int EditPopupClearSelect::handle_event()
99 {
100         mwindow->edl->tracks->clear_selected_edits();
101         popup->gui->draw_overlays(1);
102         return 1;
103 }
104
105 EditPopupCopy::EditPopupCopy(MWindow *mwindow, EditPopup *popup)
106  : BC_MenuItem(_("Copy"),_("Ctrl-c"),'c')
107 {
108         this->mwindow = mwindow;
109         this->popup = popup;
110         set_ctrl(1);
111 }
112
113 int EditPopupCopy::handle_event()
114 {
115         mwindow->selected_edits_to_clipboard(0);
116         return 1;
117 }
118
119 EditPopupCopyPack::EditPopupCopyPack(MWindow *mwindow, EditPopup *popup)
120  : BC_MenuItem(_("Copy pack"),_("Ctrl-Shift-C"),'C')
121 {
122         this->mwindow = mwindow;
123         this->popup = popup;
124         set_ctrl(1);
125         set_shift(1);
126 }
127
128 int EditPopupCopyPack::handle_event()
129 {
130         mwindow->selected_edits_to_clipboard(1);
131         return 1;
132 }
133
134 EditPopupCut::EditPopupCut(MWindow *mwindow, EditPopup *popup)
135  : BC_MenuItem(_("Cut"),_("Ctrl-x"),'x')
136 {
137         this->mwindow = mwindow;
138         this->popup = popup;
139         set_ctrl(1);
140 }
141
142 int EditPopupCut::handle_event()
143 {
144         mwindow->cut_selected_edits(1, 0);
145         return 1;
146 }
147
148 EditPopupCutPack::EditPopupCutPack(MWindow *mwindow, EditPopup *popup)
149  : BC_MenuItem(_("Cut pack"),_("Ctrl-z"),'z')
150 {
151         this->mwindow = mwindow;
152         this->popup = popup;
153         set_ctrl(1);
154 }
155
156 int EditPopupCutPack::handle_event()
157 {
158         mwindow->cut_selected_edits(1, 1);
159         return 1;
160 }
161
162 EditPopupMute::EditPopupMute(MWindow *mwindow, EditPopup *popup)
163  : BC_MenuItem(_("Mute"),_("Ctrl-m"),'m')
164 {
165         this->mwindow = mwindow;
166         this->popup = popup;
167         set_ctrl(1);
168 }
169
170 int EditPopupMute::handle_event()
171 {
172         mwindow->cut_selected_edits(0, 0);
173         return 1;
174 }
175
176 EditPopupMutePack::EditPopupMutePack(MWindow *mwindow, EditPopup *popup)
177  : BC_MenuItem(_("Mute pack"),_("Ctrl-Shift-M"),'M')
178 {
179         this->mwindow = mwindow;
180         this->popup = popup;
181         set_ctrl(1);
182         set_shift(1);
183 }
184
185 int EditPopupMutePack::handle_event()
186 {
187         mwindow->cut_selected_edits(0, 1);
188         return 1;
189 }
190
191 EditPopupPaste::EditPopupPaste(MWindow *mwindow, EditPopup *popup)
192  : BC_MenuItem(_("Paste"),_("Ctrl-v"),'v')
193 {
194         this->mwindow = mwindow;
195         this->popup = popup;
196         set_ctrl(1);
197 }
198
199 int EditPopupPaste::handle_event()
200 {
201         mwindow->paste(popup->position, popup->track, 0, 0);
202         mwindow->edl->tracks->clear_selected_edits();
203         popup->gui->draw_overlays(1);
204         if( mwindow->session->current_operation == DROP_TARGETING ) {
205                 mwindow->session->current_operation = NO_OPERATION;
206                 popup->gui->update_cursor();
207         }
208         return 1;
209 }
210
211 EditPopupOverwrite::EditPopupOverwrite(MWindow *mwindow, EditPopup *popup)
212  : BC_MenuItem(_("Overwrite"),_("Ctrl-b"),'b')
213 {
214         this->mwindow = mwindow;
215         this->popup = popup;
216         set_ctrl(1);
217 }
218
219 int EditPopupOverwrite::handle_event()
220 {
221         mwindow->paste(popup->position, popup->track, 0, -1);
222         mwindow->edl->tracks->clear_selected_edits();
223         popup->gui->draw_overlays(1);
224         if( mwindow->session->current_operation == DROP_TARGETING ) {
225                 mwindow->session->current_operation = NO_OPERATION;
226                 popup->gui->update_cursor();
227         }
228         return 1;
229 }
230
231 EditPopupOverwritePlugins::EditPopupOverwritePlugins(MWindow *mwindow, EditPopup *popup)
232  : BC_MenuItem(_("Overwrite Plugins"),_("Ctrl-Shift-P"),'P')
233 {
234         this->mwindow = mwindow;
235         this->popup = popup;
236         set_ctrl(1);
237         set_shift(1);
238 }
239
240 int EditPopupOverwritePlugins::handle_event()
241 {
242         mwindow->paste_clipboard(popup->track, popup->position, 1, 0,
243                         mwindow->edl->session->labels_follow_edits,
244                         mwindow->edl->session->autos_follow_edits,
245                         mwindow->edl->session->plugins_follow_edits);
246         mwindow->edl->tracks->clear_selected_edits();
247         if( mwindow->session->current_operation == DROP_TARGETING ) {
248                 mwindow->session->current_operation = NO_OPERATION;
249                 popup->gui->update_cursor();
250         }
251         return 1;
252 }
253