Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/mask/mask_ops.c
| Show First 20 Lines • Show All 330 Lines • ▼ Show 20 Lines | switch (sa->spacetype) { | ||||
| { | { | ||||
| SpaceImage *sima = sa->spacedata.first; | SpaceImage *sima = sa->spacedata.first; | ||||
| ED_space_image_set_mask(C, sima, mask); | ED_space_image_set_mask(C, sima, mask); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return mask; | return mask; | ||||
| } | } | ||||
mont29: Not sure that this is really wrong, but it feels a bit odd to add notifier in a helper func…… | |||||
Not Done Inline ActionsFor consistency better to put it in the operator code I think. brecht: For consistency better to put it in the operator code I think. | |||||
| /* Get ative layer. Will create mask/layer to be sure there's an active layer. */ | /* Get ative layer. Will create mask/layer to be sure there's an active layer. */ | ||||
| MaskLayer *ED_mask_layer_ensure(bContext *C) | MaskLayer *ED_mask_layer_ensure(bContext *C, bool *r_added_mask) | ||||
| { | { | ||||
| Mask *mask = CTX_data_edit_mask(C); | Mask *mask = CTX_data_edit_mask(C); | ||||
| MaskLayer *mask_layer; | MaskLayer *mask_layer; | ||||
| if (mask == NULL) { | if (mask == NULL) { | ||||
| /* If there's no active mask, create one. */ | /* If there's no active mask, create one. */ | ||||
| mask = ED_mask_new(C, NULL); | mask = ED_mask_new(C, NULL); | ||||
| *r_added_mask = true; | |||||
| } | } | ||||
| mask_layer = BKE_mask_layer_active(mask); | mask_layer = BKE_mask_layer_active(mask); | ||||
| if (mask_layer == NULL) { | if (mask_layer == NULL) { | ||||
| /* If there's no active mask layer, create one. */ | /* If there's no active mask layer, create one. */ | ||||
| mask_layer = BKE_mask_layer_new(mask, ""); | mask_layer = BKE_mask_layer_new(mask, ""); | ||||
| } | } | ||||
| return mask_layer; | return mask_layer; | ||||
| } | } | ||||
| static int mask_new_exec(bContext *C, wmOperator *op) | static int mask_new_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| char name[MAX_ID_NAME - 2]; | char name[MAX_ID_NAME - 2]; | ||||
| RNA_string_get(op->ptr, "name", name); | RNA_string_get(op->ptr, "name", name); | ||||
| ED_mask_new(C, name); | ED_mask_new(C, name); | ||||
| WM_event_add_notifier(C, NC_MASK | NA_ADDED, NULL); | |||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void MASK_OT_new(wmOperatorType *ot) | void MASK_OT_new(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "New Mask"; | ot->name = "New Mask"; | ||||
| ot->description = "Create new mask"; | ot->description = "Create new mask"; | ||||
| ▲ Show 20 Lines • Show All 2,004 Lines • Show Last 20 Lines | |||||
Not sure that this is really wrong, but it feels a bit odd to add notifier in a helper func… Usually they are supposed to be defined by operators's code itself…