2.5: Headers
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 19 Aug 2009 00:55:30 +0000 (00:55 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 19 Aug 2009 00:55:30 +0000 (00:55 +0000)
* Fix header menu spacing bug, and make it consistent for all headers.
* For consistency, always put menus first in the header, then any enums
  to switch the type of data displayed.
* Node editor header ported to python layout. Still quite a few
  operators missing to make the menus complete.
* RNA wrapped node editor, and added use_nodes property to material
  and scene.

32 files changed:
release/ui/space_buttons.py
release/ui/space_console.py
release/ui/space_filebrowser.py
release/ui/space_image.py
release/ui/space_info.py
release/ui/space_node.py [new file with mode: 0644]
release/ui/space_outliner.py
release/ui/space_sequencer.py
release/ui/space_text.py
release/ui/space_time.py
release/ui/space_view3d.py
source/blender/editors/armature/poselib.c
source/blender/editors/include/ED_node.h
source/blender/editors/include/UI_interface.h
source/blender/editors/interface/interface_layout.c
source/blender/editors/interface/interface_widgets.c
source/blender/editors/space_action/action_header.c
source/blender/editors/space_graph/graph_header.c
source/blender/editors/space_nla/nla_header.c
source/blender/editors/space_node/node_edit.c
source/blender/editors/space_node/node_header.c
source/blender/editors/space_node/node_intern.h
source/blender/editors/space_node/node_state.c
source/blender/editors/space_node/space_node.c
source/blender/editors/space_text/text_header.c
source/blender/editors/space_view3d/view3d_header.c
source/blender/makesrna/intern/rna_main.c
source/blender/makesrna/intern/rna_material.c
source/blender/makesrna/intern/rna_scene.c
source/blender/makesrna/intern/rna_space.c
source/blender/makesrna/intern/rna_texture.c
source/blender/windowmanager/WM_types.h

index cf1c385e3dc6ffade68834ffbe02fdb9ef098dfd..3cf782e615fe101fc1aa5a24ca7d7ab8d69ee8d2 100644 (file)
@@ -10,11 +10,12 @@ class Buttons_HT_header(bpy.types.Header):
                so = context.space_data
                scene = context.scene
 
-               layout.template_header()
+               row= layout.row(align=True)
+               row.template_header()
 
                if context.area.show_menus:
-                       row = layout.row(align=True)
-                       row.itemM("Buttons_MT_view", text="View")
+                       sub = row.row(align=True)
+                       sub.itemM("Buttons_MT_view", text="View")
                        
                row = layout.row()
                row.itemR(so, "buttons_context", expand=True, text="")
index 2cf41a1f88f6df4284643bf24c8b0542d5e46193..45cb2a856e13ce54b077d9e25ce2fb260de9f467 100644 (file)
@@ -12,17 +12,22 @@ class CONSOLE_HT_header(bpy.types.Header):
                # text = sc.text
                layout = self.layout
 
-               layout.template_header()
+               row= layout.row(align=True)
+               row.template_header()
 
-               row = layout.row()
-               row.itemR(sc, "console_type", expand=True)
+               if context.area.show_menus:
+                       sub = row.row(align=True)
+
+                       if sc.console_type == 'REPORT':
+                               sub.itemM("CONSOLE_MT_report")
+                       else:
+                               sub.itemM("CONSOLE_MT_console")
+
+               layout.itemS()
+               layout.itemR(sc, "console_type", expand=True)
 
                if sc.console_type == 'REPORT':
-                       
-                       if context.area.show_menus:
-                               row = layout.row()
-                               row.itemM("CONSOLE_MT_report")
-                       
+                       row = layout.row(align=True)
                        row.itemR(sc, "show_report_debug", text="Debug")
                        row.itemR(sc, "show_report_info", text="Info")
                        row.itemR(sc, "show_report_operator", text="Operators")
@@ -32,12 +37,6 @@ class CONSOLE_HT_header(bpy.types.Header):
                        row = layout.row()
                        row.enabled = sc.show_report_operator
                        row.itemO("console.report_replay")
-               
-               else:
-                       if context.area.show_menus:
-                               row = layout.row()
-                               row.itemM("CONSOLE_MT_console")
-
 
 class CONSOLE_MT_console(bpy.types.Menu):
        __space_type__ = "CONSOLE"
index 0fecbdbfbba9530b42ef8ed5037c2bd0bd4b6d36..51a8f3f78e85f38921a106c076090b6a01f447b0 100644 (file)
@@ -10,7 +10,7 @@ class FILEBROWSER_HT_header(bpy.types.Header):
                layout = self.layout
                
                params = st.params 
-               layout.template_header()
+               layout.template_header(menus=False)
                
                row = layout.row(align=True)
                row.itemO("file.parent", text="", icon='ICON_FILE_PARENT')
index 7154bb8ae1c7cd6096c10851af16bc9272b31ce6..090067120b1f979fc4fb46791d3a13c1f78b23a4 100644 (file)
@@ -205,23 +205,24 @@ class IMAGE_HT_header(bpy.types.Header):
                show_paint = sima.show_paint
                show_uvedit = sima.show_uvedit
 
-               layout.template_header()
+               row = layout.row(align=True)
+               row.template_header()
 
                # menus
                if context.area.show_menus:
-                       row = layout.row()
-                       row.itemM("IMAGE_MT_view")
+                       sub = row.row(align=True)
+                       sub.itemM("IMAGE_MT_view")
 
                        if show_uvedit:
-                               row.itemM("IMAGE_MT_select")
+                               sub.itemM("IMAGE_MT_select")
 
                        if ima and ima.dirty:
-                               row.itemM("IMAGE_MT_image", text="Image*")
+                               sub.itemM("IMAGE_MT_image", text="Image*")
                        else:
-                               row.itemM("IMAGE_MT_image", text="Image")
+                               sub.itemM("IMAGE_MT_image", text="Image")
 
                        if show_uvedit:
-                               row.itemM("IMAGE_MT_uvs")
+                               sub.itemM("IMAGE_MT_uvs")
 
                layout.template_ID(sima, "image", new="image.new")
 
index e0b5c770f29d3a65a1d0d5f415c5c416187cedec..770387498a26abaa855925e924798bd78659f112 100644 (file)
@@ -9,18 +9,19 @@ class INFO_HT_header(bpy.types.Header):
                
                st = context.space_data
                rd = context.scene.render_data
-               
-               layout.template_header()
+
+               row = layout.row(align=True)
+               row.template_header()
 
                if context.area.show_menus:
-                       row = layout.row()
-                       row.itemM("INFO_MT_file")
-                       row.itemM("INFO_MT_add")
+                       sub = row.row(align=True)
+                       sub.itemM("INFO_MT_file")
+                       sub.itemM("INFO_MT_add")
                        if rd.use_game_engine:
-                               row.itemM("INFO_MT_game")
+                               sub.itemM("INFO_MT_game")
                        else:
-                               row.itemM("INFO_MT_render")
-                       row.itemM("INFO_MT_help")
+                               sub.itemM("INFO_MT_render")
+                       sub.itemM("INFO_MT_help")
 
                layout.template_ID(context.window, "screen", new="screen.new", unlink="screen.delete")
                layout.template_ID(context.screen, "scene", new="scene.new", unlink="scene.delete")
diff --git a/release/ui/space_node.py b/release/ui/space_node.py
new file mode 100644 (file)
index 0000000..2e28cfc
--- /dev/null
@@ -0,0 +1,121 @@
+
+import bpy
+
+class NODE_HT_header(bpy.types.Header):
+       __space_type__ = "NODE_EDITOR"
+
+       def draw(self, context):
+               layout = self.layout
+               snode = context.space_data
+
+               row = layout.row(align=True)
+               row.template_header()
+
+               if context.area.show_menus:
+                       sub = row.row(align=True)
+                       sub.itemM("NODE_MT_view")
+                       sub.itemM("NODE_MT_select")
+                       sub.itemM("NODE_MT_add")
+                       sub.itemM("NODE_MT_node")
+
+               row = layout.row()
+               row.itemR(snode, "tree_type", text="", expand=True)
+
+               if snode.tree_type == 'MATERIAL':
+                       ob = snode.id_from
+                       id = snode.id
+                       if ob:
+                               layout.template_ID(ob, "active_material", new="material.new")
+                       if id:
+                               layout.itemR(id, "use_nodes", toggle=True)
+
+               elif snode.tree_type == 'TEXTURE':
+                       row.itemR(snode, "texture_type", text="", expand=True)
+
+                       id = snode.id
+                       id_from = snode.id_from
+                       if id_from:
+                               layout.template_ID(id_from, "active_texture", new="texture.new")
+                       if id:
+                               layout.itemR(id, "use_nodes", toggle=True)
+
+               elif snode.tree_type == 'COMPOSITING':
+                       id = snode.id
+
+                       layout.itemR(id, "use_nodes", toggle=True)
+                       layout.itemR(id.render_data, "free_unused_nodes", text="Free Unused", toggle=True)
+                       layout.itemR(snode, "backdrop", toggle=True)
+
+class NODE_MT_view(bpy.types.Menu):
+       __space_type__ = "NODE_EDITOR"
+       __label__ = "View"
+
+       def draw(self, context):
+               layout = self.layout
+
+               # layout.itemO("grease_pencil..")
+               # layout.itemS()
+
+               layout.itemO("view2d.zoom_in")
+               layout.itemO("view2d.zoom_out")
+
+               layout.itemS()
+
+               layout.itemO("node.view_all")
+               layout.itemO("screen.screen_full_area")
+
+class NODE_MT_select(bpy.types.Menu):
+       __space_type__ = "NODE_EDITOR"
+       __label__ = "Select"
+
+       def draw(self, context):
+               layout = self.layout
+
+               layout.itemO("node.select_border")
+
+               # XXX
+               # layout.itemS()
+               # layout.itemO("node.select_all")
+               # layout.itemO("node.select_linked_from")
+               # layout.itemO("node.select_linked_to")
+
+class NODE_MT_node(bpy.types.Menu):
+       __space_type__ = "NODE_EDITOR"
+       __label__ = "Node"
+
+       def draw(self, context):
+               layout = self.layout
+
+               layout.itemO("tfm.translate")
+               layout.itemO("tfm.resize")
+               layout.itemO("tfm.rotate")
+
+               layout.itemS()
+
+               layout.itemO("node.duplicate")
+               layout.itemO("node.delete")
+
+               # XXX
+               # layout.itemS()
+               # layout.itemO("node.make_link")
+               # layout.itemS()
+               # layout.itemO("node.edit_group")
+               # layout.itemO("node.ungroup")
+               # layout.itemO("node.group")
+               # layout.itemO("node.make_link")
+
+               layout.itemS()
+
+               layout.itemO("node.visibility_toggle")
+
+               # XXX
+               # layout.itemO("node.rename")
+               # layout.itemS()
+               # layout.itemO("node.show_cyclic_dependencies")
+
+
+bpy.types.register(NODE_HT_header)
+bpy.types.register(NODE_MT_view)
+bpy.types.register(NODE_MT_select)
+bpy.types.register(NODE_MT_node)
+
index 5815acc7e1202a137c483513f1e2bf3da554f670..f55f4633a7bb89ddb401521ea70b396694d57207 100644 (file)
@@ -9,11 +9,12 @@ class OUTLINER_HT_header(bpy.types.Header):
                sce = context.scene
                layout = self.layout
 
-               layout.template_header()
+               row = layout.row(align=True)
+               row.template_header()
 
                if context.area.show_menus:
-                       row = layout.row(align=True)
-                       row.itemM("OUTLINER_MT_view")
+                       sub = row.row(align=True)
+                       sub.itemM("OUTLINER_MT_view")
                        
                row = layout.row()
                row.itemR(so, "display_mode", text="")
index a29e0fad895d42da57dbe506d6c7d209ac86c8e7..1edcf32d3b54b1c58fa1340480ab3c82a8aa8ca3 100644 (file)
@@ -14,24 +14,28 @@ class SEQUENCER_HT_header(bpy.types.Header):
                
                st = context.space_data
 
-               layout.template_header()
+               row = layout.row(align=True)
+               row.template_header()
                
                if context.area.show_menus:
-                       row = layout.row()
-                       row.itemR(st, "display_mode", text="")
-                       row.itemM("SEQUENCER_MT_view")
+                       sub = row.row(align=True)
+                       sub.itemM("SEQUENCER_MT_view")
                        
-                       layout.itemS()
+                       row.itemS()
                        
                        if st.display_mode == 'SEQUENCER':
-                               row.itemM("SEQUENCER_MT_select")
-                               row.itemM("SEQUENCER_MT_marker")
-                               row.itemM("SEQUENCER_MT_add")
-                               row.itemM("SEQUENCER_MT_strip")
-                               layout.itemS()
-                               row.itemO("sequencer.reload")
-                       else:
-                               row.itemR(st, "display_channel", text="Channel")
+                               sub.itemM("SEQUENCER_MT_select")
+                               sub.itemM("SEQUENCER_MT_marker")
+                               sub.itemM("SEQUENCER_MT_add")
+                               sub.itemM("SEQUENCER_MT_strip")
+
+               layout.itemR(st, "display_mode", text="")
+
+               if st.display_mode == 'SEQUENCER':
+                       layout.itemS()
+                       layout.itemO("sequencer.reload")
+               else:
+                       layout.itemR(st, "display_channel", text="Channel")
 
 class SEQUENCER_MT_view(bpy.types.Menu):
        __space_type__ = "SEQUENCE_EDITOR"
index c54073c29386b000923e7c053a03b7a980fa7eab..61e8d3489a59d96f42c7efae51b1edeb94806ac2 100644 (file)
@@ -9,27 +9,28 @@ class TEXT_HT_header(bpy.types.Header):
                text = st.text
                layout = self.layout
 
-               layout.template_header()
+               row = layout.row(align=True)
+               row.template_header()
 
                if context.area.show_menus:
-                       row = layout.row()
-                       row.itemM("TEXT_MT_text")
+                       sub = row.row(align=True)
+                       sub.itemM("TEXT_MT_text")
                        if text:
-                               row.itemM("TEXT_MT_edit")
-                               row.itemM("TEXT_MT_format")
+                               sub.itemM("TEXT_MT_edit")
+                               sub.itemM("TEXT_MT_format")
 
                if text and text.modified:
                        row = layout.row()
                        # row.color(redalert)
                        row.itemO("text.resolve_conflict", text="", icon='ICON_HELP')
 
+               layout.template_ID(st, "text", new="text.new", unlink="text.unlink")
+
                row = layout.row(align=True)
                row.itemR(st, "line_numbers", text="")
                row.itemR(st, "word_wrap", text="")
                row.itemR(st, "syntax_highlight", text="")
 
-               layout.template_ID(st, "text", new="text.new", unlink="text.unlink")
-
                if text:
                        row = layout.row()
                        if text.filename != "":
@@ -123,6 +124,10 @@ class TEXT_MT_text(bpy.types.Menu):
                        # XXX if(BPY_is_pyconstraint(text))
                        # XXX   uiMenuItemO(head, 0, "text.refresh_pyconstraints");
                        #endif
+
+               layout.itemS()
+
+               layout.itemO("text.properties", icon="ICON_MENU_PANEL")
                
                #ifndef DISABLE_PYTHON
                # XXX layout.column()
@@ -219,7 +224,7 @@ class TEXT_MT_edit(bpy.types.Menu):
                layout.itemS()
 
                layout.itemO("text.jump")
-               layout.itemO("text.properties")
+               layout.itemO("text.properties", text="Find...")
 
                layout.itemS()
 
index 785d11a8fc5e377c5cae683a1a0c863965cc2bcd..d1c9f9806f3a52cf4ea9cf33c578da5b2663ee74 100644 (file)
@@ -13,13 +13,14 @@ class TIME_HT_header(bpy.types.Header):
                tools = context.tool_settings
                screen = context.screen
 
-               layout.template_header()
+               row = layout.row(align=True)
+               row.template_header()
 
                if context.area.show_menus:
-                       row = layout.row()
-                       row.itemM("TIME_MT_view")
-                       row.itemM("TIME_MT_frame")
-                       row.itemM("TIME_MT_playback")
+                       sub = row.row(align=True)
+                       sub.itemM("TIME_MT_view")
+                       sub.itemM("TIME_MT_frame")
+                       sub.itemM("TIME_MT_playback")
 
                layout.itemR(scene, "use_preview_range", text="PR", toggle=True)
                
index 1a5dd6b148cabe3c3499cd3bbb386dc58ad0270a..44b1c82ff460882a40ad7fddc02c6e144258b20e 100644 (file)
@@ -13,25 +13,26 @@ class VIEW3D_HT_header(bpy.types.Header):
                mode_string = context.mode
                edit_object = context.edit_object
                
-               layout.template_header()
-               
+               row = layout.row(align=True)
+               row.template_header()
+
                # Menus
                if context.area.show_menus:
-                       row = layout.row()
+                       sub = row.row(align=True)
 
-                       row.itemM("VIEW3D_MT_view")
+                       sub.itemM("VIEW3D_MT_view")
                        
                        # Select Menu
                        if mode_string not in ('EDIT_TEXT', 'SCULPT', 'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE', 'PARTICLE'):
                                # XXX: Particle Mode has Select Menu.
-                               row.itemM("VIEW3D_MT_select_%s" % mode_string)
+                               sub.itemM("VIEW3D_MT_select_%s" % mode_string)
                        
                        if mode_string == 'OBJECT':
-                               row.itemM("VIEW3D_MT_object")
+                               sub.itemM("VIEW3D_MT_object")
                        elif mode_string == 'SCULPT':
-                               row.itemM("VIEW3D_MT_sculpt")
+                               sub.itemM("VIEW3D_MT_sculpt")
                        elif edit_object:
-                               row.itemM("VIEW3D_MT_edit_%s" % edit_object.type)
+                               sub.itemM("VIEW3D_MT_edit_%s" % edit_object.type)
 
                layout.template_header_3D()
 
index ef2e5188487b8cdb19b098507b107e33635265db..021bec05a3ba53d02c9cf316af2c84c5c66e3918 100644 (file)
@@ -342,7 +342,7 @@ static int poselib_add_menu_invoke (bContext *C, wmOperator *op, wmEvent *evt)
                uiItemIntO(layout, "Add New (Current Frame)", 0, "POSELIB_OT_pose_add", "frame", CFRA);
                
                /* replace existing - submenu */
-               uiItemMenuF(layout, "Replace Existing...", 0, poselib_add_menu_invoke__replacemenu);
+               uiItemMenuF(layout, "Replace Existing...", 0, poselib_add_menu_invoke__replacemenu, NULL);
        }
        
        uiPupMenuEnd(C, pup);
