Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/startup/bl_ui/space_spreadsheet.py
| Show All 22 Lines | class SPREADSHEET_HT_header(bpy.types.Header): | ||||
| bl_space_type = 'SPREADSHEET' | bl_space_type = 'SPREADSHEET' | ||||
| def draw(self, context): | def draw(self, context): | ||||
| layout = self.layout | layout = self.layout | ||||
| space = context.space_data | space = context.space_data | ||||
| layout.template_header() | layout.template_header() | ||||
| pinned_id = space.pinned_id | if len(space.context_path) == 0: | ||||
| used_id = pinned_id if pinned_id else context.active_object | self.draw_without_context_path(layout) | ||||
| return | |||||
| root_context = space.context_path[0] | |||||
| if root_context.type != 'OBJECT': | |||||
| self.draw_without_context_path(layout) | |||||
| return | |||||
| obj = root_context.object | |||||
| if obj is None: | |||||
| self.draw_without_context_path(layout) | |||||
| return | |||||
| layout.prop(space, "object_eval_state", text="") | layout.prop(space, "object_eval_state", text="") | ||||
| if space.object_eval_state != 'ORIGINAL': | if space.object_eval_state != 'ORIGINAL': | ||||
| layout.prop(space, "geometry_component_type", text="") | layout.prop(space, "geometry_component_type", text="") | ||||
| if space.geometry_component_type != 'INSTANCES': | if space.geometry_component_type != 'INSTANCES': | ||||
| layout.prop(space, "attribute_domain", text="") | layout.prop(space, "attribute_domain", text="") | ||||
| if used_id: | context_path = space.context_path | ||||
| layout.label(text=used_id.name, icon='OBJECT_DATA') | if space.object_eval_state == 'ORIGINAL': | ||||
| # Only show first context. | |||||
| context_path = context_path[:1] | |||||
| if space.display_context_path_collapsed: | |||||
| self.draw_collapsed_context_path(context, layout, context_path) | |||||
| else: | |||||
| self.draw_full_context_path(context, layout, context_path) | |||||
| layout.operator("spreadsheet.toggle_pin", text="", icon='PINNED' if pinned_id else 'UNPINNED', emboss=False) | pin_icon = 'PINNED' if space.is_pinned else 'UNPINNED' | ||||
| layout.operator("spreadsheet.toggle_pin", text="", icon=pin_icon, emboss=False) | |||||
| layout.separator_spacer() | layout.separator_spacer() | ||||
| if isinstance(used_id, bpy.types.Object) and used_id.mode == 'EDIT': | if isinstance(obj, bpy.types.Object) and obj.mode == 'EDIT': | ||||
| layout.prop(space, "show_only_selected", text="Selected Only") | layout.prop(space, "show_only_selected", text="Selected Only") | ||||
| def draw_without_context_path(self, layout): | |||||
| layout.label(text="No active context") | |||||
| def draw_full_context_path(self, context, layout, context_path): | |||||
| space = context.space_data | |||||
HooglyBoogly: Unused variable | |||||
| row = layout.row() | |||||
| for ctx in context_path[:-1]: | |||||
| subrow = row.row(align=True) | |||||
| self.draw_spreadsheet_context(subrow, ctx) | |||||
| self.draw_spreadsheet_context_path_icon(subrow, space) | |||||
| self.draw_spreadsheet_context(row, context_path[-1]) | |||||
| def draw_collapsed_context_path(self, context, layout, context_path): | |||||
| space = context.space_data | |||||
Not Done Inline ActionsUnused variable HooglyBoogly: Unused variable | |||||
| row = layout.row(align=True) | |||||
| self.draw_spreadsheet_context(row, context_path[0]) | |||||
| if len(context_path) == 1: | |||||
| return | |||||
| self.draw_spreadsheet_context_path_icon(row, space) | |||||
| if len(context_path) > 2: | |||||
| self.draw_spreadsheet_context_path_icon(row, space, icon='DOT') | |||||
| self.draw_spreadsheet_context_path_icon(row, space) | |||||
| self.draw_spreadsheet_context(row, context_path[-1]) | |||||
| def draw_spreadsheet_context(self, layout, ctx): | |||||
| if ctx.type == 'OBJECT': | |||||
| if ctx.object is None: | |||||
| layout.label(text="<no object>", icon='OBJECT_DATA') | |||||
| else: | |||||
| layout.label(text=ctx.object.name, icon='OBJECT_DATA') | |||||
| elif ctx.type == 'MODIFIER': | |||||
| layout.label(text=ctx.modifier_name, icon='MODIFIER') | |||||
| elif ctx.type == 'NODE': | |||||
| layout.label(text=ctx.node_name, icon='NODE') | |||||
| def draw_spreadsheet_context_path_icon(self, layout, space, icon='RIGHTARROW_THIN'): | |||||
| layout.prop(space, "display_context_path_collapsed", icon_only=True, emboss=False, icon=icon) | |||||
Not Done Inline ActionsWhy an operator button? This seems simpler. Plus you get a nicer tooltip (and the unused variables above won't be unused) def draw_breadcrumb_path_icon(self, layout, space, icon='RIGHTARROW_THIN'):
layout.prop(space, "display_breadcrumbs_collapsed", icon_only=True, emboss=False, icon=icon)HooglyBoogly: Why an operator button? This seems simpler. Plus you get a nicer tooltip (and the unused… | |||||
| classes = ( | classes = ( | ||||
| SPREADSHEET_HT_header, | SPREADSHEET_HT_header, | ||||
| ) | ) | ||||
| if __name__ == "__main__": # Only for live edit. | if __name__ == "__main__": # Only for live edit. | ||||
| from bpy.utils import register_class | from bpy.utils import register_class | ||||
| for cls in classes: | for cls in classes: | ||||
| register_class(cls) | register_class(cls) | ||||
Unused variable