Todo items:

- New Node editor now opens with larger view, the default
  was like zoomed in factor 2.
- Add node via menu now shows new node more visible
- Click on (material) node now doesn't re-render the entire
  tree anymore, much nicer.
- Duplicate node creates preview image immediate
This commit is contained in:
2011-01-03 14:36:44 +00:00
parent 6ae84f96e0
commit 9676902006
5 changed files with 36 additions and 29 deletions

View File

@@ -347,6 +347,10 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn)
break;
}
break;
case NC_NODE:
if(wmn->action==NA_SELECTED)
ED_area_tag_redraw(sa);
break;
/* Listener for preview render, when doing an global undo. */
case NC_WINDOW:
ED_area_tag_redraw(sa);

View File

@@ -211,6 +211,8 @@ bNode *editnode_get_active(bNodeTree *ntree)
void snode_notify(bContext *C, SpaceNode *snode)
{
WM_event_add_notifier(C, NC_NODE|NA_EDITED, NULL);
if(snode->treetype==NTREE_SHADER)
WM_event_add_notifier(C, NC_MATERIAL|ND_NODES, snode->id);
else if(snode->treetype==NTREE_COMPOSIT)
@@ -1464,7 +1466,7 @@ bNode *node_add_node(SpaceNode *snode, Scene *scene, int type, float locx, float
/* generics */
if(node) {
node->locx= locx;
node->locy= locy + 60.0f; // arbitrary.. so its visible
node->locy= locy + 60.0f; // arbitrary.. so its visible, (0,0) is top of node
node->flag |= SELECT;
gnode= node_tree_get_editgroup(snode->nodetree);
@@ -1515,6 +1517,12 @@ static int node_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
ntreeCopyTree(snode->edittree, 1); /* 1 == internally selected nodes */
/* to ensure redraws or rerenders happen */
for(node= snode->edittree->nodes.first; node; node= node->next)
if(node->flag & SELECT)
if(node->id)
ED_node_changed_update(node->id, node);
ntreeSolveOrder(snode->edittree);
node_tree_verify_groups(snode->nodetree);
snode_notify(C, snode);

View File

@@ -58,8 +58,22 @@
static void do_node_add(bContext *C, void *UNUSED(arg), int event)
{
SpaceNode *snode= CTX_wm_space_node(C);
ScrArea *sa= CTX_wm_area(C);
ARegion *ar;
bNode *node;
/* get location to add node at mouse */
for(ar=sa->regionbase.first; ar; ar=ar->next) {
if(ar->regiontype == RGN_TYPE_WINDOW) {
wmWindow *win= CTX_wm_window(C);
int x= win->eventstate->x - ar->winrct.xmin;
int y= win->eventstate->y - ar->winrct.ymin;
if(y < 60) y+= 60;
UI_view2d_region_to_view(&ar->v2d, x, y, &snode->mx, &snode->my);
}
}
/* store selection in temp test flag */
for(node= snode->edittree->nodes.first; node; node= node->next) {
if(node->flag & NODE_SELECT) node->flag |= NODE_TEST;
@@ -152,20 +166,8 @@ static void node_auto_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclas
static void node_menu_add(const bContext *C, Menu *menu)
{
uiLayout *layout= menu->layout;
SpaceNode *snode= CTX_wm_space_node(C);
ScrArea *sa= CTX_wm_area(C);
ARegion *ar;
/* get location to add node at mouse */
for(ar=sa->regionbase.first; ar; ar=ar->next) {
if(ar->regiontype == RGN_TYPE_WINDOW) {
wmWindow *win= CTX_wm_window(C);
UI_view2d_region_to_view(&ar->v2d,
win->eventstate->x - ar->winrct.xmin, win->eventstate->y - ar->winrct.ymin,
&snode->mx, &snode->my);
}
}
uiLayout *layout= menu->layout;
if(!snode->nodetree)
uiLayoutSetActive(layout, 0);

View File

@@ -108,13 +108,6 @@ static int node_select_exec(bContext *C, wmOperator *op)
/* perform the select */
node= node_mouse_select(snode, ar, mval, extend);
/* WATCH THIS, there are a few other ways to change the active material */
if(node) {
if (node->id && ELEM(GS(node->id->name), ID_MA, ID_TE)) {
WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING_DRAW, node->id);
}
}
/* send notifiers */
WM_event_add_notifier(C, NC_NODE|NA_SELECTED, NULL);

View File

@@ -118,15 +118,15 @@ static SpaceLink *node_new(const bContext *UNUSED(C))
BLI_addtail(&snode->regionbase, ar);
ar->regiontype= RGN_TYPE_WINDOW;
ar->v2d.tot.xmin= -10.0f;
ar->v2d.tot.ymin= -10.0f;
ar->v2d.tot.xmax= 512.0f;
ar->v2d.tot.ymax= 512.0f;
ar->v2d.tot.xmin= -256.0f;
ar->v2d.tot.ymin= -256.0f;
ar->v2d.tot.xmax= 768.0f;
ar->v2d.tot.ymax= 768.0f;
ar->v2d.cur.xmin= 0.0f;
ar->v2d.cur.ymin= 0.0f;
ar->v2d.cur.xmax= 512.0f;
ar->v2d.cur.ymax= 512.0f;
ar->v2d.cur.xmin= -256.0f;
ar->v2d.cur.ymin= -256.0f;
ar->v2d.cur.xmax= 768.0f;
ar->v2d.cur.ymax= 768.0f;
ar->v2d.min[0]= 1.0f;
ar->v2d.min[1]= 1.0f;