Blender V4.3
mask_edit.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2012 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include "BKE_context.hh"
10#include "BKE_mask.h"
11
12#include "DNA_scene_types.h"
13
14#include "WM_api.hh"
15#include "WM_types.hh"
16
17#include "ED_clip.hh"
18#include "ED_image.hh"
19#include "ED_mask.hh" /* own include */
20#include "ED_sequencer.hh"
21
22#include "RNA_access.hh"
23
24#include "mask_intern.hh" /* own include */
25
26/* -------------------------------------------------------------------- */
31{
32 ScrArea *area = CTX_wm_area(C);
33 if (area) {
34 switch (area->spacetype) {
35 case SPACE_CLIP:
37 case SPACE_SEQ:
39 case SPACE_IMAGE:
41 }
42 }
43 return false;
44}
45
47{
48 ScrArea *area = CTX_wm_area(C);
49 if (area) {
50 switch (area->spacetype) {
51 case SPACE_CLIP:
53 case SPACE_SEQ:
55 case SPACE_IMAGE:
57 }
58 }
59 return false;
60}
61
63{
64 ScrArea *area = CTX_wm_area(C);
65 if (area) {
66 switch (area->spacetype) {
67 case SPACE_CLIP:
69 case SPACE_SEQ:
71 case SPACE_IMAGE:
73 }
74 }
75 return false;
76}
77
79{
80 const ScrArea *area = CTX_wm_area(C);
81 if (area) {
82 switch (area->spacetype) {
83 case SPACE_CLIP:
85 case SPACE_SEQ:
87 case SPACE_IMAGE:
89 }
90 }
91 return false;
92}
93
96/* -------------------------------------------------------------------- */
101{
103
104 /* mask layers */
107
108 /* add */
113
114 /* geometry */
118
119 /* select */
129
130 /* hide/reveal */
133
134 /* feather */
136
137 /* shape */
142
143 /* relationships */
146
147 /* Shape-keys. */
152
153 /* layers */
155
156 /* duplicate */
158
159 /* clipboard */
162}
163
165{
166 wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Mask Editing", SPACE_EMPTY, RGN_TYPE_WINDOW);
167 keymap->poll = ED_maskedit_poll;
168}
169
171{
173 wmOperatorTypeMacro *otmacro;
174
175 ot = WM_operatortype_append_macro("MASK_OT_add_vertex_slide",
176 "Add Vertex and Slide",
177 "Add new vertex and slide it",
179 ot->description = "Add new vertex and slide it";
180 WM_operatortype_macro_define(ot, "MASK_OT_add_vertex");
181 otmacro = WM_operatortype_macro_define(ot, "MASK_OT_slide_point");
182 RNA_boolean_set(otmacro->ptr, "is_new_point", true);
183
184 ot = WM_operatortype_append_macro("MASK_OT_add_feather_vertex_slide",
185 "Add Feather Vertex and Slide",
186 "Add new vertex to feather and slide it",
188 ot->description = "Add new feather vertex and slide it";
189 WM_operatortype_macro_define(ot, "MASK_OT_add_feather_vertex");
190 otmacro = WM_operatortype_macro_define(ot, "MASK_OT_slide_point");
191 RNA_boolean_set(otmacro->ptr, "slide_feather", true);
192
193 ot = WM_operatortype_append_macro("MASK_OT_duplicate_move",
194 "Add Duplicate",
195 "Duplicate mask and move",
197 WM_operatortype_macro_define(ot, "MASK_OT_duplicate");
198 otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
199 RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
200 RNA_boolean_set(otmacro->ptr, "mirror", false);
201}
202
205/* -------------------------------------------------------------------- */
210{
211 SpaceClip *space_clip = CTX_wm_space_clip(C);
212 if (space_clip != nullptr) {
213 ED_clip_view_lock_state_store(C, &state->space_clip_state);
214 }
215}
216
218{
219 SpaceClip *space_clip = CTX_wm_space_clip(C);
220 if (space_clip != nullptr) {
221 if ((space_clip->flag & SC_LOCK_SELECTION) == 0) {
222 /* Early output if the editor is not locked to selection.
223 * Avoids forced dependency graph evaluation here. */
224 return;
225 }
226
227 /* Mask's lock-to-selection requires deformed splines to be evaluated to calculate bounds of
228 * points after animation has been evaluated. The restore-no-jump type of function does
229 * calculation of new offset for the view for an updated state of mask to cancel the offset out
230 * by modifying locked offset. In order to do such calculation mask needs to be evaluated after
231 * modification by an operator. */
233 (void)depsgraph;
234
235 ED_clip_view_lock_state_restore_no_jump(C, &state->space_clip_state);
236 }
237}
238
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
ScrArea * CTX_wm_area(const bContext *C)
SpaceClip * CTX_wm_space_clip(const bContext *C)
@ RGN_TYPE_WINDOW
@ SPACE_CLIP
@ SPACE_SEQ
@ SPACE_EMPTY
@ SPACE_IMAGE
@ SC_LOCK_SELECTION
void ED_clip_view_lock_state_restore_no_jump(const bContext *C, const ClipViewLockState *state)
bool ED_space_clip_maskedit_visible_splines_poll(bContext *C)
bool ED_space_clip_maskedit_poll(bContext *C)
bool ED_space_clip_maskedit_mask_poll(bContext *C)
void ED_clip_view_lock_state_store(const bContext *C, ClipViewLockState *state)
bool ED_space_clip_maskedit_mask_visible_splines_poll(bContext *C)
bool ED_space_image_maskedit_visible_splines_poll(bContext *C)
bool ED_space_image_maskedit_mask_visible_splines_poll(bContext *C)
bool ED_space_image_maskedit_mask_poll(bContext *C)
bool ED_space_image_maskedit_poll(bContext *C)
bool ED_space_sequencer_maskedit_poll(bContext *C)
bool ED_space_sequencer_maskedit_mask_poll(bContext *C)
@ OPTYPE_UNDO
Definition WM_types.hh:162
@ OPTYPE_REGISTER
Definition WM_types.hh:160
const Depsgraph * depsgraph
void MASK_OT_add_feather_vertex(wmOperatorType *ot)
Definition mask_add.cc:679
void MASK_OT_primitive_square_add(wmOperatorType *ot)
Definition mask_add.cc:898
void MASK_OT_primitive_circle_add(wmOperatorType *ot)
Definition mask_add.cc:863
void MASK_OT_add_vertex(wmOperatorType *ot)
Definition mask_add.cc:582
void ED_operatormacros_mask()
Definition mask_edit.cc:170
void ED_keymap_mask(wmKeyConfig *keyconf)
Definition mask_edit.cc:164
void ED_mask_view_lock_state_restore_no_jump(const bContext *C, const MaskViewLockState *state)
Definition mask_edit.cc:217
void ED_operatortypes_mask()
Definition mask_edit.cc:100
bool ED_maskedit_visible_splines_poll(bContext *C)
Definition mask_edit.cc:46
bool ED_maskedit_mask_poll(bContext *C)
Definition mask_edit.cc:62
bool ED_maskedit_poll(bContext *C)
Definition mask_edit.cc:30
bool ED_maskedit_mask_visible_splines_poll(bContext *C)
Definition mask_edit.cc:78
void ED_mask_view_lock_state_store(const bContext *C, MaskViewLockState *state)
Definition mask_edit.cc:209
void MASK_OT_select_circle(wmOperatorType *ot)
void MASK_OT_slide_spline_curvature(wmOperatorType *ot)
Definition mask_ops.cc:1309
void MASK_OT_copy_splines(wmOperatorType *ot)
Definition mask_ops.cc:2132
void MASK_OT_layer_move(wmOperatorType *ot)
Definition mask_ops.cc:1952
void MASK_OT_select_more(wmOperatorType *ot)
void MASK_OT_feather_weight_clear(wmOperatorType *ot)
Definition mask_ops.cc:1883
void MASK_OT_layer_remove(wmOperatorType *ot)
Definition mask_ops.cc:180
void MASK_OT_shape_key_insert(wmOperatorType *ot)
void MASK_OT_paste_splines(wmOperatorType *ot)
Definition mask_ops.cc:2176
void MASK_OT_select(wmOperatorType *ot)
void MASK_OT_shape_key_feather_reset(wmOperatorType *ot)
void MASK_OT_layer_new(wmOperatorType *ot)
Definition mask_ops.cc:145
void MASK_OT_parent_clear(wmOperatorType *ot)
void MASK_OT_shape_key_rekey(wmOperatorType *ot)
void MASK_OT_shape_key_clear(wmOperatorType *ot)
void MASK_OT_select_less(wmOperatorType *ot)
void MASK_OT_select_linked(wmOperatorType *ot)
void MASK_OT_select_box(wmOperatorType *ot)
void MASK_OT_hide_view_clear(wmOperatorType *ot)
Definition mask_ops.cc:1770
void MASK_OT_new(wmOperatorType *ot)
Definition mask_ops.cc:109
void MASK_OT_handle_type_set(wmOperatorType *ot)
Definition mask_ops.cc:1717
void MASK_OT_select_all(wmOperatorType *ot)
void MASK_OT_select_lasso(wmOperatorType *ot)
void MASK_OT_duplicate(wmOperatorType *ot)
Definition mask_ops.cc:2101
void MASK_OT_cyclic_toggle(wmOperatorType *ot)
Definition mask_ops.cc:1349
void MASK_OT_delete(wmOperatorType *ot)
Definition mask_ops.cc:1525
void MASK_OT_hide_view_set(wmOperatorType *ot)
Definition mask_ops.cc:1831
void MASK_OT_slide_point(wmOperatorType *ot)
Definition mask_ops.cc:914
void MASK_OT_switch_direction(wmOperatorType *ot)
Definition mask_ops.cc:1585
void MASK_OT_normals_make_consistent(wmOperatorType *ot)
Definition mask_ops.cc:1647
void MASK_OT_parent_set(wmOperatorType *ot)
void MASK_OT_select_linked_pick(wmOperatorType *ot)
static ulong state[N]
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
bool(* poll)(struct bContext *)
const char * description
Definition WM_types.hh:996
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)