~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

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

  • Committer: Reinhard Tartler
  • Date: 2014-05-31 01:50:05 UTC
  • mfrom: (14.2.27 sid)
  • Revision ID: siretart@tauware.de-20140531015005-ml6druahuj82nsav
mergeĀ fromĀ debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
#include "DNA_object_types.h"
38
38
#include "DNA_space_types.h"
39
39
#include "DNA_screen_types.h"
 
40
#include "DNA_userdef_types.h"
40
41
 
41
42
#include "BKE_context.h"
42
43
#include "BKE_curve.h"
49
50
#include "BLF_api.h"
50
51
#include "BLF_translation.h"
51
52
 
52
 
#include "NOD_texture.h"
53
 
 
54
53
#include "BIF_gl.h"
55
54
#include "BIF_glutil.h"
56
55
 
57
 
#include "BLF_translation.h"
58
56
#include "MEM_guardedalloc.h"
59
57
 
60
58
#include "RNA_access.h"
86
84
        uiItemL(layout, text, 0);
87
85
}
88
86
 
89
 
static void node_draw_input_default(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr)
90
 
{
91
 
        bNodeSocket *sock = (bNodeSocket *)ptr->data;
92
 
        sock->typeinfo->draw(C, layout, ptr, node_ptr, IFACE_(sock->name));
93
 
}
94
 
 
95
 
static void node_draw_output_default(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr)
96
 
{
97
 
        bNodeSocket *sock = ptr->data;
98
 
        node_socket_button_label(C, layout, ptr, node_ptr, IFACE_(sock->name));
99
 
}
100
 
 
101
87
 
102
88
/* ****************** BASE DRAW FUNCTIONS FOR NEW OPERATOR NODES ***************** */
103
89
 
165
151
        
166
152
        col = uiLayoutColumn(layout, FALSE);
167
153
        uiTemplateColorPicker(col, &sockptr, "default_value", 1, 0, 0, 0);
168
 
        uiItemR(col, &sockptr, "default_value", 0, "", ICON_NONE);
 
154
        uiItemR(col, &sockptr, "default_value", UI_ITEM_R_SLIDER, "", ICON_NONE);
169
155
}
170
156
 
171
157
static void node_buts_mix_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
339
325
/* ****************** BUTTON CALLBACKS FOR COMMON NODES ***************** */
340
326
 
341
327
 
342
 
static void node_uifunc_group(uiLayout *layout, bContext *C, PointerRNA *ptr)
 
328
static void node_draw_buttons_group(uiLayout *layout, bContext *C, PointerRNA *ptr)
343
329
{
344
330
        uiTemplateIDBrowse(layout, C, ptr, "node_tree", NULL, NULL, NULL);
345
331
}
348
334
 * Not ideal to do this in every draw call, but doing as transform callback doesn't work,
349
335
 * since the child node totr rects are not updated properly at that point.
350
336
 */
351
 
static void node_update_frame(const bContext *UNUSED(C), bNodeTree *ntree, bNode *node)
 
337
static void node_draw_frame_prepare(const bContext *UNUSED(C), bNodeTree *ntree, bNode *node)
352
338
{
353
339
        const float margin = 1.5f * U.widget_unit;
354
340
        NodeFrame *data = (NodeFrame *)node->storage;
396
382
        node->totr = rect;
397
383
}
398
384
 
399
 
static void node_draw_frame_label(bNode *node, const float aspect)
 
385
static void node_draw_frame_label(bNodeTree *ntree, bNode *node, const float aspect)
400
386
{
401
387
        /* XXX font id is crap design */
402
388
        const int fontid = UI_GetStyle()->widgetlabel.uifont_id;
403
389
        NodeFrame *data = (NodeFrame *)node->storage;
404
390
        rctf *rct = &node->totr;
405
391
        int color_id = node_get_colorid(node);
406
 
        const char *label = nodeLabel(node);
 
392
        char label[MAX_NAME];
407
393
        /* XXX a bit hacky, should use separate align values for x and y */
408
394
        float width, ascender;
409
395
        float x, y;
410
396
        const int font_size = data->label_size / aspect;
411
397
 
 
398
        nodeLabel(ntree, node, label, sizeof(label));
 
399
 
412
400
        BLF_enable(fontid, BLF_ASPECT);
413
401
        BLF_aspect(fontid, aspect, aspect, 1.0f);
414
402
        BLF_size(fontid, MIN2(24, font_size), U.dpi); /* clamp otherwise it can suck up a LOT of memory */
415
403
        
416
404
        /* title color */
417
 
        UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.8f, 10);
 
405
        UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.4f, 10);
418
406
 
419
 
        width = BLF_width(fontid, label);
 
407
        width = BLF_width(fontid, label, sizeof(label));
420
408
        ascender = BLF_ascender(fontid);
421
409
        
422
410
        /* 'x' doesn't need aspect correction */
430
418
}
431
419
 
432
420
static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode,
433
 
                            bNodeTree *UNUSED(ntree), bNode *node, bNodeInstanceKey UNUSED(key))
 
421
                            bNodeTree *ntree, bNode *node, bNodeInstanceKey UNUSED(key))
434
422
{
435
423
        rctf *rct = &node->totr;
436
424
        int color_id = node_get_colorid(node);
479
467
        }
480
468
        
481
469
        /* label */
482
 
        node_draw_frame_label(node, snode->aspect);
 
470
        node_draw_frame_label(ntree, node, snode->aspect);
483
471
        
484
472
        UI_ThemeClearColor(color_id);
485
473
                
511
499
        return dir;
512
500
}
513
501
 
514
 
