Index: source/blender/editors/space_outliner/outliner.c =================================================================== --- source/blender/editors/space_outliner/outliner.c (revision 28400) +++ source/blender/editors/space_outliner/outliner.c (working copy) @@ -131,8 +131,9 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, int startx, int *starty); static void outliner_do_object_operation(bContext *C, Scene *scene, SpaceOops *soops, ListBase *lb, void (*operation_cb)(bContext *C, Scene *scene, TreeElement *, TreeStoreElem *, TreeStoreElem *)); +static void outliner_do_group_operation(bContext *C, Scene *scene, SpaceOops *soops, ListBase *lb, + void (*operation_cb)(bContext *C, Scene *scene, TreeElement *, TreeStoreElem *, TreeStoreElem *)); - /* ******************** PERSISTANT DATA ***************** */ static void outliner_storage_cleanup(SpaceOops *soops) @@ -1628,8 +1629,6 @@ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -/* --- */ - void object_toggle_renderability_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem) { Base *base= (Base *)te->directdata; @@ -1668,6 +1667,36 @@ } /* --- */ +static void group_toggle_visibility_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem) { + Group *group= (Group *)tselem->id; + GroupObject *gob; + + group->restrictflag ^= GR_RESTRICT_VIEW; + for(gob=group->gobject.first; gob; gob=gob->next) { + gob->ob->restrictflag = group->restrictflag; + } +} + +static void group_toggle_selectability_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem) { + Group *group= (Group *)tselem->id; + GroupObject *gob; + + group->restrictflag ^= GR_RESTRICT_SELECT; + for(gob=group->gobject.first; gob; gob=gob->next) { + gob->ob->restrictflag = group->restrictflag; + } +} + +static void group_toggle_renderability_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem) { + Group *group= (Group *)tselem->id; + GroupObject *gob; + + group->restrictflag ^= GR_RESTRICT_RENDER; + for(gob=group->gobject.first; gob; gob=gob->next) { + gob->ob->restrictflag = group->restrictflag; + } +} +/* --- */ static int outliner_toggle_expanded_exec(bContext *C, wmOperator *op) { @@ -3293,6 +3322,31 @@ } } +static void outliner_do_group_operation(bContext *C, Scene *scene, SpaceOops *soops, ListBase *lb, + void (*operation_cb)(bContext *C, Scene *scene, TreeElement *, TreeStoreElem *, TreeStoreElem *)) + { + TreeElement *te; + TreeStoreElem *tselem; + + for(te=lb->first; te; te= te->next) { + tselem= TREESTORE(te); + if(tselem->flag & TSE_SELECTED) { + if(tselem->type==0 && te->idcode==ID_GR) { + /* when objects selected in other scenes... dunno if that should be allowed */ + Scene *sce= (Scene *)outliner_search_back(soops, te, ID_SCE); + if(sce && scene != sce) { + ED_screen_set_scene(C, sce); + } + + operation_cb(C, scene, te, NULL, tselem); + } + } + if((tselem->flag & TSE_CLOSED)==0) { + outliner_do_group_operation(C, scene, soops, &te->subtree, operation_cb); + } + } +} + void outliner_del(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops) { @@ -3396,6 +3450,9 @@ {1, "UNLINK", 0, "Unlink", ""}, {2, "LOCAL", 0, "Make Local", ""}, {3, "LINK", 0, "Link Group Objects to Scene", ""}, + {4, "TOGVIS", 0, "Toggle Visible", ""}, + {5, "TOGSEL", 0, "Toggle Selectable", ""}, + {6, "TOGREN", 0, "Toggle Renderable", ""}, {0, NULL, 0, NULL, NULL} }; @@ -3423,6 +3480,18 @@ outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_linkobs2scene_cb); ED_undo_push(C, "Link Group Objects to Scene"); } + else if(event==4) { + outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_visibility_cb); + ED_undo_push(C, "Toggle group visibility"); + } + else if(event==5) { + outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_selectability_cb); + ED_undo_push(C, "Toggle group selectability"); + } + else if(event==6) { + outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_renderability_cb); + ED_undo_push(C, "Toggle group renderrability"); + } WM_event_add_notifier(C, NC_GROUP, NULL); @@ -4854,6 +4923,18 @@ WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); } +static void restrictbutton_gr(bContext *C, void *poin, void *poin2) +{ + Scene *scene = (Scene *)poin; + GroupObject *gob; + Group *gr = (Group *)poin2; + + for(gob= gr->gobject.first; gob; gob= gob->next) { + gob->ob->flag &= ~SELECT; + gob->ob->restrictflag = gr->restrictflag; + } + WM_event_add_notifier(C, NC_GROUP, NULL); +} static void namebutton_cb(bContext *C, void *tsep, char *oldname) { SpaceOops *soops= CTX_wm_space_outliner(C); @@ -4971,6 +5052,7 @@ TreeElement *te; TreeStoreElem *tselem; Object *ob = NULL; + Group *gr = NULL; for(te= lb->first; te; te= te->next) { tselem= TREESTORE(te); @@ -4994,6 +5076,24 @@ uiBlockSetEmboss(block, UI_EMBOSS); } + if(tselem->type==0 && te->idcode==ID_GR){ + gr = (Group *)tselem->id; + + uiBlockSetEmboss(block, UI_EMBOSSN); + bt= uiDefIconButBitS(block, ICONTOG, GR_RESTRICT_VIEW, 0, ICON_RESTRICT_VIEW_OFF, + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, &(gr->restrictflag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); + uiButSetFunc(bt, restrictbutton_gr, scene, gr); + + bt= uiDefIconButBitS(block, ICONTOG, GR_RESTRICT_SELECT, 0, ICON_RESTRICT_SELECT_OFF, + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (short)te->ys, 17, OL_H-1, &(gr->restrictflag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); + uiButSetFunc(bt, restrictbutton_gr, scene, gr); + + bt= uiDefIconButBitS(block, ICONTOG, GR_RESTRICT_RENDER, 0, ICON_RESTRICT_RENDER_OFF, + (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (short)te->ys, 17, OL_H-1, &(gr->restrictflag), 0, 0, 0, 0, "Restrict/Allow renderability"); + uiButSetFunc(bt, restrictbutton_gr, scene, gr); + + uiBlockSetEmboss(block, UI_EMBOSS); + } /* scene render layers and passes have toggle-able flags too! */ else if(tselem->type==TSE_R_LAYER) { uiBlockSetEmboss(block, UI_EMBOSSN); Index: source/blender/makesdna/DNA_group_types.h =================================================================== --- source/blender/makesdna/DNA_group_types.h (revision 28400) +++ source/blender/makesdna/DNA_group_types.h (working copy) @@ -55,8 +55,12 @@ * on the last used scene */ unsigned int layer; float dupli_ofs[3]; + int restrictflag, pad; } Group; +#define GR_RESTRICT_VIEW 1 +#define GR_RESTRICT_SELECT 2 +#define GR_RESTRICT_RENDER 4 #endif Index: source/blender/makesrna/intern/rna_group.c =================================================================== --- source/blender/makesrna/intern/rna_group.c (revision 28400) +++ source/blender/makesrna/intern/rna_group.c (working copy) @@ -30,6 +30,8 @@ #include "DNA_group_types.h" +#include "WM_types.h" + #ifdef RNA_RUNTIME #include "DNA_scene_types.h" @@ -38,8 +40,8 @@ #include "BKE_group.h" #include "WM_api.h" -#include "WM_types.h" + static PointerRNA rna_Group_objects_get(CollectionPropertyIterator *iter) { ListBaseIterator *internal= iter->internal; @@ -120,9 +122,24 @@ RNA_def_property_boolean_sdna(prop, NULL, "layer", 1); RNA_def_property_array(prop, 20); RNA_def_property_ui_text(prop, "Dupli Layers", "Layers visible when this groups is instanced as a dupli"); + + /* restrict */ + prop= RNA_def_property(srna, "restrict_view", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", GR_RESTRICT_VIEW); + RNA_def_property_ui_text(prop, "Restrict View", "Restrict visibility in the viewport."); + RNA_def_property_update(prop, NC_GROUP, NULL); + + prop= RNA_def_property(srna, "restrict_select", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", GR_RESTRICT_SELECT); + RNA_def_property_ui_text(prop, "Restrict Select", "Restrict selection."); + RNA_def_property_update(prop, NC_GROUP, NULL); + + prop= RNA_def_property(srna, "restrict_render", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", GR_RESTRICT_RENDER); + RNA_def_property_ui_text(prop, "Restrict Render", "Restrict renderability."); + RNA_def_property_update(prop, NC_GROUP, NULL); - - prop= RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE); + prop= RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "gobject", NULL); RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Objects", "A collection of this groups objects");