index 0cd5551f17fb3466301c25b9a64ef49dea2f9559..bf4632dc3da20c65e1bd2e698b647caaf4353cb0 100644 (file)
 #ifndef ED_NODE_H
 #define ED_NODE_H
 
+struct Material;
+struct Scene;
+struct Tex;
+
 /* drawnode.c */
 void ED_init_node_butfuncs(void);
 
+/* node_edit.c */
+void ED_node_shader_default(struct Material *ma);
+void ED_node_composit_default(struct Scene *sce);
+void ED_node_texture_default(struct Tex *tex);;
+
 #endif /* ED_NODE_H */
 
index 46da4b507a710e61fb1610b1dcfcbb9beff9249a..42280ad17c9f20adf04c25d47a51e5718b6834a2 100644 (file)
@@ -678,7 +678,7 @@ void uiItemM(uiLayout *layout, struct bContext *C, char *name, int icon, char *m
 void uiItemV(uiLayout *layout, char *name, int icon, int argval); /* value */
 void uiItemS(uiLayout *layout); /* separator */
 
-void uiItemMenuF(uiLayout *layout, char *name, int icon, uiMenuCreateFunc func);
+void uiItemMenuF(uiLayout *layout, char *name, int icon, uiMenuCreateFunc func, void *arg);
 void uiItemMenuEnumO(uiLayout *layout, char *name, int icon, char *opname, char *propname);
 void uiItemMenuEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname);
 
index dee486b6b93379f95e0bdd5f9cf2830803626bd2..fc4f7da56d26e47c4b37401293313604db1c52e3 100644 (file)
@@ -215,16 +215,16 @@ static int ui_layout_vary_direction(uiLayout *layout)
 }
 
 /* estimated size of text + icon */
-static int ui_text_icon_width(uiLayout *layout, char *name, int icon)
+static int ui_text_icon_width(uiLayout *layout, char *name, int icon, int compact)
 {
        int variable = ui_layout_vary_direction(layout) == UI_ITEM_VARY_X;
 
        if(icon && !name[0])
                return UI_UNIT_X; /* icon only */
        else if(icon)
-               return (variable)? UI_GetStringWidth(name) + 10 + UI_UNIT_X: 10*UI_UNIT_X; /* icon + text */
+               return (variable)? UI_GetStringWidth(name) + (compact? 5: 10) + UI_UNIT_X: 10*UI_UNIT_X; /* icon + text */
        else
-               return (variable)? UI_GetStringWidth(name) + 10 + UI_UNIT_X: 10*UI_UNIT_X; /* text only */
+               return (variable)? UI_GetStringWidth(name) + (compact? 5: 10) + UI_UNIT_X: 10*UI_UNIT_X; /* text only */
 }
 
 static void ui_item_size(uiItem *item, int *r_w, int *r_h)
