Blender V5.0
nla_ops.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009 Blender Authors, Joshua Leung. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstring>
10
11#include "DNA_scene_types.h"
12
13#include "BKE_context.hh"
14
15#include "ED_anim_api.hh"
16#include "ED_screen.hh"
17
18#include "RNA_access.hh"
19
20#include "WM_api.hh"
21#include "WM_types.hh"
22
23#include "nla_intern.hh" /* own include */
24
25/* ************************** poll callbacks for operators **********************************/
26
28{
29 Scene *scene;
30
31 /* for now, we check 2 things:
32 * 1) active editor must be NLA
33 * 2) tweak-mode is currently set as a 'per-scene' flag
34 * so that it will affect entire NLA data-sets,
35 * but not all AnimData blocks will be in tweak-mode for various reasons.
36 */
37 if (ED_operator_nla_active(C) == 0) {
38 return false;
39 }
40
41 scene = CTX_data_scene(C);
42 if ((scene == nullptr) || (scene->flag & SCE_NLA_EDIT_ON)) {
43 return false;
44 }
45
46 return true;
47}
48
50{
51 Scene *scene;
52
53 /* for now, we check 2 things:
54 * 1) active editor must be NLA
55 * 2) tweak-mode is currently set as a 'per-scene' flag
56 * so that it will affect entire NLA data-sets,
57 * but not all AnimData blocks will be in tweak-mode for various reasons.
58 */
59 if (ED_operator_nla_active(C) == 0) {
60 return false;
61 }
62
63 scene = CTX_data_scene(C);
64 if ((scene == nullptr) || !(scene->flag & SCE_NLA_EDIT_ON)) {
65 return false;
66 }
67
68 return true;
69}
70
72{
73 if (ac && ac->scene) {
74 return (ac->scene->flag & SCE_NLA_EDIT_ON) != 0;
75 }
76 return false;
77}
78
79/* ************************** registration - operator types **********************************/
80
82{
83 /* channels */
85
88
91
93
94 /* select */
99
100 /* view */
104
106
107 /* edit */
110
114
117
121
123
127
129
131
134
136
140}
141
143{
145 wmOperatorTypeMacro *otmacro;
146
148 "NLA_OT_duplicate_move",
149 "Duplicate",
150 "Duplicate selected NLA-Strips, adding the new strips to new track(s)",
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
157 "NLA_OT_duplicate_linked_move",
158 "Duplicate Linked",
159 "Duplicate Linked selected NLA-Strips, adding the new strips to new track(s)",
161
162 otmacro = WM_operatortype_macro_define(ot, "NLA_OT_duplicate");
163 RNA_boolean_set(otmacro->ptr, "linked", true);
164 WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
165}
166
167/* ************************** registration - keymaps **********************************/
168
170{
171 /* keymap for all regions ------------------------------------------- */
172 WM_keymap_ensure(keyconf, "NLA Generic", SPACE_NLA, RGN_TYPE_WINDOW);
173
174 /* channels ---------------------------------------------------------- */
175 /* Channels are not directly handled by the NLA Editor module, but are inherited from the
176 * animation module. Most of the relevant operations, keymaps, drawing, etc. can therefore all
177 * be found in that module instead, as there are many similarities with the other
178 * animation editors.
179 *
180 * However, those operations which involve clicking on channels and/or
181 * the placement of them in the view are implemented here instead
182 */
183 WM_keymap_ensure(keyconf, "NLA Tracks", SPACE_NLA, RGN_TYPE_WINDOW);
184
185 /* data ------------------------------------------------------------- */
186 WM_keymap_ensure(keyconf, "NLA Editor", SPACE_NLA, RGN_TYPE_WINDOW);
187}
Scene * CTX_data_scene(const bContext *C)
@ SCE_NLA_EDIT_ON
@ RGN_TYPE_WINDOW
@ SPACE_NLA
bool ED_operator_nla_active(bContext *C)
#define C
Definition RandGen.cpp:29
@ OPTYPE_UNDO
Definition WM_types.hh:182
@ OPTYPE_REGISTER
Definition WM_types.hh:180
void NLA_OT_view_frame(wmOperatorType *ot)
Definition nla_edit.cc:592
void NLA_OT_view_all(wmOperatorType *ot)
Definition nla_edit.cc:549
void NLA_OT_fmodifier_add(wmOperatorType *ot)
Definition nla_edit.cc:2649
void NLA_OT_split(wmOperatorType *ot)
Definition nla_edit.cc:1500
void NLA_OT_tweakmode_exit(wmOperatorType *ot)
Definition nla_edit.cc:290
void NLA_OT_soundclip_add(wmOperatorType *ot)
Definition nla_edit.cc:985
void NLA_OT_tweakmode_enter(wmOperatorType *ot)
Definition nla_edit.cc:180
void NLA_OT_clear_scale(wmOperatorType *ot)
Definition nla_edit.cc:2344
void NLA_OT_make_single_user(wmOperatorType *ot)
Definition nla_edit.cc:2137
void NLA_OT_meta_add(wmOperatorType *ot)
Definition nla_edit.cc:1060
void NLA_OT_meta_remove(wmOperatorType *ot)
Definition nla_edit.cc:1125
void NLA_OT_snap(wmOperatorType *ot)
Definition nla_edit.cc:2507
void NLA_OT_swap(wmOperatorType *ot)
Definition nla_edit.cc:1758
void NLA_OT_mute_toggle(wmOperatorType *ot)
Definition nla_edit.cc:1569
void NLA_OT_move_up(wmOperatorType *ot)
Definition nla_edit.cc:1849
void NLA_OT_delete(wmOperatorType *ot)
Definition nla_edit.cc:1337
void NLA_OT_previewrange_set(wmOperatorType *ot)
Definition nla_edit.cc:410
void NLA_OT_fmodifier_copy(wmOperatorType *ot)
Definition nla_edit.cc:2732
void NLA_OT_move_down(wmOperatorType *ot)
Definition nla_edit.cc:1940
void NLA_OT_transition_add(wmOperatorType *ot)
Definition nla_edit.cc:895
void NLA_OT_view_selected(wmOperatorType *ot)
Definition nla_edit.cc:564
void NLA_OT_duplicate(wmOperatorType *ot)
Definition nla_edit.cc:1239
void NLA_OT_actionclip_add(wmOperatorType *ot)
Definition nla_edit.cc:755
void NLA_OT_fmodifier_paste(wmOperatorType *ot)
Definition nla_edit.cc:2825
void NLA_OT_action_sync_length(wmOperatorType *ot)
Definition nla_edit.cc:2024
void NLA_OT_apply_scale(wmOperatorType *ot)
Definition nla_edit.cc:2278
void NLA_OT_selected_objects_add(wmOperatorType *ot)
void NLA_OT_tracks_delete(wmOperatorType *ot)
void NLA_OT_select_box(wmOperatorType *ot)
void NLA_OT_tracks_add(wmOperatorType *ot)
void NLA_OT_click_select(wmOperatorType *ot)
void NLA_OT_action_unlink(wmOperatorType *ot)
void NLA_OT_select_leftright(wmOperatorType *ot)
void NLA_OT_channels_click(wmOperatorType *ot)
void NLA_OT_action_pushdown(wmOperatorType *ot)
void NLA_OT_select_all(wmOperatorType *ot)
bool nlaop_poll_tweakmode_on(bContext *C)
Definition nla_ops.cc:49
bool nlaedit_is_tweakmode_on(bAnimContext *ac)
Definition nla_ops.cc:71
void nla_operatortypes()
Definition nla_ops.cc:81
void nla_keymap(wmKeyConfig *keyconf)
Definition nla_ops.cc:169
bool nlaop_poll_tweakmode_off(bContext *C)
Definition nla_ops.cc:27
void ED_operatormacros_nla()
Definition nla_ops.cc:142
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
wmOperatorType * ot
Definition wm_files.cc:4237
wmKeyMap * WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
Definition wm_keymap.cc:895
wmOperatorTypeMacro * WM_operatortype_macro_define(wmOperatorType *ot, const char *idname)
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))
wmOperatorType * WM_operatortype_append_macro(const char *idname, const char *name, const char *description, int flag)