Blender V4.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
9#include <cstdio>
10#include <cstring>
11
12#include "DNA_scene_types.h"
13
14#include "BKE_context.hh"
15
16#include "ED_anim_api.hh"
17#include "ED_screen.hh"
18
19#include "RNA_access.hh"
20
21#include "WM_api.hh"
22#include "WM_types.hh"
23
24#include "nla_intern.hh" /* 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 false;
40 }
41
42 scene = CTX_data_scene(C);
43 if ((scene == nullptr) || (scene->flag & SCE_NLA_EDIT_ON)) {
44 return false;
45 }
46
47 return true;
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 false;
62 }
63
64 scene = CTX_data_scene(C);
65 if ((scene == nullptr) || !(scene->flag & SCE_NLA_EDIT_ON)) {
66 return false;
67 }
68
69 return true;
70}
71
73{
74 if (ac && ac->scene) {
75 return (ac->scene->flag & SCE_NLA_EDIT_ON) != 0;
76 }
77 return false;
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
149 "NLA_OT_duplicate_move",
150 "Duplicate",
151 "Duplicate selected NLA-Strips, adding the new strips to new track(s)",
153 otmacro = WM_operatortype_macro_define(ot, "NLA_OT_duplicate");
154 RNA_boolean_set(otmacro->ptr, "linked", false);
155 WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
156
158 "NLA_OT_duplicate_linked_move",
159 "Duplicate Linked",
160 "Duplicate Linked selected NLA-Strips, adding the new strips to new track(s)",
162
163 otmacro = WM_operatortype_macro_define(ot, "NLA_OT_duplicate");
164 RNA_boolean_set(otmacro->ptr, "linked", true);
165 WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
166}
167
168/* ************************** registration - keymaps **********************************/
169
171{
172 /* keymap for all regions ------------------------------------------- */
173 WM_keymap_ensure(keyconf, "NLA Generic", SPACE_NLA, RGN_TYPE_WINDOW);
174
175 /* channels ---------------------------------------------------------- */
176 /* Channels are not directly handled by the NLA Editor module, but are inherited from the
177 * animation module. Most of the relevant operations, keymaps, drawing, etc. can therefore all
178 * be found in that module instead, as there are many similarities with the other
179 * animation editors.
180 *
181 * However, those operations which involve clicking on channels and/or
182 * the placement of them in the view are implemented here instead
183 */
184 WM_keymap_ensure(keyconf, "NLA Tracks", SPACE_NLA, RGN_TYPE_WINDOW);
185
186 /* data ------------------------------------------------------------- */
187 WM_keymap_ensure(keyconf, "NLA Editor", SPACE_NLA, RGN_TYPE_WINDOW);
188}
Scene * CTX_data_scene(const bContext *C)
@ SCE_NLA_EDIT_ON
@ RGN_TYPE_WINDOW
@ SPACE_NLA
bool ED_operator_nla_active(bContext *C)
@ OPTYPE_UNDO
Definition WM_types.hh:162
@ OPTYPE_REGISTER
Definition WM_types.hh:160
void NLA_OT_view_frame(wmOperatorType *ot)
Definition nla_edit.cc:585
void NLA_OT_view_all(wmOperatorType *ot)
Definition nla_edit.cc:542
void NLA_OT_fmodifier_add(wmOperatorType *ot)
Definition nla_edit.cc:2631
void NLA_OT_split(wmOperatorType *ot)
Definition nla_edit.cc:1489
void NLA_OT_tweakmode_exit(wmOperatorType *ot)
Definition nla_edit.cc:283
void NLA_OT_soundclip_add(wmOperatorType *ot)
Definition nla_edit.cc:976
void NLA_OT_tweakmode_enter(wmOperatorType *ot)
Definition nla_edit.cc:173
void NLA_OT_clear_scale(wmOperatorType *ot)
Definition nla_edit.cc:2326
void NLA_OT_make_single_user(wmOperatorType *ot)
Definition nla_edit.cc:2124
void NLA_OT_meta_add(wmOperatorType *ot)
Definition nla_edit.cc:1051
void NLA_OT_meta_remove(wmOperatorType *ot)
Definition nla_edit.cc:1116
void NLA_OT_snap(wmOperatorType *ot)
Definition nla_edit.cc:2489
void NLA_OT_swap(wmOperatorType *ot)
Definition nla_edit.cc:1747
void NLA_OT_mute_toggle(wmOperatorType *ot)
Definition nla_edit.cc:1558
void NLA_OT_move_up(wmOperatorType *ot)
Definition nla_edit.cc:1838
void NLA_OT_delete(wmOperatorType *ot)
Definition nla_edit.cc:1326
void NLA_OT_previewrange_set(wmOperatorType *ot)
Definition nla_edit.cc:403
void NLA_OT_fmodifier_copy(wmOperatorType *ot)
Definition nla_edit.cc:2714
void NLA_OT_move_down(wmOperatorType *ot)
Definition nla_edit.cc:1929
void NLA_OT_transition_add(wmOperatorType *ot)
Definition nla_edit.cc:886
void NLA_OT_view_selected(wmOperatorType *ot)
Definition nla_edit.cc:557
void NLA_OT_duplicate(wmOperatorType *ot)
Definition nla_edit.cc:1228
void NLA_OT_actionclip_add(wmOperatorType *ot)
Definition nla_edit.cc:746
void NLA_OT_fmodifier_paste(wmOperatorType *ot)
Definition nla_edit.cc:2807
void NLA_OT_action_sync_length(wmOperatorType *ot)
Definition nla_edit.cc:2013
void NLA_OT_apply_scale(wmOperatorType *ot)
Definition nla_edit.cc:2260
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:50
bool nlaedit_is_tweakmode_on(bAnimContext *ac)
Definition nla_ops.cc:72
void nla_operatortypes()
Definition nla_ops.cc:82
void nla_keymap(wmKeyConfig *keyconf)
Definition nla_ops.cc:170
bool nlaop_poll_tweakmode_off(bContext *C)
Definition nla_ops.cc:28
void ED_operatormacros_nla()
Definition nla_ops.cc:143
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
wmOperatorType * ot
Definition wm_files.cc:4125
wmKeyMap * WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
Definition wm_keymap.cc:897
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)