diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-01-08 17:09:09 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-01-08 17:09:09 +0400 |
commit | 98bdf0274b1052efe25b6216f488d2a40fa43d1c (patch) | |
tree | 71e65d918ccbf3c5addd8236c74362dfbdea466c /source/blender/editors | |
parent | da84f3d4c94cb539f2ed80c8ec57602c05b95560 (diff) | |
parent | 3dead22c7322cf72ee63a003ba50940abc12e7c9 (diff) |
svn merge ^/trunk/blender -r43183:43220
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/animation/anim_filter.c | 8 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d_ops.c | 9 | ||||
-rw-r--r-- | source/blender/editors/object/object_edit.c | 331 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 16 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_draw.c | 20 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_edit.c | 67 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_intern.h | 4 |
8 files changed, 71 insertions, 388 deletions
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 45b715c406a..b84ec5427c5 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -1852,6 +1852,10 @@ static size_t animdata_filter_ds_world (bAnimContext *ac, ListBase *anim_data, b /* textures for world */ if (!(ads->filterflag & ADS_FILTER_NOTEX)) items += animdata_filter_ds_textures(ac, &tmp_data, ads, (ID *)wo, filter_mode); + + /* nodes */ + if ((wo->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE)) + tmp_items += animdata_filter_ds_nodetree(ac, &tmp_data, ads, (ID *)wo, wo->nodetree, filter_mode); } END_ANIMFILTER_SUBCHANNELS; @@ -1947,12 +1951,12 @@ static size_t animdata_filter_dopesheet_scene (bAnimContext *ac, ListBase *anim_ } /* world */ - if ((wo && wo->adt) && !(ads->filterflag & ADS_FILTER_NOWOR)) { + if ((wo) && !(ads->filterflag & ADS_FILTER_NOWOR)) { tmp_items += animdata_filter_ds_world(ac, &tmp_data, ads, sce, wo, filter_mode); } /* nodetree */ - if ((ntree && ntree->adt) && !(ads->filterflag & ADS_FILTER_NONTREE)) { + if ((ntree) && !(ads->filterflag & ADS_FILTER_NONTREE)) { tmp_items += animdata_filter_ds_nodetree(ac, &tmp_data, ads, (ID *)sce, ntree, filter_mode); } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 6b842a6d409..2cf73eeea6d 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -55,6 +55,7 @@ #include "BKE_texture.h" #include "BKE_report.h" #include "BKE_displist.h" +#include "BKE_scene.h" #include "ED_screen.h" #include "ED_object.h" @@ -2125,6 +2126,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe else if(RNA_struct_is_a(itemptr->type, &RNA_MaterialSlot)) { /* provision to draw active node name */ Material *ma, *manode; + Scene *scene= CTX_data_scene(C); Object *ob= (Object*)ptr->id.data; int index= (Material**)itemptr->data - ob->mat; @@ -2132,7 +2134,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe uiItemL(sub, name, icon); ma= give_current_material(ob, index+1); - if(ma) { + if (ma && !scene_use_new_shading_nodes(scene)){ manode= give_node_material(ma); if(manode) { char str[MAX_ID_NAME + 12]; diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 5706da93fe9..a993e651b5f 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -248,20 +248,19 @@ static int view_pan_modal(bContext *C, wmOperator *op, wmEvent *event) view_pan_apply(op); } break; - + /* XXX - Mode switching isn't implemented. See comments in 36818. + * switch to zoom * case LEFTMOUSE: - /* switch to zoom */ if (event->val==KM_PRESS) { - /* calculate overall delta mouse-movement for redo */ + * calculate overall delta mouse-movement for redo * RNA_int_set(op->ptr, "deltax", (vpd->startx - vpd->lastx)); RNA_int_set(op->ptr, "deltay", (vpd->starty - vpd->lasty)); view_pan_exit(op); WM_cursor_restore(CTX_wm_window(C)); - WM_operator_name_call(C, "VIEW2D_OT_zoom", WM_OP_INVOKE_DEFAULT, NULL); return OPERATOR_FINISHED; - } + }*/ default: if (event->type == vpd->invoke_event || event->type==ESCKEY) { diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index fcb6e3c3610..494effc8f45 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -109,7 +109,6 @@ static void waitcursor(int UNUSED(val)) {} static int pupmenu(const char *UNUSED(msg)) {return 0;} /* port over here */ -static bContext *evil_C; static void error_libdata(void) {} Object *ED_object_context(bContext *C) @@ -723,240 +722,6 @@ static void spot_interactive(Object *ob, int mode) } #endif -static void UNUSED_FUNCTION(special_editmenu)(Scene *scene, View3D *v3d) -{ -// XXX static short numcuts= 2; - Object *ob= OBACT; - Object *obedit= NULL; // XXX - int nr,ret=0; - - if(ob==NULL) return; - - if(obedit==NULL) { - - if(ob->mode & OB_MODE_POSE) { -// XXX pose_special_editmenu(); - } - else if(paint_facesel_test(ob)) { - Mesh *me= get_mesh(ob); - MTFace *tface; - MFace *mface; - int a; - - if(me==NULL || me->mtface==NULL) return; - - nr= pupmenu("Specials%t|Set Tex%x1| Shared%x2| Light%x3| Invisible%x4| Collision%x5| TwoSide%x6|Clr Tex%x7| Shared%x8| Light%x9| Invisible%x10| Collision%x11| TwoSide%x12"); - - tface= me->mtface; - mface= me->mface; - for(a=me->totface; a>0; a--, tface++, mface++) { - if(mface->flag & ME_FACE_SEL) { - switch(nr) { - case 1: - tface->mode |= TF_TEX; break; - case 2: - tface->mode |= TF_SHAREDCOL; break; - case 3: - tface->mode |= TF_LIGHT; break; - case 4: - tface->mode |= TF_INVISIBLE; break; - case 5: - tface->mode |= TF_DYNAMIC; break; - case 6: - tface->mode |= TF_TWOSIDE; break; - case 7: - tface->mode &= ~TF_TEX; - tface->tpage= NULL; - break; - case 8: - tface->mode &= ~TF_SHAREDCOL; break; - case 9: - tface->mode &= ~TF_LIGHT; break; - case 10: - tface->mode &= ~TF_INVISIBLE; break; - case 11: - tface->mode &= ~TF_DYNAMIC; break; - case 12: - tface->mode &= ~TF_TWOSIDE; break; - } - } - } - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - } - else if(ob->mode & OB_MODE_VERTEX_PAINT) { - Mesh *me= get_mesh(ob); - - if(me==NULL || (me->mcol==NULL && me->mtface==NULL) ) return; - - nr= pupmenu("Specials%t|Shared VertexCol%x1"); - if(nr==1) { - -// XXX do_shared_vertexcol(me); - - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - } - } - else if(ob->mode & OB_MODE_WEIGHT_PAINT) { - Object *par= modifiers_isDeformedByArmature(ob); - - if(par && (par->mode & OB_MODE_POSE)) { -// XXX nr= pupmenu("Specials%t|Apply Bone Envelopes to Vertex Groups %x1|Apply Bone Heat Weights to Vertex Groups %x2"); - -// XXX if(nr==1 || nr==2) -// XXX pose_adds_vgroups(ob, (nr == 2)); - } - } - else if(ob->mode & OB_MODE_PARTICLE_EDIT) { -#if 0 - // XXX - ParticleSystem *psys = PE_get_current(ob); - ParticleEditSettings *pset = PE_settings(); - - if(!psys) - return; - - if(pset->selectmode & SCE_SELECT_POINT) - nr= pupmenu("Specials%t|Rekey%x1|Subdivide%x2|Select First%x3|Select Last%x4|Remove Doubles%x5"); - else - nr= pupmenu("Specials%t|Rekey%x1|Remove Doubles%x5"); - - switch(nr) { - case 1: -// XXX if(button(&pset->totrekey, 2, 100, "Number of Keys:")==0) return; - waitcursor(1); - PE_rekey(); - break; - case 2: - PE_subdivide(); - break; - case 3: - PE_select_root(); - break; - case 4: - PE_select_tip(); - break; - case 5: - PE_remove_doubles(); - break; - } - - DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); - - if(nr>0) waitcursor(0); -#endif - } - else { - Base *base, *base_select= NULL; - - /* Get the active object mesh. */ - Mesh *me= get_mesh(ob); - - /* Booleans, if the active object is a mesh... */ - if (me && ob->id.lib==NULL) { - - /* Bring up a little menu with the boolean operation choices on. */ - nr= pupmenu("Boolean Tools%t|Intersect%x1|Union%x2|Difference%x3|Add Intersect Modifier%x4|Add Union Modifier%x5|Add Difference Modifier%x6"); - - if (nr > 0) { - /* user has made a choice of a menu element. - All of the boolean functions require 2 mesh objects - we search through the object list to find the other - selected item and make sure it is distinct and a mesh. */ - - for(base= FIRSTBASE; base; base= base->next) { - if(TESTBASELIB(v3d, base)) { - if(base->object != ob) base_select= base; - } - } - - if (base_select) { - if (get_mesh(base_select->object)) { - if(nr <= 3){ - waitcursor(1); -// XXX ret = NewBooleanMesh(BASACT,base_select,nr); - if (ret==0) { - error("An internal error occurred"); - } else if(ret==-1) { - error("Selected meshes must have faces to perform boolean operations"); - } else if (ret==-2) { - error("Both meshes must be a closed mesh"); - } - waitcursor(0); - } else { - BooleanModifierData *bmd = NULL; - bmd = (BooleanModifierData *)modifier_new(eModifierType_Boolean); - BLI_addtail(&ob->modifiers, bmd); - modifier_unique_name(&ob->modifiers, (ModifierData*)bmd); - bmd->object = base_select->object; - bmd->modifier.mode |= eModifierMode_Realtime; - switch(nr){ - case 4: bmd->operation = eBooleanModifierOp_Intersect; break; - case 5: bmd->operation = eBooleanModifierOp_Union; break; - case 6: bmd->operation = eBooleanModifierOp_Difference; break; - } -// XXX do_common_editbuts(B_CHANGEDEP); - } - } else { - error("Please select 2 meshes"); - } - } else { - error("Please select 2 meshes"); - } - } - - } - else if (ob->type == OB_FONT) { - /* removed until this gets a decent implementation (ton) */ -/* nr= pupmenu("Split %t|Characters%x1"); - if (nr > 0) { - switch(nr) { - case 1: split_font(); - } - } -*/ - } - } - } - else if(obedit->type==OB_MESH) { - } - else if(ELEM(obedit->type, OB_CURVE, OB_SURF)) { - } - else if(obedit->type==OB_ARMATURE) { - nr= pupmenu("Specials%t|Subdivide %x1|Subdivide Multi%x2|Switch Direction%x7|Flip Left-Right Names%x3|%l|AutoName Left-Right%x4|AutoName Front-Back%x5|AutoName Top-Bottom%x6"); -// if(nr==1) -// XXX subdivide_armature(1); - if(nr==2) { -// XXX if(button(&numcuts, 1, 128, "Number of Cuts:")==0) return; - waitcursor(1); -// XXX subdivide_armature(numcuts); - } -// else if(nr==3) -// XXX armature_flip_names(); - else if(ELEM3(nr, 4, 5, 6)) { -// XXX armature_autoside_names(nr-4); - } -// else if(nr == 7) -// XXX switch_direction_armature(); - } - else if(obedit->type==OB_LATTICE) { - Lattice *lt= obedit->data; - static float weight= 1.0f; - { // XXX -// XXX if(fbutton(&weight, 0.0f, 1.0f, 10, 10, "Set Weight")) { - Lattice *editlt= lt->editlatt->latt; - int a= editlt->pntsu*editlt->pntsv*editlt->pntsw; - BPoint *bp= editlt->def; - - while(a--) { - if(bp->f1 & SELECT) - bp->weight= weight; - bp++; - } - } - } - -} - static void copymenu_properties(Scene *scene, View3D *v3d, Object *ob) { //XXX no longer used - to be removed - replaced by game_properties_copy_exec @@ -1679,102 +1444,6 @@ static void UNUSED_FUNCTION(image_aspect)(Scene *scene, View3D *v3d) } -static int vergbaseco(const void *a1, const void *a2) -{ - Base **x1, **x2; - - x1= (Base **) a1; - x2= (Base **) a2; - - if( (*x1)->sy > (*x2)->sy ) return 1; - else if( (*x1)->sy < (*x2)->sy) return -1; - else if( (*x1)->sx > (*x2)->sx ) return 1; - else if( (*x1)->sx < (*x2)->sx ) return -1; - - return 0; -} - - -static void UNUSED_FUNCTION(auto_timeoffs)(Scene *scene, View3D *v3d) -{ - Base *base, **basesort, **bs; - float start, delta; - int tot=0, a; - short offset=25; - - if(BASACT==NULL || v3d==NULL) return; -// XXX if(button(&offset, 0, 1000,"Total time")==0) return; - - /* make array of all bases, xco yco (screen) */ - for(base= FIRSTBASE; base; base= base->next) { - if(TESTBASELIB(v3d, base)) { - tot++; - } - } - - delta= (float)offset/(float)tot; - start= OBACT->sf; - - bs= basesort= MEM_mallocN(sizeof(void *)*tot,"autotimeoffs"); - for(base= FIRSTBASE; base; base= base->next) { - if(TESTBASELIB(v3d, base)) { - *bs= base; - bs++; - } - } - qsort(basesort, tot, sizeof(void *), vergbaseco); - - bs= basesort; - for(a=0; a<tot; a++) { - - (*bs)->object->sf= start; - start+= delta; - - bs++; - } - MEM_freeN(basesort); - -} - -static void UNUSED_FUNCTION(ofs_timeoffs)(Scene *scene, View3D *v3d) -{ - float offset=0.0f; - - if(BASACT==NULL || v3d==NULL) return; - -// XXX if(fbutton(&offset, -10000.0f, 10000.0f, 10, 10, "Offset")==0) return; - - /* make array of all bases, xco yco (screen) */ - CTX_DATA_BEGIN(evil_C, Object*, ob, selected_editable_objects) { - ob->sf += offset; - if (ob->sf < -MAXFRAMEF) ob->sf = -MAXFRAMEF; - else if (ob->sf > MAXFRAMEF) ob->sf = MAXFRAMEF; - } - CTX_DATA_END; - -} - - -static void UNUSED_FUNCTION(rand_timeoffs)(Scene *scene, View3D *v3d) -{ - Base *base; - float rand_ofs=0.0f; - - if(BASACT==NULL || v3d==NULL) return; - -// XXX if(fbutton(&rand_ofs, 0.0f, 10000.0f, 10, 10, "Randomize")==0) return; - - rand_ofs *= 2; - - for(base= FIRSTBASE; base; base= base->next) { - if(TESTBASELIB(v3d, base)) { - base->object->sf += ((float)BLI_drand()-0.5f) * rand_ofs; - if (base->object->sf < -MAXFRAMEF) base->object->sf = -MAXFRAMEF; - else if (base->object->sf > MAXFRAMEF) base->object->sf = MAXFRAMEF; - } - } - -} static EnumPropertyItem *object_mode_set_itemsf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index de67a702598..b2192b9dabb 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -3307,7 +3307,6 @@ static void SCREEN_OT_delete(wmOperatorType *ot) static int scene_new_exec(bContext *C, wmOperator *op) { Scene *newscene, *scene= CTX_data_scene(C); - bScreen *screen= CTX_wm_screen(C); Main *bmain= CTX_data_main(C); int type= RNA_enum_get(op->ptr, "type"); @@ -3326,11 +3325,9 @@ static int scene_new_exec(bContext *C, wmOperator *op) } } - /* this notifier calls ED_screen_set_scene, doing a lot of UI stuff, not for inside event loops */ - WM_event_add_notifier(C, NC_SCENE|ND_SCENEBROWSE, newscene); + ED_screen_set_scene(C, newscene); - if(screen) - screen->scene= newscene; + WM_event_add_notifier(C, NC_SCENE|ND_SCENEBROWSE, newscene); return OPERATOR_FINISHED; } @@ -3366,9 +3363,14 @@ static void SCENE_OT_new(wmOperatorType *ot) static int scene_delete_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene= CTX_data_scene(C); - + + ED_screen_delete_scene(C, scene); + + if(G.f & G_DEBUG) + printf("scene delete %p\n", scene); + WM_event_add_notifier(C, NC_SCENE|NA_REMOVED, scene); - + return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 7b692f55965..da7f22b2030 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -233,7 +233,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) /* output sockets */ for(nsock= node->outputs.first; nsock; nsock= nsock->next) { - if(!(nsock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) { + if(!nodeSocketIsHidden(nsock)) { nsock->locx= locx + node->width; nsock->locy= dy - NODE_DYS; dy-= NODE_DY; @@ -312,7 +312,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) /* input sockets */ for(nsock= node->inputs.first; nsock; nsock= nsock->next) { - if(!(nsock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) { + if(!nodeSocketIsHidden(nsock)) { nsock->locx= locx; nsock->locy= dy - NODE_DYS; dy-= NODE_DY; @@ -351,10 +351,10 @@ static void node_update_hidden(bNode *node) /* calculate minimal radius */ for(nsock= node->inputs.first; nsock; nsock= nsock->next) - if(!(nsock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL)) && (nsock->flag & SOCK_IN_USE)) + if(!nodeSocketIsHidden(nsock)) totin++; for(nsock= node->outputs.first; nsock; nsock= nsock->next) - if(!(nsock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL)) && (nsock->flag & SOCK_IN_USE)) + if(!nodeSocketIsHidden(nsock)) totout++; tot= MAX2(totin, totout); @@ -371,7 +371,7 @@ static void node_update_hidden(bNode *node) rad=drad= (float)M_PI/(1.0f + (float)totout); for(nsock= node->outputs.first; nsock; nsock= nsock->next) { - if(!(nsock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL)) && (nsock->flag & SOCK_IN_USE)) { + if(!nodeSocketIsHidden(nsock)) { nsock->locx= node->totr.xmax - hiddenrad + (float)sin(rad)*hiddenrad; nsock->locy= node->totr.ymin + hiddenrad + (float)cos(rad)*hiddenrad; rad+= drad; @@ -382,7 +382,7 @@ static void node_update_hidden(bNode *node) rad=drad= - (float)M_PI/(1.0f + (float)totin); for(nsock= node->inputs.first; nsock; nsock= nsock->next) { - if(!(nsock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL)) && (nsock->flag & SOCK_IN_USE)) { + if(!nodeSocketIsHidden(nsock)) { nsock->locx= node->totr.xmin + hiddenrad + (float)sin(rad)*hiddenrad; nsock->locy= node->totr.ymin + hiddenrad + (float)cos(rad)*hiddenrad; rad+= drad; @@ -713,7 +713,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN for(sock= node->inputs.first; sock; sock= sock->next) { bNodeSocketType *stype= ntreeGetSocketType(sock->type); - if(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL)) + if(nodeSocketIsHidden(sock)) continue; node_socket_circle_draw(ntree, sock, NODE_SOCKSIZE); @@ -736,7 +736,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN RNA_pointer_create((ID*)ntree, &RNA_NodeSocket, sock, &sockptr); - if(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL)) + if(nodeSocketIsHidden(sock)) continue; node_socket_circle_draw(ntree, sock, NODE_SOCKSIZE); @@ -854,12 +854,12 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b /* sockets */ for(sock= node->inputs.first; sock; sock= sock->next) { - if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL)) && (sock->flag & SOCK_IN_USE)) + if(!nodeSocketIsHidden(sock)) node_socket_circle_draw(snode->nodetree, sock, socket_size); } for(sock= node->outputs.first; sock; sock= sock->next) { - if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL)) && (sock->flag & SOCK_IN_USE)) + if(!nodeSocketIsHidden(sock)) node_socket_circle_draw(snode->nodetree, sock, socket_size); } diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 87a56274035..20fb385efdd 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1600,40 +1600,38 @@ void NODE_OT_resize(wmOperatorType *ot) /* ********************** hidden sockets ******************** */ -int node_has_hidden_sockets(bNode *node) +int node_has_hidden_sockets(bNode *node, short flag) { bNodeSocket *sock; for(sock= node->inputs.first; sock; sock= sock->next) - if(sock->flag & SOCK_HIDDEN) + if(sock->flag & flag) return 1; for(sock= node->outputs.first; sock; sock= sock->next) - if(sock->flag & SOCK_HIDDEN) + if(sock->flag & flag) return 1; return 0; } -/* note: call node_tree_verify_groups(snode->nodetree) after this - */ -void node_set_hidden_sockets(SpaceNode *snode, bNode *node, int set) +void node_set_hidden_sockets(SpaceNode *snode, bNode *node, short flag, int set) { bNodeSocket *sock; if(set==0) { for(sock= node->inputs.first; sock; sock= sock->next) - sock->flag &= ~SOCK_HIDDEN; + sock->flag &= ~flag; for(sock= node->outputs.first; sock; sock= sock->next) - sock->flag &= ~SOCK_HIDDEN; + sock->flag &= ~flag; } else { /* hide unused sockets */ for(sock= node->inputs.first; sock; sock= sock->next) { if(sock->link==NULL) - sock->flag |= SOCK_HIDDEN; + sock->flag |= flag; } for(sock= node->outputs.first; sock; sock= sock->next) { if(nodeCountSocketLinks(snode->edittree, sock)==0) - sock->flag |= SOCK_HIDDEN; + sock->flag |= flag; } } } @@ -1680,14 +1678,14 @@ static void node_link_viewer(SpaceNode *snode, bNode *tonode) /* find a socket after the previously connected socket */ for(sock=sock->next; sock; sock= sock->next) - if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) + if(!nodeSocketIsHidden(sock)) break; } /* find a socket starting from the first socket */ if(!sock) { for(sock= tonode->outputs.first; sock; sock= sock->next) - if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) + if(!nodeSocketIsHidden(sock)) break; } @@ -1805,7 +1803,7 @@ static int find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket ** if(in_out & SOCK_IN) { for(sock= node->inputs.first; sock; sock= sock->next) { - if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) { + if(!nodeSocketIsHidden(sock)) { if(BLI_in_rctf(&rect, sock->locx, sock->locy)) { if(node == visible_node(snode, &rect)) { *nodep= node; @@ -1818,7 +1816,7 @@ static int find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket ** } if(in_out & SOCK_OUT) { for(sock= node->outputs.first; sock; sock= sock->next) { - if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) { + if(!nodeSocketIsHidden(sock)) { if(BLI_in_rctf(&rect, sock->locx, sock->locy)) { if(node == visible_node(snode, &rect)) { *nodep= node; @@ -1836,7 +1834,7 @@ static int find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket ** */ if(in_out & SOCK_IN) { for(sock= snode->edittree->outputs.first; sock; sock= sock->next) { - if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) { + if(!nodeSocketIsHidden(sock)) { if(BLI_in_rctf(&rect, sock->locx, sock->locy)) { *nodep= NULL; /* NULL node pointer indicates group socket */ *sockp= sock; @@ -1847,7 +1845,7 @@ static int find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket ** } if(in_out & SOCK_OUT) { for(sock= snode->edittree->inputs.first; sock; sock= sock->next) { - if(!(sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL))) { + if(!nodeSocketIsHidden(sock)) { if(BLI_in_rctf(&rect, sock->locx, sock->locy)) { *nodep= NULL; /* NULL node pointer indicates group socket */ *sockp= sock; @@ -1930,13 +1928,12 @@ static int sort_nodes_locx(void *a, void *b) static int socket_is_available(bNodeTree *ntree, bNodeSocket *sock, int allow_used) { - if (sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL)) + if (nodeSocketIsHidden(sock)) + return 0; + + if (!allow_used && (sock->flag & SOCK_IN_USE)) return 0; - if (!allow_used) { - if (nodeCountSocketLinks(ntree, sock) > 0) - return 0; - } return 1; } @@ -2246,7 +2243,7 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeSocket *tsock, bNodeL } if(sock) { tlink->tosock= sock; - sock->flag &= ~SOCK_HIDDEN; + sock->flag &= ~(SOCK_HIDDEN|SOCK_AUTO_HIDDEN); } else { nodeRemLink(snode->edittree, tlink); @@ -2644,26 +2641,26 @@ static bNodeSocket *socket_best_match(ListBase *sockets, int type) /* first, match type */ for(sock= sockets->first; sock; sock= sock->next) - if(!(sock->flag & SOCK_HIDDEN)) + if(!nodeSocketIsHidden(sock)) if(type == sock->type) return sock; /* then just use first unhidden socket */ for(sock= sockets->first; sock; sock= sock->next) - if(!(sock->flag & SOCK_HIDDEN)) + if(!nodeSocketIsHidden(sock)) return sock; /* OK, let's unhide proper one */ for(sock= sockets->first; sock; sock= sock->next) { if(type == sock->type) { - sock->flag &= ~SOCK_HIDDEN; + sock->flag &= ~(SOCK_HIDDEN|SOCK_AUTO_HIDDEN); return sock; } } /* just the first */ sock= sockets->first; - sock->flag &= ~SOCK_HIDDEN; + sock->flag &= ~(SOCK_HIDDEN|SOCK_AUTO_HIDDEN); return sockets->first; } @@ -3003,10 +3000,20 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag) if(toggle_flag== NODE_OPTIONS && (node->typeinfo->flag & NODE_OPTIONS)==0) continue; - if( (tot_eq && tot_neq) || tot_eq==0) + if( (tot_eq && tot_neq) || tot_eq==0) { node->flag |= toggle_flag; - else + + /* hide/unhide node also toggles unlinked socket display */ + if (toggle_flag== NODE_HIDDEN) + node_set_hidden_sockets(snode, node, SOCK_AUTO_HIDDEN, 1); + } + else { node->flag &= ~toggle_flag; + + /* hide/unhide node also toggles unlinked socket display */ + if (toggle_flag== NODE_HIDDEN) + node_set_hidden_sockets(snode, node, SOCK_AUTO_HIDDEN, 0); + } } } } @@ -3119,7 +3126,7 @@ static int node_socket_toggle_exec(bContext *C, wmOperator *UNUSED(op)) hidden = 0; for(node= snode->edittree->nodes.first; node; node= node->next) { if(node->flag & SELECT) { - if(node_has_hidden_sockets(node)) { + if(node_has_hidden_sockets(node, SOCK_HIDDEN)) { hidden= 1; break; } @@ -3128,7 +3135,7 @@ static int node_socket_toggle_exec(bContext *C, wmOperator *UNUSED(op)) for(node= snode->edittree->nodes.first; node; node= node->next) { if(node->flag & SELECT) { - node_set_hidden_sockets(snode, node, !hidden); + node_set_hidden_sockets(snode, node, SOCK_HIDDEN, !hidden); } } diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index 9068493360e..186ad3768be 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -118,8 +118,8 @@ void snode_composite_job(const struct bContext *C, ScrArea *sa); bNode *node_tree_get_editgroup(bNodeTree *ntree); void node_tree_verify_groups(bNodeTree *nodetree); void snode_autoconnect(SpaceNode *snode, int allow_multiple, int replace); -int node_has_hidden_sockets(bNode *node); -void node_set_hidden_sockets(SpaceNode *snode, bNode *node, int set); +int node_has_hidden_sockets(bNode *node, short flag); +void node_set_hidden_sockets(SpaceNode *snode, bNode *node, short flag, int set); int node_render_changed_exec(bContext *, wmOperator *); void NODE_OT_duplicate(struct wmOperatorType *ot); |