From a12602e51fc0a4fcf87c905b8963ecee3df9dfa1 Mon Sep 17 00:00:00 2001 From: Roland Hess Date: Wed, 30 Jan 2008 17:58:13 +0000 Subject: [PATCH] Small outliner enhancement: With items selected in the outliner, pressing the V, S or R key will toggle, respectively, the Visibility, Selectability or Renderability locks. Note that this functions independently of what is selected in the SCENE -- this is based on the RMB selection in the outliner. The options are also available from the RMB popup menu. There are enough items in that popup now that this space should probably have its own header with a menu. --- source/blender/include/BIF_outliner.h | 3 + source/blender/src/outliner.c | 86 ++++++++++++++++++++++++++- source/blender/src/space.c | 9 +++ 3 files changed, 96 insertions(+), 2 deletions(-) diff --git a/source/blender/include/BIF_outliner.h b/source/blender/include/BIF_outliner.h index 34ed7950421..469f04d8c9f 100644 --- a/source/blender/include/BIF_outliner.h +++ b/source/blender/include/BIF_outliner.h @@ -97,6 +97,9 @@ extern void outliner_show_hierarchy(struct ScrArea *sa); extern void outliner_one_level(struct ScrArea *sa, int add); extern void outliner_select(struct ScrArea *sa); extern void outliner_toggle_selected(struct ScrArea *sa); +extern void outliner_toggle_visibility(struct ScrArea *sa); +extern void outliner_toggle_selectability(struct ScrArea *sa); +extern void outliner_toggle_renderability(struct ScrArea *sa); extern void outliner_del(struct ScrArea *sa); extern void outliner_operation_menu(struct ScrArea *sa); extern void outliner_page_up_down(struct ScrArea *sa, int up); diff --git a/source/blender/src/outliner.c b/source/blender/src/outliner.c index c8ca48f64eb..f85c77af94e 100644 --- a/source/blender/src/outliner.c +++ b/source/blender/src/outliner.c @@ -138,6 +138,8 @@ extern ListBase server_list; /* ******************** PROTOTYPES ***************** */ static void outliner_draw_tree_element(SpaceOops *soops, TreeElement *te, int startx, int *starty); +static void outliner_do_object_operation(SpaceOops *soops, ListBase *lb, + void (*operation_cb)(TreeElement *, TreeStoreElem *, TreeStoreElem *)); /* ******************** PERSISTANT DATA ***************** */ @@ -1152,6 +1154,75 @@ static void outliner_set_flag(SpaceOops *soops, ListBase *lb, short flag, short } } +void object_toggle_visibility_cb(TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem) +{ + Base *base= (Base *)te->directdata; + + if(base==NULL) base= object_in_scene((Object *)tselem->id, G.scene); + if(base) { + base->object->restrictflag^=OB_RESTRICT_VIEW; + } +} + +void outliner_toggle_visibility(struct ScrArea *sa) +{ + SpaceOops *soops= sa->spacedata.first; + + outliner_do_object_operation(soops, &soops->tree, object_toggle_visibility_cb); + + BIF_undo_push("Outliner toggle selectability"); + + allqueue(REDRAWVIEW3D, 1); + allqueue(REDRAWOOPS, 0); + allqueue(REDRAWINFO, 1); +} + +static void object_toggle_selectability_cb(TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem) +{ + Base *base= (Base *)te->directdata; + + if(base==NULL) base= object_in_scene((Object *)tselem->id, G.scene); + if(base) { + base->object->restrictflag^=OB_RESTRICT_SELECT; + } +} + +void outliner_toggle_selectability(struct ScrArea *sa) +{ + SpaceOops *soops= sa->spacedata.first; + + outliner_do_object_operation(soops, &soops->tree, object_toggle_selectability_cb); + + BIF_undo_push("Outliner toggle selectability"); + + allqueue(REDRAWVIEW3D, 1); + allqueue(REDRAWOOPS, 0); + allqueue(REDRAWINFO, 1); +} + +void object_toggle_renderability_cb(TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem) +{ + Base *base= (Base *)te->directdata; + + if(base==NULL) base= object_in_scene((Object *)tselem->id, G.scene); + if(base) { + base->object->restrictflag^=OB_RESTRICT_RENDER; + } +} + +void outliner_toggle_renderability(struct ScrArea *sa) +{ + SpaceOops *soops= sa->spacedata.first; + + outliner_do_object_operation(soops, &soops->tree, object_toggle_renderability_cb); + + BIF_undo_push("Outliner toggle renderability"); + + allqueue(REDRAWVIEW3D, 1); + allqueue(REDRAWOOPS, 0); + allqueue(REDRAWINFO, 1); +} + void outliner_toggle_visible(struct ScrArea *sa) { SpaceOops *soops= sa->spacedata.first; @@ -2712,7 +2783,7 @@ void outliner_operation_menu(ScrArea *sa) //else pupmenu("Scene Operations%t|Delete"); } else if(objectlevel) { - short event= pupmenu("Select%x1|Deselect%x2|Delete%x4"); /* make local: does not work... it doesn't set lib_extern flags... so data gets lost */ + short event= pupmenu("Select%x1|Deselect%x2|Delete%x4|Toggle Visible%x6|Toggle Selectable%x7|Toggle Renderable%x8"); /* make local: does not work... it doesn't set lib_extern flags... so data gets lost */ if(event>0) { char *str=""; @@ -2736,7 +2807,18 @@ void outliner_operation_menu(ScrArea *sa) outliner_do_object_operation(soops, &soops->tree, id_local_cb); str= "Localized Objects"; } - + else if(event==6) { + outliner_do_object_operation(soops, &soops->tree, object_toggle_visibility_cb); + str= "Toggle Visibility"; + } + else if(event==7) { + outliner_do_object_operation(soops, &soops->tree, object_toggle_selectability_cb); + str= "Toggle Selectability"; + } + else if(event==8) { + outliner_do_object_operation(soops, &soops->tree, object_toggle_renderability_cb); + str= "Toggle Renderability"; + } countall(); BIF_undo_push(str); diff --git a/source/blender/src/space.c b/source/blender/src/space.c index e045e881948..950c3dec7e4 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -5490,6 +5490,15 @@ static void winqreadoopsspace(ScrArea *sa, void *spacedata, BWinEvent *evt) outliner_find_panel(sa, again, search_flags); } break; + case RKEY: + outliner_toggle_renderability(sa); + break; + case SKEY: + outliner_toggle_selectability(sa); + break; + case VKEY: + outliner_toggle_visibility(sa); + break; case XKEY: case DELKEY: outliner_del(sa);