@@ -433,7 +433,7 @@ static void ui_item_enum_row(uiLayout *layout, uiBlock *block, PointerRNA *ptr,
                name= (!uiname || uiname[0])? (char*)item[a].name: "";
                icon= item[a].icon;
                value= item[a].value;
-               itemw= ui_text_icon_width(block->curlayout, name, icon);
+               itemw= ui_text_icon_width(block->curlayout, name, icon, 0);
 
                if(icon && strcmp(name, "") != 0)
                        uiDefIconTextButR(block, ROW, 0, icon, name, 0, 0, itemw, h, ptr, identifier, -1, 0, value, -1, -1, NULL);
@@ -526,7 +526,7 @@ static void ui_item_disabled(uiLayout *layout, char *name)
        if(!name)
                name= "";
 
-       w= ui_text_icon_width(layout, name, 0);
+       w= ui_text_icon_width(layout, name, 0, 0);
 
        but= uiDefBut(block, LABEL, 0, (char*)name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
        but->flag |= UI_BUT_DISABLED;
@@ -555,7 +555,7 @@ void uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, IDPropert
        /* create button */
        uiBlockSetCurLayout(block, layout);
 
-       w= ui_text_icon_width(layout, name, icon);
+       w= ui_text_icon_width(layout, name, icon, 0);
 
        if(icon && strcmp(name, "") != 0)
                but= uiDefIconTextButO(block, BUT, ot->idname, context, icon, (char*)name, 0, 0, w, UI_UNIT_Y, NULL);
@@ -746,7 +746,7 @@ static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PropertyRNA
        else if(type == PROP_BOOLEAN && !name[0])
                icon= ICON_DOT;
 
-       w= ui_text_icon_width(layout, name, icon);
+       w= ui_text_icon_width(layout, name, icon, 0);
        h= UI_UNIT_Y;
 
        /* increase height for arrays */
@@ -1112,7 +1112,7 @@ static void ui_item_menu(uiLayout *layout, char *name, int icon, uiMenuCreateFun
        if(layout->root->type == UI_LAYOUT_MENU && !icon)
                icon= ICON_BLANK1;
 
-       w= ui_text_icon_width(layout, name, icon);
+       w= ui_text_icon_width(layout, name, icon, 1);
        h= UI_UNIT_Y;
 
        if(layout->root->type == UI_LAYOUT_HEADER) /* ugly .. */
@@ -1170,7 +1170,7 @@ void uiItemL(uiLayout *layout, char *name, int icon)
        if(layout->root->type == UI_LAYOUT_MENU && !icon)
                icon= ICON_BLANK1;
 
-       w= ui_text_icon_width(layout, name, icon);
+       w= ui_text_icon_width(layout, name, icon, 0);
 
        if(icon && strcmp(name, "") != 0)
                but= uiDefIconTextBut(block, LABEL, 0, icon, (char*)name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
@@ -1195,7 +1195,7 @@ void uiItemV(uiLayout *layout, char *name, int icon, int argval)
        if(layout->root->type == UI_LAYOUT_MENU && !icon)
                icon= ICON_BLANK1;
 
-       w= ui_text_icon_width(layout, name, icon);
+       w= ui_text_icon_width(layout, name, icon, 0);
 
        if(icon && strcmp(name, "") != 0)
                uiDefIconTextButF(block, BUTM, 0, icon, (char*)name, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, argval, "");
@@ -1215,12 +1215,12 @@ void uiItemS(uiLayout *layout)
 }
 
 /* level items */
-void uiItemMenuF(uiLayout *layout, char *name, int icon, uiMenuCreateFunc func)
+void uiItemMenuF(uiLayout *layout, char *name, int icon, uiMenuCreateFunc func, void *arg)
 {
        if(!func)
                return;
 
-       ui_item_menu(layout, name, icon, func, NULL, NULL);
+       ui_item_menu(layout, name, icon, func, arg, NULL);
 }
 
 typedef struct MenuItemLevel {
index 2e0f0897af4a8b77e85ea4b4c4fee200728e4e38..a70fbab1aa4295a4bb38cd65bc169b8d02e95947 100644 (file)
@@ -1949,7 +1949,7 @@ static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int
                widget_init(&wtb);
                
                /* fully rounded */
-               round_box_edges(&wtb, roundboxalign, rect, rad);
+               round_box_edges(&wtb, 15, rect, rad);
                
                widgetbase_draw(&wtb, wcol);
        }
index d3929a22342cbca1c4890e271413181a42ece9be..e4750bd0a370b8c23b6dfe1cedcffa4e8687e7ef 100644 (file)
@@ -153,7 +153,7 @@ static void act_channelmenu(bContext *C, uiLayout *layout, void *arg_unused)
 
 static void act_gplayermenu(bContext *C, uiLayout *layout, void *arg_unused)
 {
-       //uiItemMenuF(layout, "Transform", 0, nla_edit_transformmenu);
+       //uiItemMenuF(layout, "Transform", 0, nla_edit_transformmenu, NULL, NULL);
        //uiItemS(layout);
        //uiItemO(layout, NULL, 0, "NLAEDIT_OT_duplicate");
 }
@@ -210,9 +210,9 @@ static void act_edit_expomenu(bContext *C, uiLayout *layout, void *arg_unused)
 
 static void act_editmenu(bContext *C, uiLayout *layout, void *arg_unused)
 {
-       uiItemMenuF(layout, "Transform", 0, act_edit_transformmenu);
-       uiItemMenuF(layout, "Snap", 0, act_edit_snapmenu);
-       uiItemMenuF(layout, "Mirror", 0, act_edit_mirrormenu);
+       uiItemMenuF(layout, "Transform", 0, act_edit_transformmenu, NULL);
+       uiItemMenuF(layout, "Snap", 0, act_edit_snapmenu, NULL);
+       uiItemMenuF(layout, "Mirror", 0, act_edit_mirrormenu, NULL);
        
        uiItemS(layout);
        
@@ -225,9 +225,9 @@ static void act_editmenu(bContext *C, uiLayout *layout, void *arg_unused)
        
        uiItemS(layout);
        
-       uiItemMenuF(layout, "Handle Type", 0, act_edit_handlesmenu);
-       uiItemMenuF(layout, "Interpolation Mode", 0, act_edit_ipomenu);
-       uiItemMenuF(layout, "Extrapolation Mode", 0, act_edit_expomenu);
+       uiItemMenuF(layout, "Handle Type", 0, act_edit_handlesmenu, NULL);
+       uiItemMenuF(layout, "Interpolation Mode", 0, act_edit_ipomenu, NULL);
+       uiItemMenuF(layout, "Extrapolation Mode", 0, act_edit_expomenu, NULL);
        
        uiItemS(layout);
        
index 2c9017db6494aa136adac66ffb2ddb7c0784487d..c4654972dcdc6200973e2a9551e17390321ff076 100644 (file)
@@ -201,9 +201,9 @@ static void graph_edit_expomenu(bContext *C, uiLayout *layout, void *arg_unused)
 
 static void graph_editmenu(bContext *C, uiLayout *layout, void *arg_unused)
 {
-       uiItemMenuF(layout, "Transform", 0, graph_edit_transformmenu);
-       uiItemMenuF(layout, "Snap", 0, graph_edit_snapmenu);
-       uiItemMenuF(layout, "Mirror", 0, graph_edit_mirrormenu);
+       uiItemMenuF(layout, "Transform", 0, graph_edit_transformmenu, NULL);
+       uiItemMenuF(layout, "Snap", 0, graph_edit_snapmenu, NULL);
+       uiItemMenuF(layout, "Mirror", 0, graph_edit_mirrormenu, NULL);
        
        uiItemS(layout);
        
@@ -217,9 +217,9 @@ static void graph_editmenu(bContext *C, uiLayout *layout, void *arg_unused)
        
        uiItemS(layout);
        
-       uiItemMenuF(layout, "Handle Type", 0, graph_edit_handlesmenu);
-       uiItemMenuF(layout, "Interpolation Mode", 0, graph_edit_ipomenu);
-       uiItemMenuF(layout, "Extrapolation Mode", 0, graph_edit_expomenu);
+       uiItemMenuF(layout, "Handle Type", 0, graph_edit_handlesmenu, NULL);
+       uiItemMenuF(layout, "Interpolation Mode", 0, graph_edit_ipomenu, NULL);
+       uiItemMenuF(layout, "Extrapolation Mode", 0, graph_edit_expomenu, NULL);
        
        uiItemS(layout);
        
index 04c2db08bda94f23ed16221a19f1f6cfc6bbeea9..e507efb0a3041f00220577fac5b6f1fdb9275dec 100644 (file)
@@ -151,8 +151,8 @@ static void nla_editmenu(bContext *C, uiLayout *layout, void *arg_unused)
 {
        Scene *scene= CTX_data_scene(C);
        
-       uiItemMenuF(layout, "Transform", 0, nla_edit_transformmenu);
-       uiItemMenuF(layout, "Snap", 0, nla_edit_snapmenu);
+       uiItemMenuF(layout, "Transform", 0, nla_edit_transformmenu, NULL);
+       uiItemMenuF(layout, "Snap", 0, nla_edit_snapmenu, NULL);
        
        uiItemS(layout);
        
index 20abcdf9f974a7e5c9aec4650dd0487cdb354837..e1b612d74e1d1a173f8dcf6f2fc8021957fcea2d 100644 (file)
@@ -485,7 +485,7 @@ static void texture_node_event(SpaceNode *snode, short event)
 #endif /* 0  */
 /* assumes nothing being done in ntree yet, sets the default in/out node */
 /* called from shading buttons or header */
-void node_shader_default(Material *ma)
+void ED_node_shader_default(Material *ma)
 {
        bNode *in, *out;
        bNodeSocket *fromsock, *tosock;
@@ -515,7 +515,7 @@ void node_shader_default(Material *ma)
 
 /* assumes nothing being done in ntree yet, sets the default in/out node */
 /* called from shading buttons or header */
-void node_composit_default(Scene *sce)
+void ED_node_composit_default(Scene *sce)
 {
        bNode *in, *out;
        bNodeSocket *fromsock, *tosock;
@@ -549,7 +549,7 @@ void node_composit_default(Scene *sce)
 
 /* assumes nothing being done in ntree yet, sets the default in/out node */
 /* called from shading buttons or header */
-void node_texture_default(Tex *tx)
+void ED_node_texture_default(Tex *tx)
 {
        bNode *in, *out;
        bNodeSocket *fromsock, *tosock;
@@ -591,7 +591,7 @@ void snode_set_context(SpaceNode *snode, Scene *scene)
                if(ob) {
                        Material *ma= give_current_material(ob, ob->actcol);
                        if(ma) {
-                               snode->from= material_from(ob, ob->actcol);
+                               snode->from= &ob->id;
                                snode->id= &ma->id;
                                snode->nodetree= ma->nodetree;
                        }
@@ -613,7 +613,13 @@ void snode_set_context(SpaceNode *snode, Scene *scene)
                if(snode->texfrom==SNODE_TEX_OBJECT) {
                        if(ob) {
                                tx= give_current_texture(ob, ob->actcol);
-                               snode->from= (ID *)ob;
+
+                               if(ob->type == OB_LAMP)
+                                       snode->from= (ID*)ob->data;
+                               else
+                                       snode->from= (ID*)give_current_material(ob, ob->actcol);
+
+                               /* from is not set fully for material nodes, should be ID + Node then */
                        }
                }
                else if(snode->texfrom==SNODE_TEX_WORLD) {
@@ -624,21 +630,18 @@ void snode_set_context(SpaceNode *snode, Scene *scene)
                        MTex *mtex= NULL;
                        Brush *brush= NULL;
                        
-                       if(ob && ob->mode & OB_MODE_SCULPT) {
+                       if(ob && (ob->mode & OB_MODE_SCULPT))
                                brush= paint_brush(&scene->toolsettings->sculpt->paint);
-                       }
                        else
                                brush= paint_brush(&scene->toolsettings->imapaint.paint);
 
-                       if(brush) {
-                               if(brush && brush->texact != -1)
-                                       mtex= brush->mtex[brush->texact];
-                       }
-                       
-                       if(mtex) {
-                               snode->from= (ID *)scene;
+                       if(brush && brush->texact != -1)
+                               mtex= brush->mtex[brush->texact];
+
+                       snode->from= (ID *)brush;
+
+                       if(mtex)
                                tx= mtex->tex;
-                       }
                }
                
                if(tx) {
index 367242d12629338e6cf56b3311b3ce1fa003364a..2abcd2f213566120e32259430f3b96a48c0f8d21 100644 (file)
@@ -45,6 +45,7 @@
 #include "BKE_screen.h"
 #include "BKE_node.h"
 #include "BKE_main.h"
+#include "BKE_utildefines.h"
 
 #include "ED_screen.h"
 #include "ED_types.h"
 
 #include "node_intern.h"
 
-/* ************************ header area region *********************** */
+/* ************************ add menu *********************** */
 
-static void do_node_selectmenu(bContext *C, void *arg, int event)
-{
-       ScrArea *curarea= CTX_wm_area(C);
-       SpaceNode *snode= CTX_wm_space_node(C); 
-       
-       /* functions in editnode.c assume there's a tree */
-       if(snode->nodetree==NULL)
-               return;
-       
-       switch(event) {
-               case 1: /* border select */
-                       WM_operator_name_call(C, "NODE_OT_select_border", WM_OP_INVOKE_REGION_WIN, NULL);
-                       break;
-               case 2: /* select/deselect all */
-                       // XXX node_deselectall(snode, 1);
-                       break;
-               case 3: /* select linked in */
-                       // XXX node_select_linked(snode, 0);
-                       break;
-               case 4: /* select linked out */
-                       // XXX node_select_linked(snode, 1);
-                       break;
-       }
-       
-       ED_area_tag_redraw(curarea);
-}
-
-static uiBlock *node_selectmenu(bContext *C, ARegion *ar, void *arg_unused)
-{
-       ScrArea *curarea= CTX_wm_area(C);
-       uiBlock *block;
-       short yco= 0, menuwidth=120;
-       
-       block= uiBeginBlock(C, ar, "node_selectmenu", UI_EMBOSSP);
-       uiBlockSetButmFunc(block, do_node_selectmenu, NULL);
-       
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Border Select|B", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
-       
-       uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
-       
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select/Deselect All|A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Linked From|L", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Linked To|Shift L", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
-       
-       if(curarea->headertype==HEADERTOP) {
-               uiBlockSetDirection(block, UI_DOWN);
-       }
-       else {
-               uiBlockSetDirection(block, UI_TOP);
-               uiBlockFlipOrder(block);
-       }
-       
-       uiTextBoundsBlock(block, 50);
-       uiEndBlock(C, block);
-       
-       return block;
-}
-
-void do_node_addmenu(bContext *C, void *arg, int event)
+static void do_node_add(bContext *C, void *arg, int event)
 {
        SpaceNode *snode= CTX_wm_space_node(C);
        bNode *node;
@@ -141,311 +84,125 @@ void do_node_addmenu(bContext *C, void *arg, int event)
        snode_handle_recalc(C, snode);
 }
 
-static void node_make_addmenu(bContext *C, int nodeclass, uiBlock *block)
+static void node_auto_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass)
 {
        Main *bmain= CTX_data_main(C);
        SpaceNode *snode= CTX_wm_space_node(C);
        bNodeTree *ntree;
+       int nodeclass= GET_INT_FROM_POINTER(arg_nodeclass);
        int tot= 0, a;
-       short yco= 0, menuwidth=120;
        
        ntree = snode->nodetree;
-       if(ntree) {
-               /* mostly taken from toolbox.c, node_add_sublevel() */
-               if(ntree) {
-                       if(nodeclass==NODE_CLASS_GROUP) {
-                               bNodeTree *ngroup= bmain->nodetree.first;
-                               for(; ngroup; ngroup= ngroup->id.next)
-                                       if(ngroup->type==ntree->type)
-                                               tot++;
-                       }
-                       else {
-                               bNodeType *type = ntree->alltypes.first;
-                               while(type) {
-                                       if(type->nclass == nodeclass)
-                                               tot++;
-                                       type= type->next;
-                               }
-                       }
-               }       
-               
-               if(tot==0) {
-                       uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
-                       return;
+
+       if(!ntree) {
+               uiItemS(layout);
+               return;
+       }
+
+       /* mostly taken from toolbox.c, node_add_sublevel() */
+       if(nodeclass==NODE_CLASS_GROUP) {
+               bNodeTree *ngroup= bmain->nodetree.first;
+               for(; ngroup; ngroup= ngroup->id.next)
+                       if(ngroup->type==ntree->type)
+                               tot++;
+       }
+       else {
+               bNodeType *type = ntree->alltypes.first;
+               while(type) {
+                       if(type->nclass == nodeclass)
+                               tot++;
+                       type= type->next;
                }
-               
-               if(nodeclass==NODE_CLASS_GROUP) {
-                       bNodeTree *ngroup= bmain->nodetree.first;
-                       for(tot=0, a=0; ngroup; ngroup= ngroup->id.next, tot++) {
-                               if(ngroup->type==ntree->type) {
-                                       
-                                       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, (ngroup->id.name+2), 0, 
-                                               yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1.0f, (float)(NODE_GROUP_MENU+tot), "");
-                                       a++;
-                               }
+       }       
+       
+       if(tot==0) {
+               uiItemS(layout);
+               return;
+       }
+
+       uiLayoutSetFunc(layout, do_node_add, NULL);
+       
+       if(nodeclass==NODE_CLASS_GROUP) {
+               bNodeTree *ngroup= bmain->nodetree.first;
+
+               for(tot=0, a=0; ngroup; ngroup= ngroup->id.next, tot++) {
+                       if(ngroup->type==ntree->type) {
+                               uiItemV(layout, ngroup->id.name+2, 0, NODE_GROUP_MENU+tot);
+                               a++;
                        }
                }
-               else {
-                       bNodeType *type;
-                       int script=0;
-                       for(a=0, type= ntree->alltypes.first; type; type=type->next) {
-                               if( type->nclass == nodeclass && type->name) {
-                                       if(type->type == NODE_DYNAMIC) {
-                                               uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, type->name, 0, 
-                                                       yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1.0f, (float)(NODE_DYNAMIC_MENU+script), "");
-                                               script++;
-                                       } else {
-                                       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, type->name, 0, 
-                                               yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1.0f, (float)(type->type), "");
-                                       }
-                                       a++;
+       }
+       else {
+               bNodeType *type;
+               int script=0;
+
+               for(a=0, type= ntree->alltypes.first; type; type=type->next) {
+                       if(type->nclass == nodeclass && type->name) {
+                               if(type->type == NODE_DYNAMIC) {
+                                       uiItemV(layout, type->name, 0, NODE_DYNAMIC_MENU+script);
+                                       script++;
                                }
+                               else
+                                       uiItemV(layout, type->name, 0, type->type);
+
+                               a++;
                        }
                }
-       } else {
-               uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
-               return;
        }
 }
 
-static uiBlock *node_add_inputmenu(bContext *C, ARegion *ar, void *arg_unused)
-{
-       uiBlock *block;
-
-       block= uiBeginBlock(C, ar, "node_add_inputmenu", UI_EMBOSSP);
-       uiBlockSetButmFunc(block, do_node_addmenu, NULL);
-       
-       node_make_addmenu(C, NODE_CLASS_INPUT, block);
-       
-       uiBlockSetDirection(block, UI_RIGHT);
-       uiTextBoundsBlock(block, 60);
-       uiEndBlock(C, block);
-       
-       return block;
-}
-static uiBlock *node_add_outputmenu(bContext *C, ARegion *ar, void *arg_unused)
-{
-       uiBlock *block;
-       
-       block= uiBeginBlock(C, ar, "node_add_outputmenu", UI_EMBOSSP);
-       uiBlockSetButmFunc(block, do_node_addmenu, NULL);
-       
-       node_make_addmenu(C, NODE_CLASS_OUTPUT, block);
-       
-       uiBlockSetDirection(block, UI_RIGHT);
-       uiTextBoundsBlock(block, 60);
-       uiEndBlock(C, block);
-       
-       return block;
-}
-static uiBlock *node_add_colormenu(bContext *C, ARegion *ar, void *arg_unused)
-{
-       uiBlock *block;
-       
-       block= uiBeginBlock(C, ar, "node_add_colormenu", UI_EMBOSSP);
-       uiBlockSetButmFunc(block, do_node_addmenu, NULL);
-       
-       node_make_addmenu(C, NODE_CLASS_OP_COLOR, block);
-       
-       uiBlockSetDirection(block, UI_RIGHT);
-       uiTextBoundsBlock(block, 60);
-       uiEndBlock(C, block);
-       
-       return block;
-}
-static uiBlock *node_add_vectormenu(bContext *C, ARegion *ar, void *arg_unused)
-{
-       uiBlock *block;
-       
-       block= uiBeginBlock(C, ar, "node_add_vectormenu", UI_EMBOSSP);
-       uiBlockSetButmFunc(block, do_node_addmenu, NULL);
-       
-       node_make_addmenu(C, NODE_CLASS_OP_VECTOR, block);
-       
-       uiBlockSetDirection(block, UI_RIGHT);
-       uiTextBoundsBlock(block, 60);
-       uiEndBlock(C, block);
-       
-       return block;
-}
-static uiBlock *node_add_filtermenu(bContext *C, ARegion *ar, void *arg_unused)
-{
-       uiBlock *block;
-       
-       block= uiBeginBlock(C, ar, "node_add_filtermenu", UI_EMBOSSP);
-       uiBlockSetButmFunc(block, do_node_addmenu, NULL);
-       
-       node_make_addmenu(C, NODE_CLASS_OP_FILTER, block);
-       
-       uiBlockSetDirection(block, UI_RIGHT);
-       uiTextBoundsBlock(block, 60);
-       uiEndBlock(C, block);
-       
-       return block;
-}
-static uiBlock *node_add_convertermenu(bContext *C, ARegion *ar, void *arg_unused)
-{
-       uiBlock *block;
-       
-       block= uiBeginBlock(C, ar, "node_add_convertermenu", UI_EMBOSSP);
-       uiBlockSetButmFunc(block, do_node_addmenu, NULL);
-       
-       node_make_addmenu(C, NODE_CLASS_CONVERTOR, block);
-       
-       uiBlockSetDirection(block, UI_RIGHT);
-       uiTextBoundsBlock(block, 60);
-       uiEndBlock(C, block);
-       
-       return block;
-}
-static uiBlock *node_add_mattemenu(bContext *C, ARegion *ar, void *arg_unused)
-{
-       uiBlock *block;
-       
-       block= uiBeginBlock(C, ar, "node_add_mattemenu", UI_EMBOSSP);
-       uiBlockSetButmFunc(block, do_node_addmenu, NULL);
-       
-       node_make_addmenu(C, NODE_CLASS_MATTE, block);
-       
-       uiBlockSetDirection(block, UI_RIGHT);
-       uiTextBoundsBlock(block, 60);
-       uiEndBlock(C, block);
-       
-       return block;
-}
-static uiBlock *node_add_distortmenu(bContext *C, ARegion *ar, void *arg_unused)
-{
-       uiBlock *block;
-       
-       block= uiBeginBlock(C, ar, "node_add_distortmenu", UI_EMBOSSP);
-       uiBlockSetButmFunc(block, do_node_addmenu, NULL);
-       
-       node_make_addmenu(C, NODE_CLASS_DISTORT, block);
-       
-       uiBlockSetDirection(block, UI_RIGHT);
-       uiTextBoundsBlock(block, 60);
-       uiEndBlock(C, block);
-       
-       return block;
-}
-static uiBlock *node_add_patternmenu(bContext *C, ARegion *ar,  void *arg_unused)
-{
-       uiBlock *block;
-       
-       block= uiBeginBlock(C, ar, "node_add_patternmenu", UI_EMBOSSP);
-       uiBlockSetButmFunc(block, do_node_addmenu, NULL);
-       
-       node_make_addmenu(C, NODE_CLASS_PATTERN, block);
-       
-       uiBlockSetDirection(block, UI_RIGHT);
-       uiTextBoundsBlock(block, 60);
-       uiEndBlock(C, block);
-       
-       return block;
-}
-static uiBlock *node_add_texturemenu(bContext *C, ARegion *ar, void *arg_unused)
+static void node_menu_add(const bContext *C, Menu *menu)
 {
-       uiBlock *block;
-       
-       block= uiBeginBlock(C, ar, "node_add_texturemenu", UI_EMBOSSP);
-       uiBlockSetButmFunc(block, do_node_addmenu, NULL);
-       
-       node_make_addmenu(C, NODE_CLASS_TEXTURE, block);
-       
-       uiBlockSetDirection(block, UI_RIGHT);
-       uiTextBoundsBlock(block, 60);
-       uiEndBlock(C, block);
-       
-       return block;
-}
-static uiBlock *node_add_groupmenu(bContext *C, ARegion *ar, void *arg_unused)
-{
-       uiBlock *block;
-       
-       block= uiBeginBlock(C, ar, "node_add_groupmenu", UI_EMBOSSP);
-       uiBlockSetButmFunc(block, do_node_addmenu, NULL);
-       
-       node_make_addmenu(C, NODE_CLASS_GROUP, block);
-       
-       uiBlockSetDirection(block, UI_RIGHT);
-       uiTextBoundsBlock(block, 60);
-       uiEndBlock(C, block);
-       
-       return block;
-}
+       uiLayout *layout= menu->layout;
+       SpaceNode *snode= CTX_wm_space_node(C);
 
-static uiBlock *node_add_dynamicmenu(bContext *C, ARegion *ar, void *arg_unused)
-{
-       uiBlock *block;
-       
-       block= uiBeginBlock(C, ar, "node_add_dynamicmenu", UI_EMBOSSP);
-       uiBlockSetButmFunc(block, do_node_addmenu, NULL);
-       
-       node_make_addmenu(C, NODE_CLASS_OP_DYNAMIC, block);
-       
-       uiBlockSetDirection(block, UI_RIGHT);
-       uiTextBoundsBlock(block, 60);
-       uiEndBlock(C, block);
-       
-       return block;
-}
+       if(!snode->nodetree)
+               uiLayoutSetActive(layout, 0);
 
-static uiBlock *node_addmenu(bContext *C, ARegion *ar, void *arg_unused)
-{
-       ScrArea *curarea= CTX_wm_area(C);
-       SpaceNode *snode= CTX_wm_space_node(C);
-       uiBlock *block;
-       short yco= 0, menuwidth=120;
-       
-       block= uiBeginBlock(C, ar, "node_addmenu", UI_EMBOSSP);
-       uiBlockSetButmFunc(block, do_node_addmenu, NULL);
-       
        if(snode->treetype==NTREE_SHADER) {
-               uiDefIconTextBlockBut(block, node_add_inputmenu, NULL, ICON_RIGHTARROW_THIN, "Input", 0, yco-=20, 120, 19, "");
-               uiDefIconTextBlockBut(block, node_add_outputmenu, NULL, ICON_RIGHTARROW_THIN, "Output", 0, yco-=20, 120, 19, "");
-               uiDefIconTextBlockBut(block, node_add_colormenu, NULL, ICON_RIGHTARROW_THIN, "Color", 0, yco-=20, 120, 19, "");
-               uiDefIconTextBlockBut(block, node_add_vectormenu, NULL, ICON_RIGHTARROW_THIN, "Vector", 0, yco-=20, 120, 19, "");
-               uiDefIconTextBlockBut(block, node_add_convertermenu, NULL, ICON_RIGHTARROW_THIN, "Convertor", 0, yco-=20, 120, 19, "");
-               uiDefIconTextBlockBut(block, node_add_groupmenu, NULL, ICON_RIGHTARROW_THIN, "Group", 0, yco-=20, 120, 19, "");
-               uiDefIconTextBlockBut(block, node_add_dynamicmenu, NULL, ICON_RIGHTARROW_THIN, "Dynamic", 0, yco-=20, 120, 19, "");
+               uiItemMenuF(layout, "Input", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_INPUT));
+               uiItemMenuF(layout, "Output", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OUTPUT));
+               uiItemMenuF(layout, "Color", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_COLOR));
+               uiItemMenuF(layout, "Vector", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_VECTOR));
+               uiItemMenuF(layout, "Convertor", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_CONVERTOR));
+               uiItemMenuF(layout, "Group", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_GROUP));
+               uiItemMenuF(layout, "Dynamic", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_DYNAMIC));
        }
        else if(snode->treetype==NTREE_COMPOSIT) {
-               uiDefIconTextBlockBut(block, node_add_inputmenu, NULL, ICON_RIGHTARROW_THIN, "Input", 0, yco-=20, 120, 19, "");
-               uiDefIconTextBlockBut(block, node_add_outputmenu, NULL, ICON_RIGHTARROW_THIN, "Output", 0, yco-=20, 120, 19, "");
-               uiDefIconTextBlockBut(block, node_add_colormenu, NULL, ICON_RIGHTARROW_THIN, "Color", 0, yco-=20, 120, 19, "");
-               uiDefIconTextBlockBut(block, node_add_vectormenu, NULL, ICON_RIGHTARROW_THIN, "Vector", 0, yco-=20, 120, 19, "");
-               uiDefIconTextBlockBut(block, node_add_filtermenu, NULL, ICON_RIGHTARROW_THIN, "Filter", 0, yco-=20, 120, 19, "");
-               uiDefIconTextBlockBut(block, node_add_convertermenu, NULL, ICON_RIGHTARROW_THIN, "Convertor", 0, yco-=20, 120, 19, "");
-               uiDefIconTextBlockBut(block, node_add_mattemenu, NULL, ICON_RIGHTARROW_THIN, "Matte", 0, yco-=20, 120, 19, "");
-               uiDefIconTextBlockBut(block, node_add_distortmenu, NULL, ICON_RIGHTARROW_THIN, "Distort", 0, yco-=20, 120, 19, "");
-               uiDefIconTextBlockBut(block, node_add_groupmenu, NULL, ICON_RIGHTARROW_THIN, "Group", 0, yco-=20, 120, 19, "");
-
-       } else if(snode->treetype==NTREE_TEXTURE) {
-               uiDefIconTextBlockBut(block, node_add_inputmenu, NULL, ICON_RIGHTARROW_THIN, "Input", 0, yco-=20, 120, 19, "");
-               uiDefIconTextBlockBut(block, node_add_outputmenu, NULL, ICON_RIGHTARROW_THIN, "Output", 0, yco-=20, 120, 19, "");
-               uiDefIconTextBlockBut(block, node_add_colormenu, NULL, ICON_RIGHTARROW_THIN, "Color", 0, yco-=20, 120, 19, "");
-               uiDefIconTextBlockBut(block, node_add_patternmenu, NULL, ICON_RIGHTARROW_THIN, "Patterns", 0, yco-=20, 120, 19, "");
-               uiDefIconTextBlockBut(block, node_add_texturemenu, NULL, ICON_RIGHTARROW_THIN, "Textures", 0, yco-=20, 120, 19, "");
-               uiDefIconTextBlockBut(block, node_add_convertermenu, NULL, ICON_RIGHTARROW_THIN, "Convertor", 0, yco-=20, 120, 19, "");
-               uiDefIconTextBlockBut(block, node_add_distortmenu, NULL, ICON_RIGHTARROW_THIN, "Distort", 0, yco-=20, 120, 19, "");
-               uiDefIconTextBlockBut(block, node_add_groupmenu, NULL, ICON_RIGHTARROW_THIN, "Group", 0, yco-=20, 120, 19, "");
+               uiItemMenuF(layout, "Input", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_INPUT));
+               uiItemMenuF(layout, "Output", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OUTPUT));
+               uiItemMenuF(layout, "Color", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_COLOR));
+               uiItemMenuF(layout, "Vector", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_VECTOR));
+               uiItemMenuF(layout, "Filter", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_FILTER));
+               uiItemMenuF(layout, "Convertor", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_CONVERTOR));
+               uiItemMenuF(layout, "Matte", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_MATTE));
+               uiItemMenuF(layout, "Distort", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_DISTORT));
+               uiItemMenuF(layout, "Group", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_GROUP));
        }
