diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-06-18 20:49:53 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-06-20 14:04:51 +0300 |
commit | 4234cddda9ed59e5a7fff7043a2add2aaf158d23 (patch) | |
tree | 9efba3cbdfb86b38bceb8def7fae1a5b90801620 /source/blender/editors/space_outliner/outliner_draw.c | |
parent | 5e968a996a5397a14d00c49e67c74b993859a1d6 (diff) |
Objects: support for hiding all objects in a collection.
In the outliner there are now icons for it, Ctrl+Click isolates a
single collections.
In the 3D view, Ctrl+H key opens a menu that is more or less the
equivalent of the old layer buttons in the header. Regular Click isolates
the collection, Shift+Click toggle the collection visibility. Pressing
number keys and letters works in this menu, which can help for quickly
selecting a specific collection.
Shortcuts for quick switching by just pressing 1/2/3/.. keys are available
again. The order can be confusing with nested collections, but that seems
unavoidable. The first numbers control the top level collections, and then
sub collections if numbers are left.
Remaining design issues:
* The 3D view menu needs to be improved: support for sub collections,
staying open on shift+click, access from the 3D view header somewhere,
shortcut key display.
* Currently collection hiding just controls per-object hiding, we plan
to separate this state still so alt+H doesn't affect collection hiding.
Diffstat (limited to 'source/blender/editors/space_outliner/outliner_draw.c')
-rw-r--r-- | source/blender/editors/space_outliner/outliner_draw.c | 58 |
1 files changed, 50 insertions, 8 deletions
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 88fa9afd116..5f97c7858af 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -280,10 +280,38 @@ static void restrictbutton_id_user_toggle(bContext *UNUSED(C), void *poin, void static void hidebutton_base_flag_cb(bContext *C, void *poin, void *poin2) { - Scene *scene = poin; - ViewLayer *view_layer = poin2; + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = poin; + Base *base = poin2; + bool extend = (CTX_wm_window(C)->eventstate->ctrl == 0); + + /* Undo button toggle, let function do it. */ + base->flag ^= BASE_HIDE; + + BKE_base_set_visible(scene, view_layer, base, extend); + + if (!extend && (base->flag & BASE_VISIBLED)) { + /* Auto select solo-ed object. */ + ED_object_base_select(base, BA_SELECT); + view_layer->basact = base; + } + + DEG_id_tag_update(&scene->id, DEG_TAG_BASE_FLAGS_UPDATE); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); +} + +static void hidebutton_layer_collection_flag_cb(bContext *C, void *poin, void *poin2) +{ + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = poin; + LayerCollection *lc = poin2; + bool extend = (CTX_wm_window(C)->eventstate->ctrl == 0); + + /* Undo button toggle, let function do it. */ + lc->runtime_flag ^= LAYER_COLLECTION_HAS_VISIBLE_OBJECTS; + + BKE_layer_collection_set_visible(scene, view_layer, lc, extend); - BKE_layer_collection_sync(scene, view_layer); DEG_id_tag_update(&scene->id, DEG_TAG_BASE_FLAGS_UPDATE); WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } @@ -482,15 +510,16 @@ static void outliner_draw_restrictbuts( UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); } else if (tselem->type == 0 && te->idcode == ID_OB) { - ob = (Object *)tselem->id; + Object *ob = (Object *)tselem->id; Base *base = BKE_view_layer_base_find(view_layer, ob); if (base) { - bt = uiDefIconButBitS(block, UI_BTYPE_ICON_TOGGLE, BASE_HIDE, 0, ICON_HIDE_OFF, + bt = uiDefIconButBitS( + block, UI_BTYPE_ICON_TOGGLE, BASE_HIDE, 0, ICON_HIDE_OFF, (int)(ar->v2d.cur.xmax - OL_TOG_HIDEX), te->ys, UI_UNIT_X, UI_UNIT_Y, &base->flag, 0, 0, 0, 0, - TIP_("Hide object in viewport")); - UI_but_func_set(bt, hidebutton_base_flag_cb, scene, view_layer); + TIP_("Hide object in viewport (Ctrl to isolate)")); + UI_but_func_set(bt, hidebutton_base_flag_cb, view_layer, base); UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); } @@ -603,6 +632,16 @@ static void outliner_draw_restrictbuts( if ((!lc || !(lc->flag & LAYER_COLLECTION_EXCLUDE)) && !(collection->flag & COLLECTION_IS_MASTER)) { + if (lc && (lc->runtime_flag & LAYER_COLLECTION_HAS_ENABLED_OBJECTS)) { + bt = uiDefIconButBitS( + block, UI_BTYPE_ICON_TOGGLE_N, LAYER_COLLECTION_HAS_VISIBLE_OBJECTS, 0, ICON_HIDE_OFF, + (int)(ar->v2d.cur.xmax - OL_TOG_HIDEX), te->ys, UI_UNIT_X, + UI_UNIT_Y, &lc->runtime_flag, 0, 0, 0, 0, + TIP_("Hide collection in viewport (Ctrl to isolate)")); + UI_but_func_set(bt, hidebutton_layer_collection_flag_cb, view_layer, lc); + UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); + } + PointerRNA collection_ptr; RNA_id_pointer_create(&collection->id, &collection_ptr); @@ -1945,7 +1984,10 @@ static void outliner_draw_restrictcols(ARegion *ar) unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformThemeColorShadeAlpha(TH_BACK, -15, -200); - immBegin(GWN_PRIM_LINES, 6); + immBegin(GWN_PRIM_LINES, 8); + + immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_HIDEX), (int)ar->v2d.cur.ymax); + immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_HIDEX), (int)ar->v2d.cur.ymin); immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)ar->v2d.cur.ymax); immVertex2i(pos, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), (int)ar->v2d.cur.ymin); |