static void node_buts_frame_details(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 
502
static void node_buts_frame_ex(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
515
503
{
516
504
        uiItemR(layout, ptr, "label_size", 0, IFACE_("Label Size"), ICON_NONE);
517
505
        uiItemR(layout, ptr, "shrink", 0, IFACE_("Shrink"), ICON_NONE);
520
508
 
521
509
#define NODE_REROUTE_SIZE   8.0f
522
510
 
523
 
static void node_update_reroute(const bContext *UNUSED(C), bNodeTree *UNUSED(ntree), bNode *node)
 
511
static void node_draw_reroute_prepare(const bContext *UNUSED(C), bNodeTree *UNUSED(ntree), bNode *node)
524
512
{
525
513
        bNodeSocket *nsock;
526
514
        float locx, locy;
571
559
         */
572
560
#if 0
573
561
        /* body */
574
 
        uiSetRoundBox(15);
 
562
        uiSetRoundBox(UI_CNR_ALL);
575
563
        UI_ThemeColor4(TH_NODE);
576
564
        glEnable(GL_BLEND);
577
565
        uiRoundBox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, size);
632
620
{
633
621
        switch (ntype->type) {
634
622
                case NODE_GROUP:
635
 
                        ntype->uifunc = node_uifunc_group;
 
623
                        ntype->draw_buttons = node_draw_buttons_group;
636
624
                        break;
637
625
                case NODE_FRAME:
638
 
                        ntype->drawfunc = node_draw_frame;
639
 
                        ntype->drawupdatefunc = node_update_frame;
640
 
                        ntype->uifuncbut = node_buts_frame_details;
 
626
                        ntype->draw_nodetype = node_draw_frame;
 
627
                        ntype->draw_nodetype_prepare = node_draw_frame_prepare;
 
628
                        ntype->draw_buttons_ex = node_buts_frame_ex;
641
629
                        ntype->resize_area_func = node_resize_area_frame;
642
630
                        break;
643
631
                case NODE_REROUTE:
644
 
                        ntype->drawfunc = node_draw_reroute;
645
 
                        ntype->drawupdatefunc = node_update_reroute;
 
632
                        ntype->draw_nodetype = node_draw_reroute;
 
633
                        ntype->draw_nodetype_prepare = node_draw_reroute_prepare;
646
634
                        ntype->tweak_area_func = node_tweak_area_reroute;
647
635
                        break;
648
636
        }
669
657
                /* don't use iuser->framenr directly because it may not be updated if auto-refresh is off */
670
658
                Scene *scene = CTX_data_scene(C);
671
659
                ImageUser *iuser = iuserptr->data;
 
660
                /* Image *ima = imaptr->data; */  /* UNUSED */
 
661
 
672
662
                char numstr[32];
673
663
                const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0, NULL);
674
664
                BLI_snprintf(numstr, sizeof(numstr), IFACE_("Frame: %d"), framenr);
681
671
                uiItemR(col, ptr, "frame_start", 0, NULL, ICON_NONE);
682
672
                uiItemR(col, ptr, "frame_offset", 0, NULL, ICON_NONE);
683
673
                uiItemR(col, ptr, "use_cyclic", 0, NULL, ICON_NONE);
684
 
                uiItemR(col, ptr, "use_auto_refresh", UI_ITEM_R_ICON_ONLY, NULL, ICON_NONE);
 
674
                uiItemR(col, ptr, "use_auto_refresh", 0, NULL, ICON_NONE);
685
675
        }
686
676
 
687
677
        col = uiLayoutColumn(layout, FALSE);
707
697
 
708
698
static void node_shader_buts_mapping(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
709
699
{
710
 
        uiLayout *row;
711
 
        
 
700
        uiLayout *row, *col, *sub;
 
701
 
712
702
        uiItemR(layout, ptr, "vector_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
713
703
 
714
 
        uiItemL(layout, IFACE_("Location:"), ICON_NONE);
715
 
        row = uiLayoutRow(layout, TRUE);
716
 
        uiItemR(row, ptr, "translation", 0, "", ICON_NONE);
717
 
        
718
 
        uiItemL(layout, IFACE_("Rotation:"), ICON_NONE);
719
 
        row = uiLayoutRow(layout, TRUE);
720
 
        uiItemR(row, ptr, "rotation", 0, "", ICON_NONE);
721
 
        
722
 
        uiItemL(layout, IFACE_("Scale:"), ICON_NONE);
723
 
        row = uiLayoutRow(layout, TRUE);
724
 
        uiItemR(row, ptr, "scale", 0, "", ICON_NONE);
725
 
        
726
 
        row = uiLayoutRow(layout, TRUE);
727
 
        uiItemR(row, ptr, "use_min", 0, IFACE_("Min"), ICON_NONE);
728
 
        uiItemR(row, ptr, "min", 0, "", ICON_NONE);
729
 
        
730
 
        row = uiLayoutRow(layout, TRUE);
731
 
        uiItemR(row, ptr, "use_max", 0, IFACE_("Max"), ICON_NONE);
732
 
        uiItemR(row, ptr, "max", 0, "", ICON_NONE);
 
704
        row = uiLayoutRow(layout, FALSE);
 
705
 
 
706
        col = uiLayoutColumn(row, TRUE);
 
707
        uiItemL(col, IFACE_("Location:"), ICON_NONE);
 
708
        uiItemR(col, ptr, "translation", 0, "", ICON_NONE);
 
709
 
 
710
        col = uiLayoutColumn(row, TRUE);
 
711
        uiItemL(col, IFACE_("Rotation:"), ICON_NONE);
 
712
        uiItemR(col, ptr, "rotation", 0, "", ICON_NONE);
 
713
 
 
714
        col = uiLayoutColumn(row, TRUE);
 
715
        uiItemL(col, IFACE_("Scale:"), ICON_NONE);
 
716
        uiItemR(col, ptr, "scale", 0, "", ICON_NONE);
 
717
 
 
718
        row = uiLayoutRow(layout, FALSE);
 
719
 
 
720
        col = uiLayoutColumn(row, TRUE);
 
721
        uiItemR(col, ptr, "use_min", 0, IFACE_("Min"), ICON_NONE);
 
722
        sub = uiLayoutColumn(col, TRUE);
 
723
        uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_min"));
 
724
        uiItemR(sub, ptr, "min", 0, "", ICON_NONE);
 
725
 
 
726
        col = uiLayoutColumn(row, TRUE);
 
727
        uiItemR(col, ptr, "use_max", 0, IFACE_("Max"), ICON_NONE);
 
728
        sub = uiLayoutColumn(col, TRUE);
 
729
        uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_max"));
 
730
        uiItemR(sub, ptr, "max", 0, "", ICON_NONE);
733
731
}
734
732
 
735
733
static void node_shader_buts_vect_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
763
761
        }
764
762
}
765
763
 
 
764
static void node_shader_buts_lamp(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 
765
{
 
766
        uiItemR(layout, ptr, "lamp_object", 0, IFACE_("Lamp Object"), ICON_NONE);
 
767
}
 
768
 
766
769
static void node_shader_buts_attribute(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
767
770
{
768
771
        uiItemR(layout, ptr, "attribute_name", 0, IFACE_("Name"), ICON_NONE);
778
781
        PointerRNA imaptr = RNA_pointer_get(ptr, "image");
779
782
        PointerRNA iuserptr = RNA_pointer_get(ptr, "image_user");
780
783
 
 
784
        uiLayoutSetContextPointer(layout, "image_user", &iuserptr);
781
785
        uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
782
786
        uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE);
783
787
        uiItemR(layout, ptr, "projection", 0, "", ICON_NONE);
792
796
        node_buts_image_user(layout, C, &iuserptr, &imaptr, &iuserptr);
793
797
}
794
798
 
795
 
static void node_shader_buts_tex_image_details(uiLayout *layout, bContext *C, PointerRNA *ptr)
 
799
static void node_shader_buts_tex_image_ex(uiLayout *layout, bContext *C, PointerRNA *ptr)
796
800
{
797
801
        PointerRNA iuserptr = RNA_pointer_get(ptr, "image_user");
798
802
        uiTemplateImage(layout, C, ptr, "image", &iuserptr, 0);
803
807
        PointerRNA imaptr = RNA_pointer_get(ptr, "image");
804
808
        PointerRNA iuserptr = RNA_pointer_get(ptr, "image_user");
805
809
 
 
810
        uiLayoutSetContextPointer(layout, "image_user", &iuserptr);
806
811
        uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
807
812
        uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE);
808
813
        uiItemR(layout, ptr, "projection", 0, "", ICON_NONE);
835
840
        uiLayout *col;
836
841
        
837
842
        col = uiLayoutColumn(layout, TRUE);
838
 
        uiItemR(col, ptr, "offset", 0, IFACE_("Offset"), ICON_NONE);
 
843
        uiItemR(col, ptr, "offset", UI_ITEM_R_SLIDER, IFACE_("Offset"), ICON_NONE);
839
844
        uiItemR(col, ptr, "offset_frequency", 0, IFACE_("Frequency"), ICON_NONE);
840
845
        
841
846
        col = uiLayoutColumn(layout, TRUE);
919
924
        PointerRNA scene = CTX_data_pointer_get(C, "scene");
920
925
        if (scene.data) {
921
926
                PointerRNA cscene = RNA_pointer_get(&scene, "cycles");
922
 
                if (cscene.data && RNA_enum_get(&cscene, "device") == 1)
 
927
                if (cscene.data && (RNA_enum_get(&cscene, "device") == 1 && U.compute_device_type != 0))
923
928
                        uiItemL(layout, IFACE_("SSS not supported on GPU"), ICON_ERROR);
924
929
        }
925
930
 
926
931
        uiItemR(layout, ptr, "falloff", 0, "", ICON_NONE);
927
932
}
928
933
 
 
934
 
 
935
static void node_shader_buts_volume(uiLayout *layout, bContext *C, PointerRNA *UNUSED(ptr))
 
936
{
 
937
        /* Volume does not work on GPU yet */
 
938
        PointerRNA scene = CTX_data_pointer_get(C, "scene");
 
939
        if (scene.data) {
 
940
                PointerRNA cscene = RNA_pointer_get(&scene, "cycles");
 
941
 
 
942
                if (cscene.data && (RNA_enum_get(&cscene, "device") == 1 && U.compute_device_type != 0))
 
943
                        uiItemL(layout, IFACE_("Volumes not supported on GPU"), ICON_ERROR);
 
944
        }
 
945
}
 
946
 
929
947
static void node_shader_buts_toon(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
930
948
{
931
949
        uiItemR(layout, ptr, "component", 0, "", ICON_NONE);
953
971
        uiItemO(row, "", ICON_FILE_REFRESH, "node.shader_script_update");
954
972
}
955
973
 
956
 
static void node_shader_buts_script_details(uiLayout *layout, bContext *C, PointerRNA *ptr)
 
974
static void node_shader_buts_script_ex(uiLayout *layout, bContext *C, PointerRNA *ptr)
957
975
{
958
976
        uiItemS(layout);
959
977
 
971
989
        switch (ntype->type) {
972
990
                case SH_NODE_MATERIAL:
973
991
                case SH_NODE_MATERIAL_EXT:
974
 
                        ntype->uifunc = node_shader_buts_material;
 
992
                        ntype->draw_buttons = node_shader_buts_material;
975
993
                        break;
976
994
                case SH_NODE_TEXTURE:
977
 
                        ntype->uifunc = node_buts_texture;
 
995
                        ntype->draw_buttons = node_buts_texture;
978
996
                        break;
979
997
                case SH_NODE_NORMAL:
980
 
                        ntype->uifunc = node_buts_normal;
 
998
                        ntype->draw_buttons = node_buts_normal;
981
999
                        break;
982
1000
                case SH_NODE_CURVE_VEC:
983
 
                        ntype->uifunc = node_buts_curvevec;
 
1001
                        ntype->draw_buttons = node_buts_curvevec;
984
1002
                        break;
985
1003
                case SH_NODE_CURVE_RGB:
986
 
                        ntype->uifunc = node_buts_curvecol;
 
1004
                        ntype->draw_buttons = node_buts_curvecol;
987
1005
                        break;
988
1006
                case SH_NODE_MAPPING:
989
 
                        ntype->uifunc = node_shader_buts_mapping;
 
1007
                        ntype->draw_buttons = node_shader_buts_mapping;
990
1008
                        break;
991
1009
                case SH_NODE_VALUE:
992
 
                        ntype->uifunc = node_buts_value;
 
1010
                        ntype->draw_buttons = node_buts_value;
993
1011
                        break;
994
1012
                case SH_NODE_RGB:
995
 
                        ntype->uifunc = node_buts_rgb;
 
1013
                        ntype->draw_buttons = node_buts_rgb;
996
1014
                        break;
997
1015
                case SH_NODE_MIX_RGB:
998
 
                        ntype->uifunc = node_buts_mix_rgb;
 
1016
                        ntype->draw_buttons = node_buts_mix_rgb;
999
1017
                        break;
1000
1018
                case SH_NODE_VALTORGB:
1001
 
                        ntype->uifunc = node_buts_colorramp;
 
1019
                        ntype->draw_buttons = node_buts_colorramp;
1002
1020
                        break;
1003
1021
                case SH_NODE_MATH: 
1004
 
                        ntype->uifunc = node_buts_math;
 
1022
                        ntype->draw_buttons = node_buts_math;
1005
1023
                        break; 
1006
1024
                case SH_NODE_VECT_MATH: 
1007
 
                        ntype->uifunc = node_shader_buts_vect_math;
 
1025
                        ntype->draw_buttons = node_shader_buts_vect_math;
1008
1026
                        break; 
1009
1027
                case SH_NODE_VECT_TRANSFORM: 
1010
 
                        ntype->uifunc = node_shader_buts_vect_transform;
 
1028
                        ntype->draw_buttons = node_shader_buts_vect_transform;
1011
1029
                        break; 
1012
1030
                case SH_NODE_GEOMETRY:
1013
 
                        ntype->uifunc = node_shader_buts_geometry;
 
1031
                        ntype->draw_buttons = node_shader_buts_geometry;
 
1032
                        break;
 
1033
                case SH_NODE_LAMP:
 
1034
                        ntype->draw_buttons = node_shader_buts_lamp;
1014
1035
                        break;
1015
1036
                case SH_NODE_ATTRIBUTE:
1016
 
                        ntype->uifunc = node_shader_buts_attribute;
 
1037
                        ntype->draw_buttons = node_shader_buts_attribute;
1017
1038
                        break;
1018
1039
                case SH_NODE_WIREFRAME:
1019
 
                        ntype->uifunc = node_shader_buts_wireframe;
 
1040
                        ntype->draw_buttons = node_shader_buts_wireframe;
1020
1041
                        break;
1021
1042
                case SH_NODE_TEX_SKY:
1022
 
                        ntype->uifunc = node_shader_buts_tex_sky;
 
1043
                        ntype->draw_buttons = node_shader_buts_tex_sky;
1023
1044
                        break;
1024
1045
                case SH_NODE_TEX_IMAGE:
1025
 
                        ntype->uifunc = node_shader_buts_tex_image;
1026
 
                        ntype->uifuncbut = node_shader_buts_tex_image_details;
 
1046
                        ntype->draw_buttons = node_shader_buts_tex_image;
 
1047
                        ntype->draw_buttons_ex = node_shader_buts_tex_image_ex;
1027
1048
                        break;
1028
1049
                case SH_NODE_TEX_ENVIRONMENT:
1029
 
                        ntype->uifunc = node_shader_buts_tex_environment;
 
1050
                        ntype->draw_buttons = node_shader_buts_tex_environment;
1030
1051
                        break;
1031
1052
                case SH_NODE_TEX_GRADIENT:
1032
 
                        ntype->uifunc = node_shader_buts_tex_gradient;
 
1053
                        ntype->draw_buttons = node_shader_buts_tex_gradient;
1033
1054
                        break;
1034
1055
                case SH_NODE_TEX_MAGIC:
1035
 
                        ntype->uifunc = node_shader_buts_tex_magic;
 
1056
                        ntype->draw_buttons = node_shader_buts_tex_magic;
1036
1057
                        break;
1037
1058
                case SH_NODE_TEX_BRICK:
1038
 
                        ntype->uifunc = node_shader_buts_tex_brick;
 
1059
                        ntype->draw_buttons = node_shader_buts_tex_brick;
1039
1060
                        break;
1040
1061
                case SH_NODE_TEX_WAVE:
1041
 
                        ntype->uifunc = node_shader_buts_tex_wave;
 
1062
                        ntype->draw_buttons = node_shader_buts_tex_wave;
1042
1063
                        break;
1043
1064
                case SH_NODE_TEX_MUSGRAVE:
1044
 
                        ntype->uifunc = node_shader_buts_tex_musgrave;
 
1065
                        ntype->draw_buttons = node_shader_buts_tex_musgrave;
1045
1066
                        break;
1046
1067
                case SH_NODE_TEX_VORONOI:
1047
 
                        ntype->uifunc = node_shader_buts_tex_voronoi;
 
1068
                        ntype->draw_buttons = node_shader_buts_tex_voronoi;
1048
1069
                        break;
1049
1070
                case SH_NODE_TEX_COORD:
1050
 
                        ntype->uifunc = node_shader_buts_tex_coord;
 
1071
                        ntype->draw_buttons = node_shader_buts_tex_coord;
1051
1072
                        break;
1052
1073
                case SH_NODE_BUMP:
1053
 
                        ntype->uifunc = node_shader_buts_bump;
 
1074
                        ntype->draw_buttons = node_shader_buts_bump;
1054
1075
                        break;
1055
1076
                case SH_NODE_NORMAL_MAP:
1056
 
                        ntype->uifunc = node_shader_buts_normal_map;
 
1077
                        ntype->draw_buttons = node_shader_buts_normal_map;
1057
1078
                        break;
1058
1079
                case SH_NODE_TANGENT:
1059
 
                        ntype->uifunc = node_shader_buts_tangent;
 
1080
                        ntype->draw_buttons = node_shader_buts_tangent;
1060
1081
                        break;
1061
1082
                case SH_NODE_BSDF_GLOSSY:
1062
1083
                case SH_NODE_BSDF_GLASS:
1063
1084
                case SH_NODE_BSDF_REFRACTION:
1064
 
                        ntype->uifunc = node_shader_buts_glossy;
 
1085
                        ntype->draw_buttons = node_shader_buts_glossy;
1065
1086
                        break;
1066
1087
                case SH_NODE_SUBSURFACE_SCATTERING:
1067
 
                        ntype->uifunc = node_shader_buts_subsurface;
 
1088
                        ntype->draw_buttons = node_shader_buts_subsurface;
 
1089
                        break;
 
1090
                case SH_NODE_VOLUME_SCATTER:
 
1091
                        ntype->draw_buttons = node_shader_buts_volume;
 
1092
                        break;
 
1093
                case SH_NODE_VOLUME_ABSORPTION:
 
1094
                        ntype->draw_buttons = node_shader_buts_volume;
1068
1095
                        break;
1069
1096
                case SH_NODE_BSDF_TOON:
1070
 
                        ntype->uifunc = node_shader_buts_toon;
 
1097
                        ntype->draw_buttons = node_shader_buts_toon;
1071
1098
                        break;
1072
1099
                case SH_NODE_BSDF_HAIR:
1073
 
                        ntype->uifunc = node_shader_buts_hair;
 
1100
                        ntype->draw_buttons = node_shader_buts_hair;
1074
1101
                        break;
1075
1102
                case SH_NODE_SCRIPT:
1076
 
                        ntype->uifunc = node_shader_buts_script;
1077
 
                        ntype->uifuncbut = node_shader_buts_script_details;
 
1103
                        ntype->draw_buttons = node_shader_buts_script;
 
1104
                        ntype->draw_buttons_ex = node_shader_buts_script_ex;
1078
1105
                        break;
1079
1106
        }
1080
1107
}
1086
1113
        bNode *node = ptr->data;
1087
1114
        PointerRNA imaptr, iuserptr;
1088
1115
        
 
1116
        RNA_pointer_create((ID *)ptr->id.data, &RNA_ImageUser, node->storage, &iuserptr);
 
1117
        uiLayoutSetContextPointer(layout, "image_user", &iuserptr);
1089
1118
        uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
1090
 
        
1091
1119
        if (!node->id) return;
1092
1120
        
1093
1121
        imaptr = RNA_pointer_get(ptr, "image");
1094
 
        RNA_pointer_create((ID *)ptr->id.data, &RNA_ImageUser, node->storage, &iuserptr);
1095
 
        
 
1122
 
1096
1123
        node_buts_image_user(layout, C, ptr, &imaptr, &iuserptr);
1097
1124
}
1098
1125
 
1099
 
static void node_composit_buts_image_details(uiLayout *layout, bContext *C, PointerRNA *ptr)
 
1126
static void node_composit_buts_image_ex(uiLayout *layout, bContext *C, PointerRNA *ptr)
1100
1127
{
1101
1128
        bNode *node = ptr->data;
1102
1129
        PointerRNA iuserptr;
1103
1130
 
1104
1131
        RNA_pointer_create((ID *)ptr->id.data, &RNA_ImageUser, node->storage, &iuserptr);
 
1132
        uiLayoutSetContextPointer(layout, "image_user", &iuserptr);
1105
1133
        uiTemplateImage(layout, C, ptr, "image", &iuserptr, 0);
1106
1134
}
1107
1135
 
1212
1240
        uiItemR(col, ptr, "sigma_space", 0, NULL, ICON_NONE);
1213
1241
}
1214
1242
 
1215
 
static void node_composit_buts_defocus(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 
1243
static void node_composit_buts_defocus(uiLayout *layout, bContext *C, PointerRNA *ptr)
1216
1244
{
1217
1245
        uiLayout *sub, *col;
1218
1246
        
1232
1260
 
1233
1261
        col = uiLayoutColumn(layout, FALSE);
1234
1262
        uiItemR(col, ptr, "use_preview", 0, NULL, ICON_NONE);
1235
 
        
 
1263
 
 
1264
        uiTemplateID(layout, C, ptr, "scene", NULL, NULL, NULL);
 
1265
 
1236
1266
        col = uiLayoutColumn(layout, FALSE);
1237
1267
        uiItemR(col, ptr, "use_zbuffer", 0, NULL, ICON_NONE);
1238
1268
        sub = uiLayoutColumn(col, FALSE);
1456
1486
 
1457
1487
        col = uiLayoutColumn(layout, FALSE);
1458
1488
        uiItemR(col, ptr, "threshold", 0, NULL, ICON_NONE);
1459
 
        uiItemR(col, ptr, "threshold_neighbour", 0, NULL, ICON_NONE);
 
1489
        uiItemR(col, ptr, "threshold_neighbor", 0, NULL, ICON_NONE);
1460
1490
}
1461
1491
 
1462
1492
static void node_composit_buts_diff_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1578
1608
        uiItemR(layout, ptr, "use_antialiasing", 0, NULL, ICON_NONE);
1579
1609
}
1580
1610
 
1581
 
/* draw function for file output node sockets, displays only sub-path and format, no value button */
1582
 
static void node_draw_input_file_output(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr)
1583
 
{
1584
 
        bNodeTree *ntree = ptr->id.data;
1585
 
        bNodeSocket *sock = ptr->data;
1586
 
        uiLayout *row;
1587
 
        PointerRNA inputptr, imfptr;
1588
 
        int imtype;
1589
 
        
1590
 
        row = uiLayoutRow(layout, FALSE);
1591
 
        
1592
 
        imfptr = RNA_pointer_get(node_ptr, "format");
1593
 
        imtype = RNA_enum_get(&imfptr, "file_format");
1594
 
        if (imtype == R_IMF_IMTYPE_MULTILAYER) {
1595
 
                NodeImageMultiFileSocket *input = sock->storage;
1596
 
                RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotLayer, input, &inputptr);
1597
 
                
1598
 
                uiItemL(row, input->layer, ICON_NONE);
1599
 
        }
1600
 
        else {
1601
 
                NodeImageMultiFileSocket *input = sock->storage;
1602
 
                PropertyRNA *imtype_prop;
1603
 
                const char *imtype_name;
1604
 
                uiBlock *block;
1605
 
                RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotFile, input, &inputptr);
1606
 
                
1607
 
                uiItemL(row, input->path, ICON_NONE);
1608
 
                
1609
 
                if (!RNA_boolean_get(&inputptr, "use_node_format"))
1610
 
                        imfptr = RNA_pointer_get(&inputptr, "format");
1611
 
                
1612
 
                imtype_prop = RNA_struct_find_property(&imfptr, "file_format");
1613
 
                RNA_property_enum_name((bContext *)C, &imfptr, imtype_prop,
1614
 
                                       RNA_property_enum_get(&imfptr, imtype_prop), &imtype_name);
1615
 
                block = uiLayoutGetBlock(row);
1616
 
                uiBlockSetEmboss(block, UI_EMBOSSP);
1617
 
                uiItemL(row, imtype_name, ICON_NONE);
1618
 
                uiBlockSetEmboss(block, UI_EMBOSSN);
1619
 
        }
