Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/startup/bl_ui/space_view3d.py
| Context not available. | |||||
| ToolActivePanelHelper, | ToolActivePanelHelper, | ||||
| ) | ) | ||||
| from bpy.app.translations import contexts as i18n_contexts | from bpy.app.translations import contexts as i18n_contexts | ||||
| from bl_ui.space_toolsystem_common import ToolSelectPanelHelper | |||||
| class VIEW3D_HT_tool_header(Header): | class VIEW3D_HT_tool_header(Header): | ||||
| Context not available. | |||||
| # Active Tool | # Active Tool | ||||
| # ----------- | # ----------- | ||||
| from bl_ui.space_toolsystem_common import ToolSelectPanelHelper | |||||
| tool = ToolSelectPanelHelper.draw_active_tool_header( | tool = ToolSelectPanelHelper.draw_active_tool_header( | ||||
| context, layout, | context, layout, | ||||
| tool_key=('VIEW_3D', tool_mode), | tool_key=('VIEW_3D', tool_mode), | ||||
| Context not available. | |||||
| tool_settings = context.tool_settings | tool_settings = context.tool_settings | ||||
| view = context.space_data | view = context.space_data | ||||
| shading = view.shading | shading = view.shading | ||||
| space_type = context.space_data.type | |||||
| _cls = ToolSelectPanelHelper._tool_class_from_space_type(space_type) | |||||
| layout.row(align=True).template_header() | layout.row(align=True).template_header() | ||||
| Context not available. | |||||
| sub.active = overlay.show_overlays | sub.active = overlay.show_overlays | ||||
| sub.popover(panel="VIEW3D_PT_overlay", text="") | sub.popover(panel="VIEW3D_PT_overlay", text="") | ||||
| row = layout.row() | row = layout.row(align=True) | ||||
| row.active = (object_mode == 'EDIT') or (shading.type in {'WIREFRAME', 'SOLID'}) | row.active = (object_mode == 'EDIT') or (shading.type in {'WIREFRAME', 'SOLID'}) | ||||
| # While exposing 'shading.show_xray(_wireframe)' is correct. | # Select Through Button | ||||
| # this hides the key shortcut from users: T70433. | if object_mode == 'EDIT' or object_mode == 'OBJECT': | ||||
| if has_pose_mode: | if tool_settings.workspace_tool_type == 'FALLBACK': | ||||
| draw_depressed = overlay.show_xray_bone | tool = _cls._tool_get_by_id_active(context, _cls.tool_fallback_id)[0].idname | ||||
| elif shading.type == 'WIREFRAME': | else: | ||||
| draw_depressed = shading.show_xray_wireframe | tool = bpy.context.workspace.tools.from_space_view3d_mode('EDIT_MESH', create=False).idname | ||||
| if shading.xray_mode_type == "AUTOMATIC": | |||||
| if tool == "builtin.select_box": | |||||
| autox_draw_depressed = tool_settings.box_auto_xray | |||||
| elif tool == "builtin.select_circle": | |||||
| autox_draw_depressed = tool_settings.circle_auto_xray | |||||
| elif tool == "builtin.select_lasso": | |||||
| autox_draw_depressed = tool_settings.lasso_auto_xray | |||||
| else: | |||||
| autox_draw_depressed = False | |||||
| row.operator("view3d.toggle_xray_auto", text="", icon='XRAY_AUTO', depress=autox_draw_depressed) | |||||
| row.popover(panel="VIEW3D_PT_xray", text="") | |||||
| elif object_mode in {'EDIT'} and shading.xray_mode_type == "BUTTON": | |||||
| if tool == "builtin.select_box": | |||||
| sthru_draw_depressed = tool_settings.box_select_through | |||||
| elif tool == "builtin.select_circle": | |||||
| sthru_draw_depressed = tool_settings.circle_select_through | |||||
| elif tool == "builtin.select_lasso": | |||||
| sthru_draw_depressed = tool_settings.lasso_select_through | |||||
| else: | |||||
| sthru_draw_depressed = False | |||||
| row.operator("view3d.toggle_select_through", text="", icon='SELECT_THROUGH', depress=sthru_draw_depressed) | |||||
| row.popover(panel="VIEW3D_PT_xray", text="") | |||||
| # While exposing 'shading.show_xray(_wireframe)' is correct. | |||||
| # this hides the key shortcut from users: T70433. | |||||
| else: | |||||
| if has_pose_mode: | |||||
| draw_depressed = overlay.show_xray_bone | |||||
| elif shading.type == 'WIREFRAME': | |||||
| draw_depressed = shading.show_xray_wireframe | |||||
| else: | |||||
| draw_depressed = shading.show_xray | |||||
| row.operator("view3d.toggle_xray", text="", icon='XRAY', depress=draw_depressed) | |||||
| row.popover(panel="VIEW3D_PT_xray", text="") | |||||
| else: | else: | ||||
| draw_depressed = shading.show_xray | if has_pose_mode: | ||||
| row.operator( | draw_depressed = overlay.show_xray_bone | ||||
| "view3d.toggle_xray", | elif shading.type == 'WIREFRAME': | ||||
| text="", | draw_depressed = shading.show_xray_wireframe | ||||
| icon='XRAY', | else: | ||||
| depress=draw_depressed, | draw_depressed = shading.show_xray | ||||
| ) | row.operator("view3d.toggle_xray", text="", icon='XRAY', depress=draw_depressed) | ||||
| row = layout.row(align=True) | row = layout.row(align=True) | ||||
| row.prop(shading, "type", text="", expand=True) | row.prop(shading, "type", text="", expand=True) | ||||
| Context not available. | |||||
| layout.operator("%s.hide" % self._operator_name, text="Hide Selected").unselected = False | layout.operator("%s.hide" % self._operator_name, text="Hide Selected").unselected = False | ||||
| layout.operator("%s.hide" % self._operator_name, text="Hide Unselected").unselected = True | layout.operator("%s.hide" % self._operator_name, text="Hide Unselected").unselected = True | ||||
| # Standard transforms which apply to all cases (mix-in class, not used directly). | # Standard transforms which apply to all cases (mix-in class, not used directly). | ||||
| class VIEW3D_MT_transform_base: | class VIEW3D_MT_transform_base: | ||||
| bl_label = "Transform" | bl_label = "Transform" | ||||
| Context not available. | |||||
| self._draw_collection(layout, view_layer, view.use_local_collections, view_layer.layer_collection, 0) | self._draw_collection(layout, view_layer, view.use_local_collections, view_layer.layer_collection, 0) | ||||
| class VIEW3D_PT_xray(Panel): | |||||
| bl_space_type = 'VIEW_3D' | |||||
| bl_region_type = 'HEADER' | |||||
| bl_label = "X-Ray and Select Through" | |||||
| bl_ui_units_x = 10 | |||||
| def draw(self, context): | |||||
| layout = self.layout | |||||
| layout.label(text="X-Ray and Select Through") | |||||
| class VIEW3D_PT_xray_select_through_mode(Panel): | |||||
| bl_space_type = 'VIEW_3D' | |||||
| bl_region_type = 'HEADER' | |||||
| bl_parent_id = 'VIEW3D_PT_xray' | |||||
| bl_label = "Select Through Mode" | |||||
| def draw(self, context): | |||||
| layout = self.layout | |||||
| shading = context.space_data.shading | |||||
| tool_settings = context.tool_settings | |||||
| row = layout.row(align=True) | |||||
| row.prop(shading, "xray_mode_type", text="") | |||||
| if shading.xray_mode_type == "AUTOMATIC" or shading.xray_mode_type == "BUTTON": | |||||
| row = layout.row(align=True) | |||||
| row.prop(tool_settings, "link_box", text="Link Box", toggle=True) | |||||
| row.prop(tool_settings, "link_lasso", text="Link Lasso", toggle=True) | |||||
| row.prop(tool_settings, "link_circle", text="Link Circle", toggle=True) | |||||
| class VIEW3D_PT_xray_options(Panel): | |||||
| bl_space_type = 'VIEW_3D' | |||||
| bl_region_type = 'HEADER' | |||||
| bl_parent_id = 'VIEW3D_PT_xray' | |||||
| bl_label = "X-Ray" | |||||
| def draw(self, context): | |||||
| layout = self.layout | |||||
| shading = context.space_data.shading | |||||
| obj = context.active_object | |||||
| object_mode = 'OBJECT' if obj is None else obj.mode | |||||
| has_pose_mode = ( | |||||
| (object_mode == 'POSE') or | |||||
| (object_mode == 'WEIGHT_PAINT' and context.pose_object is not None) | |||||
| ) | |||||
| row = layout.row(align=True) | |||||
| if has_pose_mode: | |||||
| draw_depressed = overlay.show_xray_bone | |||||
| elif shading.type == 'WIREFRAME': | |||||
| draw_depressed = shading.show_xray_wireframe | |||||
| else: | |||||
| draw_depressed = shading.show_xray | |||||
| row.operator("view3d.toggle_xray", text="", icon='XRAY', depress=draw_depressed) | |||||
| if shading.type == 'WIREFRAME': | |||||
| sub = row.row() | |||||
| sub.active = shading.show_xray_wireframe | |||||
| sub.prop(shading, "xray_alpha_wireframe", text="X-Ray Wireframe") | |||||
| elif shading.type == 'SOLID': | |||||
| sub = row.row() | |||||
| sub.active = shading.show_xray | |||||
| sub.prop(shading, "xray_alpha", text="X-Ray Shaded") | |||||
| class VIEW3D_PT_object_type_visibility(Panel): | class VIEW3D_PT_object_type_visibility(Panel): | ||||
| bl_space_type = 'VIEW_3D' | bl_space_type = 'VIEW_3D' | ||||
| bl_region_type = 'HEADER' | bl_region_type = 'HEADER' | ||||
| Context not available. | |||||
| row = col.row(align=True) | row = col.row(align=True) | ||||
| if shading.type == 'WIREFRAME': | if shading.type == 'SOLID': | ||||
| row.prop(shading, "show_xray_wireframe", text="") | |||||
| sub = row.row() | |||||
| sub.active = shading.show_xray_wireframe | |||||
| sub.prop(shading, "xray_alpha_wireframe", text="X-Ray") | |||||
| elif shading.type == 'SOLID': | |||||
| row.prop(shading, "show_xray", text="") | |||||
| sub = row.row() | |||||
| sub.active = shading.show_xray | |||||
| sub.prop(shading, "xray_alpha", text="X-Ray") | |||||
| # X-ray mode is off when alpha is 1.0 | # X-ray mode is off when alpha is 1.0 | ||||
| xray_active = shading.show_xray and shading.xray_alpha != 1 | xray_active = shading.show_xray and shading.xray_alpha != 1 | ||||
| Context not available. | |||||
| is_any_solid_shading = not (shading.show_xray or (shading.type == 'WIREFRAME')) | is_any_solid_shading = not (shading.show_xray or (shading.type == 'WIREFRAME')) | ||||
| if shading.type == 'WIREFRAME': | |||||
| xray = shading.show_xray_wireframe and shading.xray_alpha_wireframe < 1.0 | |||||
| elif shading.type == 'SOLID': | |||||
| xray = shading.show_xray and shading.xray_alpha < 1.0 | |||||
| else: | |||||
| xray = False | |||||
| if xray: | |||||
| fdot_draw_depressed = overlay.show_face_center_xray | |||||
| else: | |||||
| fdot_draw_depressed = overlay.show_face_center | |||||
| col = layout.column() | col = layout.column() | ||||
| col.active = display_all | col.active = display_all | ||||
| col = layout.column() | |||||
| col.active = display_all | |||||
| split = col.split() | split = col.split() | ||||
| sub = split.column() | sub = split.column() | ||||
| sub.active = is_any_solid_shading | sub.active = is_any_solid_shading | ||||
| sub.prop(overlay, "show_edges", text="Edges") | sub.prop(overlay, "show_edges", text="Edges") | ||||
| sub = split.column() | sub = split.column() | ||||
| sub.prop(overlay, "show_faces", text="Faces") | sub.prop(overlay, "show_faces", text="Faces") | ||||
| sub = split.column() | sub = split.column() | ||||
| sub.active = is_any_solid_shading | sub.operator("view3d.toggle_facedots", text="Facedots", depress = fdot_draw_depressed) | ||||
| sub.prop(overlay, "show_face_center", text="Center") | |||||
| row = col.row(align=True) | row = col.row(align=True) | ||||
| row.prop(overlay, "show_edge_crease", text="Creases", toggle=True) | row.prop(overlay, "show_edge_crease", text="Creases", toggle=True) | ||||
| Context not available. | |||||
| VIEW3D_PT_view3d_cursor, | VIEW3D_PT_view3d_cursor, | ||||
| VIEW3D_PT_collections, | VIEW3D_PT_collections, | ||||
| VIEW3D_PT_object_type_visibility, | VIEW3D_PT_object_type_visibility, | ||||
| VIEW3D_PT_xray, | |||||
| VIEW3D_PT_xray_select_through_mode, | |||||
| VIEW3D_PT_xray_options, | |||||
| VIEW3D_PT_grease_pencil, | VIEW3D_PT_grease_pencil, | ||||
| VIEW3D_PT_annotation_onion, | VIEW3D_PT_annotation_onion, | ||||
| VIEW3D_PT_gpencil_multi_frame, | VIEW3D_PT_gpencil_multi_frame, | ||||
| Context not available. | |||||