Blender V5.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
8
9#include "BKE_context.hh"
10
11#include "WM_api.hh"
12#include "WM_types.hh"
13
14#include "ED_clip.hh"
15#include "ED_image.hh"
16#include "ED_mask.hh" /* own include */
17#include "ED_sequencer.hh"
18
19#include "RNA_access.hh"
20
21#include "mask_intern.hh" /* own include */
22
23namespace blender {
24
25/* -------------------------------------------------------------------- */
28
30{
31 ScrArea *area = CTX_wm_area(C);
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{
47 ScrArea *area = CTX_wm_area(C);
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{
63 ScrArea *area = CTX_wm_area(C);
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
94
95/* -------------------------------------------------------------------- */
98
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 */
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{
172 wmOperatorType *ot;
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
204
205/* -------------------------------------------------------------------- */
208
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. */
232 Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
233 (void)depsgraph;
234
236 }
237}
238
240
241} // namespace blender
#define C
Definition RandGen.cpp:29
const int state
bool maskedit_poll(bContext *C)
bool maskedit_mask_poll(bContext *C)
BMesh Iterators.
void MASK_OT_primitive_square_add(wmOperatorType *ot)
Definition mask_add.cc:915
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))
bool ED_space_image_maskedit_mask_poll(bContext *C)
ScrArea * CTX_wm_area(const bContext *C)
bool ED_space_clip_maskedit_mask_visible_splines_poll(bContext *C)
void ED_operatortypes_mask()
Definition mask_edit.cc:99
void MASK_OT_switch_direction(wmOperatorType *ot)
Definition mask_ops.cc:1640
void MASK_OT_select_box(wmOperatorType *ot)
void ED_mask_view_lock_state_store(const bContext *C, MaskViewLockState *state)
Definition mask_edit.cc:209
bool ED_space_image_maskedit_mask_visible_splines_poll(bContext *C)
SpaceClip * CTX_wm_space_clip(const bContext *C)
wmOperatorTypeMacro * WM_operatortype_macro_define(wmOperatorType *ot, const char *idname)
void MASK_OT_layer_remove(wmOperatorType *ot)
Definition mask_ops.cc:227
void MASK_OT_delete(wmOperatorType *ot)
Definition mask_ops.cc:1580
void MASK_OT_hide_view_set(wmOperatorType *ot)
Definition mask_ops.cc:1886
void MASK_OT_select_circle(wmOperatorType *ot)
void MASK_OT_slide_point(wmOperatorType *ot)
Definition mask_ops.cc:962
void ED_clip_view_lock_state_restore_no_jump(const bContext *C, const ClipViewLockState *state)
void MASK_OT_layer_move(wmOperatorType *ot)
Definition mask_ops.cc:2007
bool ED_space_clip_maskedit_visible_splines_poll(bContext *C)
void MASK_OT_duplicate(wmOperatorType *ot)
Definition mask_ops.cc:2273
void MASK_OT_parent_clear(wmOperatorType *ot)
void MASK_OT_cyclic_toggle(wmOperatorType *ot)
Definition mask_ops.cc:1404
void MASK_OT_select(wmOperatorType *ot)
void ED_keymap_mask(wmKeyConfig *keyconf)
Definition mask_edit.cc:164
void MASK_OT_feather_weight_clear(wmOperatorType *ot)
Definition mask_ops.cc:1938
void MASK_OT_parent_set(wmOperatorType *ot)
bool ED_space_image_maskedit_visible_splines_poll(bContext *C)
bool ED_maskedit_poll(bContext *C)
Definition mask_edit.cc:29
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C, bool rna_write_check=false)
void MASK_OT_new(wmOperatorType *ot)
Definition mask_ops.cc:156
void MASK_OT_select_less(wmOperatorType *ot)
void MASK_OT_select_linked_pick(wmOperatorType *ot)
wmKeyMap * WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
Definition wm_keymap.cc:935
void ED_mask_view_lock_state_restore_no_jump(const bContext *C, const MaskViewLockState *state)
Definition mask_edit.cc:217
bool ED_space_image_maskedit_poll(bContext *C)
void MASK_OT_normals_make_consistent(wmOperatorType *ot)
Definition mask_ops.cc:1702
bool ED_maskedit_mask_poll(bContext *C)
Definition mask_edit.cc:61
bool ED_maskedit_mask_visible_splines_poll(bContext *C)
Definition mask_edit.cc:77
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
bool ED_space_clip_maskedit_poll(bContext *C)
void MASK_OT_paste_splines(wmOperatorType *ot)
Definition mask_ops.cc:2348
bool ED_space_clip_maskedit_mask_poll(bContext *C)
wmOperatorType * WM_operatortype_append_macro(const char *idname, const char *name, const char *description, int flag)
void MASK_OT_shape_key_insert(wmOperatorType *ot)
void MASK_OT_select_all(wmOperatorType *ot)
void ED_operatormacros_mask()
Definition mask_edit.cc:170
void MASK_OT_select_lasso(wmOperatorType *ot)
void MASK_OT_select_more(wmOperatorType *ot)
void MASK_OT_copy_splines(wmOperatorType *ot)
Definition mask_ops.cc:2304
bool ED_maskedit_visible_splines_poll(bContext *C)
Definition mask_edit.cc:45
void MASK_OT_move_to_layer(wmOperatorType *ot)
Definition mask_ops.cc:2127
void MASK_OT_handle_type_set(wmOperatorType *ot)
Definition mask_ops.cc:1772
void MASK_OT_select_linked(wmOperatorType *ot)
void MASK_OT_hide_view_clear(wmOperatorType *ot)
Definition mask_ops.cc:1825
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
void ED_clip_view_lock_state_store(const bContext *C, ClipViewLockState *state)
void MASK_OT_add_vertex(wmOperatorType *ot)
Definition mask_add.cc:585
void MASK_OT_shape_key_clear(wmOperatorType *ot)
void MASK_OT_add_feather_vertex(wmOperatorType *ot)
Definition mask_add.cc:684
void MASK_OT_primitive_circle_add(wmOperatorType *ot)
Definition mask_add.cc:880
void MASK_OT_slide_spline_curvature(wmOperatorType *ot)
Definition mask_ops.cc:1364
void MASK_OT_shape_key_rekey(wmOperatorType *ot)
void MASK_OT_shape_key_feather_reset(wmOperatorType *ot)
void MASK_OT_layer_new(wmOperatorType *ot)
Definition mask_ops.cc:192
eSpaceClip_Flag flag
bool(*) poll(struct bContext *)
const char * description
Definition WM_types.hh:1115