Blender V5.3
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
25namespace blender {
26
27/* ************************** poll callbacks for operators **********************************/
28
30{
31 Scene *scene;
32
33 /* for now, we check 2 things:
34 * 1) active editor must be NLA
35 * 2) tweak-mode is currently set as a 'per-scene' flag
36 * so that it will affect entire NLA data-sets,
37 * but not all AnimData blocks will be in tweak-mode for various reasons.
38 */
39 if (ED_operator_nla_active(C) == 0) {
40 return false;
41 }
42
43 scene = CTX_data_scene(C);
44 if ((scene == nullptr) || (scene->flag & SCE_NLA_EDIT_ON)) {
45 return false;
46 }
47
48 return true;
49}
51{
52 const ARegion *region = CTX_wm_region(C);
53 if (!(region && region->regiontype == RGN_TYPE_WINDOW)) {
54 return false;
55 }
57}
58
60{
61 Scene *scene;
62
63 /* for now, we check 2 things:
64 * 1) active editor must be NLA
65 * 2) tweak-mode is currently set as a 'per-scene' flag
66 * so that it will affect entire NLA data-sets,
67 * but not all AnimData blocks will be in tweak-mode for various reasons.
68 */
69 if (ED_operator_nla_active(C) == 0) {
70 return false;
71 }
72
73 scene = CTX_data_scene(C);
74 if ((scene == nullptr) || !(scene->flag & SCE_NLA_EDIT_ON)) {
75 return false;
76 }
77
78 return true;
79}
80
82{
83 if (ac && ac->scene) {
84 return (ac->scene->flag & SCE_NLA_EDIT_ON) != 0;
85 }
86 return false;
87}
88
89/* ************************** registration - operator types **********************************/
90
92{
93 /* channels */
95
98
101
103
104 /* select */
109
110 /* view */
114
116
117 /* edit */
120
124
127
131
133
137
139
141
144
146
150}
151
153{
154 wmOperatorType *ot;
155 wmOperatorTypeMacro *otmacro;
156
158 "NLA_OT_duplicate_move",
159 "Duplicate",
160 "Duplicate selected NLA-Strips, adding the new strips to new track(s)",
162 otmacro = WM_operatortype_macro_define(ot, "NLA_OT_duplicate");
163 RNA_boolean_set(otmacro->ptr, "linked", false);
164 WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
165
167 "NLA_OT_duplicate_linked_move",
168 "Duplicate Linked",
169 "Duplicate Linked selected NLA-Strips, adding the new strips to new track(s)",
171
172 otmacro = WM_operatortype_macro_define(ot, "NLA_OT_duplicate");
173 RNA_boolean_set(otmacro->ptr, "linked", true);
174 WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
175}
176
177/* ************************** registration - keymaps **********************************/
178
180{
181 /* keymap for all regions ------------------------------------------- */
182 WM_keymap_ensure(keyconf, "NLA Generic", SPACE_NLA, RGN_TYPE_WINDOW);
183
184 /* channels ---------------------------------------------------------- */
185 /* Channels are not directly handled by the NLA Editor module, but are inherited from the
186 * animation module. Most of the relevant operations, keymaps, drawing, etc. can therefore all
187 * be found in that module instead, as there are many similarities with the other
188 * animation editors.
189 *
190 * However, those operations which involve clicking on channels and/or
191 * the placement of them in the view are implemented here instead
192 */
193 WM_keymap_ensure(keyconf, "NLA Tracks", SPACE_NLA, RGN_TYPE_WINDOW);
194
195 /* data ------------------------------------------------------------- */
196 WM_keymap_ensure(keyconf, "NLA Editor", SPACE_NLA, RGN_TYPE_WINDOW);
197}
198
199} // namespace blender
#define C
Definition RandGen.cpp:29
BMesh Iterators.
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))
void NLA_OT_delete(wmOperatorType *ot)
Definition nla_edit.cc:1328
void NLA_OT_transition_add(wmOperatorType *ot)
Definition nla_edit.cc:886
void NLA_OT_action_unlink(wmOperatorType *ot)
void NLA_OT_previewrange_set(wmOperatorType *ot)
Definition nla_edit.cc:413
bool ED_operator_nla_active(bContext *C)
void NLA_OT_fmodifier_paste(wmOperatorType *ot)
Definition nla_edit.cc:2816
bool nlaedit_is_tweakmode_on(bAnimContext *ac)
Definition nla_ops.cc:81
void NLA_OT_move_down(wmOperatorType *ot)
Definition nla_edit.cc:1931
wmOperatorTypeMacro * WM_operatortype_macro_define(wmOperatorType *ot, const char *idname)
void NLA_OT_select_box(wmOperatorType *ot)
void NLA_OT_mute_toggle(wmOperatorType *ot)
Definition nla_edit.cc:1560
void NLA_OT_split(wmOperatorType *ot)
Definition nla_edit.cc:1491
void NLA_OT_tracks_delete(wmOperatorType *ot)
bool nlaop_poll_tweakmode_off_with_main_region(bContext *C)
Definition nla_ops.cc:50
void NLA_OT_view_all(wmOperatorType *ot)
Definition nla_edit.cc:550
void NLA_OT_actionclip_add(wmOperatorType *ot)
Definition nla_edit.cc:746
void NLA_OT_channels_click(wmOperatorType *ot)
void NLA_OT_meta_add(wmOperatorType *ot)
Definition nla_edit.cc:1051
void NLA_OT_tweakmode_exit(wmOperatorType *ot)
Definition nla_edit.cc:293
void NLA_OT_fmodifier_copy(wmOperatorType *ot)
Definition nla_edit.cc:2723
void NLA_OT_selected_objects_add(wmOperatorType *ot)
bool nlaop_poll_tweakmode_on(bContext *C)
Definition nla_ops.cc:59
void NLA_OT_snap(wmOperatorType *ot)
Definition nla_edit.cc:2498
void NLA_OT_move_up(wmOperatorType *ot)
Definition nla_edit.cc:1840
void NLA_OT_tweakmode_enter(wmOperatorType *ot)
Definition nla_edit.cc:183
void NLA_OT_fmodifier_add(wmOperatorType *ot)
Definition nla_edit.cc:2640
void NLA_OT_soundclip_add(wmOperatorType *ot)
Definition nla_edit.cc:976
wmKeyMap * WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
Definition wm_keymap.cc:935
void NLA_OT_select_all(wmOperatorType *ot)
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
void NLA_OT_swap(wmOperatorType *ot)
Definition nla_edit.cc:1749
void NLA_OT_select_leftright(wmOperatorType *ot)
void NLA_OT_apply_scale(wmOperatorType *ot)
Definition nla_edit.cc:2269
wmOperatorType * WM_operatortype_append_macro(const char *idname, const char *name, const char *description, int flag)
void NLA_OT_make_single_user(wmOperatorType *ot)
Definition nla_edit.cc:2128
void NLA_OT_duplicate(wmOperatorType *ot)
Definition nla_edit.cc:1230
void NLA_OT_action_pushdown(wmOperatorType *ot)
void NLA_OT_click_select(wmOperatorType *ot)
void nla_keymap(wmKeyConfig *keyconf)
Definition nla_ops.cc:179
void NLA_OT_tracks_add(wmOperatorType *ot)
void NLA_OT_view_frame(wmOperatorType *ot)
Definition nla_edit.cc:593
void NLA_OT_meta_remove(wmOperatorType *ot)
Definition nla_edit.cc:1116
void NLA_OT_action_sync_length(wmOperatorType *ot)
Definition nla_edit.cc:2015
Scene * CTX_data_scene(const bContext *C)
bool nlaop_poll_tweakmode_off(bContext *C)
Definition nla_ops.cc:29
void ED_operatormacros_nla()
Definition nla_ops.cc:152
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
void NLA_OT_clear_scale(wmOperatorType *ot)
Definition nla_edit.cc:2335
void NLA_OT_view_selected(wmOperatorType *ot)
Definition nla_edit.cc:565
ARegion * CTX_wm_region(const bContext *C)
void nla_operatortypes()
Definition nla_ops.cc:91
eRegion_Type regiontype