diff options
Diffstat (limited to 'release/scripts/startup/bl_ui/space_view3d.py')
-rw-r--r-- | release/scripts/startup/bl_ui/space_view3d.py | 269 |
1 files changed, 216 insertions, 53 deletions
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 078ad967789..447386b8f9d 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -31,6 +31,7 @@ from bl_ui.properties_grease_pencil_common import ( AnnotationDataPanel, AnnotationOnionSkin, GreasePencilMaterialsPanel, + GreasePencilVertexcolorPanel, ) from bl_ui.space_toolsystem_common import ( ToolActivePanelHelper, @@ -119,21 +120,27 @@ class VIEW3D_HT_tool_header(Header): if is_valid_context: brush = context.tool_settings.gpencil_paint.brush if brush.gpencil_tool != 'ERASE': - layout.popover("VIEW3D_PT_tools_grease_pencil_brush_advanced") + if brush.gpencil_tool != 'TINT': + layout.popover("VIEW3D_PT_tools_grease_pencil_brush_advanced") - if brush.gpencil_tool != 'FILL': + if brush.gpencil_tool not in {'FILL', 'TINT'}: layout.popover("VIEW3D_PT_tools_grease_pencil_brush_stroke") layout.popover("VIEW3D_PT_tools_grease_pencil_brushcurves") layout.popover("VIEW3D_PT_tools_grease_pencil_paint_appearance") elif tool_mode == 'SCULPT_GPENCIL': - settings = context.tool_settings.gpencil_sculpt - tool = settings.sculpt_tool - if tool in {'SMOOTH', 'RANDOMIZE', 'SMOOTH'}: - layout.popover("VIEW3D_PT_tools_grease_pencil_sculpt_options") - layout.popover("VIEW3D_PT_tools_grease_pencil_sculpt_appearance") + if is_valid_context: + brush = context.tool_settings.gpencil_sculpt_paint.brush + tool = brush.gpencil_tool + if tool in ('SMOOTH', 'RANDOMIZE'): + layout.popover("VIEW3D_PT_tools_grease_pencil_sculpt_options") + layout.popover("VIEW3D_PT_tools_grease_pencil_sculpt_appearance") elif tool_mode == 'WEIGHT_GPENCIL': - layout.popover("VIEW3D_PT_tools_grease_pencil_weight_appearance") + if is_valid_context: + layout.popover("VIEW3D_PT_tools_grease_pencil_weight_appearance") + elif tool_mode == 'VERTEX_GPENCIL': + if is_valid_context: + layout.popover("VIEW3D_PT_tools_grease_pencil_vertex_appearance") def draw_mode_settings(self, context): layout = self.layout @@ -425,6 +432,15 @@ class _draw_tool_settings_context_mode: row.prop(gp_settings, "use_material_pin", text="") + if brush.gpencil_tool in {'DRAW', 'FILL'} and ma: + row.separator(factor=1.0) + subrow = row.row(align=True) + row.prop_enum(settings, "color_mode", 'MATERIAL', text="", icon='MATERIAL') + row.prop_enum(settings, "color_mode", 'VERTEXCOLOR', text="", icon='VPAINT_HLT') + sub_row = row.row(align=True) + sub_row.enabled = settings.color_mode == 'VERTEXCOLOR' + sub_row.prop_with_popover(brush, "color", text="", panel="TOPBAR_PT_gpencil_vertexcolor") + row = layout.row(align=True) tool_settings = context.scene.tool_settings settings = tool_settings.gpencil_paint @@ -433,6 +449,10 @@ class _draw_tool_settings_context_mode: if context.object and brush.gpencil_tool in {'FILL', 'DRAW'}: draw_color_selector() + if context.object and brush.gpencil_tool == 'TINT': + row.separator(factor=0.4) + row.prop_with_popover(brush, "color", text="", panel="TOPBAR_PT_gpencil_vertexcolor") + from bl_ui.properties_paint_common import ( brush_basic_gpencil_paint_settings, ) @@ -444,9 +464,8 @@ class _draw_tool_settings_context_mode: def SCULPT_GPENCIL(context, layout, tool): if (tool is None) or (not tool.has_datablock): return False - tool_settings = context.tool_settings - settings = tool_settings.gpencil_sculpt - brush = settings.brush + paint = context.tool_settings.gpencil_sculpt_paint + brush = paint.brush from bl_ui.properties_paint_common import ( brush_basic_gpencil_sculpt_settings, @@ -459,9 +478,8 @@ class _draw_tool_settings_context_mode: def WEIGHT_GPENCIL(context, layout, tool): if (tool is None) or (not tool.has_datablock): return False - tool_settings = context.tool_settings - settings = tool_settings.gpencil_sculpt - brush = settings.brush + paint = context.tool_settings.gpencil_weight_paint + brush = paint.brush from bl_ui.properties_paint_common import ( brush_basic_gpencil_weight_settings, @@ -471,6 +489,31 @@ class _draw_tool_settings_context_mode: return True @staticmethod + def VERTEX_GPENCIL(context, layout, tool): + if (tool is None) or (not tool.has_datablock): + return False + + paint = context.tool_settings.gpencil_vertex_paint + brush = paint.brush + + row = layout.row(align=True) + tool_settings = context.scene.tool_settings + settings = tool_settings.gpencil_vertex_paint + row.template_ID_preview(settings, "brush", rows=3, cols=8, hide_buttons=True) + + if brush.gpencil_vertex_tool not in {'BLUR', 'AVERAGE', 'SMEAR'}: + row.separator(factor=0.4) + row.prop_with_popover(brush, "color", text="", panel="TOPBAR_PT_gpencil_vertexcolor") + + from bl_ui.properties_paint_common import ( + brush_basic_gpencil_vertex_settings, + ) + + brush_basic_gpencil_vertex_settings(layout, context, brush, compact=True) + + return True + + @staticmethod def PARTICLE(context, layout, tool): if (tool is None) or (not tool.has_datablock): return False @@ -550,7 +593,7 @@ class VIEW3D_HT_header(Header): else: if (object_mode not in { 'SCULPT', 'VERTEX_PAINT', 'WEIGHT_PAINT', 'TEXTURE_PAINT', - 'PAINT_GPENCIL', 'SCULPT_GPENCIL', 'WEIGHT_GPENCIL' + 'PAINT_GPENCIL', 'SCULPT_GPENCIL', 'WEIGHT_GPENCIL', 'VERTEX_GPENCIL' }) or has_pose_mode: show_snap = True else: @@ -687,7 +730,14 @@ class VIEW3D_HT_header(Header): row.prop(tool_settings, "use_gpencil_select_mask_stroke", text="") row.prop(tool_settings, "use_gpencil_select_mask_segment", text="") - if gpd.use_stroke_edit_mode or gpd.is_stroke_sculpt_mode or gpd.is_stroke_weight_mode: + # Select mode for Vertex Paint + if gpd.is_stroke_vertex_mode: + row = layout.row(align=True) + row.prop(tool_settings, "use_gpencil_vertex_select_mask_point", text="") + row.prop(tool_settings, "use_gpencil_vertex_select_mask_stroke", text="") + row.prop(tool_settings, "use_gpencil_vertex_select_mask_segment", text="") + + if gpd.use_stroke_edit_mode or gpd.is_stroke_sculpt_mode or gpd.is_stroke_weight_mode or gpd.is_stroke_vertex_mode: row = layout.row(align=True) row.prop(gpd, "use_multiedit", text="", icon='GP_MULTIFRAME_EDITING') @@ -812,7 +862,8 @@ class VIEW3D_MT_editor_menus(Menu): obj = context.active_object mode_string = context.mode edit_object = context.edit_object - gp_edit = obj and obj.mode in {'EDIT_GPENCIL', 'PAINT_GPENCIL', 'SCULPT_GPENCIL', 'WEIGHT_GPENCIL'} + gp_edit = obj and obj.mode in {'EDIT_GPENCIL', 'PAINT_GPENCIL', 'SCULPT_GPENCIL', + 'WEIGHT_GPENCIL', 'VERTEX_GPENCIL'} ts = context.scene.tool_settings layout.menu("VIEW3D_MT_view") @@ -827,6 +878,8 @@ class VIEW3D_MT_editor_menus(Menu): layout.menu("VIEW3D_MT_select_gpencil") elif mode_string == 'EDIT_GPENCIL': layout.menu("VIEW3D_MT_select_gpencil") + elif mode_string == 'VERTEX_GPENCIL': + layout.menu("VIEW3D_MT_select_gpencil") elif mode_string in {'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE'}: mesh = obj.data if mesh.use_paint_mask: @@ -4650,6 +4703,10 @@ class VIEW3D_MT_paint_gpencil(Menu): layout = self.layout + layout.menu("GPENCIL_MT_layer_active", text="Active Layer") + + layout.separator() + layout.menu("VIEW3D_MT_gpencil_animation") layout.menu("VIEW3D_MT_edit_gpencil_interpolate") @@ -4708,6 +4765,10 @@ class VIEW3D_MT_edit_gpencil(Menu): layout.separator() + layout.menu("GPENCIL_MT_layer_active", text="Active Layer") + + layout.separator() + layout.menu("VIEW3D_MT_gpencil_animation") layout.menu("VIEW3D_MT_edit_gpencil_interpolate") @@ -4742,6 +4803,7 @@ class VIEW3D_MT_edit_gpencil_stroke(Menu): def draw(self, _context): layout = self.layout + settings = _context.tool_settings.gpencil_sculpt layout.operator("gpencil.stroke_subdivide", text="Subdivide").only_selected = False layout.menu("VIEW3D_MT_gpencil_simplify") @@ -4767,6 +4829,10 @@ class VIEW3D_MT_edit_gpencil_stroke(Menu): layout.operator("gpencil.stroke_cyclical_set", text="Toggle Cyclic").type = 'TOGGLE' layout.operator_menu_enum("gpencil.stroke_caps_set", text="Toggle Caps", property="type") layout.operator("gpencil.stroke_flip", text="Switch Direction") + layout.prop(settings, "use_scale_thickness") + + layout.separator() + layout.operator("gpencil.reset_transform_fill", text="Reset Fill Transform") class VIEW3D_MT_edit_gpencil_point(Menu): @@ -4811,6 +4877,22 @@ class VIEW3D_MT_weight_gpencil(Menu): layout.menu("VIEW3D_MT_gpencil_autoweights") +class VIEW3D_MT_vertex_gpencil(Menu): + bl_label = "Paint" + + def draw(self, _context): + layout = self.layout + layout.operator("gpencil.vertex_color_set", text="Set Vertex Colors") + layout.separator() + layout.operator("gpencil.vertex_color_invert", text="Invert") + layout.operator("gpencil.vertex_color_levels", text="Levels") + layout.operator("gpencil.vertex_color_hsv", text="Hue Saturation Value") + layout.operator("gpencil.vertex_color_brightness_contrast", text="Bright/Contrast") + + layout.separator() + layout.menu("VIEW3D_MT_join_palette") + + class VIEW3D_MT_gpencil_animation(Menu): bl_label = "Animation" @@ -6473,6 +6555,7 @@ class VIEW3D_PT_overlay_gpencil_options(Panel): 'EDIT_GPENCIL': "Edit Grease Pencil", 'SCULPT_GPENCIL': "Sculpt Grease Pencil", 'WEIGHT_GPENCIL': "Weight Grease Pencil", + 'VERTEX_GPENCIL': "Vertex Grease Pencil", 'OBJECT': "Grease Pencil", }[context.mode]) @@ -6497,17 +6580,32 @@ class VIEW3D_PT_overlay_gpencil_options(Panel): sub.prop(overlay, "gpencil_fade_layer", text="Fade Layers", slider=True) row = col.row() - row.prop(overlay, "use_gpencil_paper", text="") + row.prop(overlay, "use_gpencil_fade_objects", text="") sub = row.row(align=True) - sub.active = overlay.use_gpencil_paper - sub.prop(overlay, "gpencil_paper_opacity", text="Fade Objects", slider=True) - sub.prop(overlay, "use_gpencil_fade_objects", text="", icon='OUTLINER_OB_GREASEPENCIL') + sub.active = overlay.use_gpencil_fade_objects + sub.prop(overlay, "gpencil_fade_objects", text="Fade Objects", slider=True) + sub.prop(overlay, "use_gpencil_fade_gp_objects", text="", icon='OUTLINER_OB_GREASEPENCIL') + + if context.object.mode in {'EDIT_GPENCIL', 'SCULPT_GPENCIL', 'WEIGHT_GPENCIL', 'VERTEX_GPENCIL'}: + split = layout.split() + col = split.column() + col.prop(overlay, "use_gpencil_edit_lines", text="Edit Lines") + col = split.column() + col.prop(overlay, "use_gpencil_multiedit_line_only", text="Only in Multiframe") + + if context.object.mode == 'EDIT_GPENCIL': + split = layout.split() + col = split.column() + col.prop(overlay, "use_gpencil_show_directions") + col = split.column() + col.prop(overlay, "use_gpencil_show_material_name", text="Material Name") - if context.object.mode in {'EDIT_GPENCIL', 'SCULPT_GPENCIL', 'WEIGHT_GPENCIL'}: - layout.prop(overlay, "use_gpencil_edit_lines", text="Edit Lines") - layout.prop(overlay, "use_gpencil_multiedit_line_only", text="Show Edit Lines only in multiframe") layout.prop(overlay, "vertex_opacity", text="Vertex Opacity", slider=True) + if context.object.mode in {'PAINT_GPENCIL', 'VERTEX_GPENCIL'}: + layout.label(text="Vertex Paint") + layout.prop(overlay, "gpencil_vertex_paint_opacity", text="Opacity", slider=True) + class VIEW3D_PT_quad_view(Panel): bl_space_type = 'VIEW_3D' @@ -6783,77 +6881,127 @@ class VIEW3D_MT_gpencil_edit_context_menu(Menu): col.operator("gpencil.reproject", text="Reproject Strokes") +def draw_gpencil_layer_active(context, layout): + gpl = context.active_gpencil_layer + if gpl: + layout.label(text="Active Layer") + row = layout.row(align=True) + row.operator_context = 'EXEC_REGION_WIN' + row.operator_menu_enum("gpencil.layer_change", "layer", text="", icon='GREASEPENCIL') + row.prop(gpl, "info", text="") + row.operator("gpencil.layer_remove", text="", icon='X') + + class VIEW3D_PT_gpencil_sculpt_context_menu(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'WINDOW' bl_label = "Sculpt Context Menu" + bl_ui_units_x = 12 def draw(self, context): - brush = context.tool_settings.gpencil_sculpt.brush + ts = context.tool_settings + settings = ts.gpencil_paint + brush = settings.brush layout = self.layout - if context.mode == 'WEIGHT_GPENCIL': - layout.prop(brush, "weight") layout.prop(brush, "size", slider=True) layout.prop(brush, "strength") - layout.separator() - - # Frames - layout.label(text="Frames:") + # Layers + draw_gpencil_layer_active(context, layout) - layout.operator_context = 'INVOKE_REGION_WIN' - layout.operator("gpencil.blank_frame_add", text="Insert Blank in Active Layer", icon='ADD') - layout.operator("gpencil.blank_frame_add", text="Insert Blank in All Layers", icon='ADD').all_layers = True +class VIEW3D_PT_gpencil_weight_context_menu(Panel): + bl_space_type = 'VIEW_3D' + bl_region_type = 'WINDOW' + bl_label = "Weight Paint Context Menu" + bl_ui_units_x = 12 - layout.separator() + def draw(self, context): + ts = context.tool_settings + settings = ts.gpencil_paint + brush = settings.brush - layout.operator("gpencil.frame_duplicate", text="Duplicate Active Layer", icon='DUPLICATE') - layout.operator("gpencil.frame_duplicate", text="Duplicate All Layers", icon='DUPLICATE').mode = 'ALL' + layout = self.layout - layout.separator() + layout.prop(brush, "size", slider=True) + layout.prop(brush, "strength") + layout.prop(brush, "weight") - layout.operator("gpencil.delete", text="Delete Active Layer", icon='REMOVE').type = 'FRAME' - layout.operator("gpencil.active_frames_delete_all", text="Delete All Layers", icon='REMOVE') + # Layers + draw_gpencil_layer_active(context, layout) class VIEW3D_PT_gpencil_draw_context_menu(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'WINDOW' bl_label = "Draw Context Menu" + bl_ui_units_x = 12 def draw(self, context): - brush = context.tool_settings.gpencil_paint.brush + ts = context.tool_settings + settings = ts.gpencil_paint + brush = settings.brush gp_settings = brush.gpencil_settings layout = self.layout + if brush.gpencil_tool not in {'ERASE', 'CUTTER', 'EYEDROPPER'} and settings.color_mode == 'VERTEXCOLOR': + split = layout.split(factor=0.1) + split.prop(brush, "color", text="") + split.template_color_picker(brush, "color", value_slider=True) + + col = layout.column() + col.separator() + col.prop_menu_enum(gp_settings, "vertex_mode", text="Mode") + col.separator() + if brush.gpencil_tool not in {'FILL', 'CUTTER'}: layout.prop(brush, "size", slider=True) if brush.gpencil_tool not in {'ERASE', 'FILL', 'CUTTER'}: layout.prop(gp_settings, "pen_strength") - layout.separator() + # Layers + draw_gpencil_layer_active(context, layout) - # Frames - layout.label(text="Frames:") - layout.operator_context = 'INVOKE_REGION_WIN' +class VIEW3D_PT_gpencil_vertex_context_menu(Panel): + bl_space_type = 'VIEW_3D' + bl_region_type = 'WINDOW' + bl_label = "Vertex Paint Context Menu" + bl_ui_units_x = 12 - layout.operator("gpencil.blank_frame_add", text="Insert Blank in Active Layer", icon='ADD') - layout.operator("gpencil.blank_frame_add", text="Insert Blank in All Layers", icon='ADD').all_layers = True + def draw(self, context): + layout = self.layout + ts = context.tool_settings + settings = ts.gpencil_vertex_paint + brush = settings.brush + gp_settings = brush.gpencil_settings - layout.separator() + col = layout.column() - layout.operator("gpencil.frame_duplicate", text="Duplicate Active Layer", icon='DUPLICATE') - layout.operator("gpencil.frame_duplicate", text="Duplicate All Layers", icon='DUPLICATE').mode = 'ALL' + if brush.gpencil_vertex_tool in {'DRAW', 'REPLACE'}: + split = layout.split(factor=0.1) + split.prop(brush, "color", text="") + split.template_color_picker(brush, "color", value_slider=True) - layout.separator() + col = layout.column() + col.separator() + col.prop_menu_enum(gp_settings, "vertex_mode", text="Mode") + col.separator() + + row = col.row(align=True) + row.prop(brush, "size", text="Radius") + row.prop(gp_settings, "use_pressure", text="", icon='STYLUS_PRESSURE') - layout.operator("gpencil.delete", text="Delete Active Layer", icon='REMOVE').type = 'FRAME' - layout.operator("gpencil.active_frames_delete_all", text="Delete All Layers", icon='REMOVE') + if brush.gpencil_vertex_tool in {'DRAW', 'BLUR', 'SMEAR'}: + row = layout.row(align=True) + row.prop(gp_settings, "pen_strength", slider=True) + row.prop(gp_settings, "use_strength_pressure", text="", icon='STYLUS_PRESSURE') + + # Layers + draw_gpencil_layer_active(context, layout) class VIEW3D_PT_paint_vertex_context_menu(Panel): @@ -7037,6 +7185,17 @@ class TOPBAR_PT_gpencil_materials(GreasePencilMaterialsPanel, Panel): return ob and ob.type == 'GPENCIL' +class TOPBAR_PT_gpencil_vertexcolor(GreasePencilVertexcolorPanel, Panel): + bl_space_type = 'VIEW_3D' + bl_region_type = 'HEADER' + bl_label = "Vertex Color" + bl_ui_units_x = 10 + + @classmethod + def poll(cls, context): + ob = context.object + return ob and ob.type == 'GPENCIL' + classes = ( VIEW3D_HT_header, VIEW3D_HT_tool_header, @@ -7163,6 +7322,7 @@ classes = ( VIEW3D_MT_edit_gpencil_delete, VIEW3D_MT_edit_gpencil_showhide, VIEW3D_MT_weight_gpencil, + VIEW3D_MT_vertex_gpencil, VIEW3D_MT_gpencil_animation, VIEW3D_MT_gpencil_simplify, VIEW3D_MT_gpencil_copy_layer, @@ -7249,10 +7409,13 @@ classes = ( VIEW3D_PT_paint_vertex_context_menu, VIEW3D_PT_paint_texture_context_menu, VIEW3D_PT_paint_weight_context_menu, + VIEW3D_PT_gpencil_vertex_context_menu, VIEW3D_PT_gpencil_sculpt_context_menu, + VIEW3D_PT_gpencil_weight_context_menu, VIEW3D_PT_gpencil_draw_context_menu, VIEW3D_PT_sculpt_context_menu, TOPBAR_PT_gpencil_materials, + TOPBAR_PT_gpencil_vertexcolor, TOPBAR_PT_annotation_layers, ) |