2.5: Headers

* 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.
This commit is contained in:
2009-08-19 00:55:30 +00:00
parent e21c1dde81
commit 184ac26dd0
32 changed files with 510 additions and 747 deletions

View 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="")

View 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")
@@ -33,12 +38,6 @@ class CONSOLE_HT_header(bpy.types.Header):
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"
__label__ = "Console"

View 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')

View 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")

View File

@@ -10,17 +10,18 @@ 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")

121
release/ui/space_node.py Normal file
View File

@@ -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)

View 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="")

View 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"

View 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 != "":
@@ -124,6 +125,10 @@ class TEXT_MT_text(bpy.types.Menu):
# XXX uiMenuItemO(head, 0, "text.refresh_pyconstraints");
#endif
layout.itemS()
layout.itemO("text.properties", icon="ICON_MENU_PANEL")
#ifndef DISABLE_PYTHON
# XXX layout.column()
# XXX uiDefIconTextBlockBut(block, text_template_scriptsmenu, NULL, ICON_RIGHTARROW_THIN, "Script Templates", 0, yco-=20, 120, 19, "");
@@ -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()

View 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)

View 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()

View 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);

View File

@@ -28,8 +28,17 @@
#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 */

View 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);

View 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 {

View 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);
}

View 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);

View 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);

View 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);

View 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(brush && brush->texact != -1)
mtex= brush->mtex[brush->texact];
if(mtex) {
snode->from= (ID *)scene;
snode->from= (ID *)brush;
if(mtex)
tx= mtex->tex;
}
}
if(tx) {

View 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"
@@ -62,67 +63,9 @@
#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(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++;
}
}
}
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 {
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
if(!ntree) {
uiItemS(layout);
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)
{
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;
}
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;
}
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, "");
}
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, "");
}
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);
/* 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 {
uiBlockSetDirection(block, UI_TOP);
uiBlockFlipOrder(block);
bNodeType *type = ntree->alltypes.first;
while(type) {
if(type->nclass == nodeclass)
tot++;
type= type->next;
}
}
uiTextBoundsBlock(block, 50);
if(tot==0) {
uiItemS(layout);
return;
}
return block;
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) {
uiItemV(layout, type->name, 0, NODE_DYNAMIC_MENU+script);
script++;
}
else
uiItemV(layout, type->name, 0, type->type);
a++;
}
}
}
}
static void node_menu_add(const bContext *C, Menu *menu)
{
uiLayout *layout= menu->layout;
SpaceNode *snode= CTX_wm_space_node(C);
if(!snode->nodetree)
uiLayoutSetActive(layout, 0);
if(snode->treetype==NTREE_SHADER) {
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) {
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 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));
}
}
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

View 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);

View 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 */

View 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];
SpaceNode *snode= CTX_wm_space_node(C);
Scene *scene= CTX_data_scene(C);
/* clear */
if(ED_screen_area_active(C))
UI_GetThemeColor3fv(TH_HEADER, col);
else
UI_GetThemeColor3fv(TH_HEADERDESEL, col);
/* find and set the context */
snode_set_context(snode, scene);
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);
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;
}
@@ -358,6 +344,8 @@ void ED_spacetype_node(void)
BLI_addhead(&st->regiontypes, art);
node_menus_register(art);
#if 0
/* regions: channels */
art= MEM_callocN(sizeof(ARegionType), "spacetype node region");

View File

@@ -186,12 +186,18 @@ ARegion *text_has_properties_region(ScrArea *sa)
return arnew;
}
void text_toggle_properties_region(bContext *C, ScrArea *sa, ARegion *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);
}
static int properties_poll(bContext *C)
{
SpaceText *st= CTX_wm_space_text(C);
Text *text= CTX_data_edit_text(C);
return (st && text);
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;
}

View 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)

View 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},

View 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",

View 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)
@@ -1664,6 +1675,11 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
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);
@@ -1904,6 +1920,12 @@ void RNA_def_scene(BlenderRNA *brna)
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);
RNA_def_property_pointer_sdna(prop, NULL, "ed");

View 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)

View 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)

View 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