1620
 
}
1621
1611
static void node_composit_buts_file_output(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1622
1612
{
1623
1613
        PointerRNA imfptr = RNA_pointer_get(ptr, "format");
1629
1619
                uiItemL(layout, IFACE_("Base Path:"), ICON_NONE);
1630
1620
        uiItemR(layout, ptr, "base_path", 0, "", ICON_NONE);
1631
1621
}
1632
 
static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C, PointerRNA *ptr)
 
1622
static void node_composit_buts_file_output_ex(uiLayout *layout, bContext *C, PointerRNA *ptr)
1633
1623
{
1634
1624
        PointerRNA imfptr = RNA_pointer_get(ptr, "format");
1635
1625
        PointerRNA active_input_ptr, op_ptr;
1685
1675
                else {
1686
1676
                        col = uiLayoutColumn(layout, TRUE);
1687
1677
                        
1688
 
                        uiItemL(col, IFACE_("File Path:"), ICON_NONE);
 
1678
                        uiItemL(col, IFACE_("File Subpath:"), ICON_NONE);
1689
1679
                        row = uiLayoutRow(col, FALSE);
1690
1680
                        uiItemR(row, &active_input_ptr, "path", 0, "", ICON_NONE);
1691
1681
                        uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "",
1787
1777
        }
1788
1778
 
1789
1779
}
1790
 
