Blender  V2.93
nla_ops.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung
17  * All rights reserved.
18  */
19 
24 #include <stdio.h>
25 #include <string.h>
26 
27 #include "DNA_scene_types.h"
28 
29 #include "BKE_context.h"
30 #include "BKE_screen.h"
31 
32 #include "ED_anim_api.h"
33 #include "ED_screen.h"
34 
35 #include "WM_api.h"
36 #include "WM_types.h"
37 
38 #include "nla_intern.h" /* own include */
39 
40 /* ************************** poll callbacks for operators **********************************/
41 
42 /* tweakmode is NOT enabled */
44 {
45  Scene *scene;
46 
47  /* for now, we check 2 things:
48  * 1) active editor must be NLA
49  * 2) tweakmode is currently set as a 'per-scene' flag
50  * so that it will affect entire NLA data-sets,
51  * but not all AnimData blocks will be in tweakmode for
52  * various reasons
53  */
54  if (ED_operator_nla_active(C) == 0) {
55  return 0;
56  }
57 
59  if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON)) {
60  return 0;
61  }
62 
63  return 1;
64 }
65 
66 /* tweakmode IS enabled */
68 {
69  Scene *scene;
70 
71  /* for now, we check 2 things:
72  * 1) active editor must be NLA
73  * 2) tweakmode is currently set as a 'per-scene' flag
74  * so that it will affect entire NLA data-sets,
75  * but not all AnimData blocks will be in tweakmode for
76  * various reasons
77  */
78  if (ED_operator_nla_active(C) == 0) {
79  return 0;
80  }
81 
83  if ((scene == NULL) || !(scene->flag & SCE_NLA_EDIT_ON)) {
84  return 0;
85  }
86 
87  return 1;
88 }
89 
90 /* is tweakmode enabled - for use in NLA operator code */
92 {
93  if (ac && ac->scene) {
94  return (ac->scene->flag & SCE_NLA_EDIT_ON) != 0;
95  }
96  return 0;
97 }
98 
99 /* ************************** registration - operator types **********************************/
100 
102 {
103  /* channels */
105 
108 
111 
113 
114  /* select */
119 
120  /* view */
124 
126 
127  /* edit */
130 
134 
137 
141 
143 
147 
149 
151 
154 
156 
160 }
161 
162 /* ************************** registration - keymaps **********************************/
163 
164 void nla_keymap(wmKeyConfig *keyconf)
165 {
166  /* keymap for all regions ------------------------------------------- */
167  WM_keymap_ensure(keyconf, "NLA Generic", SPACE_NLA, 0);
168 
169  /* channels ---------------------------------------------------------- */
170  /* Channels are not directly handled by the NLA Editor module, but are inherited from the
171  * animation module. Most of the relevant operations, keymaps, drawing, etc. can therefore all
172  * be found in that module instead, as there are many similarities with the other
173  * animation editors.
174  *
175  * However, those operations which involve clicking on channels and/or
176  * the placement of them in the view are implemented here instead
177  */
178  WM_keymap_ensure(keyconf, "NLA Channels", SPACE_NLA, 0);
179 
180  /* data ------------------------------------------------------------- */
181  WM_keymap_ensure(keyconf, "NLA Editor", SPACE_NLA, 0);
182 }
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1034
#define SCE_NLA_EDIT_ON
@ SPACE_NLA
bool ED_operator_nla_active(struct bContext *C)
Definition: screen_ops.c:334
#define C
Definition: RandGen.cpp:39
Scene scene
void NLA_OT_selected_objects_add(wmOperatorType *ot)
Definition: nla_channels.c:889
void NLA_OT_tracks_delete(wmOperatorType *ot)
Definition: nla_channels.c:833
void NLA_OT_tracks_add(wmOperatorType *ot)
Definition: nla_channels.c:753
void NLA_OT_action_unlink(wmOperatorType *ot)
Definition: nla_channels.c:606
void NLA_OT_channels_click(wmOperatorType *ot)
Definition: nla_channels.c:413
void NLA_OT_action_pushdown(wmOperatorType *ot)
Definition: nla_channels.c:533
void NLA_OT_view_frame(wmOperatorType *ot)
Definition: nla_edit.c:585
void NLA_OT_view_all(wmOperatorType *ot)
Definition: nla_edit.c:542
void NLA_OT_fmodifier_add(wmOperatorType *ot)
Definition: nla_edit.c:2599
void NLA_OT_split(wmOperatorType *ot)
Definition: nla_edit.c:1484
void NLA_OT_tweakmode_exit(wmOperatorType *ot)
Definition: nla_edit.c:283
void NLA_OT_soundclip_add(wmOperatorType *ot)
Definition: nla_edit.c:964
void NLA_OT_tweakmode_enter(wmOperatorType *ot)
Definition: nla_edit.c:176
void NLA_OT_clear_scale(wmOperatorType *ot)
Definition: nla_edit.c:2292
void NLA_OT_make_single_user(wmOperatorType *ot)
Definition: nla_edit.c:2103
void NLA_OT_meta_add(wmOperatorType *ot)
Definition: nla_edit.c:1041
void NLA_OT_meta_remove(wmOperatorType *ot)
Definition: nla_edit.c:1107
void NLA_OT_snap(wmOperatorType *ot)
Definition: nla_edit.c:2455
void NLA_OT_swap(wmOperatorType *ot)
Definition: nla_edit.c:1737
void NLA_OT_mute_toggle(wmOperatorType *ot)
Definition: nla_edit.c:1555
void NLA_OT_move_up(wmOperatorType *ot)
Definition: nla_edit.c:1828
void NLA_OT_delete(wmOperatorType *ot)
Definition: nla_edit.c:1323
void NLA_OT_previewrange_set(wmOperatorType *ot)
Definition: nla_edit.c:405
void NLA_OT_fmodifier_copy(wmOperatorType *ot)
Definition: nla_edit.c:2681
void NLA_OT_move_down(wmOperatorType *ot)
Definition: nla_edit.c:1919
void NLA_OT_transition_add(wmOperatorType *ot)
Definition: nla_edit.c:870
void NLA_OT_view_selected(wmOperatorType *ot)
Definition: nla_edit.c:557
void NLA_OT_duplicate(wmOperatorType *ot)
Definition: nla_edit.c:1226
void NLA_OT_actionclip_add(wmOperatorType *ot)
Definition: nla_edit.c:729
void NLA_OT_fmodifier_paste(wmOperatorType *ot)
Definition: nla_edit.c:2776
void NLA_OT_action_sync_length(wmOperatorType *ot)
Definition: nla_edit.c:2005
void NLA_OT_apply_scale(wmOperatorType *ot)
Definition: nla_edit.c:2222
void NLA_OT_select_box(wmOperatorType *ot)
Definition: nla_select.c:402
void NLA_OT_click_select(wmOperatorType *ot)
Definition: nla_select.c:711
void NLA_OT_select_leftright(wmOperatorType *ot)
Definition: nla_select.c:571
void NLA_OT_select_all(wmOperatorType *ot)
Definition: nla_select.c:192
bool nlaop_poll_tweakmode_on(bContext *C)
Definition: nla_ops.c:67
bool nlaedit_is_tweakmode_on(bAnimContext *ac)
Definition: nla_ops.c:91
void nla_keymap(wmKeyConfig *keyconf)
Definition: nla_ops.c:164
bool nlaop_poll_tweakmode_off(bContext *C)
Definition: nla_ops.c:43
void nla_operatortypes(void)
Definition: nla_ops.c:101
short flag
struct Scene * scene
Definition: ED_anim_api.h:97
wmKeyMap * WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
Definition: wm_keymap.c:852
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))