-       else
-               uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); 
-       
-       if(curarea->headertype==HEADERTOP) {
-               uiBlockSetDirection(block, UI_DOWN);
-       }
-       else {
-               uiBlockSetDirection(block, UI_TOP);
-               uiBlockFlipOrder(block);
+       else if(snode->treetype==NTREE_TEXTURE) {
+               uiItemMenuF(layout, "Input", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_INPUT));
+               uiItemMenuF(layout, "Output", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OUTPUT));
+               uiItemMenuF(layout, "Color", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_COLOR));
+               uiItemMenuF(layout, "Patterns", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_PATTERN));
+               uiItemMenuF(layout, "Textures", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_TEXTURE));
+               uiItemMenuF(layout, "Convertor", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_CONVERTOR));
+               uiItemMenuF(layout, "Distort", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_DISTORT));
+               uiItemMenuF(layout, "Group", 0, node_auto_add_menu, SET_INT_IN_POINTER(NODE_CLASS_GROUP));
        }
-       
-       uiTextBoundsBlock(block, 50);
-       
-       return block;
 }
 
+void node_menus_register(ARegionType *art)
+{
+       MenuType *mt;
+
+       mt= MEM_callocN(sizeof(MenuType), "spacetype node menu add");
+       strcpy(mt->idname, "NODE_MT_add");
+       strcpy(mt->label, "Add");
+       mt->draw= node_menu_add;
+       BLI_addtail(&art->menutypes, mt);
+}
+
+#if 0
 static void do_node_nodemenu(bContext *C, void *arg, int event)
 {
        ScrArea *curarea= CTX_wm_area(C);
@@ -571,218 +328,5 @@ static uiBlock *node_nodemenu(bContext *C, ARegion *ar, void *arg_unused)
        
        return block;
 }
