4 #include "keyframepopup.h"
8 #include "mwindowgui.h"
9 #include "localsession.h"
10 #include "cwindowgui.h"
14 #include "apatchgui.h"
15 #include "vpatchgui.h"
17 #include "maincursor.h"
18 #include "bcwindowbase.h"
20 #include "edlsession.h"
23 KeyframePopup::KeyframePopup(MWindow *mwindow, MWindowGUI *gui)
30 this->mwindow = mwindow;
37 KeyframePopup::~KeyframePopup()
41 void KeyframePopup::create_objects()
43 // add_item(key_show = new KeyframePopupShow(mwindow, this));
44 add_item(key_delete = new KeyframePopupDelete(mwindow, this));
45 add_item(key_copy = new KeyframePopupCopy(mwindow, this));
48 int KeyframePopup::update(Plugin *plugin, KeyFrame *keyframe)
50 this->keyframe_plugin = plugin;
51 this->keyframe_auto = keyframe;
52 this->keyframe_autos = 0;
53 this->keyframe_automation = 0;
57 int KeyframePopup::update(Automation *automation, Autos *autos, Auto *auto_keyframe)
59 this->keyframe_plugin = 0;
60 this->keyframe_automation = automation;
61 this->keyframe_autos = autos;
62 this->keyframe_auto = auto_keyframe;
65 double current_position = mwindow->edl->local_session->get_selectionstart(1);
66 double new_position = keyframe_automation->track->from_units(keyframe_auto->position);
67 mwindow->edl->local_session->set_selectionstart(new_position);
68 mwindow->edl->local_session->set_selectionend(new_position);
69 if (current_position != new_position)
71 mwindow->edl->local_session->set_selectionstart(new_position);
72 mwindow->edl->local_session->set_selectionend(new_position);
73 mwindow->gui->lock_window();
74 mwindow->gui->update(1, 1, 1, 1, 1, 1, 0);
75 mwindow->gui->unlock_window();
80 KeyframePopupDelete::KeyframePopupDelete(MWindow *mwindow, KeyframePopup *popup)
81 : BC_MenuItem(_("Delete keyframe"))
83 this->mwindow = mwindow;
87 KeyframePopupDelete::~KeyframePopupDelete()
91 int KeyframePopupDelete::handle_event()
93 delete popup->keyframe_auto;
94 mwindow->save_backup();
95 mwindow->undo->update_undo(_("delete keyframe"), LOAD_ALL);
97 mwindow->gui->update(0,
98 1, // 1 for incremental drawing. 2 for full refresh
104 mwindow->update_plugin_guis();
105 mwindow->restart_brender();
106 mwindow->sync_parameters(CHANGE_EDL);
111 KeyframePopupShow::KeyframePopupShow(MWindow *mwindow, KeyframePopup *popup)
112 : BC_MenuItem(_("Show keyframe settings"))
114 this->mwindow = mwindow;
118 KeyframePopupShow::~KeyframePopupShow()
122 int KeyframePopupShow::handle_event()
124 if (popup->keyframe_plugin)
126 mwindow->update_plugin_guis();
127 mwindow->show_plugin(popup->keyframe_plugin);
129 if (popup->keyframe_automation)
133 mwindow->cwindow->gui->lock_window();
135 if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->projector_autos ||
136 popup->keyframe_autos == (Autos *)popup->keyframe_automation->pzoom_autos)
139 mwindow->cwindow->gui->set_operation(CWINDOW_PROJECTOR);
141 if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->camera_autos ||
142 popup->keyframe_autos == (Autos *)popup->keyframe_automation->czoom_autos)
145 mwindow->cwindow->gui->set_operation(CWINDOW_CAMERA);
147 if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->mode_autos)
150 // no window to be shown
152 // first find the appropriate patchgui
153 PatchBay *patchbay = mwindow->gui->patchbay;
154 PatchGUI *patchgui = 0;
155 for (int i = 0; i < patchbay->patches.total; i++)
156 if (patchbay->patches.values[i]->track == popup->keyframe_automation->track)
157 patchgui = patchbay->patches.values[i];
160 // FIXME: repositioning of the listbox needs support in guicast
161 // int cursor_x = popup->get_relative_cursor_x();
162 // int cursor_y = popup->get_relative_cursor_y();
163 // vpatchgui->mode->reposition_window(cursor_x, cursor_y);
166 // Open the popup menu
167 VPatchGUI *vpatchgui = (VPatchGUI *)patchgui;
168 vpatchgui->mode->activate_menu();
171 if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->mask_autos)
174 mwindow->cwindow->gui->set_operation(CWINDOW_MASK);
176 if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->pan_autos)
179 // no window to be shown
181 // first find the appropriate patchgui
182 PatchBay *patchbay = mwindow->gui->patchbay;
183 PatchGUI *patchgui = 0;
184 for (int i = 0; i < patchbay->patches.total; i++)
185 if (patchbay->patches.values[i]->track == popup->keyframe_automation->track)
186 patchgui = patchbay->patches.values[i];
189 // Open the popup menu at current mouse position
190 APatchGUI *apatchgui = (APatchGUI *)patchgui;
191 int cursor_x = popup->get_relative_cursor_x();
192 int cursor_y = popup->get_relative_cursor_y();
193 apatchgui->pan->activate(cursor_x, cursor_y);
198 if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->fade_autos)
201 // no window to be shown, so do nothing
202 // IDEA: open window for fading
205 if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->mute_autos)
208 // no window to be shown, so do nothing
209 // IDEA: directly switch
214 // ensure bringing to front
217 ((CPanelToolWindow *)(mwindow->cwindow->gui->composite_panel->operation[CWINDOW_TOOL_WINDOW]))->set_shown(0);
218 ((CPanelToolWindow *)(mwindow->cwindow->gui->composite_panel->operation[CWINDOW_TOOL_WINDOW]))->set_shown(1);
220 mwindow->cwindow->gui->unlock_window();
230 KeyframePopupCopy::KeyframePopupCopy(MWindow *mwindow, KeyframePopup *popup)
231 : BC_MenuItem(_("Copy keyframe"))
233 this->mwindow = mwindow;
237 KeyframePopupCopy::~KeyframePopupCopy()
241 int KeyframePopupCopy::handle_event()
245 we want to copy just keyframe under cursor, NOT all keyframes at this frame
246 - very hard to do, so this is good approximation for now...
250 if (popup->keyframe_automation)
253 EDL *edl = mwindow->edl;
254 Track *track = popup->keyframe_automation->track;
255 int64_t position = popup->keyframe_auto->position;
257 // first find out type of our auto
259 if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->projector_autos)
260 autoconf.projector = 1;
261 else if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->pzoom_autos)
263 else if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->camera_autos)
265 else if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->czoom_autos)
267 else if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->mode_autos)
269 else if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->mask_autos)
271 else if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->pan_autos)
273 else if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->fade_autos)
275 else if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->mute_autos)
279 // now create a clipboard
280 file.tag.set_title("AUTO_CLIPBOARD");
281 file.tag.set_property("LENGTH", 0);
282 file.tag.set_property("FRAMERATE", edl->session->frame_rate);
283 file.tag.set_property("SAMPLERATE", edl->session->sample_rate);
285 file.append_newline();
286 file.append_newline();
288 /* track->copy_automation(position,
294 file.tag.set_title("TRACK");
296 track->save_header(&file);
298 file.append_newline();
300 track->automation->copy(position,
309 file.tag.set_title("/TRACK");
311 file.append_newline();
312 file.append_newline();
313 file.append_newline();
314 file.append_newline();
318 file.tag.set_title("/AUTO_CLIPBOARD");
320 file.append_newline();
321 file.terminate_string();
323 mwindow->gui->lock_window();
324 mwindow->gui->get_clipboard()->to_clipboard(file.string,
326 SECONDARY_SELECTION);
327 mwindow->gui->unlock_window();
331 mwindow->copy_automation();
340 // c-file-style: "linux"