~ubuntu-branches/ubuntu/utopic/blender/utopic-proposed

« back to all changes in this revision

Viewing changes to source/blender/editors/space_node/node_add.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2014-02-19 11:24:23 UTC
  • mfrom: (14.2.23 sid)
  • Revision ID: package-import@ubuntu.com-20140219112423-rkmaz2m7ha06d4tk
Tags: 2.69-3ubuntu1
* Merge with Debian; remaining changes:
  - Configure without OpenImageIO on armhf, as it is not available on
    Ubuntu.

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
        node->locy = locy + 60.0f;     /* arbitrary... so its visible, (0,0) is top of node */
85
85
        nodeSetSelected(node, TRUE);
86
86
        
87
 
        /* node location is mapped */
88
 
        locx /= UI_DPI_FAC;
89
 
        locy /= UI_DPI_FAC;
90
 
        
91
87
        node->locx = locx;
92
88
        node->locy = locy + 60.0f;
93
89
        
215
211
        int i = 0;
216
212
        
217
213
        /* Get the cut path */
218
 
        RNA_BEGIN(op->ptr, itemptr, "path")
 
214
        RNA_BEGIN (op->ptr, itemptr, "path")
219
215
        {
220
216
                float loc[2];
221
217
 
339
335
                }
340
336
        }
341
337
 
342
 
        node_deselect_all(snode);
343
 
 
344
338
        switch (snode->nodetree->type) {
345
339
                case NTREE_SHADER:
346
340
                        type = SH_NODE_TEX_IMAGE;
410
404
        RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME - 2, "Name", "Datablock name to assign");
411
405
}
412
406
 
 
407
/* ****************** Add Mask Node Operator  ******************* */
 
408
 
 
409
static int node_add_mask_poll(bContext *C)
 
410
{
 
411
        SpaceNode *snode = CTX_wm_space_node(C);
 
412
 
 
413
        return ED_operator_node_editable(C) && snode->nodetree->type == NTREE_COMPOSIT;
 
414
}
 
415
 
 
416
static int node_add_mask_exec(bContext *C, wmOperator *op)
 
417
{
 
418
        SpaceNode *snode = CTX_wm_space_node(C);
 
419
        bNode *node;
 
420
        ID *mask = NULL;
 
421
 
 
422
        /* check input variables */
 
423
        char name[MAX_ID_NAME - 2];
 
424
        RNA_string_get(op->ptr, "name", name);
 
425
        mask = BKE_libblock_find_name(ID_MSK, name);
 
426
        if (!mask) {
 
427
                BKE_reportf(op->reports, RPT_ERROR, "Mask '%s' not found", name);
 
428
                return OPERATOR_CANCELLED;
 
429
        }
 
430
 
 
431
        ED_preview_kill_jobs(C);
 
432
 
 
433
        node = node_add_node(C, NULL, CMP_NODE_MASK, snode->cursor[0], snode->cursor[1]);
 
434
 
 
435
        if (!node) {
 
436
                BKE_report(op->reports, RPT_WARNING, "Could not add a mask node");
 
437
                return OPERATOR_CANCELLED;
 
438
        }
 
439
 
 
440
        node->id = mask;
 
441
        id_us_plus(mask);
 
442
 
 
443
        snode_notify(C, snode);
 
444
        snode_dag_update(C, snode);
 
445
 
 
446
        return OPERATOR_FINISHED;
 
447
}
 
448
 
 
449
void NODE_OT_add_mask(wmOperatorType *ot)
 
450
{
 
451
        /* identifiers */
 
452
        ot->name = "Add Mask Node";
 
453
        ot->description = "Add a mask node to the current node editor";
 
454
        ot->idname = "NODE_OT_add_mask";
 
455
 
 
456
        /* callbacks */
 
457
        ot->exec = node_add_mask_exec;
 
458
        ot->poll = node_add_mask_poll;
 
459
 
 
460
        /* flags */
 
461
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
462
 
 
463
        RNA_def_string(ot->srna, "name", "Mask", MAX_ID_NAME - 2, "Name", "Datablock name to assign");
 
464
}
 
465
 
413
466
/********************** New node tree operator *********************/
414
467
 
415
468
static int new_node_tree_exec(bContext *C, wmOperator *op)