Blender V5.0
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
8
9#include "BKE_context.hh"
10#include "BKE_mask.h"
11
12#include "WM_api.hh"
13#include "WM_types.hh"
14
15#include "ED_clip.hh"
16#include "ED_image.hh"
17#include "ED_mask.hh" /* own include */
18#include "ED_sequencer.hh"
19
20#include "RNA_access.hh"
21
22#include "mask_intern.hh" /* own include */
23
24/* -------------------------------------------------------------------- */
27
29{
30 ScrArea *area = CTX_wm_area(C);
31 if (area) {
32 switch (area->spacetype) {
33 case SPACE_CLIP:
35 case SPACE_SEQ:
37 case SPACE_IMAGE:
39 }
40 }
41 return false;
42}
43
45{
46 ScrArea *area = CTX_wm_area(C);
47 if (area) {
48 switch (area->spacetype) {
49 case SPACE_CLIP:
51 case SPACE_SEQ:
53 case SPACE_IMAGE:
55 }
56 }
57 return false;
58}
59
61{
62 ScrArea *area = CTX_wm_area(C);
63 if (area) {
64 switch (area->spacetype) {
65 case SPACE_CLIP:
67 case SPACE_SEQ:
69 case SPACE_IMAGE:
71 }
72 }
73 return false;
74}
75
77{
78 const ScrArea *area = CTX_wm_area(C);
79 if (area) {
80 switch (area->spacetype) {
81 case SPACE_CLIP:
83 case SPACE_SEQ:
85 case SPACE_IMAGE:
87 }
88 }
89 return false;
90}
91
93
94/* -------------------------------------------------------------------- */
97
99{
101
102 /* mask layers */
105
106 /* add */
111
112 /* geometry */
116
117 /* select */
127
128 /* hide/reveal */
131
132 /* feather */
134
135 /* shape */
140
141 /* relationships */
144
145 /* Shape-keys. */
150
151 /* layers */
153
154 /* duplicate */
156
157 /* clipboard */
160}
161
163{
164 wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Mask Editing", SPACE_EMPTY, RGN_TYPE_WINDOW);
165 keymap->poll = ED_maskedit_poll;
166}
167
169{
171 wmOperatorTypeMacro *otmacro;
172
173 ot = WM_operatortype_append_macro("MASK_OT_add_vertex_slide",
174 "Add Vertex and Slide",
175 "Add new vertex and slide it",
177 ot->description = "Add new vertex and slide it";
178 WM_operatortype_macro_define(ot, "MASK_OT_add_vertex");
179 otmacro = WM_operatortype_macro_define(ot, "MASK_OT_slide_point");
180 RNA_boolean_set(otmacro->ptr, "is_new_point", true);
181
182 ot = WM_operatortype_append_macro("MASK_OT_add_feather_vertex_slide",
183 "Add Feather Vertex and Slide",
184 "Add new vertex to feather and slide it",
186 ot->description = "Add new feather vertex and slide it";
187 WM_operatortype_macro_define(ot, "MASK_OT_add_feather_vertex");
188 otmacro = WM_operatortype_macro_define(ot, "MASK_OT_slide_point");
189 RNA_boolean_set(otmacro->ptr, "slide_feather", true);
190
191 ot = WM_operatortype_append_macro("MASK_OT_duplicate_move",
192 "Add Duplicate",
193 "Duplicate mask and move",
195 WM_operatortype_macro_define(ot, "MASK_OT_duplicate");
196 otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
197 RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
198 RNA_boolean_set(otmacro->ptr, "mirror", false);
199}
200
202
203/* -------------------------------------------------------------------- */
206
208{
209 SpaceClip *space_clip = CTX_wm_space_clip(C);
210 if (space_clip != nullptr) {
211 ED_clip_view_lock_state_store(C, &state->space_clip_state);
212 }
213}
214
216{
217 SpaceClip *space_clip = CTX_wm_space_clip(C);
218 if (space_clip != nullptr) {
219 if ((space_clip->flag & SC_LOCK_SELECTION) == 0) {
220 /* Early output if the editor is not locked to selection.
221 * Avoids forced dependency graph evaluation here. */
222 return;
223 }
224
225 /* Mask's lock-to-selection requires deformed splines to be evaluated to calculate bounds of
226 * points after animation has been evaluated. The restore-no-jump type of function does
227 * calculation of new offset for the view for an updated state of mask to cancel the offset out
228 * by modifying locked offset. In order to do such calculation mask needs to be evaluated after
229 * modification by an operator. */
231 (void)depsgraph;
232
234 }
235}
236
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_maskedit_poll(bContext *C)
Definition mask_edit.cc:28
#define C
Definition RandGen.cpp:29
@ OPTYPE_UNDO
Definition WM_types.hh:182
@ OPTYPE_REGISTER
Definition WM_types.hh:180
BPy_StructRNA * depsgraph
void MASK_OT_add_feather_vertex(wmOperatorType *ot)
Definition mask_add.cc:683
void MASK_OT_primitive_square_add(wmOperatorType *ot)
Definition mask_add.cc:904
void MASK_OT_primitive_circle_add(wmOperatorType *ot)
Definition mask_add.cc:869
void MASK_OT_add_vertex(wmOperatorType *ot)
Definition mask_add.cc:584
void ED_operatormacros_mask()
Definition mask_edit.cc:168
void ED_keymap_mask(wmKeyConfig *keyconf)
Definition mask_edit.cc:162
void ED_mask_view_lock_state_restore_no_jump(const bContext *C, const MaskViewLockState *state)
Definition mask_edit.cc:215
void ED_operatortypes_mask()
Definition mask_edit.cc:98
bool ED_maskedit_visible_splines_poll(bContext *C)
Definition mask_edit.cc:44
bool ED_maskedit_mask_poll(bContext *C)
Definition mask_edit.cc:60
bool ED_maskedit_poll(bContext *C)
Definition mask_edit.cc:28
bool ED_maskedit_mask_visible_splines_poll(bContext *C)
Definition mask_edit.cc:76
void ED_mask_view_lock_state_store(const bContext *C, MaskViewLockState *state)
Definition mask_edit.cc:207
void MASK_OT_select_circle(wmOperatorType *ot)
void MASK_OT_slide_spline_curvature(wmOperatorType *ot)
Definition mask_ops.cc:1319
void MASK_OT_copy_splines(wmOperatorType *ot)
Definition mask_ops.cc:2142
void MASK_OT_layer_move(wmOperatorType *ot)
Definition mask_ops.cc:1962
void MASK_OT_select_more(wmOperatorType *ot)
void MASK_OT_feather_weight_clear(wmOperatorType *ot)
Definition mask_ops.cc:1893
void MASK_OT_layer_remove(wmOperatorType *ot)
Definition mask_ops.cc:182
void MASK_OT_shape_key_insert(wmOperatorType *ot)
void MASK_OT_paste_splines(wmOperatorType *ot)
Definition mask_ops.cc:2186
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:147
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:1780
void MASK_OT_new(wmOperatorType *ot)
Definition mask_ops.cc:111
void MASK_OT_handle_type_set(wmOperatorType *ot)
Definition mask_ops.cc:1727
void MASK_OT_select_all(wmOperatorType *ot)
void MASK_OT_select_lasso(wmOperatorType *ot)
void MASK_OT_duplicate(wmOperatorType *ot)
Definition mask_ops.cc:2111
void MASK_OT_cyclic_toggle(wmOperatorType *ot)
Definition mask_ops.cc:1359
void MASK_OT_delete(wmOperatorType *ot)
Definition mask_ops.cc:1535
void MASK_OT_hide_view_set(wmOperatorType *ot)
Definition mask_ops.cc:1841
void MASK_OT_slide_point(wmOperatorType *ot)
Definition mask_ops.cc:917
void MASK_OT_switch_direction(wmOperatorType *ot)
Definition mask_ops.cc:1595
void MASK_OT_normals_make_consistent(wmOperatorType *ot)
Definition mask_ops.cc:1657
void MASK_OT_parent_set(wmOperatorType *ot)
void MASK_OT_select_linked_pick(wmOperatorType *ot)
static ulong state[N]
bool maskedit_poll(bContext *C)
bool maskedit_mask_poll(bContext *C)
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
bool(* poll)(struct bContext *)
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)