Blender V2.61 - r43446

sequencer_ops.c

Go to the documentation of this file.
00001 
00002 /*
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * The Original Code is Copyright (C) 2008 Blender Foundation.
00021  * All rights reserved.
00022  *
00023  *
00024  * Contributor(s): Blender Foundation
00025  *
00026  * ***** END GPL LICENSE BLOCK *****
00027  */
00028 
00034 #include <stdlib.h>
00035 #include <math.h>
00036 
00037 
00038 #include "DNA_space_types.h"
00039 
00040 #include "BLI_math.h"
00041 #include "BLI_blenlib.h"
00042 
00043 
00044 
00045 #include "WM_api.h"
00046 #include "WM_types.h"
00047 
00048 #include "ED_transform.h" /* transform keymap */
00049 
00050 #include "sequencer_intern.h"
00051 
00052 
00053 /* ************************** registration **********************************/
00054 
00055 
00056 void sequencer_operatortypes(void)
00057 {
00058     /* sequencer_edit.c */
00059     WM_operatortype_append(SEQUENCER_OT_cut);
00060     WM_operatortype_append(SEQUENCER_OT_mute);
00061     WM_operatortype_append(SEQUENCER_OT_unmute);
00062     WM_operatortype_append(SEQUENCER_OT_lock);
00063     WM_operatortype_append(SEQUENCER_OT_unlock);
00064     WM_operatortype_append(SEQUENCER_OT_reload);
00065     WM_operatortype_append(SEQUENCER_OT_refresh_all);
00066     WM_operatortype_append(SEQUENCER_OT_reassign_inputs);
00067     WM_operatortype_append(SEQUENCER_OT_swap_inputs);
00068     WM_operatortype_append(SEQUENCER_OT_duplicate);
00069     WM_operatortype_append(SEQUENCER_OT_delete);
00070     WM_operatortype_append(SEQUENCER_OT_offset_clear);
00071     WM_operatortype_append(SEQUENCER_OT_images_separate);
00072     WM_operatortype_append(SEQUENCER_OT_meta_toggle);
00073     WM_operatortype_append(SEQUENCER_OT_meta_make);
00074     WM_operatortype_append(SEQUENCER_OT_meta_separate);
00075     WM_operatortype_append(SEQUENCER_OT_snap);
00076     WM_operatortype_append(SEQUENCER_OT_next_edit);
00077     WM_operatortype_append(SEQUENCER_OT_previous_edit);
00078     WM_operatortype_append(SEQUENCER_OT_swap);
00079     WM_operatortype_append(SEQUENCER_OT_swap_data);
00080     WM_operatortype_append(SEQUENCER_OT_rendersize);
00081 
00082     WM_operatortype_append(SEQUENCER_OT_view_all);
00083     WM_operatortype_append(SEQUENCER_OT_view_selected);
00084     WM_operatortype_append(SEQUENCER_OT_view_all_preview);
00085     WM_operatortype_append(SEQUENCER_OT_view_toggle);
00086     WM_operatortype_append(SEQUENCER_OT_view_zoom_ratio);
00087     WM_operatortype_append(SEQUENCER_OT_view_ghost_border);
00088 
00089     WM_operatortype_append(SEQUENCER_OT_rebuild_proxy);
00090     WM_operatortype_append(SEQUENCER_OT_change_effect_input);
00091     WM_operatortype_append(SEQUENCER_OT_change_effect_type);
00092     WM_operatortype_append(SEQUENCER_OT_change_path);
00093 
00094     /* sequencer_select.c */
00095     WM_operatortype_append(SEQUENCER_OT_select_all);
00096     WM_operatortype_append(SEQUENCER_OT_select);
00097     WM_operatortype_append(SEQUENCER_OT_select_more);
00098     WM_operatortype_append(SEQUENCER_OT_select_less);
00099     WM_operatortype_append(SEQUENCER_OT_select_linked_pick);
00100     WM_operatortype_append(SEQUENCER_OT_select_linked);
00101     WM_operatortype_append(SEQUENCER_OT_select_handles);
00102     WM_operatortype_append(SEQUENCER_OT_select_active_side);
00103     WM_operatortype_append(SEQUENCER_OT_select_border);
00104     WM_operatortype_append(SEQUENCER_OT_select_grouped);
00105 
00106     /* sequencer_add.c */
00107     WM_operatortype_append(SEQUENCER_OT_scene_strip_add);
00108     WM_operatortype_append(SEQUENCER_OT_movie_strip_add);
00109     WM_operatortype_append(SEQUENCER_OT_sound_strip_add);
00110     WM_operatortype_append(SEQUENCER_OT_image_strip_add);
00111     WM_operatortype_append(SEQUENCER_OT_effect_strip_add);
00112     WM_operatortype_append(SEQUENCER_OT_properties);
00113 
00114     WM_operatortype_append(SEQUENCER_OT_copy);
00115     WM_operatortype_append(SEQUENCER_OT_paste);
00116 }
00117 
00118 
00119 void sequencer_keymap(wmKeyConfig *keyconf)
00120 {
00121     wmKeyMap *keymap= WM_keymap_find(keyconf, "SequencerCommon", SPACE_SEQ, 0);
00122     wmKeyMapItem *kmi;
00123 
00124     kmi= WM_keymap_add_item(keymap, "WM_OT_context_toggle", OKEY, KM_PRESS, KM_SHIFT, 0);
00125     RNA_string_set(kmi->ptr, "data_path", "scene.sequence_editor.show_overlay");
00126 
00127     /* operators common to sequence and preview view */
00128     WM_keymap_add_item(keymap, "SEQUENCER_OT_view_toggle", TABKEY, KM_PRESS, KM_CTRL, 0);
00129 
00130     /* operators for sequence */
00131     keymap= WM_keymap_find(keyconf, "Sequencer", SPACE_SEQ, 0);
00132     
00133     WM_keymap_add_item(keymap, "SEQUENCER_OT_properties", NKEY, KM_PRESS, 0, 0);
00134     
00135     kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_all", AKEY, KM_PRESS, 0, 0);
00136         RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
00137     kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
00138         RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
00139 
00140     kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_cut", KKEY, KM_PRESS, 0, 0);
00141         RNA_enum_set(kmi->ptr, "type", SEQ_CUT_SOFT);
00142     kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_cut", KKEY, KM_PRESS, KM_SHIFT, 0);
00143         RNA_enum_set(kmi->ptr, "type", SEQ_CUT_HARD);
00144     
00145     kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, 0, 0);
00146         RNA_boolean_set(kmi->ptr, "unselected", FALSE);
00147     kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, KM_SHIFT, 0);
00148         RNA_boolean_set(kmi->ptr, "unselected", TRUE);
00149     
00150     kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT, 0);
00151         RNA_boolean_set(kmi->ptr, "unselected", FALSE);
00152     kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0);
00153         RNA_boolean_set(kmi->ptr, "unselected", TRUE);
00154 
00155     WM_keymap_add_item(keymap, "SEQUENCER_OT_lock", LKEY, KM_PRESS, KM_SHIFT, 0);
00156     WM_keymap_add_item(keymap, "SEQUENCER_OT_unlock", LKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0);
00157 
00158     WM_keymap_add_item(keymap, "SEQUENCER_OT_reassign_inputs", RKEY, KM_PRESS, 0, 0);
00159     WM_keymap_add_item(keymap, "SEQUENCER_OT_reload", RKEY, KM_PRESS, KM_ALT, 0);
00160 
00161     WM_keymap_add_item(keymap, "SEQUENCER_OT_offset_clear", OKEY, KM_PRESS, KM_ALT, 0);
00162 
00163     WM_keymap_add_item(keymap, "SEQUENCER_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
00164 
00165     WM_keymap_add_item(keymap, "SEQUENCER_OT_delete", XKEY, KM_PRESS, 0, 0);
00166     WM_keymap_add_item(keymap, "SEQUENCER_OT_delete", DELKEY, KM_PRESS, 0, 0);
00167     
00168     WM_keymap_add_item(keymap, "SEQUENCER_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0);
00169     WM_keymap_add_item(keymap, "SEQUENCER_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0);
00170 
00171     WM_keymap_add_item(keymap, "SEQUENCER_OT_images_separate", YKEY, KM_PRESS, 0, 0);
00172 
00173     WM_keymap_add_item(keymap, "SEQUENCER_OT_meta_toggle", TABKEY, KM_PRESS, 0, 0);
00174 
00175     WM_keymap_add_item(keymap, "SEQUENCER_OT_meta_make", GKEY, KM_PRESS, KM_CTRL, 0);
00176     WM_keymap_add_item(keymap, "SEQUENCER_OT_meta_separate", GKEY, KM_PRESS, KM_ALT, 0);
00177 
00178     WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
00179     WM_keymap_add_item(keymap, "SEQUENCER_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
00180 
00181     WM_keymap_add_item(keymap, "SEQUENCER_OT_next_edit", PAGEUPKEY, KM_PRESS, 0, 0);
00182     WM_keymap_add_item(keymap, "SEQUENCER_OT_previous_edit", PAGEDOWNKEY, KM_PRESS, 0, 0);
00183 
00184     RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_swap", LEFTARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "side", SEQ_SIDE_LEFT);
00185     RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_swap", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "side", SEQ_SIDE_RIGHT);
00186     
00187     WM_keymap_add_item(keymap, "SEQUENCER_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0);
00188     WM_keymap_add_item(keymap, "SEQUENCER_OT_swap_inputs", SKEY, KM_PRESS, KM_ALT, 0);
00189 
00190     /* multicam editing keyboard layout, switch to camera 1-10 using
00191        regular number keys */
00192     {
00193         int keys[] = { ONEKEY, TWOKEY, THREEKEY, FOURKEY, FIVEKEY,
00194                        SIXKEY, SEVENKEY, EIGHTKEY, NINEKEY, ZEROKEY };
00195         int i;
00196 
00197         for (i = 1; i <= 10; i++) {
00198             RNA_int_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_cut_multicam", keys[i-1], KM_PRESS, 0, 0)->ptr, "camera", i);
00199         }
00200     }
00201 
00202     /* Mouse selection, a bit verbose :/ */
00203     kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
00204         RNA_boolean_set(kmi->ptr, "extend", FALSE);
00205         RNA_boolean_set(kmi->ptr, "linked_handle", FALSE);
00206         RNA_boolean_set(kmi->ptr, "left_right", FALSE);
00207         RNA_boolean_set(kmi->ptr, "linked_time", FALSE);
00208     kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0);
00209         RNA_boolean_set(kmi->ptr, "extend", TRUE);
00210         RNA_boolean_set(kmi->ptr, "linked_handle", FALSE);
00211         RNA_boolean_set(kmi->ptr, "left_right", FALSE);
00212         RNA_boolean_set(kmi->ptr, "linked_time", FALSE);
00213 
00214 
00215     /* 2.4x method, now use Alt for handles and select the side based on which handle was selected */
00216     /*
00217     kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
00218     RNA_boolean_set(kmi->ptr, "linked_left", TRUE);
00219     kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0);
00220     RNA_boolean_set(kmi->ptr, "linked_right", TRUE);
00221     
00222     kmi= WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_ALT, 0);
00223     RNA_boolean_set(kmi->ptr, "linked_left", TRUE);
00224     RNA_boolean_set(kmi->ptr, "linked_right", TRUE);
00225 
00226     kmi= WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL|KM_ALT, 0);
00227     RNA_boolean_set(kmi->ptr, "extend", TRUE);
00228     RNA_boolean_set(kmi->ptr, "linked_left", TRUE);
00229     RNA_boolean_set(kmi->ptr, "linked_right", TRUE);
00230 
00231     kmi= WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
00232     RNA_boolean_set(kmi->ptr, "extend", TRUE);
00233     RNA_boolean_set(kmi->ptr, "linked_left", TRUE);
00234 
00235     kmi= WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_ALT, 0);
00236     RNA_boolean_set(kmi->ptr, "extend", TRUE);
00237     RNA_boolean_set(kmi->ptr, "linked_right", TRUE);
00238      */
00239 
00240     /* 2.5 method, Alt and use selected handle */
00241     kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0);
00242         RNA_boolean_set(kmi->ptr, "extend", FALSE);
00243         RNA_boolean_set(kmi->ptr, "linked_handle", TRUE);
00244         RNA_boolean_set(kmi->ptr, "left_right", FALSE);
00245         RNA_boolean_set(kmi->ptr, "linked_time", FALSE);
00246 
00247     kmi= WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_ALT, 0);
00248         RNA_boolean_set(kmi->ptr, "extend", TRUE);
00249         RNA_boolean_set(kmi->ptr, "linked_handle", TRUE);
00250         RNA_boolean_set(kmi->ptr, "left_right", FALSE);
00251         RNA_boolean_set(kmi->ptr, "linked_time", FALSE);
00252 
00253     /* match action editor */
00254     kmi= WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
00255         RNA_boolean_set(kmi->ptr, "extend", FALSE);
00256         RNA_boolean_set(kmi->ptr, "linked_handle", FALSE);
00257         RNA_boolean_set(kmi->ptr, "left_right", TRUE); /* grr, these conflict - only use left_right if not over an active seq */
00258         RNA_boolean_set(kmi->ptr, "linked_time", TRUE);
00259     /* adjusted since 2.4 */
00260 
00261     kmi= WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
00262         RNA_boolean_set(kmi->ptr, "extend", TRUE);
00263         RNA_boolean_set(kmi->ptr, "linked_handle", FALSE);
00264         RNA_boolean_set(kmi->ptr, "left_right", FALSE);
00265         RNA_boolean_set(kmi->ptr, "linked_time", TRUE);
00266 
00267     WM_keymap_add_item(keymap, "SEQUENCER_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
00268     WM_keymap_add_item(keymap, "SEQUENCER_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
00269     
00270     kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_linked_pick", LKEY, KM_PRESS, 0, 0);
00271     RNA_boolean_set(kmi->ptr, "extend", FALSE);
00272     kmi = WM_keymap_add_item(keymap, "SEQUENCER_OT_select_linked_pick", LKEY, KM_PRESS, KM_SHIFT, 0);
00273     RNA_boolean_set(kmi->ptr, "extend", TRUE);
00274     
00275     WM_keymap_add_item(keymap, "SEQUENCER_OT_select_linked", LKEY, KM_PRESS, KM_CTRL, 0);
00276     
00277     WM_keymap_add_item(keymap, "SEQUENCER_OT_select_border", BKEY, KM_PRESS, 0, 0);
00278 
00279     WM_keymap_add_item(keymap, "SEQUENCER_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0);
00280 
00281     WM_keymap_add_menu(keymap, "SEQUENCER_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0);
00282 
00283     WM_keymap_add_menu(keymap, "SEQUENCER_MT_change", CKEY, KM_PRESS, 0, 0);
00284     
00285     kmi= WM_keymap_add_item(keymap, "WM_OT_context_set_int", OKEY, KM_PRESS, 0, 0);
00286     RNA_string_set(kmi->ptr, "data_path", "scene.sequence_editor.overlay_frame");
00287     RNA_int_set(kmi->ptr, "value", 0);
00288 
00289     transform_keymap_for_space(keyconf, keymap, SPACE_SEQ);
00290 
00291     keymap= WM_keymap_find(keyconf, "SequencerPreview", SPACE_SEQ, 0);
00292     WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all_preview", HOMEKEY, KM_PRESS, 0, 0);
00293     WM_keymap_add_item(keymap, "SEQUENCER_OT_properties", NKEY, KM_PRESS, 0, 0);
00294 
00295     WM_keymap_add_item(keymap, "SEQUENCER_OT_view_ghost_border", OKEY, KM_PRESS, 0, 0);
00296 
00297     /* would prefer to use numpad keys for job */
00298     RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD1, KM_PRESS, 0, 0)->ptr, "ratio", 1.0f);
00299     
00300     /* Setting zoom levels is not that useful, except for back to zoom level 1, removing keymap because of conflicts for now */
00301 #if 0
00302     RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD8, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 8.0f);
00303     RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD4, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 4.0f);
00304     RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD2, KM_PRESS, KM_SHIFT, 0)->ptr, "ratio", 2.0f);
00305     
00306     RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD2, KM_PRESS, 0, 0)->ptr, "ratio", 0.5f);
00307     RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD4, KM_PRESS, 0, 0)->ptr, "ratio", 0.25f);
00308     RNA_float_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom_ratio", PAD8, KM_PRESS, 0, 0)->ptr, "ratio", 0.125f);
00309 #endif
00310 
00311 }
00312