-
-static void do_node_viewmenu(bContext *C, void *arg, int event)
-{
-//     SpaceNode *snode= CTX_wm_space_node(C);
-//     ARegion *ar= CTX_wm_region(C);
-       ScrArea *sa= CTX_wm_area(C);
-       
-       switch(event) {
-               case 1: /* Zoom in */
-                       WM_operator_name_call(C, "VIEW2D_OT_zoom_in", WM_OP_EXEC_REGION_WIN, NULL);
-                       break;
-               case 2: /* View all */
-                       WM_operator_name_call(C, "VIEW2D_OT_zoom_out", WM_OP_EXEC_REGION_WIN, NULL);
-                       break;
-               case 3: /* View all */
-                       WM_operator_name_call(C, "NODE_OT_view_all", WM_OP_EXEC_REGION_WIN, NULL);
-                       break;
-               case 4: /* Grease Pencil */
-                       // XXX add_blockhandler(sa, NODES_HANDLER_GREASEPENCIL, UI_PNL_UNSTOW);
-                       break;
-       }
-       ED_area_tag_redraw(sa);
-}
-
-static uiBlock *node_viewmenu(bContext *C, ARegion *ar, void *arg_unused)
-{
-       ScrArea *curarea= CTX_wm_area(C);
-       SpaceNode *snode= CTX_wm_space_node(C);
-       uiBlock *block;
-       short yco= 0, menuwidth=120;
-       
-       block= uiBeginBlock(C, ar, "node_viewmenu", UI_EMBOSSP);
-       uiBlockSetButmFunc(block, do_node_viewmenu, NULL);
-
-       if (snode->nodetree) {
-               uiDefIconTextBut(block, BUTM, 1, ICON_MENU_PANEL, "Grease Pencil...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
-               
-               uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
-       }
-       
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Zoom In|NumPad +", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Zoom Out|NumPad -", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
-       
-       uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
-       
-       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "View All|Home", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
-       
-       /* XXX if (!curarea->full) 
-               uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Maximize Window|Ctrl UpArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
-       else 
-               uiDefIconTextBut(block, BUTM, B_FULL, ICON_BLANK1, "Tile Window|Ctrl DownArrow", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
-       */
-       if(curarea->headertype==HEADERTOP) {
-               uiBlockSetDirection(block, UI_DOWN);
-       }
-       else {
-               uiBlockSetDirection(block, UI_TOP);
-               uiBlockFlipOrder(block);
-       }
-       
-       uiTextBoundsBlock(block, 50);
-       uiEndBlock(C, block);
-       
-       return block;
-}
-
-static void do_node_buttons(bContext *C, void *arg, int event)
-{
-       // NODE_FIX_ME : instead of using "current material/texture/scene", node editor can also pin context?
-       // note: scene context better not gets overridden, that'll clash too much (ton)
-       SpaceNode *snode= CTX_wm_space_node(C);
-       Scene *scene= CTX_data_scene(C);
-       Material *ma;
-       Tex *tx;
-       
-       switch(event) {
-               case B_REDR:
-                       ED_area_tag_redraw(CTX_wm_area(C));                     
-                       break;
-               case B_NODE_USEMAT:
-                       ma= (Material *)snode->id;
-                       if(ma) {
-                               if(ma->use_nodes && ma->nodetree==NULL) {
-                                       node_shader_default(ma);
-                                       snode_set_context(snode, scene);
-                               }
-                       }               
-                       ED_area_tag_redraw(CTX_wm_area(C));                     
-                       break;
-                       
-               case B_NODE_USESCENE:
-                       if(scene->use_nodes) {
-                               if(scene->nodetree==NULL)
-                                       node_composit_default(scene);
-                       }
-                       snode_set_context(snode, scene);
-                       ED_area_tag_redraw(CTX_wm_area(C));                     
-                       break;
-                       
-               case B_NODE_USETEX:
-                       tx = (Tex *)snode->id;
-                       if(tx) {
-                               tx->type = 0;
-                               if(tx->use_nodes && tx->nodetree==NULL) {
-                                       node_texture_default(tx);
-                                       snode_set_context(snode, scene);
-                               }
-                       }
-                       ED_area_tag_redraw(CTX_wm_area(C));                     
-                       break;
-       }
-}
-
-void node_header_buttons(const bContext *C, ARegion *ar)
-{
-       ScrArea *sa= CTX_wm_area(C);
-       SpaceNode *snode= CTX_wm_space_node(C);
-       Scene *scene= CTX_data_scene(C);
-       uiBlock *block;
-       short xco, yco= 3;
-       
-       block= uiBeginBlock(C, ar, "header node", UI_EMBOSS);
-       uiBlockSetHandleFunc(block, do_node_buttons, NULL);
-       
-       xco= ED_area_header_standardbuttons(C, block, yco);
-       
-       if((sa->flag & HEADER_NO_PULLDOWN)==0) {
-               int xmax;
-       
-               xmax= GetButStringLength("View");
-               uiDefPulldownBut(block, node_viewmenu, NULL, 
-                                         "View", xco, yco, xmax-3, 20, "");
-               xco+= xmax;
-               
-               xmax= GetButStringLength("Select");
-               uiDefPulldownBut(block, node_selectmenu, NULL, 
-                                                "Select", xco, yco, xmax-3, 20, "");
-               xco+= xmax;
-               
-               xmax= GetButStringLength("Add");
-               uiDefPulldownBut(block, node_addmenu, NULL, 
-                                                "Add", xco, yco, xmax-3, 20, "");
-               xco+= xmax;
-               
-               xmax= GetButStringLength("Node");
-               uiDefPulldownBut(block, node_nodemenu, NULL, 
-                                                "Node", xco, yco, xmax-3, 20, "");
-               xco+= xmax;
-       }
-       
-       uiBlockSetEmboss(block, UI_EMBOSS);
-
-       uiBlockSetEmboss(block, UI_EMBOSS);
-       
-       /* main type choosing */
-       uiBlockBeginAlign(block);
-       uiDefIconButI(block, ROW, B_REDR, ICON_MATERIAL_DATA, xco,yco,XIC,YIC-2,
-                                 &(snode->treetype), 2.0f, 0.0f, 0.0f, 0.0f, "Material Nodes");
-       xco+= XIC;
-       uiDefIconButI(block, ROW, B_REDR, ICON_IMAGE_DATA, xco,yco,XIC,YIC-2,
-                                 &(snode->treetype), 2.0f, 1.0f, 0.0f, 0.0f, "Composite Nodes");
-       xco+= XIC;
-       uiDefIconButI(block, ROW, B_REDR, ICON_TEXTURE_DATA, xco,yco,XIC,YIC-2,
-                                 &(snode->treetype), 2.0f, 2.0f, 0.0f, 0.0f, "Texture Nodes");
-       xco+= 2*XIC;
-       uiBlockEndAlign(block);
-
-       /* find and set the context */
-       snode_set_context(snode, scene);
-       
-       if(snode->treetype==NTREE_SHADER) {
-               if(snode->from) {
-                                                                               /* 0, NULL -> pin */
-                       // XXX xco= std_libbuttons(block, xco, 0, 0, NULL, B_MATBROWSE, ID_MA, 1, snode->id, snode->from, &(snode->menunr), 
-                       //   B_MATALONE, B_MATLOCAL, B_MATDELETE, B_AUTOMATNAME, B_KEEPDATA);
-                       
-                       if(snode->id) {
-                               Material *ma= (Material *)snode->id;
-                               uiDefButC(block, TOG, B_NODE_USEMAT, "Use Nodes", xco+5,yco,90,19, &ma->use_nodes, 0.0f, 0.0f, 0, 0, "");
-                               xco+=80;
-                       }
-               }
-       }
-       else if(snode->treetype==NTREE_COMPOSIT) {
-               int icon;
-               
-               if(WM_jobs_test(CTX_wm_manager(C), sa)) icon= ICON_REC; else icon= ICON_BLANK1;
-               uiDefIconTextButS(block, TOG, B_NODE_USESCENE, icon, "Use Nodes", xco+5,yco,100,19, &scene->use_nodes, 0.0f, 0.0f, 0, 0, "Indicate this Scene will use Nodes and execute them while editing");
-               xco+= 100;
-               uiDefButBitI(block, TOG, R_COMP_FREE, B_NOP, "Free Unused", xco+5,yco,100,19, &scene->r.scemode, 0.0f, 0.0f, 0, 0, "Free Nodes that are not used while composite");
-               xco+= 100;
-               uiDefButBitS(block, TOG, SNODE_BACKDRAW, B_REDR, "Backdrop", xco+5,yco,90,19, &snode->flag, 0.0f, 0.0f, 0, 0, "Use active Viewer Node output as backdrop");
-               xco+= 90;
-       }
-       else if(snode->treetype==NTREE_TEXTURE) {
-               if(snode->from) {
-                       
-                       // XXX xco= std_libbuttons(block, xco, 0, 0, NULL, B_TEXBROWSE, ID_TE, 1, snode->id, snode->from, &(snode->menunr), 
-                       //                 B_TEXALONE, B_TEXLOCAL, B_TEXDELETE, B_AUTOTEXNAME, B_KEEPDATA);
-                       
-                       if(snode->id) {
-                               Tex *tx= (Tex *)snode->id;
-                               uiDefButC(block, TOG, B_NODE_USETEX, "Use Nodes", xco+5,yco,90,19, &tx->use_nodes, 0.0f, 0.0f, 0, 0, "");
-                               xco+=80;
-                       }
-               }
-       }
-       
-       UI_view2d_totRect_set(&ar->v2d, xco+XIC+100, (int)(ar->v2d.tot.ymax-ar->v2d.tot.ymin));
-       
-       uiEndBlock(C, block);
-       uiDrawBlock(C, block);
-}
-
+#endif
 
index d6680457376e0a0deffc1f26b58c66958a15a543..5c66c902797345271b3355e171710703811b605a 100644 (file)
@@ -31,6 +31,7 @@
 /* internal exports only */
 
 struct ARegion;
+struct ARegionType;
 struct View2D;
 struct bContext;
 struct wmWindowManager;
@@ -45,6 +46,7 @@ struct wmWindowManager;
 
 /* node_header.c */
 void node_header_buttons(const bContext *C, ARegion *ar);
+void node_menus_register(struct ARegionType *art);
 
 /* node_draw.c */
 void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d);
