Blender  V3.3
nla_ops.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2009 Blender Foundation, Joshua Leung. All rights reserved. */
3 
8 #include <stdio.h>
9 #include <string.h>
10 
11 #include "DNA_scene_types.h"
12 
13 #include "BKE_context.h"
14 #include "BKE_screen.h"
15 
16 #include "ED_anim_api.h"
17 #include "ED_screen.h"
18 
19 #include "RNA_access.h"
20 
21 #include "WM_api.h"
22 #include "WM_types.h"
23 
24 #include "nla_intern.h" /* own include */
25 
26 /* ************************** poll callbacks for operators **********************************/
27 
29 {
30  Scene *scene;
31 
32  /* for now, we check 2 things:
33  * 1) active editor must be NLA
34  * 2) tweak-mode is currently set as a 'per-scene' flag
35  * so that it will affect entire NLA data-sets,
36  * but not all AnimData blocks will be in tweak-mode for various reasons.
37  */
38  if (ED_operator_nla_active(C) == 0) {
39  return 0;
40  }
41 
43  if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON)) {
44  return 0;
45  }
46 
47  return 1;
48 }
49 
51 {
52  Scene *scene;
53 
54  /* for now, we check 2 things:
55  * 1) active editor must be NLA
56  * 2) tweak-mode is currently set as a 'per-scene' flag
57  * so that it will affect entire NLA data-sets,
58  * but not all AnimData blocks will be in tweak-mode for various reasons.
59  */
60  if (ED_operator_nla_active(C) == 0) {
61  return 0;
62  }
63 
65  if ((scene == NULL) || !(scene->flag & SCE_NLA_EDIT_ON)) {
66  return 0;
67  }
68 
69  return 1;
70 }
71 
73 {
74  if (ac && ac->scene) {
75  return (ac->scene->flag & SCE_NLA_EDIT_ON) != 0;
76  }
77  return 0;
78 }
79 
80 /* ************************** registration - operator types **********************************/
81 
83 {
84  /* channels */
86 
89 
92 
94 
95  /* select */
100 
101  /* view */
105 
107 
108  /* edit */
111 
115 
118 
122 
124 
128 
130 
132 
135 
137 
141 }
142 
144 {
146  wmOperatorTypeMacro *otmacro;
147 
148  ot = WM_operatortype_append_macro("NLA_OT_duplicate_move",
149  "Duplicate",
150  "Duplicate selected strips and their Actions and move them",
152  otmacro = WM_operatortype_macro_define(ot, "NLA_OT_duplicate");
153  RNA_boolean_set(otmacro->ptr, "linked", false);
154  WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
155 
156  ot = WM_operatortype_append_macro("NLA_OT_duplicate_linked_move",
157  "Duplicate Linked",
158  "Duplicate selected strips and move them",
160  otmacro = WM_operatortype_macro_define(ot, "NLA_OT_duplicate");
161  RNA_boolean_set(otmacro->ptr, "linked", true);
162  WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
163 }
164 
165 /* ************************** registration - keymaps **********************************/
166 
167 void nla_keymap(wmKeyConfig *keyconf)
168 {
169  /* keymap for all regions ------------------------------------------- */
170  WM_keymap_ensure(keyconf, "NLA Generic", SPACE_NLA, 0);
171 
172  /* channels ---------------------------------------------------------- */
173  /* Channels are not directly handled by the NLA Editor module, but are inherited from the
174  * animation module. Most of the relevant operations, keymaps, drawing, etc. can therefore all
175  * be found in that module instead, as there are many similarities with the other
176  * animation editors.
177  *
178  * However, those operations which involve clicking on channels and/or
179  * the placement of them in the view are implemented here instead
180  */
181  WM_keymap_ensure(keyconf, "NLA Channels", SPACE_NLA, 0);
182 
183  /* data ------------------------------------------------------------- */
184  WM_keymap_ensure(keyconf, "NLA Editor", SPACE_NLA, 0);
185 }
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1090
#define SCE_NLA_EDIT_ON
@ SPACE_NLA
bool ED_operator_nla_active(struct bContext *C)
Definition: screen_ops.c:349
#define C
Definition: RandGen.cpp:25
@ OPTYPE_UNDO
Definition: WM_types.h:148
@ OPTYPE_REGISTER
Definition: WM_types.h:146
Scene scene
void NLA_OT_selected_objects_add(wmOperatorType *ot)
Definition: nla_channels.c:811
void NLA_OT_tracks_delete(wmOperatorType *ot)
Definition: nla_channels.c:755
void NLA_OT_tracks_add(wmOperatorType *ot)
Definition: nla_channels.c:675
void NLA_OT_action_unlink(wmOperatorType *ot)
Definition: nla_channels.c:530
void NLA_OT_channels_click(wmOperatorType *ot)
Definition: nla_channels.c:336
void NLA_OT_action_pushdown(wmOperatorType *ot)
Definition: nla_channels.c:457
void NLA_OT_view_frame(wmOperatorType *ot)
Definition: nla_edit.c:583
void NLA_OT_view_all(wmOperatorType *ot)
Definition: nla_edit.c:540
void NLA_OT_fmodifier_add(wmOperatorType *ot)
Definition: nla_edit.c:2633
void NLA_OT_split(wmOperatorType *ot)
Definition: nla_edit.c:1492
void NLA_OT_tweakmode_exit(wmOperatorType *ot)
Definition: nla_edit.c:279
void NLA_OT_soundclip_add(wmOperatorType *ot)
Definition: nla_edit.c:964
void NLA_OT_tweakmode_enter(wmOperatorType *ot)
Definition: nla_edit.c:168
void NLA_OT_clear_scale(wmOperatorType *ot)
Definition: nla_edit.c:2324
void NLA_OT_make_single_user(wmOperatorType *ot)
Definition: nla_edit.c:2117
void NLA_OT_meta_add(wmOperatorType *ot)
Definition: nla_edit.c:1042
void NLA_OT_meta_remove(wmOperatorType *ot)
Definition: nla_edit.c:1109
void NLA_OT_snap(wmOperatorType *ot)
Definition: nla_edit.c:2488
void NLA_OT_swap(wmOperatorType *ot)
Definition: nla_edit.c:1747
void NLA_OT_mute_toggle(wmOperatorType *ot)
Definition: nla_edit.c:1564
void NLA_OT_move_up(wmOperatorType *ot)
Definition: nla_edit.c:1839
void NLA_OT_delete(wmOperatorType *ot)
Definition: nla_edit.c:1327
void NLA_OT_previewrange_set(wmOperatorType *ot)
Definition: nla_edit.c:402
void NLA_OT_fmodifier_copy(wmOperatorType *ot)
Definition: nla_edit.c:2716
void NLA_OT_move_down(wmOperatorType *ot)
Definition: nla_edit.c:1931
void NLA_OT_transition_add(wmOperatorType *ot)
Definition: nla_edit.c:870
void NLA_OT_view_selected(wmOperatorType *ot)
Definition: nla_edit.c:555
void NLA_OT_duplicate(wmOperatorType *ot)
Definition: nla_edit.c:1226
void NLA_OT_actionclip_add(wmOperatorType *ot)
Definition: nla_edit.c:728
void NLA_OT_fmodifier_paste(wmOperatorType *ot)
Definition: nla_edit.c:2811
void NLA_OT_action_sync_length(wmOperatorType *ot)
Definition: nla_edit.c:2018
void NLA_OT_apply_scale(wmOperatorType *ot)
Definition: nla_edit.c:2253
void NLA_OT_select_box(wmOperatorType *ot)
Definition: nla_select.c:388
void NLA_OT_click_select(wmOperatorType *ot)
Definition: nla_select.c:697
void NLA_OT_select_leftright(wmOperatorType *ot)
Definition: nla_select.c:557
void NLA_OT_select_all(wmOperatorType *ot)
Definition: nla_select.c:176
bool nlaop_poll_tweakmode_on(bContext *C)
Definition: nla_ops.c:50
bool nlaedit_is_tweakmode_on(bAnimContext *ac)
Definition: nla_ops.c:72
void nla_keymap(wmKeyConfig *keyconf)
Definition: nla_ops.c:167
bool nlaop_poll_tweakmode_off(bContext *C)
Definition: nla_ops.c:28
void ED_operatormacros_nla()
Definition: nla_ops.c:143
void nla_operatortypes(void)
Definition: nla_ops.c:82
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
Definition: rna_access.c:4874
short flag
struct Scene * scene
Definition: ED_anim_api.h:84
wmOperatorType * ot
Definition: wm_files.c:3479
wmKeyMap * WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
Definition: wm_keymap.c:852
wmOperatorType * WM_operatortype_append_macro(const char *idname, const char *name, const char *description, int flag)
wmOperatorTypeMacro * WM_operatortype_macro_define(wmOperatorType *ot, const char *idname)
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))