OLD | NEW |
1 /* | 1 /* |
2 * ***** BEGIN GPL LICENSE BLOCK ***** | 2 * ***** BEGIN GPL LICENSE BLOCK ***** |
3 * | 3 * |
4 * This program is free software; you can redistribute it and/or | 4 * This program is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU General Public License | 5 * modify it under the terms of the GNU General Public License |
6 * as published by the Free Software Foundation; either version 2 | 6 * as published by the Free Software Foundation; either version 2 |
7 * of the License, or (at your option) any later version.· | 7 * of the License, or (at your option) any later version.· |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 /* note: this assumes only 1 group at a time is drawn (linked data) */ | 460 /* note: this assumes only 1 group at a time is drawn (linked data) */ |
461 /* in node->totr the entire boundbox for the group is stored */ | 461 /* in node->totr the entire boundbox for the group is stored */ |
462 static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode) | 462 static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode) |
463 { | 463 { |
464 if (!(gnode->flag & NODE_GROUP_EDIT)) { | 464 if (!(gnode->flag & NODE_GROUP_EDIT)) { |
465 node_update_default(C, ntree, gnode); | 465 node_update_default(C, ntree, gnode); |
466 } | 466 } |
467 else { | 467 else { |
468 bNodeTree *ngroup= (bNodeTree *)gnode->id; | 468 bNodeTree *ngroup= (bNodeTree *)gnode->id; |
469 bNode *node; | 469 bNode *node; |
470 bNodeSocket *sock, *gsock; | |
471 float locx, locy; | 470 float locx, locy; |
472 rctf *rect= &gnode->totr; | 471 rctf *rect= &gnode->totr; |
473 » » float node_group_frame= U.dpi*NODE_GROUP_FRAME/72; | 472 » » float group_frame= U.dpi*NODE_GROUP_FRAME/72; |
474 float group_header= 26*U.dpi/72; | 473 float group_header= 26*U.dpi/72; |
475 int counter; | 474 int counter; |
476 int dy; | 475 int dy; |
477 ················ | 476 ················ |
478 /* get "global" coords */ | 477 /* get "global" coords */ |
479 nodeSpaceCoords(gnode, &locx, &locy); | 478 nodeSpaceCoords(gnode, &locx, &locy); |
480 ················ | 479 ················ |
481 /* center them, is a bit of abuse of locx and locy though */ | 480 /* center them, is a bit of abuse of locx and locy though */ |
482 node_update_nodetree(C, ngroup, locx, locy); | 481 node_update_nodetree(C, ngroup, locx, locy); |
483 ················ | 482 ················ |
484 rect->xmin = rect->xmax = locx; | 483 rect->xmin = rect->xmax = locx; |
485 rect->ymin = rect->ymax = locy; | 484 rect->ymin = rect->ymax = locy; |
486 ················ | 485 ················ |
487 counter= 1; | 486 counter= 1; |
488 for(node= ngroup->nodes.first; node; node= node->next) { | 487 for(node= ngroup->nodes.first; node; node= node->next) { |
489 if(counter) { | 488 if(counter) { |
490 *rect= node->totr; | 489 *rect= node->totr; |
491 counter= 0; | 490 counter= 0; |
492 } | 491 } |
493 else | 492 else |
494 BLI_union_rctf(rect, &node->totr); | 493 BLI_union_rctf(rect, &node->totr); |
495 } | 494 } |
496 ················ | 495 ················ |
497 /* add some room for links to group sockets */ | 496 /* add some room for links to group sockets */ |
498 rect->xmin -= 4*NODE_DY; | 497 rect->xmin -= 4*NODE_DY; |
499 rect->xmax += 4*NODE_DY; | 498 rect->xmax += 4*NODE_DY; |
500 rect->ymin-= NODE_DY; | 499 rect->ymin-= NODE_DY; |
501 rect->ymax+= NODE_DY; | 500 rect->ymax+= NODE_DY; |
502 ················ | 501 ················ |
503 » » /* input sockets */ | 502 » » { |
504 » » dy = 0.5f*(rect->ymin+rect->ymax) + NODE_DY*(BLI_countlist(&gnod
e->inputs)-1); | 503 » » » bNodeProxyItem *item; |
505 » » gsock=ngroup->inputs.first; | 504 » » » bNodeSocket *sock; |
506 » » sock=gnode->inputs.first; | 505 » » » int num_items; |
507 » » while (gsock || sock) { | 506 » » » float socket_size= NODE_SOCKSIZE * U.dpi/72; |
508 » » » while (sock && !sock->groupsock) { | 507 » » » float item_height = NODE_DY * U.dpi/72; |
509 » » » » sock->locx = rect->xmin - node_group_frame; | 508 » » » float item_margin = 3 * U.dpi/72; |
| 509 » » »······· |
| 510 » » » /* input sockets */ |
| 511 » » » num_items = BLI_countlist(&ngroup->proxy_inputs); |
| 512 » » » dy = 0.5f*(rect->ymin+rect->ymax) + 0.5*item_height*(num
_items-1); |
| 513 » » » for (item=ngroup->proxy_inputs.first, sock=gnode->inputs
.first; item; item=item->next, sock=sock->next) { |
| 514 » » » » item->totr.xmin = rect->xmin - group_frame + ite
m_margin + socket_size; |
| 515 » » » » item->totr.xmax = rect->xmin - item_margin; |
| 516 » » » » item->totr.ymin = dy - 0.5f*item_height + 0.5f*i
tem_margin; |
| 517 » » » » item->totr.ymax = dy + 0.5f*item_height - 0.5f*i
tem_margin; |
| 518 » » » »······· |
| 519 » » » » sock->locx = rect->xmin - group_frame; |
510 sock->locy = dy; | 520 sock->locy = dy; |
511 | |
512 /* prevent long socket lists from growing out of
the group box */ | |
513 if (dy-3*NODE_DYS < rect->ymin) | |
514 rect->ymin = dy-3*NODE_DYS; | |
515 if (dy+3*NODE_DYS > rect->ymax) | |
516 rect->ymax = dy+3*NODE_DYS; | |
517 dy -= 2*NODE_DY; | |
518 ································ | |
519 sock = sock->next; | |
520 } | |
521 while (gsock && (!sock || sock->groupsock!=gsock)) { | |
522 gsock->locx = rect->xmin; | |
523 gsock->locy = dy; | |
524 ································ | 521 ································ |
525 /* prevent long socket lists from growing out of
the group box */ | 522 /* prevent long socket lists from growing out of
the group box */ |
526 if (dy-3*NODE_DYS < rect->ymin) | 523 if (dy-3*NODE_DYS < rect->ymin) |
527 rect->ymin = dy-3*NODE_DYS; | 524 rect->ymin = dy-3*NODE_DYS; |
528 if (dy+3*NODE_DYS > rect->ymax) | 525 if (dy+3*NODE_DYS > rect->ymax) |
529 rect->ymax = dy+3*NODE_DYS; | 526 rect->ymax = dy+3*NODE_DYS; |
530 » » » » dy -= 2*NODE_DY; | 527 » » » » dy -= item_height; |
| 528 » » » } |
| 529 » » »······· |
| 530 » » » /* output sockets */ |
| 531 » » » num_items = BLI_countlist(&ngroup->proxy_outputs); |
| 532 » » » dy = 0.5f*(rect->ymin+rect->ymax) + 0.5*item_height*(num
_items-1); |
| 533 » » » for (item=ngroup->proxy_outputs.first, sock=gnode->outpu
ts.first; item; item=item->next, sock=sock->next) { |
| 534 » » » » item->totr.xmin = rect->xmax + item_margin; |
| 535 » » » » item->totr.xmax = rect->xmax + group_frame - ite
m_margin - socket_size; |
| 536 » » » » item->totr.ymin = dy - 0.5f*item_height + 0.5f*i
tem_margin; |
| 537 » » » » item->totr.ymax = dy + 0.5f*item_height - 0.5f*i
tem_margin; |
531 ································ | 538 ································ |
532 » » » » gsock = gsock->next; | 539 » » » » sock->locx = rect->xmax + group_frame; |
533 » » » } | 540 » » » » sock->locy = dy; |
534 » » » while (sock && gsock && sock->groupsock==gsock) { | |
535 » » » » gsock->locx = rect->xmin; | |
536 » » » » sock->locx = rect->xmin - node_group_frame; | |
537 » » » » sock->locy = gsock->locy = dy; | |
538 ································ | 541 ································ |
539 /* prevent long socket lists from growing out of
the group box */ | 542 /* prevent long socket lists from growing out of
the group box */ |
540 if (dy-3*NODE_DYS < rect->ymin) | 543 if (dy-3*NODE_DYS < rect->ymin) |
541 rect->ymin = dy-3*NODE_DYS; | 544 rect->ymin = dy-3*NODE_DYS; |
542 if (dy+3*NODE_DYS > rect->ymax) | 545 if (dy+3*NODE_DYS > rect->ymax) |
543 rect->ymax = dy+3*NODE_DYS; | 546 rect->ymax = dy+3*NODE_DYS; |
544 » » » » dy -= 2*NODE_DY; | 547 » » » » dy -= item_height; |
545 » » » »······· | |
546 » » » » sock = sock->next; | |
547 » » » » gsock = gsock->next; | |
548 » » » } | |
549 » » } | |
550 » »······· | |
551 » » /* output sockets */ | |
552 » » dy = 0.5f*(rect->ymin+rect->ymax) + NODE_DY*(BLI_countlist(&gnod
e->outputs)-1); | |
553 » » gsock=ngroup->outputs.first; | |
554 » » sock=gnode->outputs.first; | |
555 » » while (gsock || sock) { | |
556 » » » while (sock && !sock->groupsock) { | |
557 » » » » sock->locx = rect->xmax + node_group_frame; | |
558 » » » » sock->locy = dy - NODE_DYS; | |
559 » » » »······· | |
560 » » » » /* prevent long socket lists from growing out of
the group box */ | |
561 » » » » if (dy-3*NODE_DYS < rect->ymin) | |
562 » » » » » rect->ymin = dy-3*NODE_DYS; | |
563 » » » » if (dy+3*NODE_DYS > rect->ymax) | |
564 » » » » » rect->ymax = dy+3*NODE_DYS; | |
565 » » » » dy -= 2*NODE_DY; | |
566 » » » »······· | |
567 » » » » sock = sock->next; | |
568 » » » } | |
569 » » » while (gsock && (!sock || sock->groupsock!=gsock)) { | |
570 » » » » gsock->locx = rect->xmax; | |
571 » » » » gsock->locy = dy - NODE_DYS; | |
572 » » » »······· | |
573 » » » » /* prevent long socket lists from growing out of
the group box */ | |
574 » » » » if (dy-3*NODE_DYS < rect->ymin) | |
575 » » » » » rect->ymin = dy-3*NODE_DYS; | |
576 » » » » if (dy+3*NODE_DYS > rect->ymax) | |
577 » » » » » rect->ymax = dy+3*NODE_DYS; | |
578 » » » » dy -= 2*NODE_DY; | |
579 » » » »······· | |
580 » » » » gsock = gsock->next; | |
581 » » » } | |
582 » » » while (sock && gsock && sock->groupsock==gsock) { | |
583 » » » » gsock->locx = rect->xmax; | |
584 » » » » sock->locx = rect->xmax + node_group_frame; | |
585 » » » » sock->locy = gsock->locy = dy - NODE_DYS; | |
586 » » » »······· | |
587 » » » » /* prevent long socket lists from growing out of
the group box */ | |
588 » » » » if (dy-3*NODE_DYS < rect->ymin) | |
589 » » » » » rect->ymin = dy-3*NODE_DYS; | |
590 » » » » if (dy+3*NODE_DYS > rect->ymax) | |
591 » » » » » rect->ymax = dy+3*NODE_DYS; | |
592 » » » » dy -= 2*NODE_DY; | |
593 » » » »······· | |
594 » » » » sock = sock->next; | |
595 » » » » gsock = gsock->next; | |
596 } | 548 } |
597 } | 549 } |
598 ················ | 550 ················ |
599 /* Set the block bounds to clip mouse events from underlying nod
es. | 551 /* Set the block bounds to clip mouse events from underlying nod
es. |
600 * Add margin for header and input/output columns. | 552 * Add margin for header and input/output columns. |
601 */ | 553 */ |
602 uiExplicitBoundsBlock(gnode->block, | 554 uiExplicitBoundsBlock(gnode->block, |
603 » » » » » » » rect->xmin - node_grou
p_frame, | 555 » » » » » » » rect->xmin - group_fra
me, |
604 rect->ymin, | 556 rect->ymin, |
605 » » » » » » » rect->xmax + node_grou
p_frame, | 557 » » » » » » » rect->xmax + group_fra
me, |
606 rect->ymax + group_hea
der); | 558 rect->ymax + group_hea
der); |
607 } | 559 } |
608 } | 560 } |
609 | 561 |
610 static void update_group_input_cb(bContext *UNUSED(C), void *UNUSED(snode_v), vo
id *ngroup_v) | |
611 { | |
612 bNodeTree *ngroup= (bNodeTree*)ngroup_v; | |
613 ········ | |
614 ngroup->update |= NTREE_UPDATE_GROUP_IN; | |
615 ntreeUpdateTree(ngroup); | |
616 } | |
617 | |
618 static void update_group_output_cb(bContext *UNUSED(C), void *UNUSED(snode_v), v
oid *ngroup_v) | |
619 { | |
620 bNodeTree *ngroup= (bNodeTree*)ngroup_v; | |
621 ········ | |
622 ngroup->update |= NTREE_UPDATE_GROUP_OUT; | |
623 ntreeUpdateTree(ngroup); | |
624 } | |
625 | |
626 static void draw_group_socket_name(SpaceNode *snode, bNode *gnode, bNodeSocket *
sock, int in_out, float xoffset, float yoffset) | |
627 { | |
628 bNodeTree *ngroup= (bNodeTree*)gnode->id; | |
629 uiBut *bt; | |
630 ········ | |
631 if (sock->flag & SOCK_DYNAMIC) { | |
632 bt = uiDefBut(gnode->block, TEX, 0, "",· | |
633 sock->locx+xoffset, sock->locy+1+yoffs
et, 72, NODE_DY, | |
634 sock->name, 0, sizeof(sock->name), 0,
0, ""); | |
635 if (in_out==SOCK_IN) | |
636 uiButSetFunc(bt, update_group_input_cb, snode, ngroup); | |
637 else | |
638 uiButSetFunc(bt, update_group_output_cb, snode, ngroup); | |
639 } | |
640 else { | |
641 uiDefBut(gnode->block, LABEL, 0, sock->name, | |
642 sock->locx+xoffset, sock->locy+1+yoffset, 72, NODE_DY, | |
643 NULL, 0, sizeof(sock->name), 0, 0, ""); | |
644 } | |
645 } | |
646 | |
647 static void draw_group_socket(const bContext *C, SpaceNode *snode, bNodeTree *nt
ree, bNode *gnode, bNodeSocket *sock, bNodeSocket *gsock, int index, int in_out) | |
648 { | |
649 bNodeTree *ngroup= (bNodeTree*)gnode->id; | |
650 bNodeSocketType *stype= ntreeGetSocketType(gsock ? gsock->type : sock->t
ype); | |
651 uiBut *bt; | |
652 float offset; | |
653 int draw_value; | |
654 float node_group_frame= U.dpi*NODE_GROUP_FRAME/72; | |
655 float socket_size= NODE_SOCKSIZE*U.dpi/72; | |
656 float arrowbutw= 0.8f*UI_UNIT_X; | |
657 /* layout stuff for buttons on group left frame */ | |
658 float colw= 0.6f*node_group_frame; | |
659 float col1= 6 - node_group_frame; | |
660 float col2= col1 + colw+6; | |
661 float col3= - arrowbutw - 6; | |
662 /* layout stuff for buttons on group right frame */ | |
663 float cor1= 6; | |
664 float cor2= cor1 + arrowbutw + 6; | |
665 float cor3= cor2 + arrowbutw + 6; | |
666 ········ | |
667 /* node and group socket circles */ | |
668 if (sock) | |
669 node_socket_circle_draw(ntree, sock, socket_size); | |
670 if (gsock) | |
671 node_socket_circle_draw(ngroup, gsock, socket_size); | |
672 ········ | |
673 /* socket name */ | |
674 offset = (in_out==SOCK_IN ? col1 : cor3); | |
675 if (!gsock) | |
676 offset += (in_out==SOCK_IN ? node_group_frame : -node_group_fram
e); | |
677 ········ | |
678 /* draw both name and value button if: | |
679 * 1) input: not internal | |
680 * 2) output: (node type uses const outputs) and (group output is unlink
ed) | |
681 */ | |
682 draw_value = 0; | |
683 switch (in_out) { | |
684 case SOCK_IN: | |
685 draw_value = !(gsock && (gsock->flag & SOCK_INTERNAL)); | |
686 break; | |
687 case SOCK_OUT: | |
688 if (gnode->typeinfo->flag & NODE_CONST_OUTPUT) | |
689 draw_value = !(gsock && gsock->link); | |
690 break; | |
691 } | |
692 if (draw_value) { | |
693 /* both name and value buttons */ | |
694 if (gsock) { | |
695 draw_group_socket_name(snode, gnode, gsock, in_out, offs
et, 0); | |
696 if (stype->buttonfunc) | |
697 stype->buttonfunc(C, gnode->block, ngroup, NULL,
gsock, "", gsock->locx+offset, gsock->locy-NODE_DY, colw); | |
698 } | |
699 else { | |
700 draw_group_socket_name(snode, gnode, sock, in_out, offse
t, 0); | |
701 if (stype->buttonfunc) | |
702 stype->buttonfunc(C, gnode->block, ngroup, NULL,
sock, "", sock->locx+offset, sock->locy-NODE_DY, colw); | |
703 } | |
704 } | |
705 else { | |
706 /* only name, no value button */ | |
707 if (gsock) | |
708 draw_group_socket_name(snode, gnode, gsock, in_out, offs
et, -NODE_DYS); | |
709 else | |
710 draw_group_socket_name(snode, gnode, sock, in_out, offse
t, -NODE_DYS); | |
711 } | |
712 ········ | |
713 if (gsock && (gsock->flag & SOCK_DYNAMIC)) { | |
714 /* up/down buttons */ | |
715 offset = (in_out==SOCK_IN ? col2 : cor2); | |
716 uiBlockSetDirection(gnode->block, UI_TOP); | |
717 uiBlockBeginAlign(gnode->block); | |
718 bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_move
_up", 0, ICON_TRIA_UP, | |
719 gsock->locx+offset, gsock->lo
cy, arrowbutw, arrowbutw, ""); | |
720 if (!gsock->prev || !(gsock->prev->flag & SOCK_DYNAMIC)) | |
721 uiButSetFlag(bt, UI_BUT_DISABLED); | |
722 RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index); | |
723 RNA_enum_set(uiButGetOperatorPtrRNA(bt), "in_out", in_out); | |
724 bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_move
_down", 0, ICON_TRIA_DOWN, | |
725 gsock->locx+offset, gsock->lo
cy-arrowbutw, arrowbutw, arrowbutw, ""); | |
726 if (!gsock->next || !(gsock->next->flag & SOCK_DYNAMIC)) | |
727 uiButSetFlag(bt, UI_BUT_DISABLED); | |
728 RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index); | |
729 RNA_enum_set(uiButGetOperatorPtrRNA(bt), "in_out", in_out); | |
730 uiBlockEndAlign(gnode->block); | |
731 uiBlockSetDirection(gnode->block, 0); | |
732 ················ | |
733 /* remove button */ | |
734 offset = (in_out==SOCK_IN ? col3 : cor1); | |
735 uiBlockSetEmboss(gnode->block, UI_EMBOSSN); | |
736 bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_remo
ve", 0, ICON_X, | |
737 gsock->locx+offset, gsock->lo
cy-0.5f*arrowbutw, arrowbutw, arrowbutw, ""); | |
738 RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index); | |
739 RNA_enum_set(uiButGetOperatorPtrRNA(bt), "in_out", in_out); | |
740 uiBlockSetEmboss(gnode->block, UI_EMBOSS); | |
741 } | |
742 } | |
743 | |
744 /* groups are, on creation, centered around 0,0 */ | 562 /* groups are, on creation, centered around 0,0 */ |
745 static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN
odeTree *ntree, bNode *gnode) | 563 static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN
odeTree *ntree, bNode *gnode) |
746 { | 564 { |
747 if (!(gnode->flag & NODE_GROUP_EDIT)) { | 565 if (!(gnode->flag & NODE_GROUP_EDIT)) { |
748 node_draw_default(C, ar, snode, ntree, gnode); | 566 node_draw_default(C, ar, snode, ntree, gnode); |
749 } | 567 } |
750 else { | 568 else { |
751 bNodeTree *ngroup= (bNodeTree *)gnode->id; | 569 bNodeTree *ngroup= (bNodeTree *)gnode->id; |
752 bNodeSocket *sock, *gsock; | |
753 uiLayout *layout; | 570 uiLayout *layout; |
754 » » PointerRNA ptr; | 571 » » PointerRNA gnode_ptr, ngroup_ptr; |
755 rctf rect= gnode->totr; | 572 rctf rect= gnode->totr; |
756 » » float node_group_frame= U.dpi*NODE_GROUP_FRAME/72; | 573 » » float group_frame= U.dpi*NODE_GROUP_FRAME/72; |
757 float group_header= 26*U.dpi/72; | 574 float group_header= 26*U.dpi/72; |
758 ················ | 575 ················ |
759 » » int index; | 576 » » RNA_id_pointer_create((ID*)ntree, &ngroup_ptr); |
| 577 » » RNA_pointer_create(&ntree->id, &RNA_Node, gnode, &gnode_ptr); |
760 ················ | 578 ················ |
761 /* backdrop header */ | 579 /* backdrop header */ |
762 glEnable(GL_BLEND); | 580 glEnable(GL_BLEND); |
763 uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT); | 581 uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT); |
764 UI_ThemeColorShadeAlpha(TH_NODE_GROUP, 0, -70); | 582 UI_ThemeColorShadeAlpha(TH_NODE_GROUP, 0, -70); |
765 » » uiDrawBox(GL_POLYGON, rect.xmin-node_group_frame, rect.ymax, rec
t.xmax+node_group_frame, rect.ymax+group_header, BASIS_RAD); | 583 » » uiDrawBox(GL_POLYGON, rect.xmin-group_frame, rect.ymax, rect.xma
x+group_frame, rect.ymax+group_header, BASIS_RAD); |
766 ················ | 584 ················ |
767 /* backdrop body */ | 585 /* backdrop body */ |
768 UI_ThemeColorShadeAlpha(TH_BACK, -8, -70); | 586 UI_ThemeColorShadeAlpha(TH_BACK, -8, -70); |
769 uiSetRoundBox(UI_CNR_NONE); | 587 uiSetRoundBox(UI_CNR_NONE); |
770 uiDrawBox(GL_POLYGON, rect.xmin, rect.ymin, rect.xmax, rect.ymax
, BASIS_RAD); | 588 uiDrawBox(GL_POLYGON, rect.xmin, rect.ymin, rect.xmax, rect.ymax
, BASIS_RAD); |
771 ········ | 589 ········ |
772 /* input column */ | 590 /* input column */ |
773 UI_ThemeColorShadeAlpha(TH_BACK, 10, -50); | 591 UI_ThemeColorShadeAlpha(TH_BACK, 10, -50); |
774 uiSetRoundBox(UI_CNR_BOTTOM_LEFT); | 592 uiSetRoundBox(UI_CNR_BOTTOM_LEFT); |
775 » » uiDrawBox(GL_POLYGON, rect.xmin-node_group_frame, rect.ymin, rec
t.xmin, rect.ymax, BASIS_RAD); | 593 » » uiDrawBox(GL_POLYGON, rect.xmin-group_frame, rect.ymin, rect.xmi
n, rect.ymax, BASIS_RAD); |
776 ········ | 594 ········ |
777 /* output column */ | 595 /* output column */ |
778 UI_ThemeColorShadeAlpha(TH_BACK, 10, -50); | 596 UI_ThemeColorShadeAlpha(TH_BACK, 10, -50); |
779 uiSetRoundBox(UI_CNR_BOTTOM_RIGHT); | 597 uiSetRoundBox(UI_CNR_BOTTOM_RIGHT); |
780 » » uiDrawBox(GL_POLYGON, rect.xmax, rect.ymin, rect.xmax+node_group
_frame, rect.ymax, BASIS_RAD); | 598 » » uiDrawBox(GL_POLYGON, rect.xmax, rect.ymin, rect.xmax+group_fram
e, rect.ymax, BASIS_RAD); |
781 ········ | 599 ········ |
782 /* input column separator */ | 600 /* input column separator */ |
783 glColor4ub(200, 200, 200, 140); | 601 glColor4ub(200, 200, 200, 140); |
784 glBegin(GL_LINES); | 602 glBegin(GL_LINES); |
785 glVertex2f(rect.xmin, rect.ymin); | 603 glVertex2f(rect.xmin, rect.ymin); |
786 glVertex2f(rect.xmin, rect.ymax); | 604 glVertex2f(rect.xmin, rect.ymax); |
787 glEnd(); | 605 glEnd(); |
788 ········ | 606 ········ |
789 /* output column separator */ | 607 /* output column separator */ |
790 glColor4ub(200, 200, 200, 140); | 608 glColor4ub(200, 200, 200, 140); |
791 glBegin(GL_LINES); | 609 glBegin(GL_LINES); |
792 glVertex2f(rect.xmax, rect.ymin); | 610 glVertex2f(rect.xmax, rect.ymin); |
793 glVertex2f(rect.xmax, rect.ymax); | 611 glVertex2f(rect.xmax, rect.ymax); |
794 glEnd(); | 612 glEnd(); |
795 ········ | 613 ········ |
796 /* group node outline */ | 614 /* group node outline */ |
797 uiSetRoundBox(UI_CNR_ALL); | 615 uiSetRoundBox(UI_CNR_ALL); |
798 glColor4ub(200, 200, 200, 140); | 616 glColor4ub(200, 200, 200, 140); |
799 glEnable( GL_LINE_SMOOTH ); | 617 glEnable( GL_LINE_SMOOTH ); |
800 » » uiDrawBox(GL_LINE_LOOP, rect.xmin-node_group_frame, rect.ymin, r
ect.xmax+node_group_frame, rect.ymax+group_header, BASIS_RAD); | 618 » » uiDrawBox(GL_LINE_LOOP, rect.xmin-group_frame, rect.ymin, rect.x
max+group_frame, rect.ymax+group_header, BASIS_RAD); |
801 glDisable( GL_LINE_SMOOTH ); | 619 glDisable( GL_LINE_SMOOTH ); |
802 glDisable(GL_BLEND); | 620 glDisable(GL_BLEND); |
803 ················ | 621 ················ |
804 /* backdrop title */ | 622 /* backdrop title */ |
805 UI_ThemeColor(TH_TEXT_HI); | 623 UI_ThemeColor(TH_TEXT_HI); |
806 ········ | 624 ········ |
807 layout = uiBlockLayout(gnode->block, UI_LAYOUT_VERTICAL, UI_LAYO
UT_PANEL, (short)(rect.xmin+15), (short)(rect.ymax+group_header), | 625 layout = uiBlockLayout(gnode->block, UI_LAYOUT_VERTICAL, UI_LAYO
UT_PANEL, (short)(rect.xmin+15), (short)(rect.ymax+group_header), |
808 » » » » » » » MIN2((int)(rect.xmax
- rect.xmin-18.0f), node_group_frame+20), group_header, UI_GetStyle()); | 626 » » » » » » » MIN2((int)(rect.xmax
- rect.xmin-18.0f), group_frame+20), group_header, UI_GetStyle()); |
809 » » RNA_pointer_create(&ntree->id, &RNA_Node, gnode, &ptr); | 627 » » uiTemplateIDBrowse(layout, (bContext*)C, &gnode_ptr, "node_tree"
, NULL, NULL, NULL); |
810 » » uiTemplateIDBrowse(layout, (bContext*)C, &ptr, "node_tree", NULL
, NULL, NULL); | |
811 uiBlockLayoutResolve(gnode->block, NULL, NULL); | 628 uiBlockLayoutResolve(gnode->block, NULL, NULL); |
812 ········ | 629 ········ |
813 /* draw the internal tree nodes and links */ | 630 /* draw the internal tree nodes and links */ |
814 node_draw_nodetree(C, ar, snode, ngroup); | 631 node_draw_nodetree(C, ar, snode, ngroup); |
815 »······· | 632 » »······· |
816 » » /* group sockets */ | 633 » » { |
817 » » gsock=ngroup->inputs.first; | 634 » » » bNodeProxyItem *item; |
818 » » sock=gnode->inputs.first; | 635 » » » bNodeSocket *sock; |
819 » » index = 0; | 636 » » » uiBut *but; |
820 » » while (gsock || sock) { | 637 » » » PointerRNA *op_ptr; |
821 » » » while (sock && !sock->groupsock) { | 638 » » »······· |
822 » » » » draw_group_socket(C, snode, ntree, gnode, sock,
NULL, index, SOCK_IN); | 639 » » » float proxy_item_corner = 5*U.dpi/72; |
823 » » » » sock = sock->next; | 640 » » » float socket_size= NODE_SOCKSIZE*U.dpi/72; |
| 641 » » » float move_but_size= NODE_DY * U.dpi/72; |
| 642 » » »······· |
| 643 » » » /* group inputs */ |
| 644 » » » for (item=ngroup->proxy_inputs.first, sock=gnode->inputs
.first; item; item=item->next, sock=sock->next) { |
| 645 //» » » » bNodeSocket *proxy_sock = item->node->outputs.fi
rst; |
| 646 » » » » /* XXX UI_GetStringWidth does not work reliably
with view2d scaling */ |
| 647 //» » » » float name_width = UI_GetStringWidth(proxy_sock-
>name) * U.dpi/72; |
| 648 » » » » float name_width = item->totr.xmax - item->totr.
xmin - 12 * U.dpi/72; |
| 649 » » » » float name_x = item->totr.xmin + 6 * U.dpi/72; |
| 650 » » » » float name_y = 0.5f*(item->totr.ymax+item->totr.
ymin) - NODE_DYS; |
| 651 » » » »······· |
| 652 » » » » uiSetRoundBox(UI_CNR_ALL); |
| 653 » » » » if (item->node->flag & NODE_ACTIVE) |
| 654 » » » » » UI_ThemeColorShadeAlpha(TH_TEXT_HI, 0, -
40); |
| 655 » » » » else |
| 656 » » » » » UI_ThemeColorShadeAlpha(TH_NODE_PROXY, 0
, -40); |
| 657 » » » » uiRoundBox(item->totr.xmin, item->totr.ymin, ite
m->totr.xmax, item->totr.ymax, proxy_item_corner); |
| 658 » » » »······· |
| 659 » » » » uiDefBut(gnode->block, LABEL, 0, sock->name, |
| 660 » » » » » » name_x, name_y, name_width, NOD
E_DY, |
| 661 » » » » » » NULL, 0, sizeof(sock->name), 0,
0, ""); |
| 662 » » » »······· |
| 663 » » » » node_socket_circle_draw(ntree, sock, socket_size
); |
824 } | 664 } |
825 » » » while (gsock && (!sock || sock->groupsock!=gsock)) { | 665 » » »······· |
826 » » » » draw_group_socket(C, snode, ntree, gnode, NULL,
gsock, index, SOCK_IN); | 666 » » » /* up/down buttons */ |
827 » » » » gsock = gsock->next; | 667 » » » uiBlockBeginAlign(gnode->block); |
828 » » » » ++index; | 668 » » »······· |
| 669 » » » but = uiDefIconButO(gnode->block, BUT, "NODE_OT_move_inp
ut_item", 0, ICON_TRIA_UP, |
| 670 » » » » » » » » rect.xmin - 0.5f
*group_frame - move_but_size, rect.ymax + 0.5f*group_header - 0.5f*move_but_size
, |
| 671 » » » » » » » » move_but_size, m
ove_but_size, ""); |
| 672 » » » op_ptr = uiButGetOperatorPtrRNA(but); |
| 673 » » » RNA_enum_set(op_ptr, "direction", 1); |
| 674 » » »······· |
| 675 » » » but = uiDefIconButO(gnode->block, BUT, "NODE_OT_move_inp
ut_item", 0, ICON_TRIA_DOWN, |
| 676 » » » » » » » » rect.xmin - 0.5f
*group_frame, rect.ymax + 0.5f*group_header - 0.5f*move_but_size, |
| 677 » » » » » » » » move_but_size, m
ove_but_size, ""); |
| 678 » » » op_ptr = uiButGetOperatorPtrRNA(but); |
| 679 » » » RNA_enum_set(op_ptr, "direction", 2); |
| 680 » » »······· |
| 681 » » » uiBlockEndAlign(gnode->block); |
| 682 » » »······· |
| 683 » » » /* group outputs */ |
| 684 » » » for (item=ngroup->proxy_outputs.first, sock=gnode->outpu
ts.first; item; item=item->next, sock=sock->next) { |
| 685 //» » » » bNodeSocket *proxy_sock = item->node->inputs.fir
st; |
| 686 » » » » /* XXX UI_GetStringWidth does not work reliably
with view2d scaling */ |
| 687 //» » » » float name_width = UI_GetStringWidth(proxy_sock-
>name); |
| 688 » » » » float name_width = item->totr.xmax - item->totr.
xmin - 12 * U.dpi/72; |
| 689 » » » » float name_x = item->totr.xmax - 6 * U.dpi/72 -
name_width; |
| 690 » » » » float name_y = 0.5f*(item->totr.ymax+item->totr.
ymin) - NODE_DYS; |
| 691 » » » »······· |
| 692 » » » » uiSetRoundBox(UI_CNR_ALL); |
| 693 » » » » if (item->node->flag & NODE_ACTIVE) |
| 694 » » » » » UI_ThemeColorShadeAlpha(TH_TEXT_HI, 0, -
40); |
| 695 » » » » else |
| 696 » » » » » UI_ThemeColorShadeAlpha(TH_NODE_PROXY, 0
, -40); |
| 697 » » » » uiRoundBox(item->totr.xmin, item->totr.ymin, ite
m->totr.xmax, item->totr.ymax, proxy_item_corner); |
| 698 » » » »······· |
| 699 » » » » uiDefBut(gnode->block, LABEL, 0, sock->name, |
| 700 » » » » » » name_x, name_y, name_width, NOD
E_DY, |
| 701 » » » » » » NULL, 0, sizeof(sock->name), 0,
0, ""); |
| 702 » » » »······· |
| 703 » » » » node_socket_circle_draw(ntree, sock, socket_size
); |
829 } | 704 } |
830 » » » while (sock && gsock && sock->groupsock==gsock) { | 705 » » »······· |
831 » » » » draw_group_socket(C, snode, ntree, gnode, sock,
gsock, index, SOCK_IN); | 706 » » » /* up/down buttons */ |
832 » » » » sock = sock->next; | 707 » » » uiBlockBeginAlign(gnode->block); |
833 » » » » gsock = gsock->next; | 708 » » »······· |
834 » » » » ++index; | 709 » » » but = uiDefIconButO(gnode->block, BUT, "NODE_OT_move_out
put_item", 0, ICON_TRIA_UP, |
835 » » » } | 710 » » » » » » » » rect.xmax + 0.5f
*group_frame - move_but_size, rect.ymax + 0.5f*group_header - 0.5f*move_but_size
, |
836 » » } | 711 » » » » » » » » move_but_size, m
ove_but_size, ""); |
837 » » gsock=ngroup->outputs.first; | 712 » » » op_ptr = uiButGetOperatorPtrRNA(but); |
838 » » sock=gnode->outputs.first; | 713 » » » RNA_enum_set(op_ptr, "direction", 1); |
839 » » index = 0; | 714 » » »······· |
840 » » while (gsock || sock) { | 715 » » » but = uiDefIconButO(gnode->block, BUT, "NODE_OT_move_out
put_item", 0, ICON_TRIA_DOWN, |
841 » » » while (sock && !sock->groupsock) { | 716 » » » » » » » » rect.xmax + 0.5f
*group_frame, rect.ymax + 0.5f*group_header - 0.5f*move_but_size, |
842 » » » » draw_group_socket(C, snode, ntree, gnode, sock,
NULL, index, SOCK_OUT); | 717 » » » » » » » » move_but_size, m
ove_but_size, ""); |
843 » » » » sock = sock->next; | 718 » » » op_ptr = uiButGetOperatorPtrRNA(but); |
844 » » » } | 719 » » » RNA_enum_set(op_ptr, "direction", 2); |
845 » » » while (gsock && (!sock || sock->groupsock!=gsock)) { | 720 » » »······· |
846 » » » » draw_group_socket(C, snode, ntree, gnode, NULL,
gsock, index, SOCK_OUT); | 721 » » » uiBlockEndAlign(gnode->block); |
847 » » » » gsock = gsock->next; | |
848 » » » » ++index; | |
849 » » » } | |
850 » » » while (sock && gsock && sock->groupsock==gsock) { | |
851 » » » » draw_group_socket(C, snode, ntree, gnode, sock,
gsock, index, SOCK_OUT); | |
852 » » » » sock = sock->next; | |
853 » » » » gsock = gsock->next; | |
854 » » » » ++index; | |
855 » » » } | |
856 } | 722 } |
857 ················ | 723 ················ |
858 uiEndBlock(C, gnode->block); | 724 uiEndBlock(C, gnode->block); |
859 uiDrawBlock(C, gnode->block); | 725 uiDrawBlock(C, gnode->block); |
860 gnode->block= NULL; | 726 gnode->block= NULL; |
861 } | 727 } |
862 } | 728 } |
863 | 729 |
864 void node_uifunc_group(uiLayout *layout, bContext *C, PointerRNA *ptr) | 730 void node_uifunc_group(uiLayout *layout, bContext *C, PointerRNA *ptr) |
865 { | 731 { |
866 uiTemplateIDBrowse(layout, C, ptr, "node_tree", NULL, NULL, NULL); | 732 uiTemplateIDBrowse(layout, C, ptr, "node_tree", NULL, NULL, NULL); |
867 } | 733 } |
868 | 734 |
| 735 static void node_common_buts_proxy(uiLayout *layout, bContext *C, PointerRNA *pt
r) |
| 736 { |
| 737 bNode *node = (bNode*)ptr->data; |
| 738 bNodeSocket *sock = (node->type==NODE_PROXY_INPUT ? node->outputs.first
: node->inputs.first); |
| 739 PointerRNA sock_ptr; |
| 740 uiLayout *row; |
| 741 PropertyRNA *prop_type; |
| 742 const char *type_name; |
| 743 int show_default = (node->type==NODE_PROXY_INPUT); /* no socket in
input proxy node, display default value separately */ |
| 744 int show_details = !((node->custom1 & NODE_PROXY_AUTOTYPE) && sock->link
); /* with automatic type don't show type detail buttons */ |
| 745 ········ |
| 746 RNA_pointer_create((ID*)ptr->id.data, &RNA_NodeSocket, sock, &sock_ptr); |
| 747 ········ |
| 748 uiItemR(layout, ptr, "socket_name", 0, "", 0); |
| 749 ········ |
| 750 row = uiLayoutRow(layout, 1); |
| 751 uiItemL(row, "Type", 0); |
| 752 prop_type = RNA_struct_find_property(ptr, "socket_type"); |
| 753 RNA_property_enum_name(C, ptr, prop_type, RNA_property_enum_get(ptr, pro
p_type), &type_name); |
| 754 uiItemMenuEnumR(row, ptr, "socket_type", type_name, 0); |
| 755 ········ |
| 756 switch (sock->type) { |
| 757 case SOCK_FLOAT: { |
| 758 if (show_default) |
| 759 uiItemR(layout, &sock_ptr, "default_value", 0, "Default"
, 0); |
| 760 ················ |
| 761 if (show_details) { |
| 762 row = uiLayoutRow(layout, 1); |
| 763 uiItemL(row, "Subtype", 0); |
| 764 prop_type = RNA_struct_find_property(&sock_ptr, "subtype
"); |
| 765 RNA_property_enum_name(C, &sock_ptr, prop_type, RNA_prop
erty_enum_get(&sock_ptr, prop_type), &type_name); |
| 766 uiItemMenuEnumR(row, &sock_ptr, "subtype", type_name, 0)
; |
| 767 ························ |
| 768 row = uiLayoutRow(layout, 1); |
| 769 uiItemR(row, &sock_ptr, "min", 0, "Min.", 0); |
| 770 uiItemR(row, &sock_ptr, "max", 0, "Max.", 0); |
| 771 } |
| 772 break; |
| 773 } |
| 774 case SOCK_INT: { |
| 775 if (show_default) |
| 776 uiItemR(layout, &sock_ptr, "default_value", 0, "Default"
, 0); |
| 777 ················ |
| 778 if (show_details) { |
| 779 row = uiLayoutRow(layout, 1); |
| 780 uiItemL(row, "Subtype", 0); |
| 781 prop_type = RNA_struct_find_property(&sock_ptr, "subtype
"); |
| 782 RNA_property_enum_name(C, &sock_ptr, prop_type, RNA_prop
erty_enum_get(&sock_ptr, prop_type), &type_name); |
| 783 uiItemMenuEnumR(row, &sock_ptr, "subtype", type_name, 0)
; |
| 784 ························ |
| 785 row = uiLayoutRow(layout, 1); |
| 786 uiItemR(row, &sock_ptr, "min", 0, "Min.", 0); |
| 787 uiItemR(row, &sock_ptr, "max", 0, "Max.", 0); |
| 788 } |
| 789 break; |
| 790 } |
| 791 case SOCK_BOOLEAN: { |
| 792 if (show_default) |
| 793 uiItemR(layout, &sock_ptr, "default_value", 0, "Default"
, 0); |
| 794 break; |
| 795 } |
| 796 case SOCK_VECTOR: { |
| 797 if (show_default) |
| 798 uiItemR(layout, &sock_ptr, "default_value", 0, "Default"
, 0); |
| 799 ················ |
| 800 if (show_details) { |
| 801 row = uiLayoutRow(layout, 1); |
| 802 uiItemL(row, "Subtype", 0); |
| 803 prop_type = RNA_struct_find_property(&sock_ptr, "subtype
"); |
| 804 RNA_property_enum_name(C, &sock_ptr, prop_type, RNA_prop
erty_enum_get(&sock_ptr, prop_type), &type_name); |
| 805 uiItemMenuEnumR(row, &sock_ptr, "subtype", type_name, 0)
; |
| 806 ························ |
| 807 row = uiLayoutRow(layout, 1); |
| 808 uiItemR(row, &sock_ptr, "min", 0, "Min.", 0); |
| 809 uiItemR(row, &sock_ptr, "max", 0, "Max.", 0); |
| 810 } |
| 811 break; |
| 812 } |
| 813 case SOCK_RGBA: { |
| 814 if (show_default) |
| 815 uiItemR(layout, &sock_ptr, "default_value", 0, "Default"
, 0); |
| 816 break; |
| 817 } |
| 818 } |
| 819 } |
| 820 |
869 static void node_common_buts_whileloop(uiLayout *layout, bContext *UNUSED(C), Po
interRNA *ptr) | 821 static void node_common_buts_whileloop(uiLayout *layout, bContext *UNUSED(C), Po
interRNA *ptr) |
870 { | 822 { |
871 uiItemR(layout, ptr, "max_iterations", 0, NULL, 0); | 823 uiItemR(layout, ptr, "max_iterations", 0, NULL, 0); |
872 } | 824 } |
873 | 825 |
874 static void node_update_frame(const bContext *UNUSED(C), bNodeTree *UNUSED(ntree
), bNode *node) | 826 static void node_update_frame(const bContext *UNUSED(C), bNodeTree *UNUSED(ntree
), bNode *node) |
875 { | 827 { |
876 float locx, locy; | 828 float locx, locy; |
877 | 829 |
878 /* get "global" coords */ | 830 /* get "global" coords */ |
879 nodeSpaceCoords(node, &locx, &locy); | 831 nodeSpaceCoords(node, &locx, &locy); |
880 | 832 |
881 node->prvr.xmin= locx + NODE_DYS; | 833 node->prvr.xmin= locx + NODE_DYS; |
882 node->prvr.xmax= locx + node->width- NODE_DYS; | 834 node->prvr.xmax= locx + node->width- NODE_DYS; |
883 | 835 |
884 node->totr.xmin= locx; | 836 node->totr.xmin= locx; |
885 node->totr.xmax= locx + node->width; | 837 node->totr.xmax= locx + node->width; |
886 node->totr.ymax= locy; | 838 node->totr.ymax= locy; |
887 node->totr.ymin= locy - node->height; | 839 node->totr.ymin= locy - node->height; |
888 } | 840 } |
889 | 841 |
890 static void node_common_set_butfunc(bNodeType *ntype) | 842 static void node_common_set_butfunc(bNodeType *ntype) |
891 { | 843 { |
892 switch(ntype->type) { | 844 switch(ntype->type) { |
893 case NODE_GROUP: | 845 case NODE_GROUP: |
894 ntype->uifunc= node_uifunc_group; | 846 ntype->uifunc= node_uifunc_group; |
895 ntype->drawfunc= node_draw_group; | 847 ntype->drawfunc= node_draw_group; |
896 ntype->drawupdatefunc= node_update_group; | 848 ntype->drawupdatefunc= node_update_group; |
897 break; | 849 break; |
| 850 case NODE_PROXY_INPUT: |
| 851 ntype->uifunc = node_common_buts_proxy; |
| 852 break; |
| 853 case NODE_PROXY_OUTPUT: |
| 854 ntype->uifunc = node_common_buts_proxy; |
| 855 break; |
898 case NODE_FORLOOP: | 856 case NODE_FORLOOP: |
899 // ntype->uifunc= node_common_buts_group; | 857 // ntype->uifunc= node_common_buts_group; |
900 ntype->drawfunc= node_draw_group; | 858 ntype->drawfunc= node_draw_group; |
901 ntype->drawupdatefunc= node_update_group; | 859 ntype->drawupdatefunc= node_update_group; |
902 break; | 860 break; |
903 case NODE_WHILELOOP: | 861 case NODE_WHILELOOP: |
904 ntype->uifunc= node_common_buts_whileloop; | 862 ntype->uifunc= node_common_buts_whileloop; |
905 ntype->drawfunc= node_draw_group; | 863 ntype->drawfunc= node_draw_group; |
906 ntype->drawupdatefunc= node_update_group; | 864 ntype->drawupdatefunc= node_update_group; |
907 break; | 865 break; |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1086 // XXX ui_rasterpos_safe(butr->xmin + xoff, butr->ymin +
5, snode->aspect); | 1044 // XXX ui_rasterpos_safe(butr->xmin + xoff, butr->ymin +
5, snode->aspect); |
1087 // XXX snode_drawstring(snode, "Error! Check console..."
, butr->xmax - butr->xmin); | 1045 // XXX snode_drawstring(snode, "Error! Check console..."
, butr->xmax - butr->xmin); |
1088 ; | 1046 ; |
1089 } | 1047 } |
1090 } | 1048 } |
1091 } | 1049 } |
1092 | 1050 |
1093 /* only once called */ | 1051 /* only once called */ |
1094 static void node_shader_set_butfunc(bNodeType *ntype) | 1052 static void node_shader_set_butfunc(bNodeType *ntype) |
1095 { | 1053 { |
1096 ntype->uifuncbut = NULL; | |
1097 switch(ntype->type) { | 1054 switch(ntype->type) { |
1098 /* case NODE_GROUP: note, typeinfo for group is generated..
. see "XXX ugly hack" */ | |
1099 | |
1100 case SH_NODE_MATERIAL: | 1055 case SH_NODE_MATERIAL: |
1101 case SH_NODE_MATERIAL_EXT: | 1056 case SH_NODE_MATERIAL_EXT: |
1102 ntype->uifunc= node_shader_buts_material; | 1057 ntype->uifunc= node_shader_buts_material; |
1103 break; | 1058 break; |
1104 case SH_NODE_TEXTURE: | 1059 case SH_NODE_TEXTURE: |
1105 ntype->uifunc= node_buts_texture; | 1060 ntype->uifunc= node_buts_texture; |
1106 break; | 1061 break; |
1107 case SH_NODE_NORMAL: | 1062 case SH_NODE_NORMAL: |
1108 ntype->uifunc= node_buts_normal; | 1063 ntype->uifunc= node_buts_normal; |
1109 break; | 1064 break; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1165 ntype->uifunc= node_shader_buts_tex_voronoi; | 1120 ntype->uifunc= node_shader_buts_tex_voronoi; |
1166 break; | 1121 break; |
1167 case SH_NODE_BSDF_GLOSSY: | 1122 case SH_NODE_BSDF_GLOSSY: |
1168 case SH_NODE_BSDF_GLASS: | 1123 case SH_NODE_BSDF_GLASS: |
1169 ntype->uifunc= node_shader_buts_glossy; | 1124 ntype->uifunc= node_shader_buts_glossy; |
1170 break; | 1125 break; |
1171 case NODE_DYNAMIC: | 1126 case NODE_DYNAMIC: |
1172 ntype->uifunc= node_shader_buts_dynamic; | 1127 ntype->uifunc= node_shader_buts_dynamic; |
1173 break; | 1128 break; |
1174 } | 1129 } |
1175 if (ntype->uifuncbut == NULL) ntype->uifuncbut = ntype->uifunc; | |
1176 } | 1130 } |
1177 | 1131 |
1178 /* ****************** BUTTON CALLBACKS FOR COMPOSITE NODES ***************** */ | 1132 /* ****************** BUTTON CALLBACKS FOR COMPOSITE NODES ***************** */ |
1179 | 1133 |
1180 static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA *
ptr) | 1134 static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA *
ptr) |
1181 { | 1135 { |
1182 uiLayout *col; | 1136 uiLayout *col; |
1183 bNode *node= ptr->data; | 1137 bNode *node= ptr->data; |
1184 PointerRNA imaptr; | 1138 PointerRNA imaptr; |
1185 PropertyRNA *prop; | 1139 PropertyRNA *prop; |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1813 | 1767 |
1814 if(!node->id) | 1768 if(!node->id) |
1815 return; | 1769 return; |
1816 | 1770 |
1817 uiItemR(layout, ptr, "distortion_type", 0, "", 0); | 1771 uiItemR(layout, ptr, "distortion_type", 0, "", 0); |
1818 } | 1772 } |
1819 | 1773 |
1820 /* only once called */ | 1774 /* only once called */ |
1821 static void node_composit_set_butfunc(bNodeType *ntype) | 1775 static void node_composit_set_butfunc(bNodeType *ntype) |
1822 { | 1776 { |
1823 ntype->uifuncbut = NULL; | |
1824 switch(ntype->type) { | 1777 switch(ntype->type) { |
1825 /* case NODE_GROUP: note, typeinfo for group is generated..
. see "XXX ugly hack" */ | |
1826 | |
1827 case CMP_NODE_IMAGE: | 1778 case CMP_NODE_IMAGE: |
1828 ntype->uifunc= node_composit_buts_image; | 1779 ntype->uifunc= node_composit_buts_image; |
1829 break; | 1780 break; |
1830 case CMP_NODE_R_LAYERS: | 1781 case CMP_NODE_R_LAYERS: |
1831 ntype->uifunc= node_composit_buts_renderlayers; | 1782 ntype->uifunc= node_composit_buts_renderlayers; |
1832 break; | 1783 break; |
1833 case CMP_NODE_NORMAL: | 1784 case CMP_NODE_NORMAL: |
1834 ntype->uifunc= node_buts_normal; | 1785 ntype->uifunc= node_buts_normal; |
1835 break; | 1786 break; |
1836 case CMP_NODE_CURVE_VEC: | 1787 case CMP_NODE_CURVE_VEC: |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1975 break; | 1926 break; |
1976 case CMP_NODE_STABILIZE2D: | 1927 case CMP_NODE_STABILIZE2D: |
1977 ntype->uifunc= node_composit_buts_stabilize2d; | 1928 ntype->uifunc= node_composit_buts_stabilize2d; |
1978 break; | 1929 break; |
1979 case CMP_NODE_TRANSFORM: | 1930 case CMP_NODE_TRANSFORM: |
1980 ntype->uifunc= node_composit_buts_transform; | 1931 ntype->uifunc= node_composit_buts_transform; |
1981 break; | 1932 break; |
1982 case CMP_NODE_MOVIEDISTORTION: | 1933 case CMP_NODE_MOVIEDISTORTION: |
1983 ntype->uifunc= node_composit_buts_moviedistortion; | 1934 ntype->uifunc= node_composit_buts_moviedistortion; |
1984 break; | 1935 break; |
1985 default: | |
1986 ntype->uifunc= NULL; | |
1987 } | 1936 } |
1988 if (ntype->uifuncbut == NULL) ntype->uifuncbut = ntype->uifunc; | |
1989 | |
1990 } | 1937 } |
1991 | 1938 |
1992 /* ****************** BUTTON CALLBACKS FOR TEXTURE NODES ***************** */ | 1939 /* ****************** BUTTON CALLBACKS FOR TEXTURE NODES ***************** */ |
1993 | 1940 |
1994 static void node_texture_buts_bricks(uiLayout *layout, bContext *UNUSED(C), Poin
terRNA *ptr) | 1941 static void node_texture_buts_bricks(uiLayout *layout, bContext *UNUSED(C), Poin
terRNA *ptr) |
1995 { | 1942 { |
1996 uiLayout *col; | 1943 uiLayout *col; |
1997 ········ | 1944 ········ |
1998 col= uiLayoutColumn(layout, 1); | 1945 col= uiLayoutColumn(layout, 1); |
1999 uiItemR(col, ptr, "offset", 0, "Offset", ICON_NONE); | 1946 uiItemR(col, ptr, "offset", 0, "Offset", ICON_NONE); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2090 } | 2037 } |
2091 | 2038 |
2092 static void node_texture_buts_output(uiLayout *layout, bContext *UNUSED(C), Poin
terRNA *ptr) | 2039 static void node_texture_buts_output(uiLayout *layout, bContext *UNUSED(C), Poin
terRNA *ptr) |
2093 { | 2040 { |
2094 uiItemR(layout, ptr, "filepath", 0, "", ICON_NONE); | 2041 uiItemR(layout, ptr, "filepath", 0, "", ICON_NONE); |
2095 } | 2042 } |
2096 | 2043 |
2097 /* only once called */ | 2044 /* only once called */ |
2098 static void node_texture_set_butfunc(bNodeType *ntype) | 2045 static void node_texture_set_butfunc(bNodeType *ntype) |
2099 { | 2046 { |
2100 ntype->uifuncbut = NULL; | |
2101 if( ntype->type >= TEX_NODE_PROC && ntype->type < TEX_NODE_PROC_MAX ) { | 2047 if( ntype->type >= TEX_NODE_PROC && ntype->type < TEX_NODE_PROC_MAX ) { |
2102 ntype->uifunc = node_texture_buts_proc; | 2048 ntype->uifunc = node_texture_buts_proc; |
2103 } | 2049 } |
2104 else switch(ntype->type) { | 2050 else switch(ntype->type) { |
2105 ················ | 2051 ················ |
2106 case TEX_NODE_MATH: | 2052 case TEX_NODE_MATH: |
2107 ntype->uifunc = node_buts_math; | 2053 ntype->uifunc = node_buts_math; |
2108 break; | 2054 break; |
2109 ················ | 2055 ················ |
2110 case TEX_NODE_MIX_RGB: | 2056 case TEX_NODE_MIX_RGB: |
(...skipping 21 matching lines...) Expand all Loading... |
2132 break; | 2078 break; |
2133 ························ | 2079 ························ |
2134 case TEX_NODE_IMAGE: | 2080 case TEX_NODE_IMAGE: |
2135 ntype->uifunc = node_texture_buts_image; | 2081 ntype->uifunc = node_texture_buts_image; |
2136 break; | 2082 break; |
2137 ························ | 2083 ························ |
2138 case TEX_NODE_OUTPUT: | 2084 case TEX_NODE_OUTPUT: |
2139 ntype->uifunc = node_texture_buts_output; | 2085 ntype->uifunc = node_texture_buts_output; |
2140 break; | 2086 break; |
2141 } | 2087 } |
2142 if (ntype->uifuncbut == NULL) ntype->uifuncbut = ntype->uifunc; | |
2143 } | 2088 } |
2144 | 2089 |
2145 /* ******* init draw callbacks for all tree types, only called in usiblender.c,
once ************* */ | 2090 /* ******* init draw callbacks for all tree types, only called in usiblender.c,
once ************* */ |
2146 | 2091 |
2147 void ED_init_node_butfuncs(void) | 2092 void ED_init_node_butfuncs(void) |
2148 { | 2093 { |
2149 bNodeTreeType *treetype; | 2094 bNodeTreeType *treetype; |
2150 bNodeType *ntype; | 2095 bNodeType *ntype; |
2151 bNodeSocketType *stype; | 2096 bNodeSocketType *stype; |
2152 int i; | 2097 int i; |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2567 }······························· | 2512 }······························· |
2568 else { | 2513 else { |
2569 th_col1 = TH_REDALERT; | 2514 th_col1 = TH_REDALERT; |
2570 } | 2515 } |
2571 } | 2516 } |
2572 } | 2517 } |
2573 ········ | 2518 ········ |
2574 node_draw_link_bezier(v2d, snode, link, th_col1, do_shaded, th_col2, do_
triple, th_col3); | 2519 node_draw_link_bezier(v2d, snode, link, th_col1, do_shaded, th_col2, do_
triple, th_col3); |
2575 // node_draw_link_straight(v2d, snode, link, th_col1, do_shaded, th_col2, d
o_triple, th_col3); | 2520 // node_draw_link_straight(v2d, snode, link, th_col1, do_shaded, th_col2, d
o_triple, th_col3); |
2576 } | 2521 } |
OLD | NEW |