@@ -75,9 +77,6 @@ void snode_make_group_editable(SpaceNode *snode, bNode *gnode);
 void snode_home(ScrArea *sa, ARegion *ar, SpaceNode *snode);
 void node_set_active(SpaceNode *snode, bNode *node);
 void node_deselectall(SpaceNode *snode, int swap);
-void node_shader_default(Material *ma);
-void node_composit_default(Scene *sce);
-void node_texture_default(Tex *tx);
 void snode_composite_job(const struct bContext *C, ScrArea *sa);
 bNode *snode_get_editgroup(SpaceNode *snode);
 void snode_autoconnect(SpaceNode *snode, bNode *node_to, int flag);
index 8d805490942d0dbed9831999f14ae0a675c8fa1f..dcab3dc08952fea8d368b7835b2b10c3b5ce9dde 100644 (file)
@@ -183,7 +183,7 @@ void NODE_OT_visibility_toggle(wmOperatorType *ot)
        RNA_def_int(ot->srna, "mouse_y", 0, INT_MIN, INT_MAX, "Mouse Y", "", INT_MIN, INT_MAX);
 }
 
-static int node_fit_all_exec(bContext *C, wmOperator *op)
+static int node_view_all_exec(bContext *C, wmOperator *op)
 {
        ScrArea *sa= CTX_wm_area(C);
        ARegion *ar= CTX_wm_region(C);
@@ -196,11 +196,11 @@ static int node_fit_all_exec(bContext *C, wmOperator *op)
 void NODE_OT_view_all(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name= "Fit All";
+       ot->name= "View All";
        ot->idname= "NODE_OT_view_all";
        
        /* api callbacks */
-       ot->exec= node_fit_all_exec;
+       ot->exec= node_view_all_exec;
        ot->poll= ED_operator_node_active;
        
        /* flags */
index 2087356686729335ef0745bb1f88d4800ed39975..cb25d29fd276b86f59921fff94cc69262d91e88f 100644 (file)
@@ -254,29 +254,18 @@ static void node_main_area_draw(const bContext *C, ARegion *ar)
 /* add handlers, stuff you only do once or on area/region changes */
 static void node_header_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy);
+       ED_region_header_init(ar);
 }
 
 static void node_header_area_draw(const bContext *C, ARegion *ar)
 {
-       float col[3];
-       
-       /* clear */
-       if(ED_screen_area_active(C))
-               UI_GetThemeColor3fv(TH_HEADER, col);
-       else
-               UI_GetThemeColor3fv(TH_HEADERDESEL, col);
-       
-       glClearColor(col[0], col[1], col[2], 0.0);
-       glClear(GL_COLOR_BUFFER_BIT);
-       
-       /* set view2d view matrix for scrolling (without scrollers) */
-       UI_view2d_view_ortho(C, &ar->v2d);
-       
-       node_header_buttons(C, ar);
-       
-       /* restore view matrix? */
-       UI_view2d_view_restore(C);
+       SpaceNode *snode= CTX_wm_space_node(C);
+       Scene *scene= CTX_data_scene(C);
+
+    /* find and set the context */
+       snode_set_context(snode, scene);
+
+       ED_region_header(C, ar);
 }
 
 /* used for header + main area */
