Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-10-18 16:29:22 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-10-18 16:29:22 +0400
commitb3c605e13923b372b2ff18b5970818e2aaae470a (patch)
tree29e3128462f5fc5e4309bb9710821e840a0c52d4
parentdd56cc0cddc0372d0db0678c38e56364cd26a54c (diff)
Mask editor: create new mask when trying to create new vertex without active mask set
-rw-r--r--source/blender/editors/mask/mask_add.c8
-rw-r--r--source/blender/editors/mask/mask_intern.h3
-rw-r--r--source/blender/editors/mask/mask_ops.c16
3 files changed, 22 insertions, 5 deletions
diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c
index c929436bc82..e43c8a2b53b 100644
--- a/source/blender/editors/mask/mask_add.c
+++ b/source/blender/editors/mask/mask_add.c
@@ -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;
diff --git a/source/blender/editors/mask/mask_intern.h b/source/blender/editors/mask/mask_intern.h
index ffd4afca182..fcfcfb237e9 100644
--- a/source/blender/editors/mask/mask_intern.h
+++ b/source/blender/editors/mask/mask_intern.h
@@ -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);
diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c
index bea6b153d20..35f85f3faee 100644
--- a/source/blender/editors/mask/mask_ops.c
+++ b/source/blender/editors/mask/mask_ops.c
@@ -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;
}