static void node_composit_buts_colorbalance_but(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 
1780
static void node_composit_buts_colorbalance_ex(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1791
1781
{
1792
1782
        uiItemR(layout, ptr, "correction_method", 0, NULL, ICON_NONE);
1793
1783
 
1841
1831
        uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
1842
1832
}
1843
1833
 
1844
 
static void node_composit_buts_movieclip_details(uiLayout *layout, bContext *C, PointerRNA *ptr)
 
1834
static void node_composit_buts_movieclip_ex(uiLayout *layout, bContext *C, PointerRNA *ptr)
1845
1835
{
1846
1836
        bNode *node = ptr->data;
1847
1837
        PointerRNA clipptr;
1945
1935
        uiItemR(row, ptr, "midtones_end", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1946
1936
}
1947
1937
 
1948
 
static void node_composit_buts_colorcorrection_but(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 
1938
static void node_composit_buts_colorcorrection_ex(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1949
1939
{
1950
1940
        uiLayout *row;
1951
1941
        
2052
2042
        const float backdropWidth = backdrop->x;
2053
2043
        const float backdropHeight = backdrop->y;
2054
2044
        const float aspect = backdropWidth / backdropHeight;
2055
 
        const float rad = DEG2RADF(-boxmask->rotation);
 
2045
        const float rad = -boxmask->rotation;
2056
2046
        const float cosine = cosf(rad);
2057
2047
        const float sine = sinf(rad);
2058
2048
        const float halveBoxWidth = backdropWidth * (boxmask->width / 2.0f);
2090
2080
        const float backdropWidth = backdrop->x;
2091
2081
        const float backdropHeight = backdrop->y;
2092
2082
        const float aspect = backdropWidth / backdropHeight;
2093
 
        const float rad = DEG2RADF(-ellipsemask->rotation);
 
2083
        const float rad = -ellipsemask->rotation;
2094
2084
        const float cosine = cosf(rad);
2095
2085
        const float sine = sinf(rad);
2096
2086
        const float halveBoxWidth = backdropWidth * (ellipsemask->width / 2.0f);
2147
2137
        uiItemR(layout, ptr, "use_alpha", 0, NULL, ICON_NONE);
2148
2138
}
2149
2139
 
2150
 
static void node_composit_buts_viewer_but(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 
2140
static void node_composit_buts_viewer_ex(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2151
2141
{
2152
2142
        uiLayout *col;
2153
2143
        
2295
2285
{
2296
2286
        switch (ntype->type) {
2297
2287
                case CMP_NODE_IMAGE:
2298
 
                        ntype->uifunc = node_composit_buts_image;
2299
 
                        ntype->uifuncbut = node_composit_buts_image_details;
 
2288
                        ntype->draw_buttons = node_composit_buts_image;
 
2289
                        ntype->draw_buttons_ex = node_composit_buts_image_ex;
2300
2290
                        break;
2301
2291
                case CMP_NODE_R_LAYERS:
2302
 
                        ntype->uifunc = node_composit_buts_renderlayers;
 
2292
                        ntype->draw_buttons = node_composit_buts_renderlayers;
2303
2293
                        break;
2304
2294
                case CMP_NODE_NORMAL:
2305
 
                        ntype->uifunc = node_buts_normal;
 
2295
                        ntype->draw_buttons = node_buts_normal;
2306
2296
                        break;
2307
2297
                case CMP_NODE_CURVE_VEC:
2308
 
                        ntype->uifunc = node_buts_curvevec;
 
2298
                        ntype->draw_buttons = node_buts_curvevec;
2309
2299
                        break;
2310
2300
                case CMP_NODE_CURVE_RGB:
2311
 
                        ntype->uifunc = node_buts_curvecol;
 
2301
                        ntype->draw_buttons = node_buts_curvecol;
2312
2302
                        break;
2313
2303
                case CMP_NODE_VALUE:
2314
 
                        ntype->uifunc = node_buts_value;
 
2304
                        ntype->draw_buttons = node_buts_value;
2315
2305
                        break;
2316
2306
                case CMP_NODE_RGB:
2317
 
                        ntype->uifunc = node_buts_rgb;
 
2307
                        ntype->draw_buttons = node_buts_rgb;
2318
2308
                        break;
2319
2309
                case CMP_NODE_FLIP:
2320
 
                        ntype->uifunc = node_composit_buts_flip;
 
2310
                        ntype->draw_buttons = node_composit_buts_flip;
2321
2311
                        break;
2322
2312
                case CMP_NODE_SPLITVIEWER:
2323
 
                        ntype->uifunc = node_composit_buts_splitviewer;
 
2313
                        ntype->draw_buttons = node_composit_buts_splitviewer;
2324
2314
                        break;
2325
2315
                case CMP_NODE_MIX_RGB:
2326
 
                        ntype->uifunc = node_buts_mix_rgb;
 
2316
                        ntype->draw_buttons = node_buts_mix_rgb;
2327
2317
                        break;
2328
2318
                case CMP_NODE_VALTORGB:
2329
 
                        ntype->uifunc = node_buts_colorramp;
 
2319
                        ntype->draw_buttons = node_buts_colorramp;
2330
2320
                        break;
2331
2321
                case CMP_NODE_CROP:
2332
 
                        ntype->uifunc = node_composit_buts_crop;
 
2322
                        ntype->draw_buttons = node_composit_buts_crop;
2333
2323
                        break;
2334
2324
                case CMP_NODE_BLUR:
2335
 
                        ntype->uifunc = node_composit_buts_blur;
 
2325
                        ntype->draw_buttons = node_composit_buts_blur;
2336
2326
                        break;
2337
2327
                case CMP_NODE_DBLUR:
2338
 
                        ntype->uifunc = node_composit_buts_dblur;
 
2328
                        ntype->draw_buttons = node_composit_buts_dblur;
2339
2329
                        break;
2340
2330
                case CMP_NODE_BILATERALBLUR:
2341
 
                        ntype->uifunc = node_composit_buts_bilateralblur;
 
2331
                        ntype->draw_buttons = node_composit_buts_bilateralblur;
2342
2332
                        break;
2343
2333
                case CMP_NODE_DEFOCUS:
2344
 
                        ntype->uifunc = node_composit_buts_defocus;
 
2334
                        ntype->draw_buttons = node_composit_buts_defocus;
2345
2335
                        break;
2346
2336
                case CMP_NODE_GLARE:
2347
 
                        ntype->uifunc = node_composit_buts_glare;
 
2337
                        ntype->draw_buttons = node_composit_buts_glare;
2348
2338
                        break;
2349
2339
                case CMP_NODE_TONEMAP:
2350
 
                        ntype->uifunc = node_composit_buts_tonemap;
 
2340
                        ntype->draw_buttons = node_composit_buts_tonemap;
2351
2341
                        break;
2352
2342
                case CMP_NODE_LENSDIST:
2353
 
                        ntype->uifunc = node_composit_buts_lensdist;
 
2343
                        ntype->draw_buttons = node_composit_buts_lensdist;
2354
2344
                        break;
2355
2345
                case CMP_NODE_VECBLUR:
2356
 
                        ntype->uifunc = node_composit_buts_vecblur;
 
2346
                        ntype->draw_buttons = node_composit_buts_vecblur;
2357
2347
                        break;
2358
2348
                case CMP_NODE_FILTER:
2359
 
                        ntype->uifunc = node_composit_buts_filter;
 
2349
                        ntype->draw_buttons = node_composit_buts_filter;
2360
2350
                        break;
2361
2351
                case CMP_NODE_MAP_VALUE:
2362
 
                        ntype->uifunc = node_composit_buts_map_value;
 
2352
                        ntype->draw_buttons = node_composit_buts_map_value;
2363
2353
                        break;
2364
2354
                case CMP_NODE_MAP_RANGE:
2365
 
                        ntype->uifunc = node_composit_buts_map_range;
 
2355
                        ntype->draw_buttons = node_composit_buts_map_range;
2366
2356
                        break;
2367
2357
                case CMP_NODE_TIME:
2368
 
                        ntype->uifunc = node_buts_time;
 
2358
                        ntype->draw_buttons = node_buts_time;
2369
2359
                        break;
2370
2360
                case CMP_NODE_ALPHAOVER:
2371
 
                        ntype->uifunc = node_composit_buts_alphaover;
 
2361
                        ntype->draw_buttons = node_composit_buts_alphaover;
2372
2362
                        break;
2373
2363
                case CMP_NODE_HUE_SAT:
2374
 
                        ntype->uifunc = node_composit_buts_hue_sat;
 
2364
                        ntype->draw_buttons = node_composit_buts_hue_sat;
2375
2365
                        break;
2376
2366
                case CMP_NODE_TEXTURE:
2377
 
                        ntype->uifunc = node_buts_texture;
 
2367
                        ntype->draw_buttons = node_buts_texture;
2378
2368
                        break;
2379
2369
                case CMP_NODE_DILATEERODE:
2380
 
                        ntype->uifunc = node_composit_buts_dilateerode;
 
2370
                        ntype->draw_buttons = node_composit_buts_dilateerode;
2381
2371
                        break;
2382
2372
                case CMP_NODE_INPAINT:
2383
 
                        ntype->uifunc = node_composit_buts_inpaint;
 
2373
                        ntype->draw_buttons = node_composit_buts_inpaint;
2384
2374
                        break;
2385
2375
                case CMP_NODE_DESPECKLE:
2386
 
                        ntype->uifunc = node_composit_buts_despeckle;
 
2376
                        ntype->draw_buttons = node_composit_buts_despeckle;
2387
2377
                        break;
2388
2378
                case CMP_NODE_OUTPUT_FILE:
2389
 
                        ntype->uifunc = node_composit_buts_file_output;
2390
 
                        ntype->uifuncbut = node_composit_buts_file_output_details;
2391
 
                        ntype->drawinputfunc = node_draw_input_file_output;
 
2379
                        ntype->draw_buttons = node_composit_buts_file_output;
 
2380
                        ntype->draw_buttons_ex = node_composit_buts_file_output_ex;
2392
2381
                        break;
2393
2382
                case CMP_NODE_DIFF_MATTE:
2394
 
                        ntype->uifunc = node_composit_buts_diff_matte;
 
2383
                        ntype->draw_buttons = node_composit_buts_diff_matte;
2395
2384
                        break;
2396
2385
                case CMP_NODE_DIST_MATTE:
2397
 
                        ntype->uifunc = node_composit_buts_distance_matte;
 
2386
                        ntype->draw_buttons = node_composit_buts_distance_matte;
2398
2387
                        break;
2399
2388
                case CMP_NODE_COLOR_SPILL:
2400
 
                        ntype->uifunc = node_composit_buts_color_spill;
 
2389
                        ntype->draw_buttons = node_composit_buts_color_spill;
2401
2390
                        break;
2402
2391
                case CMP_NODE_CHROMA_MATTE:
2403
 
                        ntype->uifunc = node_composit_buts_chroma_matte;
 
2392
                        ntype->draw_buttons = node_composit_buts_chroma_matte;
2404
2393
                        break;
2405
2394
                case CMP_NODE_COLOR_MATTE:
2406
 
                        ntype->uifunc = node_composit_buts_color_matte;
 
2395
                        ntype->draw_buttons = node_composit_buts_color_matte;
2407
2396
                        break;
2408
2397
                case CMP_NODE_SCALE:
2409
 
                        ntype->uifunc = node_composit_buts_scale;
 
2398
                        ntype->draw_buttons = node_composit_buts_scale;
2410
2399
                        break;
2411
2400
                case CMP_NODE_ROTATE:
2412
 
                        ntype->uifunc = node_composit_buts_rotate;
 
2401
                        ntype->draw_buttons = node_composit_buts_rotate;
2413
2402
                        break;
2414
2403
                case CMP_NODE_CHANNEL_MATTE:
2415
 
                        ntype->uifunc = node_composit_buts_channel_matte;
 
2404
                        ntype->draw_buttons = node_composit_buts_channel_matte;
2416
2405
                        break;
2417
2406
                case CMP_NODE_LUMA_MATTE:
2418
 
                        ntype->uifunc = node_composit_buts_luma_matte;
 
2407
                        ntype->draw_buttons = node_composit_buts_luma_matte;
2419
2408
                        break;
2420
2409
                case CMP_NODE_MAP_UV:
2421
 
                        ntype->uifunc = node_composit_buts_map_uv;
 
2410
                        ntype->draw_buttons = node_composit_buts_map_uv;
2422
2411
                        break;
2423
2412
                case CMP_NODE_ID_MASK:
2424
 
                        ntype->uifunc = node_composit_buts_id_mask;
 
2413
                        ntype->draw_buttons = node_composit_buts_id_mask;
2425
2414
                        break;
2426
2415
                case CMP_NODE_DOUBLEEDGEMASK:
2427
 
                        ntype->uifunc = node_composit_buts_double_edge_mask;
 
2416
                        ntype->draw_buttons = node_composit_buts_double_edge_mask;
2428
2417
                        break;
2429
2418
                case CMP_NODE_MATH:
2430
 
                        ntype->uifunc = node_buts_math;
 
2419
                        ntype->draw_buttons = node_buts_math;
2431
2420
                        break;
2432
2421
                case CMP_NODE_INVERT:
2433
 
                        ntype->uifunc = node_composit_buts_invert;
 
2422
                        ntype->draw_buttons = node_composit_buts_invert;
2434
2423
                        break;
2435
2424
                case CMP_NODE_PREMULKEY:
2436
 
                        ntype->uifunc = node_composit_buts_premulkey;
 
2425
                        ntype->draw_buttons = node_composit_buts_premulkey;
2437
2426
                        break;
2438
2427
                case CMP_NODE_VIEW_LEVELS:
2439
 
                        ntype->uifunc = node_composit_buts_view_levels;
 
2428
                        ntype->draw_buttons = node_composit_buts_view_levels;
2440
2429
                        break;
2441
2430
                case CMP_NODE_COLORBALANCE:
2442
 
                        ntype->uifunc = node_composit_buts_colorbalance;
2443
 
                        ntype->uifuncbut = node_composit_buts_colorbalance_but;
 
2431
                        ntype->draw_buttons = node_composit_buts_colorbalance;
 
2432
                        ntype->draw_buttons_ex = node_composit_buts_colorbalance_ex;
2444
2433
                        break;
2445
2434
                case CMP_NODE_HUECORRECT:
2446
 
                        ntype->uifunc = node_composit_buts_huecorrect;
 
2435
                        ntype->draw_buttons = node_composit_buts_huecorrect;
2447
2436
                        break;
2448
2437
                case CMP_NODE_ZCOMBINE:
2449
 
                        ntype->uifunc = node_composit_buts_zcombine;
 
2438
                        ntype->draw_buttons = node_composit_buts_zcombine;
2450
2439
                        break;
2451
2440
                case CMP_NODE_COMBYCCA:
2452
2441
                case CMP_NODE_SEPYCCA:
2453
 
                        ntype->uifunc = node_composit_buts_ycc;
 
2442
                        ntype->draw_buttons = node_composit_buts_ycc;
2454
2443
                        break;
2455
2444
                case CMP_NODE_MOVIECLIP:
2456
 
                        ntype->uifunc = node_composit_buts_movieclip;
2457
 
                        ntype->uifuncbut = node_composit_buts_movieclip_details;
 
2445
                        ntype->draw_buttons = node_composit_buts_movieclip;
 
2446
                        ntype->draw_buttons_ex = node_composit_buts_movieclip_ex;
2458
2447
                        break;
2459
2448
                case CMP_NODE_STABILIZE2D:
2460
 
                        ntype->uifunc = node_composit_buts_stabilize2d;
 
2449
                        ntype->draw_buttons = node_composit_buts_stabilize2d;
2461
2450
                        break;
2462
2451
                case CMP_NODE_TRANSFORM:
2463
 
                        ntype->uifunc = node_composit_buts_transform;
 
2452
                        ntype->draw_buttons = node_composit_buts_transform;
2464
2453
                        break;
2465
2454
                case CMP_NODE_TRANSLATE:
2466
 
                        ntype->uifunc = node_composit_buts_translate;
 
2455
                        ntype->draw_buttons = node_composit_buts_translate;
2467
2456
                        break;
2468
2457
                case CMP_NODE_MOVIEDISTORTION:
2469
 
                        ntype->uifunc = node_composit_buts_moviedistortion;
 
2458
                        ntype->draw_buttons = node_composit_buts_moviedistortion;
2470
2459
                        break;
2471
2460
                case CMP_NODE_COLORCORRECTION:
2472
 
                        ntype->uifunc = node_composit_buts_colorcorrection;
2473
 
                        ntype->uifuncbut = node_composit_buts_colorcorrection_but;
 
2461
                        ntype->draw_buttons = node_composit_buts_colorcorrection;
 
2462
                        ntype->draw_buttons_ex = node_composit_buts_colorcorrection_ex;
2474
2463
                        break;
2475
2464
                case CMP_NODE_SWITCH:
2476
 
                        ntype->uifunc = node_composit_buts_switch;
 
2465
                        ntype->draw_buttons = node_composit_buts_switch;
2477
2466
                        break;
2478
2467
                case CMP_NODE_MASK_BOX:
2479
 
                        ntype->uifunc = node_composit_buts_boxmask;
2480
 
                        ntype->uibackdropfunc = node_composit_backdrop_boxmask;
 
2468
                        ntype->draw_buttons = node_composit_buts_boxmask;
 
2469
                        ntype->draw_backdrop = node_composit_backdrop_boxmask;
2481
2470
                        break;
2482
2471
                case CMP_NODE_MASK_ELLIPSE:
2483
 
                        ntype->uifunc = node_composit_buts_ellipsemask;
2484
 
                        ntype->uibackdropfunc = node_composit_backdrop_ellipsemask;
 
2472
                        ntype->draw_buttons = node_composit_buts_ellipsemask;
 
2473
                        ntype->draw_backdrop = node_composit_backdrop_ellipsemask;
2485
2474
                        break;
2486
2475
                case CMP_NODE_BOKEHIMAGE:
2487
 
                        ntype->uifunc = node_composit_buts_bokehimage;
 
2476
                        ntype->draw_buttons = node_composit_buts_bokehimage;
2488
2477
                        break;
2489
2478
                case CMP_NODE_BOKEHBLUR:
2490
 
                        ntype->uifunc = node_composit_buts_bokehblur;
 
2479
                        ntype->draw_buttons = node_composit_buts_bokehblur;
2491
2480
                        break;
2492
2481
                case CMP_NODE_VIEWER:
2493
 
                        ntype->uifunc = node_composit_buts_viewer;
2494
 
                        ntype->uifuncbut = node_composit_buts_viewer_but;
2495
 
                        ntype->uibackdropfunc = node_composit_backdrop_viewer;
 
2482
                        ntype->draw_buttons = node_composit_buts_viewer;
 
2483
                        ntype->draw_buttons_ex = node_composit_buts_viewer_ex;
 
2484
                        ntype->draw_backdrop = node_composit_backdrop_viewer;
2496
2485
                        break;
2497
2486
                case CMP_NODE_COMPOSITE:
2498
 
                        ntype->uifunc = node_composit_buts_composite;
 
2487
                        ntype->draw_buttons = node_composit_buts_composite;
2499
2488
                        break;
2500
2489
                case CMP_NODE_MASK:
2501
 
                        ntype->uifunc = node_composit_buts_mask;
 
2490
                        ntype->draw_buttons = node_composit_buts_mask;
2502
2491
                        break;
2503
2492
                case CMP_NODE_KEYINGSCREEN:
2504
 
                        ntype->uifunc = node_composit_buts_keyingscreen;
 
2493
                        ntype->draw_buttons = node_composit_buts_keyingscreen;
2505
2494
                        break;
2506
2495
                case CMP_NODE_KEYING:
2507
 
                        ntype->uifunc = node_composit_buts_keying;
 
2496
                        ntype->draw_buttons = node_composit_buts_keying;
2508
2497
                        break;
2509
2498
                case CMP_NODE_TRACKPOS:
2510
 
                        ntype->uifunc = node_composit_buts_trackpos;
 
2499
                        ntype->draw_buttons = node_composit_buts_trackpos;
2511
2500
                        break;
2512
2501
                case CMP_NODE_PLANETRACKDEFORM:
2513
 
                        ntype->uifunc = node_composit_buts_planetrackdeform;
 
2502
                        ntype->draw_buttons = node_composit_buts_planetrackdeform;
2514
2503
                        break;
2515
2504
        }
2516
2505
}
2522
2511
        uiLayout *col;
2523
2512
        
2524
2513
        col = uiLayoutColumn(layout, TRUE);
2525
 
        uiItemR(col, ptr, "offset", 0, IFACE_("Offset"), ICON_NONE);
 
2514
        uiItemR(col, ptr, "offset", UI_ITEM_R_SLIDER, IFACE_("Offset"), ICON_NONE);
2526
2515
        uiItemR(col, ptr, "offset_frequency", 0, IFACE_("Frequency"), ICON_NONE);
2527
2516
        
2528
2517
        col = uiLayoutColumn(layout, TRUE);
2615
2604
        uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
2616
2605
}
2617
2606
 
2618
 
static void node_texture_buts_image_details(uiLayout *layout, bContext *C, PointerRNA *ptr)
 
2607
static void node_texture_buts_image_ex(uiLayout *layout, bContext *C, PointerRNA *ptr)
2619
2608
{
2620
2609
        bNode *node = ptr->data;
2621
2610
        PointerRNA iuserptr;
2633
2622
static void node_texture_set_butfunc(bNodeType *ntype)
2634
2623
{
2635
2624
        if (ntype->type >= TEX_NODE_PROC && ntype->type < TEX_NODE_PROC_MAX) {
2636
 
                ntype->uifunc = node_texture_buts_proc;
 
2625
                ntype->draw_buttons = node_texture_buts_proc;
2637
2626
        }
2638
2627
        else {
2639
2628
                switch (ntype->type) {
2640
2629
 
2641
2630
                        case TEX_NODE_MATH:
2642
 
                                ntype->uifunc = node_buts_math;
 
2631
                                ntype->draw_buttons = node_buts_math;
2643
2632
                                break;
2644
2633
 
2645
2634
                        case TEX_NODE_MIX_RGB:
2646
 
                                ntype->uifunc = node_buts_mix_rgb;
 
2635
                                ntype->draw_buttons = node_buts_mix_rgb;
2647
2636
                                break;
2648
2637
 
2649
2638
                        case TEX_NODE_VALTORGB:
2650
 
                                ntype->uifunc = node_buts_colorramp;
 
2639
                                ntype->draw_buttons = node_buts_colorramp;
2651
2640
                                break;
2652
2641
 
2653
2642
                        case TEX_NODE_CURVE_RGB:
2654
 
                                ntype->uifunc = node_buts_curvecol;
 
2643
                                ntype->draw_buttons = node_buts_curvecol;
2655
2644
                                break;
2656
2645
 
2657
2646
                        case TEX_NODE_CURVE_TIME:
2658
 
                                ntype->uifunc = node_buts_time;
 
2647
                                ntype->draw_buttons = node_buts_time;
2659
2648
                                break;
2660
2649
 
2661
2650
                        case TEX_NODE_TEXTURE:
2662
 
                                ntype->uifunc = node_buts_texture;
 
2651
                                ntype->draw_buttons = node_buts_texture;
2663
2652
                                break;
2664
2653
 
2665
2654
                        case TEX_NODE_BRICKS:
2666
 
                                ntype->uifunc = node_texture_buts_bricks;
 
2655
                                ntype->draw_buttons = node_texture_buts_bricks;
2667
2656
                                break;
2668
2657
 
2669
2658
                        case TEX_NODE_IMAGE:
2670
 
                                ntype->uifunc = node_texture_buts_image;
2671
 
                                ntype->uifuncbut = node_texture_buts_image_details;
 
2659
                                ntype->draw_buttons = node_texture_buts_image;
 
2660
                                ntype->draw_buttons_ex = node_texture_buts_image_ex;
2672
2661
                                break;
2673
2662
 
2674
2663
                        case TEX_NODE_OUTPUT:
2675
 
                                ntype->uifunc = node_texture_buts_output;
 
2664
                                ntype->draw_buttons = node_texture_buts_output;
2676
2665
                                break;
2677
2666
                }
2678
2667
        }
2746
2735
        extern bNodeSocketType NodeSocketTypeUndefined;
2747
2736
        
2748
2737
        /* default ui functions */
2749
 
        NodeTypeUndefined.drawfunc = node_draw_default;
2750
 
        NodeTypeUndefined.drawupdatefunc = node_update_default;
 
2738
        NodeTypeUndefined.draw_nodetype = node_draw_default;
 
2739
        NodeTypeUndefined.draw_nodetype_prepare = node_update_default;
2751
2740
        NodeTypeUndefined.select_area_func = node_select_area_default;
2752
2741
        NodeTypeUndefined.tweak_area_func = node_tweak_area_default;
2753
 
        NodeTypeUndefined.uifunc = NULL;
2754
 
        NodeTypeUndefined.uifuncbut = NULL;
2755
 
        NodeTypeUndefined.drawinputfunc = node_draw_input_default;
2756
 
        NodeTypeUndefined.drawoutputfunc = node_draw_output_default;
 
2742
        NodeTypeUndefined.draw_buttons = NULL;
 
2743
        NodeTypeUndefined.draw_buttons_ex = NULL;
2757
2744
        NodeTypeUndefined.resize_area_func = node_resize_area_default;
2758
2745
        
2759
2746
        NodeSocketTypeUndefined.draw = node_socket_undefined_draw;
2764
2751
        /* node type ui functions */
2765
2752
        NODE_TYPES_BEGIN(ntype)
2766
2753
                /* default ui functions */
2767
 
                ntype->drawfunc = node_draw_default;
2768
 
                ntype->drawupdatefunc = node_update_default;
 
2754
                ntype->draw_nodetype = node_draw_default;
 
2755
                ntype->draw_nodetype_prepare = node_update_default;
2769
2756
                ntype->select_area_func = node_select_area_default;
2770
2757
                ntype->tweak_area_func = node_tweak_area_default;
2771
 
                ntype->uifunc = NULL;
2772
 
                ntype->uifuncbut = NULL;
2773
 
                ntype->drawinputfunc = node_draw_input_default;
2774
 
                ntype->drawoutputfunc = node_draw_output_default;
 
2758
                ntype->draw_buttons = NULL;
 
2759
                ntype->draw_buttons_ex = NULL;
2775
2760
                ntype->resize_area_func = node_resize_area_default;
2776
2761
                
2777
2762
                node_common_set_butfunc(ntype);
2793
2778
void ED_init_custom_node_type(bNodeType *ntype)
2794
2779
{
2795
2780
        /* default ui functions */
2796
 
        ntype->drawfunc = node_draw_default;
2797
 
        ntype->drawupdatefunc = node_update_default;
2798
 
        ntype->drawinputfunc = node_draw_input_default;
2799
 
        ntype->drawoutputfunc = node_draw_output_default;
 
2781
        ntype->draw_nodetype = node_draw_default;
 
2782
        ntype->draw_nodetype_prepare = node_update_default;
2800
2783
        ntype->resize_area_func = node_resize_area_default;
2801
2784
        ntype->select_area_func = node_select_area_default;
2802
2785
        ntype->tweak_area_func = node_tweak_area_default;
2834
2817
        copy_v4_v4(r_color, std_node_socket_colors[type]);
2835
2818
}
2836
2819
 
 
2820
/* draw function for file output node sockets, displays only sub-path and format, no value button */
 
2821
static void node_file_output_socket_draw(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr)
 
2822
{
 
2823
        bNodeTree *ntree = ptr->id.data;
 
2824
        bNodeSocket *sock = ptr->data;
 
2825
        uiLayout *row;
 
2826
        PointerRNA inputptr, imfptr;
 
2827
        int imtype;
 
2828
        
 
2829
        row = uiLayoutRow(layout, FALSE);
 
2830
        
 
2831
        imfptr = RNA_pointer_get(node_ptr, "format");
 
2832
        imtype = RNA_enum_get(&imfptr, "file_format");
 
2833
        if (imtype == R_IMF_IMTYPE_MULTILAYER) {
 
2834
                NodeImageMultiFileSocket *input = sock->storage;
 
2835
                RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotLayer, input, &inputptr);
 
2836
                
 
2837
                uiItemL(row, input->layer, ICON_NONE);
 
2838
        }
 
2839
        else {
 
2840
                NodeImageMultiFileSocket *input = sock->storage;
 
2841
                PropertyRNA *imtype_prop;
 
2842
                const char *imtype_name;
 
2843
                uiBlock *block;
 
2844
                RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotFile, input, &inputptr);
 
2845
                
 
2846
                uiItemL(row, input->path, ICON_NONE);
 
2847
                
 
2848
                if (!RNA_boolean_get(&inputptr, "use_node_format"))
 
2849
                        imfptr = RNA_pointer_get(&inputptr, "format");
 
2850
                
 
2851
                imtype_prop = RNA_struct_find_property(&imfptr, "file_format");
 
2852
                RNA_property_enum_name((bContext *)C, &imfptr, imtype_prop,
 
2853
                                       RNA_property_enum_get(&imfptr, imtype_prop), &imtype_name);
 
2854
                block = uiLayoutGetBlock(row);
 
2855
                uiBlockSetEmboss(block, UI_EMBOSSP);
 
2856
                uiItemL(row, imtype_name, ICON_NONE);
 
2857
                uiBlockSetEmboss(block, UI_EMBOSSN);
 
2858
        }
 
2859
}
 
2860
 
2837
2861
static void std_node_socket_draw(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr, const char *text)
2838
2862
{
 
2863
        bNode *node = node_ptr->data;
2839
2864
        bNodeSocket *sock = ptr->data;
2840
2865
        int type = sock->typeinfo->type;
2841
2866
        /*int subtype = sock->typeinfo->subtype;*/
2842
2867
        
2843
 
        if ((sock->flag & SOCK_IN_USE) || (sock->flag & SOCK_HIDE_VALUE)) {
 
2868
        /* XXX not nice, eventually give this node its own socket type ... */
 
2869
        if (node->type == CMP_NODE_OUTPUT_FILE) {
 
2870
                node_file_output_socket_draw(C, layout, ptr, node_ptr);
 
2871
                return;
 
2872
        }
 
2873
        
 
2874
        if ((sock->in_out == SOCK_OUT) || (sock->flag & SOCK_IN_USE) || (sock->flag & SOCK_HIDE_VALUE)) {
2844
2875
                node_socket_button_label(C, layout, ptr, node_ptr, text);
2845
2876
                return;
2846
2877
        }
3053
3084
                        rctf *viewer_border = &snode->nodetree->viewer_border;
3054
3085
                        while (node) {
3055
3086
                                if (node->flag & NODE_SELECT) {
3056
 
                                        if (node->typeinfo->uibackdropfunc) {
3057
 
                                                node->typeinfo->uibackdropfunc(snode, ibuf, node, x, y);
 
3087
                                        if (node->typeinfo->draw_backdrop) {
 
3088
                                                node->typeinfo->draw_backdrop(snode, ibuf, node, x, y);
3058
3089
                                        }
3059
3090
                                }
3060
3091
                                node = node->next;
3125
3156
                toreroute = 0;
3126
3157
        }
3127
3158
 
3128
 
        dist = UI_GetThemeValue(TH_NODE_CURVING) * 0.10f * ABS(vec[0][0] - vec[3][0]);
 
3159
        dist = UI_GetThemeValue(TH_NODE_CURVING) * 0.10f * fabsf(vec[0][0] - vec[3][0]);
3129
3160
        deltax = vec[3][0] - vec[0][0];
3130
3161
        deltay = vec[3][1] - vec[0][1];
3131
3162
        /* check direction later, for top sockets */
3180
3211
#define LINK_ARROW  12  /* position of arrow on the link, LINK_RESOL/2 */
3181
3212
#define ARROW_SIZE 7
3182
3213
void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link,
3183
 
                           int th_col1, int do_shaded, int th_col2, int do_triple, int th_col3)
 
3214
                           int th_col1, bool do_shaded, int th_col2, bool do_triple, int th_col3)
3184
3215
{
3185
3216
        float coord_array[LINK_RESOL + 1][2];
3186
3217
        
3366
3397
/* note; this is used for fake links in groups too */
3367
3398
void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link)
3368
3399
{
3369
 
        int do_shaded = FALSE, th_col1 = TH_HEADER, th_col2 = TH_HEADER;
3370
 
        int do_triple = FALSE, th_col3 = TH_WIRE;
 
3400
        bool do_shaded = false;
 
3401
        bool do_triple = false;
 
3402
        int th_col1 = TH_HEADER, th_col2 = TH_HEADER, th_col3 = TH_WIRE;
3371
3403
        
3372
3404
        if (link->fromsock == NULL && link->tosock == NULL)
3373
3405
                return;