forked from bartvdbraak/blender
Mask editor: create new mask when trying to create new vertex without active mask set
This commit is contained in:
parent
dd56cc0cdd
commit
b3c605e139
@ -46,6 +46,7 @@
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "ED_mask.h" /* own include */
|
||||
#include "ED_screen.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_define.h"
|
||||
@ -562,6 +563,11 @@ static int add_vertex_exec(bContext *C, wmOperator *op)
|
||||
|
||||
float co[2];
|
||||
|
||||
if (mask == NULL) {
|
||||
/* if there's no active mask, create one */
|
||||
mask = ED_mask_new(C, NULL);
|
||||
}
|
||||
|
||||
masklay = BKE_mask_layer_active(mask);
|
||||
|
||||
if (masklay && masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
|
||||
@ -647,7 +653,7 @@ void MASK_OT_add_vertex(wmOperatorType *ot)
|
||||
/* api callbacks */
|
||||
ot->exec = add_vertex_exec;
|
||||
ot->invoke = add_vertex_invoke;
|
||||
ot->poll = ED_maskedit_mask_poll;
|
||||
ot->poll = ED_operator_mask;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
@ -33,6 +33,7 @@
|
||||
#define __MASK_INTERN_H__
|
||||
|
||||
struct bContext;
|
||||
struct Mask;
|
||||
struct wmEvent;
|
||||
struct wmOperatorType;
|
||||
|
||||
@ -43,6 +44,8 @@ void MASK_OT_add_vertex(struct wmOperatorType *ot);
|
||||
void MASK_OT_add_feather_vertex(struct wmOperatorType *ot);
|
||||
|
||||
/* mask_ops.c */
|
||||
struct Mask *ED_mask_new(struct bContext *C, const char *name);
|
||||
|
||||
void MASK_OT_new(struct wmOperatorType *ot);
|
||||
void MASK_OT_layer_new(struct wmOperatorType *ot);
|
||||
void MASK_OT_layer_remove(struct wmOperatorType *ot);
|
||||
|
@ -258,13 +258,10 @@ int ED_mask_feather_find_nearest(const bContext *C, Mask *mask, float normal_co[
|
||||
|
||||
/******************** create new mask *********************/
|
||||
|
||||
static int mask_new_exec(bContext *C, wmOperator *op)
|
||||
Mask *ED_mask_new(bContext *C, const char *name)
|
||||
{
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
Mask *mask;
|
||||
char name[MAX_ID_NAME - 2];
|
||||
|
||||
RNA_string_get(op->ptr, "name", name);
|
||||
|
||||
mask = BKE_mask_new(name);
|
||||
|
||||
@ -290,6 +287,17 @@ static int mask_new_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
}
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
static int mask_new_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
char name[MAX_ID_NAME - 2];
|
||||
|
||||
RNA_string_get(op->ptr, "name", name);
|
||||
|
||||
ED_mask_new(C, name);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user