From bb9c9d0eaaab836b8f20ab7b2228795f607b823a Mon Sep 17 00:00:00 2001 From: Antonioya Date: Fri, 11 Jan 2019 19:15:23 +0100 Subject: GP: New Cutter, Constraints and Segment selection This commit groups a set of new tools that were tested in grease pencil object branch before moving to master. We decide to do all the development in a separated branch because it could break master during days or weeks before the new tools were ready to deploy. The commit includes: - New Cutter tool to trim strokes and help cleaning up drawings. - New set of constraints and guides to draw different types of shapes. All the credits for this development goes to Charlie Jolly (@charlie), thanks for your help! - Segment selection mode to select strokes between intersections. - New operator to change strokes cap mode. - New option to display only keyframed frames. This option is very important when fill strokes with color. - Multiple small fixes and tweaks. Thanks to @pepeland and @mendio for their ideas, tests, reviews and support. Note: Still pending the final icons for Cutter in Toolbar and Segment Selection in Topbar. @billreynish could help us here? --- .../startup/bl_ui/properties_data_gpencil.py | 3 ++ .../bl_ui/properties_grease_pencil_common.py | 1 + .../startup/bl_ui/space_toolsystem_toolbar.py | 18 ++++++- release/scripts/startup/bl_ui/space_topbar.py | 11 ++++- release/scripts/startup/bl_ui/space_view3d.py | 55 ++++++++++++++++++++++ 5 files changed, 85 insertions(+), 3 deletions(-) (limited to 'release/scripts/startup/bl_ui') diff --git a/release/scripts/startup/bl_ui/properties_data_gpencil.py b/release/scripts/startup/bl_ui/properties_data_gpencil.py index 59e54a4c62d..d6633c99456 100644 --- a/release/scripts/startup/bl_ui/properties_data_gpencil.py +++ b/release/scripts/startup/bl_ui/properties_data_gpencil.py @@ -145,6 +145,9 @@ class DATA_PT_gpencil_datapanel(Panel): srow.prop(gpl, "clamp_layer", text="", icon='MOD_MASK' if gpl.clamp_layer else 'LAYER_ACTIVE') + srow = col.row(align=True) + srow.prop(gpl, "use_solo_mode", text="Show Only On Keyframed") + col = row.column() sub = col.column(align=True) diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py index 8a93014670a..49f857492f3 100644 --- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py +++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py @@ -191,6 +191,7 @@ class GreasePencilStrokeEditPanel: col.operator("gpencil.duplicate_move", text="Duplicate") if is_3d_view: col.operator("gpencil.stroke_cyclical_set", text="Toggle Cyclic").type = 'TOGGLE' + col.operator_menu_enum("gpencil.stroke_caps_set", text="Toggle Caps...", property="type") layout.separator() diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py index 18dff12185f..8f4a2ca1c84 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py @@ -1077,6 +1077,16 @@ class _defs_gpencil_paint: ), ) + @ToolDef.from_fn + def cutter(): + return dict( + text="Cutter", + icon="ops.gpencil.stroke_cutter", + cursor='KNIFE', + widget=None, + keymap=(), + ) + @ToolDef.from_fn def line(): return dict( @@ -1141,7 +1151,7 @@ class _defs_gpencil_edit: @ToolDef.from_fn def select(): def draw_settings(context, layout, tool): - pass + layout.prop(context.tool_settings.gpencil_sculpt, "intersection_threshold") return dict( text="Select", icon="ops.generic.select", @@ -1155,6 +1165,7 @@ class _defs_gpencil_edit: def draw_settings(context, layout, tool): props = tool.operator_properties("gpencil.select_box") layout.prop(props, "mode", expand=True) + layout.prop(context.tool_settings.gpencil_sculpt, "intersection_threshold") return dict( text="Select Box", icon="ops.generic.select_box", @@ -1168,6 +1179,7 @@ class _defs_gpencil_edit: def draw_settings(context, layout, tool): props = tool.operator_properties("gpencil.select_lasso") layout.prop(props, "mode", expand=True) + layout.prop(context.tool_settings.gpencil_sculpt, "intersection_threshold") return dict( text="Select Lasso", icon="ops.generic.select_lasso", @@ -1178,11 +1190,14 @@ class _defs_gpencil_edit: @ToolDef.from_fn def circle_select(): + def draw_settings(context, layout, tool): + layout.prop(context.tool_settings.gpencil_sculpt, "intersection_threshold") return dict( text="Select Circle", icon="ops.generic.select_circle", widget=None, keymap=(), + draw_settings=draw_settings, ) @ToolDef.from_fn @@ -1629,6 +1644,7 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel): _defs_view3d_generic.cursor, None, _defs_gpencil_paint.generate_from_brushes, + _defs_gpencil_paint.cutter, None, _defs_gpencil_paint.line, _defs_gpencil_paint.arc, diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py index 06a6e3dc5ac..d27f8e303c9 100644 --- a/release/scripts/startup/bl_ui/space_topbar.py +++ b/release/scripts/startup/bl_ui/space_topbar.py @@ -303,9 +303,13 @@ class _draw_left_context_mode: return is_paint = True - if (tool.name in {"Line", "Box", "Circle", "Arc", "Curve"}): + if tool.name in {"Line", "Box", "Circle", "Arc", "Curve"}: is_paint = False - elif (not tool.has_datablock): + elif tool.name == "Cutter": + row = layout.row(align=True) + row.prop(context.tool_settings.gpencil_sculpt, "intersection_threshold") + return + elif not tool.has_datablock: return paint = context.tool_settings.gpencil_paint @@ -509,6 +513,9 @@ class TOPBAR_PT_gpencil_layers(Panel): srow.prop(gpl, "clamp_layer", text="", icon='MOD_MASK' if gpl.clamp_layer else 'LAYER_ACTIVE') + srow = col.row(align=True) + srow.prop(gpl, "use_solo_mode", text="Show Only On Keyframed") + col = row.column() sub = col.column(align=True) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 5342ae44d11..5c2cf8d529f 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -245,6 +245,18 @@ class VIEW3D_HT_header(Header): text=lk_name, icon=lk_icon, ) + + if object_mode in {'PAINT_GPENCIL'}: + if context.workspace.tools.from_space_view3d_mode(object_mode).name == "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() @@ -3955,6 +3967,7 @@ class VIEW3D_MT_edit_gpencil(Menu): layout.menu("VIEW3D_MT_edit_gpencil_delete") 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.separator() @@ -5317,7 +5330,47 @@ class VIEW3D_PT_gpencil_lock(Panel): col = row.column() col.prop(context.tool_settings.gpencil_sculpt, "lock_axis", expand=True) + +class VIEW3D_PT_gpencil_guide(Panel): + bl_space_type = 'VIEW_3D' + bl_region_type = 'HEADER' + bl_label = "Guides" + + @staticmethod + def draw(self, context): + from math import pi + settings = context.tool_settings.gpencil_sculpt.guide + layout = self.layout + layout.label(text="Guides") + + col = layout.column() + col.active = settings.use_guide + col.prop(settings, "type", expand=True) + + if settings.type in {'PARALLEL'}: + col.prop(settings, "angle") + row = col.row(align=True) + + col.prop(settings, "use_snapping") + if settings.use_snapping: + + if settings.type in {'RADIAL'}: + col.prop(settings, "angle_snap") + else: + col.prop(settings, "spacing") + + col.label(text="Reference Point") + row = col.row(align=True) + row.prop(settings, "reference_point", expand=True) + if settings.reference_point in {'CUSTOM'}: + col.prop(settings, "location", text="Custom Location") + if settings.reference_point in {'OBJECT'}: + col.prop(settings, "reference_object", text="Object Location") + if not settings.reference_object: + col.label(text="No object selected, using cursor") + + class VIEW3D_PT_overlay_gpencil_options(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'HEADER' @@ -5560,6 +5613,7 @@ class VIEW3D_MT_gpencil_edit_specials(Menu): layout.operator("gpencil.stroke_join", text="Join").type = 'JOIN' layout.operator("gpencil.stroke_join", text="Join & Copy").type = 'JOINCOPY' layout.operator("gpencil.stroke_flip", text="Flip Direction") + layout.operator_menu_enum("gpencil.stroke_caps_set", text="Toggle Caps...", property="type") layout.separator() layout.operator("gpencil.frame_duplicate", text="Duplicate Active Frame") @@ -5787,6 +5841,7 @@ classes = ( VIEW3D_PT_snapping, VIEW3D_PT_gpencil_origin, VIEW3D_PT_gpencil_lock, + VIEW3D_PT_gpencil_guide, VIEW3D_PT_transform_orientations, VIEW3D_PT_overlay_gpencil_options, VIEW3D_PT_context_properties, -- cgit v1.2.3