Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/startup/bl_ui/space_view3d.py
| Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | def draw(self, context): | ||||
| object_mode = 'OBJECT' if obj is None else obj.mode | object_mode = 'OBJECT' if obj is None else obj.mode | ||||
| has_pose_mode = ( | has_pose_mode = ( | ||||
| (object_mode == 'POSE') or | (object_mode == 'POSE') or | ||||
| (object_mode == 'WEIGHT_PAINT' and context.pose_object is not None) | (object_mode == 'WEIGHT_PAINT' and context.pose_object is not None) | ||||
| ) | ) | ||||
| self.draw_tool_settings(context) | self.draw_tool_settings(context) | ||||
| layout.separator_spacer() | |||||
| # Mode & Transform Settings | |||||
| scene = context.scene | |||||
| # Orientation | |||||
| if object_mode in {'OBJECT', 'EDIT', 'EDIT_GPENCIL'} or has_pose_mode: | |||||
| orient_slot = scene.transform_orientation_slots[0] | |||||
| row = layout.row(align=True) | |||||
| sub = row.row() | |||||
| sub.ui_units_x = 4 | |||||
| sub.prop_with_popover( | |||||
| orient_slot, | |||||
| "type", | |||||
| text="", | |||||
| panel="VIEW3D_PT_transform_orientations", | |||||
| ) | |||||
| # Pivot | |||||
| if object_mode in {'OBJECT', 'EDIT', 'EDIT_GPENCIL', 'SCULPT_GPENCIL'} or has_pose_mode: | |||||
| layout.prop_with_popover( | |||||
| tool_settings, | |||||
| "transform_pivot_point", | |||||
| text="", | |||||
| icon_only=True, | |||||
| panel="VIEW3D_PT_pivot_point", | |||||
| ) | |||||
| # Snap | |||||
| show_snap = False | |||||
| if obj is None: | |||||
| show_snap = True | |||||
| else: | |||||
| if (object_mode not in { | |||||
| 'SCULPT', 'VERTEX_PAINT', 'WEIGHT_PAINT', 'TEXTURE_PAINT', | |||||
| 'PAINT_GPENCIL', 'SCULPT_GPENCIL', 'WEIGHT_GPENCIL' | |||||
| }) or has_pose_mode: | |||||
| show_snap = True | |||||
| else: | |||||
| from .properties_paint_common import UnifiedPaintPanel | |||||
| paint_settings = UnifiedPaintPanel.paint_settings(context) | |||||
| if paint_settings: | |||||
| brush = paint_settings.brush | |||||
| if brush and brush.stroke_method == 'CURVE': | |||||
| show_snap = True | |||||
| if show_snap: | |||||
| snap_items = bpy.types.ToolSettings.bl_rna.properties["snap_elements"].enum_items | |||||
| snap_elements = tool_settings.snap_elements | |||||
| if len(snap_elements) == 1: | |||||
| text = "" | |||||
| for elem in snap_elements: | |||||
| icon = snap_items[elem].icon | |||||
| break | |||||
| else: | |||||
| text = "Mix" | |||||
| icon = 'NONE' | |||||
| del snap_items, snap_elements | |||||
| row = layout.row(align=True) | |||||
| row.prop(tool_settings, "use_snap", text="") | |||||
| sub = row.row(align=True) | |||||
| sub.popover( | |||||
| panel="VIEW3D_PT_snapping", | |||||
| icon=icon, | |||||
| text=text, | |||||
| ) | |||||
| # Proportional editing | |||||
| gpd = context.gpencil_data | |||||
| if object_mode in {'EDIT', 'PARTICLE_EDIT'}: | |||||
| row = layout.row(align=True) | |||||
| row.prop(tool_settings, "proportional_edit", icon_only=True) | |||||
| sub = row.row(align=True) | |||||
| sub.active = tool_settings.proportional_edit != 'DISABLED' | |||||
| sub.prop(tool_settings, "proportional_edit_falloff", icon_only=True) | |||||
| elif object_mode == 'OBJECT': | |||||
| row = layout.row(align=True) | |||||
| row.prop(tool_settings, "use_proportional_edit_objects", icon_only=True) | |||||
| sub = row.row(align=True) | |||||
| sub.active = tool_settings.use_proportional_edit_objects | |||||
| sub.prop(tool_settings, "proportional_edit_falloff", icon_only=True) | |||||
| elif gpd is not None and obj.type == 'GPENCIL': | |||||
| if gpd.use_stroke_edit_mode or gpd.is_stroke_sculpt_mode: | |||||
| row = layout.row(align=True) | |||||
| row.prop(tool_settings, "proportional_edit", icon_only=True) | |||||
| sub = row.row(align=True) | |||||
| sub.active = tool_settings.proportional_edit != 'DISABLED' | |||||
| sub.prop(tool_settings, "proportional_edit_falloff", icon_only=True) | |||||
| # grease pencil | |||||
| if object_mode == 'PAINT_GPENCIL': | |||||
| layout.prop_with_popover( | |||||
| tool_settings, | |||||
| "gpencil_stroke_placement_view3d", | |||||
| text="", | |||||
| panel="VIEW3D_PT_gpencil_origin", | |||||
| ) | |||||
| if object_mode in {'PAINT_GPENCIL', 'SCULPT_GPENCIL'}: | |||||
| layout.prop_with_popover( | |||||
| tool_settings.gpencil_sculpt, | |||||
| "lock_axis", | |||||
| text="", | |||||
| panel="VIEW3D_PT_gpencil_lock", | |||||
| ) | |||||
| if object_mode == 'PAINT_GPENCIL': | |||||
| # FIXME: this is bad practice! | |||||
| # Tool options are to be displayed in the topbar. | |||||
| if context.workspace.tools.from_space_view3d_mode(object_mode).idname == "builtin_brush.Draw": | |||||
| settings = tool_settings.gpencil_sculpt.guide | |||||
| row = layout.row(align=True) | |||||
| row.prop(settings, "use_guide", text="", icon='GRID') | |||||
| sub = row.row(align=True) | |||||
| sub.active = settings.use_guide | |||||
| sub.popover( | |||||
| panel="VIEW3D_PT_gpencil_guide", | |||||
| text="Guides", | |||||
| ) | |||||
| layout.separator_spacer() | layout.separator_spacer() | ||||
| self.draw_mode_settings(context) | self.draw_mode_settings(context) | ||||
| def draw_tool_settings(self, context): | def draw_tool_settings(self, context): | ||||
| layout = self.layout | layout = self.layout | ||||
| ▲ Show 20 Lines • Show All 332 Lines • ▼ Show 20 Lines | def draw(self, context): | ||||
| # mode_string = context.mode | # mode_string = context.mode | ||||
| obj = context.active_object | obj = context.active_object | ||||
| if not view.show_region_tool_header: | if not view.show_region_tool_header: | ||||
| layout.row(align=True).template_header() | layout.row(align=True).template_header() | ||||
| row = layout.row(align=True) | row = layout.row(align=True) | ||||
| object_mode = 'OBJECT' if obj is None else obj.mode | 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) | |||||
| ) | |||||
| # Note: This is actually deadly in case enum_items have to be dynamically generated | # Note: This is actually deadly in case enum_items have to be dynamically generated | ||||
| # (because internal RNA array iterator will free everything immediately...). | # (because internal RNA array iterator will free everything immediately...). | ||||
| # XXX This is an RNA internal issue, not sure how to fix it. | # XXX This is an RNA internal issue, not sure how to fix it. | ||||
| # Note: Tried to add an accessor to get translated UI strings instead of manual call | # Note: Tried to add an accessor to get translated UI strings instead of manual call | ||||
| # to pgettext_iface below, but this fails because translated enumitems | # to pgettext_iface below, but this fails because translated enumitems | ||||
| # are always dynamically allocated. | # are always dynamically allocated. | ||||
| act_mode_item = bpy.types.Object.bl_rna.properties["mode"].enum_items[object_mode] | act_mode_item = bpy.types.Object.bl_rna.properties["mode"].enum_items[object_mode] | ||||
| ▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | def draw(self, context): | ||||
| ) | ) | ||||
| overlay = view.overlay | overlay = view.overlay | ||||
| VIEW3D_MT_editor_menus.draw_collapsible(context, layout) | VIEW3D_MT_editor_menus.draw_collapsible(context, layout) | ||||
| layout.separator_spacer() | layout.separator_spacer() | ||||
| # Mode & Transform Settings | |||||
| scene = context.scene | |||||
| # Orientation | |||||
| if object_mode in {'OBJECT', 'EDIT', 'EDIT_GPENCIL'} or has_pose_mode: | |||||
| orient_slot = scene.transform_orientation_slots[0] | |||||
| row = layout.row(align=True) | |||||
| sub = row.row() | |||||
| sub.ui_units_x = 4 | |||||
| sub.prop_with_popover( | |||||
| orient_slot, | |||||
| "type", | |||||
| text="", | |||||
| panel="VIEW3D_PT_transform_orientations", | |||||
| ) | |||||
| # Pivot | |||||
| if object_mode in {'OBJECT', 'EDIT', 'EDIT_GPENCIL', 'SCULPT_GPENCIL'} or has_pose_mode: | |||||
| layout.prop_with_popover( | |||||
| tool_settings, | |||||
| "transform_pivot_point", | |||||
| text="", | |||||
| icon_only=True, | |||||
| panel="VIEW3D_PT_pivot_point", | |||||
| ) | |||||
| # Snap | |||||
| show_snap = False | |||||
| if obj is None: | |||||
| show_snap = True | |||||
| else: | |||||
| if (object_mode not in { | |||||
| 'SCULPT', 'VERTEX_PAINT', 'WEIGHT_PAINT', 'TEXTURE_PAINT', | |||||
| 'PAINT_GPENCIL', 'SCULPT_GPENCIL', 'WEIGHT_GPENCIL' | |||||
| }) or has_pose_mode: | |||||
| show_snap = True | |||||
| else: | |||||
| from .properties_paint_common import UnifiedPaintPanel | |||||
| paint_settings = UnifiedPaintPanel.paint_settings(context) | |||||
| if paint_settings: | |||||
| brush = paint_settings.brush | |||||
| if brush and brush.stroke_method == 'CURVE': | |||||
| show_snap = True | |||||
| if show_snap: | |||||
| snap_items = bpy.types.ToolSettings.bl_rna.properties["snap_elements"].enum_items | |||||
| snap_elements = tool_settings.snap_elements | |||||
| if len(snap_elements) == 1: | |||||
| text = "" | |||||
| for elem in snap_elements: | |||||
| icon = snap_items[elem].icon | |||||
| break | |||||
| else: | |||||
| text = "Mix" | |||||
| icon = 'NONE' | |||||
| del snap_items, snap_elements | |||||
| row = layout.row(align=True) | |||||
| row.prop(tool_settings, "use_snap", text="") | |||||
| sub = row.row(align=True) | |||||
| sub.popover( | |||||
| panel="VIEW3D_PT_snapping", | |||||
| icon=icon, | |||||
| text=text, | |||||
| ) | |||||
| # Proportional editing | |||||
| gpd = context.gpencil_data | |||||
| if object_mode in {'EDIT', 'PARTICLE_EDIT'}: | |||||
| row = layout.row(align=True) | |||||
| row.prop(tool_settings, "proportional_edit", icon_only=True) | |||||
| sub = row.row(align=True) | |||||
| sub.active = tool_settings.proportional_edit != 'DISABLED' | |||||
| sub.prop(tool_settings, "proportional_edit_falloff", icon_only=True) | |||||
| elif object_mode == 'OBJECT': | |||||
| row = layout.row(align=True) | |||||
| row.prop(tool_settings, "use_proportional_edit_objects", icon_only=True) | |||||
| sub = row.row(align=True) | |||||
| sub.active = tool_settings.use_proportional_edit_objects | |||||
| sub.prop(tool_settings, "proportional_edit_falloff", icon_only=True) | |||||
| elif gpd is not None and obj.type == 'GPENCIL': | |||||
| if gpd.use_stroke_edit_mode or gpd.is_stroke_sculpt_mode: | |||||
| row = layout.row(align=True) | |||||
| row.prop(tool_settings, "proportional_edit", icon_only=True) | |||||
| sub = row.row(align=True) | |||||
| sub.active = tool_settings.proportional_edit != 'DISABLED' | |||||
| sub.prop(tool_settings, "proportional_edit_falloff", icon_only=True) | |||||
| # grease pencil | |||||
| if object_mode == 'PAINT_GPENCIL': | |||||
| layout.prop_with_popover( | |||||
| tool_settings, | |||||
| "gpencil_stroke_placement_view3d", | |||||
| text="", | |||||
| panel="VIEW3D_PT_gpencil_origin", | |||||
| ) | |||||
| if object_mode in {'PAINT_GPENCIL', 'SCULPT_GPENCIL'}: | |||||
| layout.prop_with_popover( | |||||
| tool_settings.gpencil_sculpt, | |||||
| "lock_axis", | |||||
| text="", | |||||
| panel="VIEW3D_PT_gpencil_lock", | |||||
| ) | |||||
| if object_mode == 'PAINT_GPENCIL': | |||||
| # FIXME: this is bad practice! | |||||
| # Tool options are to be displayed in the topbar. | |||||
| if context.workspace.tools.from_space_view3d_mode(object_mode).idname == "builtin_brush.Draw": | |||||
| settings = tool_settings.gpencil_sculpt.guide | |||||
| row = layout.row(align=True) | |||||
| row.prop(settings, "use_guide", text="", icon='GRID') | |||||
| sub = row.row(align=True) | |||||
| sub.active = settings.use_guide | |||||
| sub.popover( | |||||
| panel="VIEW3D_PT_gpencil_guide", | |||||
| text="Guides", | |||||
| ) | |||||
| layout.separator_spacer() | |||||
| # Viewport Settings | # Viewport Settings | ||||
| layout.popover( | layout.popover( | ||||
| panel="VIEW3D_PT_object_type_visibility", | panel="VIEW3D_PT_object_type_visibility", | ||||
| icon_value=view.icon_from_show_object_viewport, | icon_value=view.icon_from_show_object_viewport, | ||||
| text="", | text="", | ||||
| ) | ) | ||||
| # Gizmo toggle & popover. | # Gizmo toggle & popover. | ||||
| ▲ Show 20 Lines • Show All 4,011 Lines • ▼ Show 20 Lines | def draw(self, context): | ||||
| tool_settings = context.scene.tool_settings | tool_settings = context.scene.tool_settings | ||||
| pie.prop(tool_settings, "proportional_edit_falloff", expand=True) | pie.prop(tool_settings, "proportional_edit_falloff", expand=True) | ||||
| # ********** Panel ********** | # ********** Panel ********** | ||||
| class VIEW3D_PT_active_tool(Panel): | |||||
| bl_space_type = 'VIEW_3D' | |||||
| bl_region_type = 'UI' | |||||
| bl_label = "Active Tool" | |||||
| # For now don't add an extra tab. | |||||
| # bl_category = "Tool Settings" | |||||
| bl_category = "View" | |||||
| def draw(self, context): | |||||
| layout = self.layout | |||||
| # Panel display of topbar tool settings. | |||||
| # currently displays in tool settings, keep here since the same functionality is used for the topbar. | |||||
| layout.use_property_split = True | |||||
| layout.use_property_decorate = False | |||||
| from .space_toolsystem_common import ToolSelectPanelHelper | |||||
| ToolSelectPanelHelper.draw_active_tool_header(context, layout, show_tool_name=True) | |||||
| class VIEW3D_PT_view3d_properties(Panel): | class VIEW3D_PT_view3d_properties(Panel): | ||||
| bl_space_type = 'VIEW_3D' | bl_space_type = 'VIEW_3D' | ||||
| bl_region_type = 'UI' | bl_region_type = 'UI' | ||||
| bl_category = "View" | bl_category = "View" | ||||
| bl_label = "View" | bl_label = "View" | ||||
| bl_options = {'DEFAULT_CLOSED'} | |||||
| def draw(self, context): | def draw(self, context): | ||||
| layout = self.layout | layout = self.layout | ||||
| view = context.space_data | view = context.space_data | ||||
| layout.use_property_split = True | layout.use_property_split = True | ||||
| layout.use_property_decorate = False # No animation. | layout.use_property_decorate = False # No animation. | ||||
| ▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | def draw(self, context): | ||||
| col.prop(view, "lock_camera") | col.prop(view, "lock_camera") | ||||
| class VIEW3D_PT_view3d_cursor(Panel): | class VIEW3D_PT_view3d_cursor(Panel): | ||||
| bl_space_type = 'VIEW_3D' | bl_space_type = 'VIEW_3D' | ||||
| bl_region_type = 'UI' | bl_region_type = 'UI' | ||||
| bl_category = "View" | bl_category = "View" | ||||
| bl_label = "3D Cursor" | bl_label = "3D Cursor" | ||||
| bl_options = {'DEFAULT_CLOSED'} | |||||
| def draw(self, context): | def draw(self, context): | ||||
| layout = self.layout | layout = self.layout | ||||
| cursor = context.scene.cursor | cursor = context.scene.cursor | ||||
| layout.column().prop(cursor, "location", text="Location") | layout.column().prop(cursor, "location", text="Location") | ||||
| rotation_mode = cursor.rotation_mode | rotation_mode = cursor.rotation_mode | ||||
| ▲ Show 20 Lines • Show All 1,683 Lines • ▼ Show 20 Lines | classes = ( | ||||
| VIEW3D_MT_object_mode_pie, | VIEW3D_MT_object_mode_pie, | ||||
| VIEW3D_MT_view_pie, | VIEW3D_MT_view_pie, | ||||
| VIEW3D_MT_shading_pie, | VIEW3D_MT_shading_pie, | ||||
| VIEW3D_MT_shading_ex_pie, | VIEW3D_MT_shading_ex_pie, | ||||
| VIEW3D_MT_pivot_pie, | VIEW3D_MT_pivot_pie, | ||||
| VIEW3D_MT_snap_pie, | VIEW3D_MT_snap_pie, | ||||
| VIEW3D_MT_orientations_pie, | VIEW3D_MT_orientations_pie, | ||||
| VIEW3D_MT_proportional_editing_falloff_pie, | VIEW3D_MT_proportional_editing_falloff_pie, | ||||
| VIEW3D_PT_active_tool, | |||||
| VIEW3D_PT_view3d_properties, | VIEW3D_PT_view3d_properties, | ||||
| VIEW3D_PT_view3d_lock, | VIEW3D_PT_view3d_lock, | ||||
| 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_grease_pencil, | VIEW3D_PT_grease_pencil, | ||||
| VIEW3D_PT_annotation_onion, | VIEW3D_PT_annotation_onion, | ||||
| VIEW3D_PT_gpencil_multi_frame, | VIEW3D_PT_gpencil_multi_frame, | ||||
| ▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines | |||||