tweak zoom/fullscr to remember cwdw scale after fullscr
[goodguy/cinelerra.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 "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->clear_select();
101         return 1;
102 }
103
104 EditPopupCopy::EditPopupCopy(MWindow *mwindow, EditPopup *popup)
105  : BC_MenuItem(_("Copy"),_("Ctrl-c"),'c')
106 {
107         this->mwindow = mwindow;
108         this->popup = popup;
109         set_ctrl(1);
110 }
111
112 int EditPopupCopy::handle_event()
113 {
114         mwindow->selected_edits_to_clipboard(0);
115         return 1;
116 }
117
118 EditPopupCopyPack::EditPopupCopyPack(MWindow *mwindow, EditPopup *popup)
119  : BC_MenuItem(_("Copy pack"),_("Ctrl-Shift-C"),'C')
120 {
121         this->mwindow = mwindow;
122         this->popup = popup;
123         set_ctrl(1);
124         set_shift(1);
125 }
126
127 int EditPopupCopyPack::handle_event()
128 {
129         mwindow->selected_edits_to_clipboard(1);
130         return 1;
131 }
132
133 EditPopupCut::EditPopupCut(MWindow *mwindow, EditPopup *popup)
134  : BC_MenuItem(_("Cut"),_("Ctrl-x"),'x')
135 {
136         this->mwindow = mwindow;
137         this->popup = popup;
138         set_ctrl(1);
139 }
140
141 int EditPopupCut::handle_event()
142 {
143         mwindow->cut_selected_edits(1, 0);
144         return 1;
145 }
146
147 EditPopupCutPack::EditPopupCutPack(MWindow *mwindow, EditPopup *popup)
148  : BC_MenuItem(_("Cut pack"),_("Ctrl-z"),'z')
149 {
150         this->mwindow = mwindow;
151         this->popup = popup;
152         set_ctrl(1);
153 }
154
155 int EditPopupCutPack::handle_event()
156 {
157         mwindow->cut_selected_edits(1, 1);
158         return 1;
159 }
160
161 EditPopupMute::EditPopupMute(MWindow *mwindow, EditPopup *popup)
162  : BC_MenuItem(_("Mute"),_("Ctrl-m"),'m')
163 {
164         this->mwindow = mwindow;
165         this->popup = popup;
166         set_ctrl(1);
167 }
168
169 int EditPopupMute::handle_event()
170 {
171         mwindow->cut_selected_edits(0, 0);
172         return 1;
173 }
174
175 EditPopupMutePack::EditPopupMutePack(MWindow *mwindow, EditPopup *popup)
176  : BC_MenuItem(_("Mute pack"),_("Ctrl-Shift-M"),'M')
177 {
178         this->mwindow = mwindow;
179         this->popup = popup;
180         set_ctrl(1);
181         set_shift(1);
182 }
183
184 int EditPopupMutePack::handle_event()
185 {
186         mwindow->cut_selected_edits(0, 1);
187         return 1;
188 }
189
190 EditPopupPaste::EditPopupPaste(MWindow *mwindow, EditPopup *popup)
191  : BC_MenuItem(_("Paste"),_("Ctrl-v"),'v')
192 {
193         this->mwindow = mwindow;
194         this->popup = popup;
195         set_ctrl(1);
196 }
197
198 int EditPopupPaste::handle_event()
199 {
200         mwindow->paste(popup->position, popup->track, 0, 0);
201         mwindow->edl->tracks->clear_selected_edits();
202         popup->gui->draw_overlays(1);
203         if( mwindow->session->current_operation == DROP_TARGETING ) {
204                 mwindow->session->current_operation = NO_OPERATION;
205                 popup->gui->update_cursor();
206         }
207         return 1;
208 }
209
210 EditPopupOverwrite::EditPopupOverwrite(MWindow *mwindow, EditPopup *popup)
211  : BC_MenuItem(_("Overwrite"),_("Ctrl-b"),'b')
212 {
213         this->mwindow = mwindow;
214         this->popup = popup;
215         set_ctrl(1);
216 }
217
218 int EditPopupOverwrite::handle_event()
219 {
220         mwindow->paste(popup->position, popup->track, 0, -1);
221         mwindow->edl->tracks->clear_selected_edits();
222         popup->gui->draw_overlays(1);
223         if( mwindow->session->current_operation == DROP_TARGETING ) {
224                 mwindow->session->current_operation = NO_OPERATION;
225                 popup->gui->update_cursor();
226         }
227         return 1;
228 }
229
230 EditPopupOverwritePlugins::EditPopupOverwritePlugins(MWindow *mwindow, EditPopup *popup)
231  : BC_MenuItem(_("Overwrite Plugins"),_("Ctrl-Shift-P"),'P')
232 {
233         this->mwindow = mwindow;
234         this->popup = popup;
235         set_ctrl(1);
236         set_shift(1);
237 }
238
239 int EditPopupOverwritePlugins::handle_event()
240 {
241         mwindow->paste_clipboard(popup->track, popup->position, 1, 0,
242                         mwindow->edl->session->labels_follow_edits,
243                         mwindow->edl->session->autos_follow_edits,
244                         mwindow->edl->session->plugins_follow_edits);
245         mwindow->edl->tracks->clear_selected_edits();
246         if( mwindow->session->current_operation == DROP_TARGETING ) {
247                 mwindow->session->current_operation = NO_OPERATION;
248                 popup->gui->update_cursor();
249         }
250         return 1;
251 }
252