diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2018-11-15 18:32:03 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-11-15 21:59:42 +0300 |
commit | f8964809b82e679d58669342ee0035db01a6c0c9 (patch) | |
tree | da96affd922579dff8bcdb46e1d40b162f10f5d3 | |
parent | 0ff424b299264f9db09f513e394322137c317a4e (diff) |
Viewport collections visibility: Viewport and Selection options
Right now we have a different behaviour whether users click on the name or on
the visibility eye.
When clicking on the eye, it is a toggle. When clicking in the name, you
are isolating this collection (unless you use shift).
As for the UI I tried using separator_spacer, but it was more work than
worth. A lot of sub panels, and LEFT/RIGHT alignment work just fine.
-rw-r--r-- | release/scripts/startup/bl_ui/space_view3d.py | 26 | ||||
-rw-r--r-- | source/blender/editors/object/object_edit.c | 9 |
2 files changed, 28 insertions, 7 deletions
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 8dbaf5e7fff..0d96e11cb72 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -4011,7 +4011,7 @@ class VIEW3D_PT_collections(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'HEADER' bl_label = "Collections Visibility" - bl_ui_units_x = 7 + bl_ui_units_x = 10 def _draw_collection(self, layout, view_layer, collection, index): need_separator = index @@ -4029,15 +4029,31 @@ class VIEW3D_PT_collections(Panel): need_separator = False icon = 'BLANK1' + has_objects = True if child.has_selected_objects(view_layer): icon = 'LAYER_ACTIVE' elif child.has_objects(): icon = 'LAYER_USED' + else: + has_objects = False + + has_visible_objects = has_objects and child.has_visible_objects(view_layer) row = layout.row() - row.alignment = 'LEFT' - row.active = child.has_visible_objects(view_layer) - row.operator("object.hide_collection", text=child.name, icon=icon, emboss=False).collection_index = index + sub = row.split(factor=0.98) + subrow = sub.row() + subrow.alignment = 'LEFT' + subrow.active = has_visible_objects + subrow.operator("object.hide_collection", text=child.name, icon=icon, emboss=False).collection_index = index + + sub = row.split() + subrow = sub.row(align=True) + subrow.alignment = 'RIGHT' + icon = 'HIDE_OFF' if has_visible_objects else 'HIDE_ON' + props = subrow.operator("object.hide_collection", text="", icon=icon, emboss=False) + props.collection_index = index + props.toggle = True + subrow.prop(child.collection, "hide_select", text="", emboss=False) for child in collection.children: index = self._draw_collection(layout, view_layer, child, index) @@ -4046,7 +4062,7 @@ class VIEW3D_PT_collections(Panel): def draw(self, context): layout = self.layout - layout.use_property_split = True + layout.use_property_split = False layout.label(text="Collections Visibility") col = layout.column() diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 2e8ae8f2cc2..e9bea64b56c 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -275,10 +275,13 @@ void OBJECT_OT_hide_view_set(wmOperatorType *ot) static int object_hide_collection_exec(bContext *C, wmOperator *op) { + wmWindow *win = CTX_wm_window(C); + int index = RNA_int_get(op->ptr, "collection_index"); - bool extend = (CTX_wm_window(C)->eventstate->shift != 0); + const bool extend = (win->eventstate->shift != 0) || + RNA_boolean_get(op->ptr, "toggle"); - if (CTX_wm_window(C)->eventstate->alt != 0) { + if (win->eventstate->alt != 0) { index += 10; } @@ -382,6 +385,8 @@ void OBJECT_OT_hide_collection(wmOperatorType *ot) prop = RNA_def_int(ot->srna, "collection_index", COLLECTION_INVALID_INDEX, COLLECTION_INVALID_INDEX, INT_MAX, "Collection Index", "Index of the collection to change visibility", 0, INT_MAX); RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN); + prop = RNA_def_boolean(ot->srna, "toggle", 0, "Toggle", "Toggle visibility"); + RNA_def_property_flag(prop, PROP_SKIP_SAVE | PROP_HIDDEN); } /* ******************* toggle editmode operator ***************** */ |