@@ -285,12 +274,9 @@ static void node_region_listener(ARegion *ar, wmNotifier *wmn)
        /* context changes */
        switch(wmn->category) {
                case NC_SCENE:
-                       ED_region_tag_redraw(ar);
-                       break;
                case NC_MATERIAL:
-                       ED_region_tag_redraw(ar);
-                       break;
                case NC_TEXTURE:
+               case NC_NODE:
                        ED_region_tag_redraw(ar);
                        break;
        }
@@ -357,6 +343,8 @@ void ED_spacetype_node(void)
        art->draw= node_header_area_draw;
        
        BLI_addhead(&st->regiontypes, art);
+
+       node_menus_register(art);
        
 #if 0
        /* regions: channels */
index c761587198f268348b937c71cde2a3678d11decc..0e2d2ce1698f07d02c584ae519c17fd2136a70db 100644 (file)
@@ -186,12 +186,18 @@ ARegion *text_has_properties_region(ScrArea *sa)
        return arnew;
 }
 
-static int properties_poll(bContext *C)
+void text_toggle_properties_region(bContext *C, ScrArea *sa, ARegion *ar)
 {
-       SpaceText *st= CTX_wm_space_text(C);
-       Text *text= CTX_data_edit_text(C);
+       ar->flag ^= RGN_FLAG_HIDDEN;
+       ar->v2d.flag &= ~V2D_IS_INITIALISED; /* XXX should become hide/unhide api? */
+       
+       ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa);
+       ED_area_tag_redraw(sa);
+}
 
-       return (st && text);
+static int properties_poll(bContext *C)
+{
+       return (CTX_wm_space_text(C) != NULL);
 }
 
 static int properties_exec(bContext *C, wmOperator *op)
@@ -199,13 +205,8 @@ static int properties_exec(bContext *C, wmOperator *op)
        ScrArea *sa= CTX_wm_area(C);
        ARegion *ar= text_has_properties_region(sa);
        
-       if(ar) {
-               ar->flag ^= RGN_FLAG_HIDDEN;
-               ar->v2d.flag &= ~V2D_IS_INITIALISED; /* XXX should become hide/unhide api? */
-               
-               ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa);
-               ED_area_tag_redraw(sa);
-       }
+       if(ar)
+               text_toggle_properties_region(C, sa, ar);
 
        return OPERATOR_FINISHED;
 }
index 2a7b718a664ba5b2ad53af11152cf694a5d7c255..6c86c87302c51dd25d2bec64562ad1a6f697080c 100644 (file)
@@ -2092,7 +2092,7 @@ static void view3d_edit_meshmenu(bContext *C, uiLayout *layout, void *arg_unused
        uiDefIconTextBlockBut(block, view3d_edit_snapmenu, NULL, ICON_RIGHTARROW_THIN, "Snap", 0, yco-=20, 120, 19, "");
 #endif
 
-       uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu);
+       uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu, NULL);
 
        uiItemS(layout);
 
