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:
authorSv. Lockal <lockalsash@gmail.com>2013-07-22 23:24:39 +0400
committerSv. Lockal <lockalsash@gmail.com>2013-07-22 23:24:39 +0400
commit6e98932e90df7575f371f492f31b0f7f9da713fa (patch)
tree1ff30a64d02ec57782a54ec56423e4027158ec39 /source/blender/editors/space_node/node_add.c
parent02b0c227fef8432221b432c813174171e80c4c7a (diff)
Allow creation of mask nodes in compositor with drag&drop of mask datablocks
Also remove superfluous "deselect all" operation in drag&drop for images
Diffstat (limited to 'source/blender/editors/space_node/node_add.c')
-rw-r--r--source/blender/editors/space_node/node_add.c65
1 files changed, 63 insertions, 2 deletions
diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c
index d5224a37358..0dc1415ea69 100644
--- a/source/blender/editors/space_node/node_add.c
+++ b/source/blender/editors/space_node/node_add.c
@@ -339,8 +339,6 @@ static int node_add_file_exec(bContext *C, wmOperator *op)
}
}
- node_deselect_all(snode);
-
switch (snode->nodetree->type) {
case NTREE_SHADER:
type = SH_NODE_TEX_IMAGE;
@@ -410,6 +408,69 @@ void NODE_OT_add_file(wmOperatorType *ot)
RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME - 2, "Name", "Datablock name to assign");
}
+/* ****************** Add Mask Node Operator ******************* */
+
+static int node_add_mask_poll(bContext *C)
+{
+ SpaceNode *snode = CTX_wm_space_node(C);
+
+ return ED_operator_node_editable(C) && snode->nodetree->type == NTREE_COMPOSIT;
+}
+
+static int node_add_mask_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ ARegion *ar = CTX_wm_region(C);
+ SpaceNode *snode = CTX_wm_space_node(C);
+ bNode *node;
+ ID *mask = NULL;
+
+ /* check input variables */
+ char name[MAX_ID_NAME - 2];
+ RNA_string_get(op->ptr, "name", name);
+ mask = BKE_libblock_find_name(ID_MSK, name);
+ if (!mask) {
+ BKE_reportf(op->reports, RPT_ERROR, "Mask '%s' not found", name);
+ return OPERATOR_CANCELLED;
+ }
+
+ ED_preview_kill_jobs(C);
+
+ /* convert mouse coordinates to v2d space */
+ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1],
+ &snode->cursor[0], &snode->cursor[1]);
+ node = node_add_node(C, NULL, CMP_NODE_MASK, snode->cursor[0], snode->cursor[1]);
+
+ if (!node) {
+ BKE_report(op->reports, RPT_WARNING, "Could not add an mask node");
+ return OPERATOR_CANCELLED;
+ }
+
+ node->id = mask;
+ id_us_plus(mask);
+
+ snode_notify(C, snode);
+ snode_dag_update(C, snode);
+
+ return OPERATOR_FINISHED;
+}
+
+void NODE_OT_add_mask(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Add Mask Node";
+ ot->description = "Add a mask node to the current node editor";
+ ot->idname = "NODE_OT_add_mask";
+
+ /* callbacks */
+ ot->invoke = node_add_mask_invoke;
+ ot->poll = node_add_mask_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ RNA_def_string(ot->srna, "name", "Mask", MAX_ID_NAME - 2, "Name", "Datablock name to assign");
+}
+
/********************** New node tree operator *********************/
static int new_node_tree_exec(bContext *C, wmOperator *op)