Blender  V3.3
mask_edit.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2012 Blender Foundation. All rights reserved. */
3 
8 #include "BKE_context.h"
9 #include "BKE_mask.h"
10 
11 #include "DNA_scene_types.h"
12 
13 #include "WM_api.h"
14 #include "WM_types.h"
15 
16 #include "ED_clip.h"
17 #include "ED_image.h"
18 #include "ED_mask.h" /* own include */
19 #include "ED_sequencer.h"
20 
21 #include "RNA_access.h"
22 
23 #include "mask_intern.h" /* own include */
24 
25 /* -------------------------------------------------------------------- */
30 {
32  if (area) {
33  switch (area->spacetype) {
34  case SPACE_CLIP:
36  case SPACE_SEQ:
38  case SPACE_IMAGE:
40  }
41  }
42  return false;
43 }
44 
46 {
48  if (area) {
49  switch (area->spacetype) {
50  case SPACE_CLIP:
52  case SPACE_SEQ:
54  case SPACE_IMAGE:
56  }
57  }
58  return false;
59 }
60 
62 {
64  if (area) {
65  switch (area->spacetype) {
66  case SPACE_CLIP:
68  case SPACE_SEQ:
70  case SPACE_IMAGE:
72  }
73  }
74  return false;
75 }
76 
78 {
79  const ScrArea *area = CTX_wm_area(C);
80  if (area) {
81  switch (area->spacetype) {
82  case SPACE_CLIP:
84  case SPACE_SEQ:
86  case SPACE_IMAGE:
88  }
89  }
90  return false;
91 }
92 
95 /* -------------------------------------------------------------------- */
100 {
102 
103  /* mask layers */
106 
107  /* add */
112 
113  /* geometry */
117 
118  /* select */
128 
129  /* hide/reveal */
132 
133  /* feather */
135 
136  /* shape */
141 
142  /* relationships */
145 
146  /* Shape-keys. */
151 
152  /* layers */
154 
155  /* duplicate */
157 
158  /* clipboard */
161 }
162 
164 {
165  wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Mask Editing", 0, 0);
166  keymap->poll = ED_maskedit_poll;
167 }
168 
170 {
172  wmOperatorTypeMacro *otmacro;
173 
174  ot = WM_operatortype_append_macro("MASK_OT_add_vertex_slide",
175  "Add Vertex and Slide",
176  "Add new vertex and slide it",
178  ot->description = "Add new vertex and slide it";
179  WM_operatortype_macro_define(ot, "MASK_OT_add_vertex");
180  otmacro = WM_operatortype_macro_define(ot, "MASK_OT_slide_point");
181  RNA_boolean_set(otmacro->ptr, "is_new_point", true);
182 
183  ot = WM_operatortype_append_macro("MASK_OT_add_feather_vertex_slide",
184  "Add Feather Vertex and Slide",
185  "Add new vertex to feather and slide it",
187  ot->description = "Add new feather vertex and slide it";
188  WM_operatortype_macro_define(ot, "MASK_OT_add_feather_vertex");
189  otmacro = WM_operatortype_macro_define(ot, "MASK_OT_slide_point");
190  RNA_boolean_set(otmacro->ptr, "slide_feather", true);
191 
192  ot = WM_operatortype_append_macro("MASK_OT_duplicate_move",
193  "Add Duplicate",
194  "Duplicate mask and move",
196  WM_operatortype_macro_define(ot, "MASK_OT_duplicate");
197  otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
198  RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
199  RNA_boolean_set(otmacro->ptr, "mirror", false);
200 }
201 
204 /* -------------------------------------------------------------------- */
209 {
210  SpaceClip *space_clip = CTX_wm_space_clip(C);
211  if (space_clip != NULL) {
212  ED_clip_view_lock_state_store(C, &state->space_clip_state);
213  }
214 }
215 
217 {
218  SpaceClip *space_clip = CTX_wm_space_clip(C);
219  if (space_clip != NULL) {
220  if ((space_clip->flag & SC_LOCK_SELECTION) == 0) {
221  /* Early output if the editor is not locked to selection.
222  * Avoids forced dependency graph evaluation here. */
223  return;
224  }
225 
226  /* Mask's lock-to-selection requires deformed splines to be evaluated to calculate bounds of
227  * points after animation has been evaluated. The restore-no-jump type of function does
228  * calculation of new offset for the view for an updated state of mask to cancel the offset out
229  * by modifying locked offset. In order to do such calculation mask needs to be evaluated after
230  * modification by an operator. */
232  (void)depsgraph;
233 
234  ED_clip_view_lock_state_restore_no_jump(C, &state->space_clip_state);
235  }
236 }
237 
struct ScrArea * CTX_wm_area(const bContext *C)
Definition: context.c:738
struct SpaceClip * CTX_wm_space_clip(const bContext *C)
Definition: context.c:923
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
Definition: context.c:1528
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
@ SPACE_CLIP
@ SPACE_SEQ
@ SPACE_IMAGE
@ SC_LOCK_SELECTION
bool ED_space_clip_maskedit_poll(struct bContext *C)
Definition: clip_editor.c:94
void ED_clip_view_lock_state_restore_no_jump(const struct bContext *C, const ClipViewLockState *state)
bool ED_space_clip_maskedit_mask_poll(struct bContext *C)
Definition: clip_editor.c:115
bool ED_space_clip_maskedit_visible_splines_poll(struct bContext *C)
Definition: clip_editor.c:105
bool ED_space_clip_maskedit_mask_visible_splines_poll(struct bContext *C)
Definition: clip_editor.c:130
void ED_clip_view_lock_state_store(const struct bContext *C, ClipViewLockState *state)
bool ED_space_image_maskedit_visible_splines_poll(struct bContext *C)
Definition: image_edit.c:481
bool ED_space_image_maskedit_mask_visible_splines_poll(struct bContext *C)
Definition: image_edit.c:516
bool ED_space_image_maskedit_mask_poll(struct bContext *C)
Definition: image_edit.c:506
bool ED_space_image_maskedit_poll(struct bContext *C)
Definition: image_edit.c:468
bool ED_space_sequencer_maskedit_poll(struct bContext *C)
bool ED_space_sequencer_maskedit_mask_poll(struct bContext *C)
#define C
Definition: RandGen.cpp:25
@ OPTYPE_UNDO
Definition: WM_types.h:148
@ OPTYPE_REGISTER
Definition: WM_types.h:146
const Depsgraph * depsgraph
SyclQueue void void size_t num_bytes void
const int state
void MASK_OT_add_feather_vertex(wmOperatorType *ot)
Definition: mask_add.c:672
void MASK_OT_primitive_square_add(wmOperatorType *ot)
Definition: mask_add.c:890
void MASK_OT_primitive_circle_add(wmOperatorType *ot)
Definition: mask_add.c:855
void MASK_OT_add_vertex(wmOperatorType *ot)
Definition: mask_add.c:576
void ED_operatormacros_mask(void)
Definition: mask_edit.c:169
void ED_keymap_mask(wmKeyConfig *keyconf)
Definition: mask_edit.c:163
void ED_mask_view_lock_state_restore_no_jump(const bContext *C, const MaskViewLockState *state)
Definition: mask_edit.c:216
bool ED_maskedit_visible_splines_poll(bContext *C)
Definition: mask_edit.c:45
bool ED_maskedit_mask_poll(bContext *C)
Definition: mask_edit.c:61
bool ED_maskedit_poll(bContext *C)
Definition: mask_edit.c:29
bool ED_maskedit_mask_visible_splines_poll(bContext *C)
Definition: mask_edit.c:77
void ED_mask_view_lock_state_store(const bContext *C, MaskViewLockState *state)
Definition: mask_edit.c:208
void ED_operatortypes_mask(void)
Definition: mask_edit.c:99
void MASK_OT_select(struct wmOperatorType *ot)
Definition: mask_select.c:389
void MASK_OT_new(struct wmOperatorType *ot)
Definition: mask_ops.c:104
void MASK_OT_shape_key_clear(struct wmOperatorType *ot)
void MASK_OT_select_circle(struct wmOperatorType *ot)
Definition: mask_select.c:735
void MASK_OT_slide_point(struct wmOperatorType *ot)
Definition: mask_ops.c:898
void MASK_OT_hide_view_clear(struct wmOperatorType *ot)
Definition: mask_ops.c:1730
void MASK_OT_hide_view_set(struct wmOperatorType *ot)
Definition: mask_ops.c:1791
void MASK_OT_duplicate(struct wmOperatorType *ot)
Definition: mask_ops.c:2037
void MASK_OT_select_less(struct wmOperatorType *ot)
Definition: mask_select.c:975
void MASK_OT_slide_spline_curvature(struct wmOperatorType *ot)
Definition: mask_ops.c:1290
void MASK_OT_delete(struct wmOperatorType *ot)
Definition: mask_ops.c:1486
void MASK_OT_layer_new(struct wmOperatorType *ot)
Definition: mask_ops.c:140
void MASK_OT_select_linked_pick(struct wmOperatorType *ot)
Definition: mask_select.c:801
void MASK_OT_switch_direction(struct wmOperatorType *ot)
Definition: mask_ops.c:1545
void MASK_OT_shape_key_rekey(struct wmOperatorType *ot)
void MASK_OT_handle_type_set(struct wmOperatorType *ot)
Definition: mask_ops.c:1677
void MASK_OT_normals_make_consistent(struct wmOperatorType *ot)
Definition: mask_ops.c:1607
void MASK_OT_shape_key_insert(struct wmOperatorType *ot)
Definition: mask_shapekey.c:61
void MASK_OT_select_more(struct wmOperatorType *ot)
Definition: mask_select.c:955
void MASK_OT_copy_splines(struct wmOperatorType *ot)
Definition: mask_ops.c:2068
void MASK_OT_shape_key_feather_reset(struct wmOperatorType *ot)
void MASK_OT_layer_remove(struct wmOperatorType *ot)
Definition: mask_ops.c:175
void MASK_OT_select_all(struct wmOperatorType *ot)
Definition: mask_select.c:214
void MASK_OT_feather_weight_clear(struct wmOperatorType *ot)
Definition: mask_ops.c:1843
void MASK_OT_parent_clear(struct wmOperatorType *ot)
void MASK_OT_layer_move(struct wmOperatorType *ot)
Definition: mask_ops.c:1911
void MASK_OT_select_lasso(struct wmOperatorType *ot)
Definition: mask_select.c:617
void MASK_OT_select_box(struct wmOperatorType *ot)
Definition: mask_select.c:494
void MASK_OT_cyclic_toggle(struct wmOperatorType *ot)
Definition: mask_ops.c:1330
void MASK_OT_paste_splines(struct wmOperatorType *ot)
Definition: mask_ops.c:2112
void MASK_OT_select_linked(struct wmOperatorType *ot)
Definition: mask_select.c:856
void MASK_OT_parent_set(struct wmOperatorType *ot)
static void area(int d1, int d2, int e1, int e2, float weights[2])
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
Definition: rna_access.c:4874
bool(* poll)(struct bContext *)
const char * description
Definition: WM_types.h:893
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 *))