@@ -2113,10 +2113,10 @@ static void view3d_edit_meshmenu(bContext *C, uiLayout *layout, void *arg_unused
 
        uiItemS(layout);
 
-       uiItemMenuF(layout, "Vertices", 0, view3d_edit_mesh_verticesmenu);
-       uiItemMenuF(layout, "Edges", 0, view3d_edit_mesh_edgesmenu);
-       uiItemMenuF(layout, "Faces", 0, view3d_edit_mesh_facesmenu);
-       uiItemMenuF(layout, "Normals", 0, view3d_edit_mesh_normalsmenu);
+       uiItemMenuF(layout, "Vertices", 0, view3d_edit_mesh_verticesmenu, NULL);
+       uiItemMenuF(layout, "Edges", 0, view3d_edit_mesh_edgesmenu, NULL);
+       uiItemMenuF(layout, "Faces", 0, view3d_edit_mesh_facesmenu, NULL);
+       uiItemMenuF(layout, "Normals", 0, view3d_edit_mesh_normalsmenu, NULL);
 
        uiItemS(layout);
 
@@ -2126,7 +2126,7 @@ static void view3d_edit_meshmenu(bContext *C, uiLayout *layout, void *arg_unused
 
        uiItemS(layout);
 
-       uiItemMenuF(layout, "Show/Hide", 0, view3d_edit_mesh_showhidemenu);
+       uiItemMenuF(layout, "Show/Hide", 0, view3d_edit_mesh_showhidemenu, NULL);
 
 #if 0
 #ifndef DISABLE_PYTHON
@@ -2180,7 +2180,7 @@ static void view3d_edit_curvemenu(bContext *C, uiLayout *layout, void *arg_unuse
        uiDefIconTextBlockBut(block, view3d_edit_mirrormenu, NULL, ICON_RIGHTARROW_THIN, "Mirror", 0, yco-=20, menuwidth, 19, "");      
 #endif
 
-       uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu);
+       uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu, NULL);
 
        uiItemS(layout);
        
@@ -2199,8 +2199,8 @@ static void view3d_edit_curvemenu(bContext *C, uiLayout *layout, void *arg_unuse
 
        uiItemS(layout);
 
-       uiItemMenuF(layout, "Control Points", 0, view3d_edit_curve_controlpointsmenu);
-       uiItemMenuF(layout, "Segments", 0, view3d_edit_curve_segmentsmenu);
+       uiItemMenuF(layout, "Control Points", 0, view3d_edit_curve_controlpointsmenu, NULL);
+       uiItemMenuF(layout, "Segments", 0, view3d_edit_curve_segmentsmenu, NULL);
 
        uiItemS(layout);
 
@@ -2209,7 +2209,7 @@ static void view3d_edit_curvemenu(bContext *C, uiLayout *layout, void *arg_unuse
 
        uiItemS(layout);
 
-       uiItemMenuF(layout, "Show/Hide Control Points", 0, view3d_edit_curve_showhidemenu);
+       uiItemMenuF(layout, "Show/Hide Control Points", 0, view3d_edit_curve_showhidemenu, NULL);
 }
 #endif
 
@@ -2232,7 +2232,7 @@ static void view3d_edit_latticemenu(bContext *C, uiLayout *layout, void *arg_unu
        uiDefIconTextBlockBut(block, view3d_edit_mirrormenu, NULL, ICON_RIGHTARROW_THIN, "Mirror", 0, yco-=20, menuwidth, 19, "");              
 #endif
 
-       uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu);
+       uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu, NULL);
 
        uiItemS(layout);
 
@@ -2287,8 +2287,8 @@ static void view3d_edit_armaturemenu(bContext *C, uiLayout *layout, void *arg_un
        uiDefIconTextBlockBut(block, view3d_transformmenu, NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 19, "");
        uiDefIconTextBlockBut(block, view3d_edit_mirrormenu, NULL, ICON_RIGHTARROW_THIN, "Mirror", 0, yco-=20, menuwidth, 19, "");
 #endif
-       uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu);
-       uiItemMenuF(layout, "Bone Roll", 0, view3d_edit_armature_rollmenu);
+       uiItemMenuF(layout, "Snap", 0, view3d_edit_snapmenu, NULL);
+       uiItemMenuF(layout, "Bone Roll", 0, view3d_edit_armature_rollmenu, NULL);
        
        if (arm->drawtype == ARM_ENVELOPE)
                uiItemEnumO(layout, "Scale Envelope Distance", 0, "TFM_OT_transform", "mode", TFM_BONESIZE);
@@ -2325,11 +2325,11 @@ static void view3d_edit_armaturemenu(bContext *C, uiLayout *layout, void *arg_un
        
        uiItemS(layout);
        
-       uiItemMenuF(layout, "Parent", 0, view3d_edit_armature_parentmenu);
+       uiItemMenuF(layout, "Parent", 0, view3d_edit_armature_parentmenu, NULL);
        
        uiItemS(layout);
        
-       uiItemMenuF(layout, "Bone Settings ", 0, view3d_edit_armature_settingsmenu);
+       uiItemMenuF(layout, "Bone Settings ", 0, view3d_edit_armature_settingsmenu, NULL);
 }
 #endif
 
@@ -2430,7 +2430,7 @@ static void view3d_pose_armaturemenu(bContext *C, uiLayout *layout, void *arg_un
 #endif 
        if ( (arm) && ((arm->drawtype == ARM_B_BONE) || (arm->drawtype == ARM_ENVELOPE)) )
                uiItemEnumO(layout, "Scale Envelope Distance", 0, "TFM_OT_transform", "mode", TFM_BONESIZE);
-       uiItemMenuF(layout, "Clear Transform", 0, view3d_pose_armature_transformmenu);
+       uiItemMenuF(layout, "Clear Transform", 0, view3d_pose_armature_transformmenu, NULL);
        
        uiItemS(layout);
        
@@ -2453,14 +2453,14 @@ static void view3d_pose_armaturemenu(bContext *C, uiLayout *layout, void *arg_un
        
        uiItemS(layout);
 
-       uiItemMenuF(layout, "Pose Library", 0, view3d_pose_armature_poselibmenu);
-       uiItemMenuF(layout, "Motion Paths", 0, view3d_pose_armature_motionpathsmenu);
-       uiItemMenuF(layout, "Bone Groups", 0, view3d_pose_armature_groupmenu);
+       uiItemMenuF(layout, "Pose Library", 0, view3d_pose_armature_poselibmenu, NULL);
+       uiItemMenuF(layout, "Motion Paths", 0, view3d_pose_armature_motionpathsmenu, NULL);
+       uiItemMenuF(layout, "Bone Groups", 0, view3d_pose_armature_groupmenu, NULL);
        
        uiItemS(layout);
        
-       uiItemMenuF(layout, "Inverse Kinematics", 0, view3d_pose_armature_ikmenu);
-       uiItemMenuF(layout, "Constraints", 0, view3d_pose_armature_constraintsmenu);
+       uiItemMenuF(layout, "Inverse Kinematics", 0, view3d_pose_armature_ikmenu, NULL);
+       uiItemMenuF(layout, "Constraints", 0, view3d_pose_armature_constraintsmenu, NULL);
        
        uiItemS(layout);
        
@@ -2477,8 +2477,8 @@ static void view3d_pose_armaturemenu(bContext *C, uiLayout *layout, void *arg_un
        
        uiItemS(layout);
        
-       uiItemMenuF(layout, "Show/Hide Bones", 0, view3d_pose_armature_showhidemenu);
-       uiItemMenuF(layout, "Bone Settings", 0, view3d_pose_armature_settingsmenu);
+       uiItemMenuF(layout, "Show/Hide Bones", 0, view3d_pose_armature_showhidemenu, NULL);
+       uiItemMenuF(layout, "Bone Settings", 0, view3d_pose_armature_settingsmenu, NULL);
        
 #if 0
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Copy Attributes...|Ctrl C",                      0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
@@ -2776,7 +2776,7 @@ static void view3d_particlemenu(bContext *C, uiLayout *layout, void *arg_unused)
 
        uiItemS(layout);
 
-       uiItemMenuF(layout, "Show/Hide Particles", 0, view3d_particle_showhidemenu);
+       uiItemMenuF(layout, "Show/Hide Particles", 0, view3d_particle_showhidemenu, NULL);
 }
 
 static char *view3d_modeselect_pup(Scene *scene)
index c09b83dd6826893d37b2902e9a2c9ed7ab549212..4a24027f7e909b3a202552e495ec4ed23d787d06 100644 (file)
@@ -225,7 +225,7 @@ void RNA_def_main(BlenderRNA *brna)
                {"scenes", "Scene", "rna_Main_scene_begin", "Scenes", "Scene datablocks.", NULL, NULL},
                {"objects", "Object", "rna_Main_object_begin", "Objects", "Object datablocks.", NULL, NULL},
                {"materials", "Material", "rna_Main_mat_begin", "Materials", "Material datablocks.", NULL, NULL},
-               {"nodetrees", "NodeTree", "rna_Main_nodetree_begin", "Node Trees", "Nodetree datablocks.", NULL, NULL},
+               {"nodegroups", "NodeTree", "rna_Main_nodetree_begin", "Node Groups", "Node group datablocks.", NULL, NULL},
                {"meshes", "Mesh", "rna_Main_mesh_begin", "Meshes", "Mesh datablocks.", "add_mesh", "remove_mesh"}, 
                {"lamps", "Lamp", "rna_Main_lamp_begin", "Lamps", "Lamp datablocks.", NULL, NULL},
                {"libraries", "Library", "rna_Main_library_begin", "Libraries", "Library datablocks.", NULL, NULL},
index 6f0a19b7aa9c9ef4d334461c537ed72f7e954dfa..5ebaeb1da8de0f4d09e0353970e0b2821c1fab1f 100644 (file)
@@ -41,6 +41,8 @@
 
 #include "BKE_texture.h"
 
+#include "ED_node.h"
+
 static PointerRNA rna_Material_mirror_get(PointerRNA *ptr)
 {
        return rna_pointer_inherit_refine(ptr, &RNA_MaterialRaytraceMirror, ptr->id.data);
@@ -196,6 +198,15 @@ static void rna_Material_use_specular_ramp_set(PointerRNA *ptr, int value)
                ma->ramp_spec= add_colorband(0);
 }
 
+void rna_Material_use_nodes_set(PointerRNA *ptr, int value)
+{
+       Material *ma= (Material*)ptr->data;
+
+       ma->use_nodes= value;
+       if(ma->use_nodes && ma->nodetree==NULL)
+               ED_node_shader_default(ma);
+}
+
 #else
 
 static void rna_def_material_mtex(BlenderRNA *brna)
@@ -1379,6 +1390,12 @@ void RNA_def_material(BlenderRNA *brna)
        RNA_def_property_pointer_sdna(prop, NULL, "nodetree");
        RNA_def_property_ui_text(prop, "Node Tree", "Node tree for node based materials.");
 
+       prop= RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1);
+       RNA_def_property_boolean_funcs(prop, NULL, "rna_Material_use_nodes_set");
+       RNA_def_property_ui_text(prop, "Use Nodes", "Use shader nodes to render the material.");
+       RNA_def_property_update(prop, NC_MATERIAL, NULL);
+
        /* common */
        rna_def_animdata_common(srna);
        rna_def_mtex_common(srna, "rna_Material_mtex_begin", "rna_Material_active_texture_get",
index c8be3c7afac318d0102ec3dedc8f371857315010..88796919c3e9e36084b854a3367862363caf63b6 100644 (file)
@@ -62,6 +62,8 @@ EnumPropertyItem prop_mode_items[] ={
 
 #include "BLI_threads.h"
 
+#include "ED_node.h"
+
 #include "RE_pipeline.h"
 
 PointerRNA rna_Scene_objects_get(CollectionPropertyIterator *iter)
@@ -371,6 +373,15 @@ static void rna_SceneRenderLayer_pass_update(bContext *C, PointerRNA *ptr)
                ntreeCompositForceHidden(scene->nodetree, scene);
 }
 
+void rna_Scene_use_nodes_set(PointerRNA *ptr, int value)
+{
+       Scene *scene= (Scene*)ptr->data;
+
+       scene->use_nodes= value;
+       if(scene->use_nodes && scene->nodetree==NULL)
+               ED_node_composit_default(scene);
+}
+
 #else
 
 static void rna_def_tool_settings(BlenderRNA  *brna)
@@ -1663,7 +1674,12 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
        RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_FREE_IMAGE);
        RNA_def_property_ui_text(prop, "Free Image Textures", "Free all image texture from memory after render, to save memory before compositing.");
        RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
-       
+
+       prop= RNA_def_property(srna, "free_unused_nodes", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_FREE_IMAGE);
+       RNA_def_property_ui_text(prop, "Free Unused Nodes", "Free Nodes that are not used while compositing, to save memory.");
+       RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
+
        prop= RNA_def_property(srna, "save_buffers", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_EXR_TILE_FILE);
        RNA_def_property_boolean_funcs(prop, "rna_SceneRenderData_save_buffers_get", NULL);
@@ -1903,6 +1919,12 @@ void RNA_def_scene(BlenderRNA *brna)
        /* Nodes (Compositing) */
        prop= RNA_def_property(srna, "nodetree", PROP_POINTER, PROP_NONE);
        RNA_def_property_ui_text(prop, "Node Tree", "Compositing node tree.");
+
+       prop= RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1);
+       RNA_def_property_boolean_funcs(prop, NULL, "rna_Scene_use_nodes_set");
+       RNA_def_property_ui_text(prop, "Use Nodes", "Enable the compositing node tree.");
+       RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
        
        /* Sequencer */
        prop= RNA_def_property(srna, "sequence_editor", PROP_POINTER, PROP_NONE);
index e5332d32f139e827280c3ed7e8f847c8cf5f808d..be0707390c473e9538e03c89f15efc7bcf419d0d 100644 (file)
@@ -33,6 +33,7 @@
 #include "rna_internal.h"
 
 #include "DNA_action_types.h"
+#include "DNA_node_types.h"
 #include "DNA_object_types.h"
 #include "DNA_space_types.h"
 #include "DNA_view3d_types.h"
@@ -1403,10 +1404,53 @@ static void rna_def_space_userpref(BlenderRNA *brna)
 static void rna_def_space_node(BlenderRNA *brna)
 {
        StructRNA *srna;
+       PropertyRNA *prop;
+
+       static EnumPropertyItem tree_type_items[] = {
+               {NTREE_SHADER, "MATERIAL", ICON_MATERIAL, "Material", "Material nodes."},
+               {NTREE_TEXTURE, "TEXTURE", ICON_TEXTURE, "Texture", "Texture nodes."},
+               {NTREE_COMPOSIT, "COMPOSITING", ICON_RENDER_RESULT, "Compositing", "Compositing nodes."},
+               {0, NULL, 0, NULL, NULL}};
 
+       static EnumPropertyItem texture_type_items[] = {
+               {SNODE_TEX_OBJECT, "OBJECT", ICON_OBJECT_DATA, "Object", "Edit texture nodes from Object."},
+               {SNODE_TEX_WORLD, "WORLD", ICON_WORLD_DATA, "World", "Edit texture nodes from World."},
+               {SNODE_TEX_BRUSH, "BRUSH", ICON_BRUSH_DATA, "Brush", "Edit texture nodes from Brush."},
+               {0, NULL, 0, NULL, NULL}};
+       
        srna= RNA_def_struct(brna, "SpaceNodeEditor", "Space");
        RNA_def_struct_sdna(srna, "SpaceNode");
        RNA_def_struct_ui_text(srna, "Space Node Editor", "Node editor space data.");
+
+       prop= RNA_def_property(srna, "tree_type", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "treetype");
+       RNA_def_property_enum_items(prop, tree_type_items);
+       RNA_def_property_ui_text(prop, "Tree Type", "Node tree type to display and edit.");
+       RNA_def_property_update(prop, NC_NODE, NULL);
+
+       prop= RNA_def_property(srna, "texture_type", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "texfrom");
+       RNA_def_property_enum_items(prop, texture_type_items);
+       RNA_def_property_ui_text(prop, "Texture Type", "Type of data to take texture from.");
+       RNA_def_property_update(prop, NC_NODE, NULL);
+
+       prop= RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_ui_text(prop, "ID", "Datablock whose nodes are being edited.");
+
+       prop= RNA_def_property(srna, "id_from", PROP_POINTER, PROP_NONE);
+       RNA_def_property_pointer_sdna(prop, NULL, "from");
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_ui_text(prop, "ID From", "Datablock from which the edited datablock is linked.");
+
+       prop= RNA_def_property(srna, "nodetree", PROP_POINTER, PROP_NONE);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_ui_text(prop, "Node Tree", "Node tree being displayed and edited.");
+
+       prop= RNA_def_property(srna, "backdrop", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", SNODE_BACKDRAW);
+       RNA_def_property_ui_text(prop, "Backdrop", "Use active Viewer Node output as backdrop for compositing nodes.");
+       RNA_def_property_update(prop, NC_NODE, NULL);
 }
 
 static void rna_def_space_logic(BlenderRNA *brna)
index a5737536b7d721fba6d647543df967f44aacf148..b7403ab1178eb11b1dd2edb1d69e33234a93d838 100644 (file)
@@ -53,6 +53,7 @@ static EnumPropertyItem texture_filter_items[] = {
 #ifdef RNA_RUNTIME
 
 #include "BKE_texture.h"
+#include "ED_node.h"
 
 StructRNA *rna_Texture_refine(struct PointerRNA *ptr)
 {
@@ -187,9 +188,8 @@ void rna_Texture_use_nodes_set(PointerRNA *ptr, int v)
        tex->use_nodes = v;
        tex->type = 0;
        
-       if(v && tex->nodetree==NULL) {
-               node_texture_default(tex);
-       }
+       if(v && tex->nodetree==NULL)
+               ED_node_texture_default(tex);
 }
 
 static void rna_ImageTexture_mipmap_set(PointerRNA *ptr, int value)
index 899270032209267a697bf2fcc02653d59a9a07dc..00e9f6a2fa22d28105f86d04d74725ae289e9b19 100644 (file)
@@ -133,6 +133,7 @@ typedef struct wmNotifier {
 #define NC_FILE                                (14<<24)
 #define NC_ANIMATION           (15<<24)
 #define NC_CONSOLE                     (16<<24)
+#define NC_NODE                                (17<<24)
 
 /* data type, 256 entries is enough, it can overlap */
 #define NOTE_DATA                      0x00FF0000