Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

keyframepopup.C

Go to the documentation of this file.
00001 #include "cwindow.h"
00002 #include "edl.h"
00003 #include "keyframe.h"
00004 #include "keyframepopup.h"
00005 #include "language.h"
00006 #include "mainundo.h"
00007 #include "mwindow.h"
00008 #include "mwindowgui.h"
00009 #include "localsession.h"
00010 #include "cwindowgui.h" 
00011 #include "cpanel.h"
00012 #include "patchbay.h"
00013 #include "patchgui.h" 
00014 #include "apatchgui.h"
00015 #include "vpatchgui.h"
00016 #include "track.h"
00017 #include "maincursor.h"
00018 #include "bcwindowbase.h"
00019 #include "filexml.h"
00020 #include "edlsession.h"
00021 #include "autoconf.h"
00022 
00023 KeyframePopup::KeyframePopup(MWindow *mwindow, MWindowGUI *gui)
00024  : BC_PopupMenu(0, 
00025                 0, 
00026                 0, 
00027                 "", 
00028                 0)
00029 {
00030         this->mwindow = mwindow;
00031         this->gui = gui;
00032         key_show = 0;
00033         key_delete = 0;
00034         key_copy = 0;
00035 }
00036 
00037 KeyframePopup::~KeyframePopup()
00038 {
00039 }
00040 
00041 void KeyframePopup::create_objects()
00042 {
00043         add_item(key_show = new KeyframePopupShow(mwindow, this));
00044         add_item(key_delete = new KeyframePopupDelete(mwindow, this));
00045         add_item(key_copy = new KeyframePopupCopy(mwindow, this));
00046 }
00047 
00048 int KeyframePopup::update(Plugin *plugin, KeyFrame *keyframe)
00049 {
00050         this->keyframe_plugin = plugin;
00051         this->keyframe_auto = keyframe;
00052         this->keyframe_autos = 0;
00053         this->keyframe_automation = 0;
00054         return 0;
00055 }
00056 
00057 int KeyframePopup::update(Automation *automation, Autos *autos, Auto *auto_keyframe)
00058 {
00059         this->keyframe_plugin = 0;
00060         this->keyframe_automation = automation;
00061         this->keyframe_autos = autos;
00062         this->keyframe_auto = auto_keyframe;
00063 
00064         /* snap to cursor */
00065         double current_position = mwindow->edl->local_session->get_selectionstart(1);
00066         double new_position = keyframe_automation->track->from_units(keyframe_auto->position);
00067         mwindow->edl->local_session->set_selectionstart(new_position);
00068         mwindow->edl->local_session->set_selectionend(new_position);
00069         if (current_position != new_position)
00070         {
00071                 mwindow->edl->local_session->set_selectionstart(new_position);
00072                 mwindow->edl->local_session->set_selectionend(new_position);
00073                 mwindow->gui->lock_window();
00074                 mwindow->gui->update(1, 1, 1, 1, 1, 1, 0);      
00075                 mwindow->gui->unlock_window();
00076         }
00077         return 0;
00078 }
00079 
00080 KeyframePopupDelete::KeyframePopupDelete(MWindow *mwindow, KeyframePopup *popup)
00081  : BC_MenuItem(_("Delete keyframe"))
00082 {
00083         this->mwindow = mwindow;
00084         this->popup = popup;
00085 }
00086 
00087 KeyframePopupDelete::~KeyframePopupDelete()
00088 {
00089 }
00090 
00091 int KeyframePopupDelete::handle_event()
00092 {
00093         delete popup->keyframe_auto;
00094         mwindow->save_backup();
00095         mwindow->undo->update_undo(_("delete keyframe"), LOAD_ALL);
00096 
00097         mwindow->gui->update(0,
00098                 1,      // 1 for incremental drawing.  2 for full refresh
00099                 0,
00100                 0,
00101                 0,
00102             0,   
00103             0);
00104         mwindow->update_plugin_guis();
00105         mwindow->restart_brender();
00106         mwindow->sync_parameters(CHANGE_EDL);
00107 
00108         return 1;
00109 }
00110 
00111 KeyframePopupShow::KeyframePopupShow(MWindow *mwindow, KeyframePopup *popup)
00112  : BC_MenuItem(_("Show keyframe settings"))
00113 {
00114         this->mwindow = mwindow;
00115         this->popup = popup;
00116 }
00117 
00118 KeyframePopupShow::~KeyframePopupShow()
00119 {
00120 }
00121 
00122 int KeyframePopupShow::handle_event()
00123 {
00124         if (popup->keyframe_plugin)
00125         {
00126                 mwindow->update_plugin_guis();
00127                 mwindow->show_plugin(popup->keyframe_plugin);
00128         } else
00129         if (popup->keyframe_automation)
00130         {
00131 /*
00132 
00133                 mwindow->cwindow->gui->lock_window();
00134                 int show_window = 1;
00135                 if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->projector_autos ||
00136                    popup->keyframe_autos == (Autos *)popup->keyframe_automation->pzoom_autos)
00137                    
00138                 {
00139                         mwindow->cwindow->gui->set_operation(CWINDOW_PROJECTOR);        
00140                 } else
00141                 if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->camera_autos ||
00142                    popup->keyframe_autos == (Autos *)popup->keyframe_automation->czoom_autos)
00143                    
00144                 {
00145                         mwindow->cwindow->gui->set_operation(CWINDOW_CAMERA);   
00146                 } else
00147                 if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->mode_autos)
00148                    
00149                 {
00150                         // no window to be shown
00151                         show_window = 0;
00152                         // first find the appropriate patchgui
00153                         PatchBay *patchbay = mwindow->gui->patchbay;
00154                         PatchGUI *patchgui = 0;
00155                         for (int i = 0; i < patchbay->patches.total; i++)
00156                                 if (patchbay->patches.values[i]->track == popup->keyframe_automation->track)
00157                                         patchgui = patchbay->patches.values[i];         
00158                         if (patchgui != 0)
00159                         {
00160 // FIXME: repositioning of the listbox needs support in guicast
00161 //                              int cursor_x = popup->get_relative_cursor_x();
00162 //                              int cursor_y = popup->get_relative_cursor_y();
00163 //                              vpatchgui->mode->reposition_window(cursor_x, cursor_y);
00164 
00165 
00166 // Open the popup menu
00167                                 VPatchGUI *vpatchgui = (VPatchGUI *)patchgui;
00168                                 vpatchgui->mode->activate_menu();
00169                         }
00170                 } else
00171                 if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->mask_autos)
00172                    
00173                 {
00174                         mwindow->cwindow->gui->set_operation(CWINDOW_MASK);     
00175                 } else
00176                 if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->pan_autos)
00177                    
00178                 {
00179                         // no window to be shown
00180                         show_window = 0;
00181                         // first find the appropriate patchgui
00182                         PatchBay *patchbay = mwindow->gui->patchbay;
00183                         PatchGUI *patchgui = 0;
00184                         for (int i = 0; i < patchbay->patches.total; i++)
00185                                 if (patchbay->patches.values[i]->track == popup->keyframe_automation->track)
00186                                         patchgui = patchbay->patches.values[i];         
00187                         if (patchgui != 0)
00188                         {
00189 // Open the popup menu at current mouse position
00190                                 APatchGUI *apatchgui = (APatchGUI *)patchgui;
00191                                 int cursor_x = popup->get_relative_cursor_x();
00192                                 int cursor_y = popup->get_relative_cursor_y();
00193                                 apatchgui->pan->activate(cursor_x, cursor_y);
00194                         }
00195                         
00196 
00197                 } else
00198                 if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->fade_autos)
00199                    
00200                 {
00201                         // no window to be shown, so do nothing
00202                         // IDEA: open window for fading
00203                         show_window = 0;
00204                 } else
00205                 if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->mute_autos)
00206                    
00207                 {
00208                         // no window to be shown, so do nothing
00209                         // IDEA: directly switch
00210                         show_window = 0;
00211                 } else;
00212                 
00213 
00214 // ensure bringing to front
00215                 if (show_window)
00216                 {
00217                         ((CPanelToolWindow *)(mwindow->cwindow->gui->composite_panel->operation[CWINDOW_TOOL_WINDOW]))->set_shown(0);
00218                         ((CPanelToolWindow *)(mwindow->cwindow->gui->composite_panel->operation[CWINDOW_TOOL_WINDOW]))->set_shown(1);
00219                 }
00220                 mwindow->cwindow->gui->unlock_window();
00221 
00222 
00223 */
00224         }
00225         return 1;
00226 }
00227 
00228 
00229 
00230 KeyframePopupCopy::KeyframePopupCopy(MWindow *mwindow, KeyframePopup *popup)
00231  : BC_MenuItem(_("Copy keyframe"))
00232 {
00233         this->mwindow = mwindow;
00234         this->popup = popup;
00235 }
00236 
00237 KeyframePopupCopy::~KeyframePopupCopy()
00238 {
00239 }
00240 
00241 int KeyframePopupCopy::handle_event()
00242 {
00243 /*
00244         FIXME:
00245         we want to copy just keyframe under cursor, NOT all keyframes at this frame
00246         - very hard to do, so this is good approximation for now...
00247 */
00248         
00249 #if 0
00250         if (popup->keyframe_automation)
00251         {
00252                 FileXML file;
00253                 EDL *edl = mwindow->edl;
00254                 Track *track = popup->keyframe_automation->track;
00255                 int64_t position = popup->keyframe_auto->position;
00256                 AutoConf autoconf;
00257 // first find out type of our auto
00258                 autoconf.set_all(0);
00259                 if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->projector_autos)
00260                         autoconf.projector = 1;
00261                 else if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->pzoom_autos)
00262                         autoconf.pzoom = 1;
00263                 else if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->camera_autos)
00264                         autoconf.camera = 1;
00265                 else if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->czoom_autos)
00266                         autoconf.czoom = 1;             
00267                 else if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->mode_autos)
00268                         autoconf.mode = 1;
00269                 else if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->mask_autos)
00270                         autoconf.mask = 1;
00271                 else if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->pan_autos)
00272                         autoconf.pan = 1;                  
00273                 else if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->fade_autos)
00274                         autoconf.fade = 1;
00275                 else if (popup->keyframe_autos == (Autos *)popup->keyframe_automation->mute_autos)
00276                         autoconf.mute = 1;              
00277 
00278 
00279 // now create a clipboard
00280                 file.tag.set_title("AUTO_CLIPBOARD");
00281                 file.tag.set_property("LENGTH", 0);
00282                 file.tag.set_property("FRAMERATE", edl->session->frame_rate);
00283                 file.tag.set_property("SAMPLERATE", edl->session->sample_rate);
00284                 file.append_tag();
00285                 file.append_newline();
00286                 file.append_newline();
00287 
00288 /*              track->copy_automation(position, 
00289                         position, 
00290                         &file,
00291                         0,
00292                         0);
00293                         */
00294                 file.tag.set_title("TRACK");
00295 // Video or audio
00296                 track->save_header(&file);
00297                 file.append_tag();
00298                 file.append_newline();
00299 
00300                 track->automation->copy(position, 
00301                         position, 
00302                         &file,
00303                         0,
00304                         0,
00305                         &autoconf);
00306                 
00307                 
00308                 
00309                 file.tag.set_title("/TRACK");
00310                 file.append_tag();
00311                 file.append_newline();
00312                 file.append_newline();
00313                 file.append_newline();
00314                 file.append_newline();
00315 
00316 
00317 
00318                 file.tag.set_title("/AUTO_CLIPBOARD");
00319                 file.append_tag();
00320                 file.append_newline();
00321                 file.terminate_string();
00322 
00323                 mwindow->gui->lock_window();
00324                 mwindow->gui->get_clipboard()->to_clipboard(file.string, 
00325                         strlen(file.string), 
00326                         SECONDARY_SELECTION);
00327                 mwindow->gui->unlock_window();
00328 
00329         } else
00330 #endif
00331                 mwindow->copy_automation();
00332         return 1;
00333 }
00334 
00335 
00336 

Generated on Sun Jan 8 13:38:56 2006 for Cinelerra-svn by  doxygen 1.4.4