UI: Add brush controls to contextual menu for GPencil Draw and Sculpt modes
authorWilliam Reynish <billrey@me.com>
Mon, 11 Mar 2019 14:51:54 +0000 (15:51 +0100)
committerWilliam Reynish <billrey@me.com>
Mon, 11 Mar 2019 14:51:54 +0000 (15:51 +0100)
Maniphest task: T62130

release/scripts/presets/keyconfig/keymap_data/blender_default.py
release/scripts/startup/bl_ui/properties_grease_pencil_common.py
release/scripts/startup/bl_ui/space_view3d.py

index 793488761f984772ad6584b1cac502f01e5b05b0..474200c57542ae131c1b38ea58c9633d9087b937 100644 (file)
@@ -3047,7 +3047,7 @@ def km_grease_pencil_stroke_paint_mode(params):
         ("wm.radial_control", {"type": 'F', "value": 'PRESS'},
          {"properties": [("data_path_primary", 'tool_settings.gpencil_paint.brush.size')]}),
         # Draw context menu
-        op_menu("GPENCIL_MT_gpencil_draw_specials", params.context_menu_event),
+        op_panel("VIEW3D_PT_gpencil_draw_specials", params.context_menu_event),
         # Draw delete menu
         op_menu("GPENCIL_MT_gpencil_draw_delete", {"type": 'X', "value": 'PRESS'}),
     ])
@@ -3187,7 +3187,7 @@ def km_grease_pencil_stroke_sculpt_mode(params):
         ("wm.radial_control", {"type": 'F', "value": 'PRESS'},
          {"properties": [("data_path_primary", 'tool_settings.gpencil_sculpt.brush.size')]}),
         # Context menu
-        op_menu("VIEW3D_MT_gpencil_sculpt_specials", params.context_menu_event),
+        op_panel("VIEW3D_PT_gpencil_sculpt_specials", params.context_menu_event),
         # Display
         *_grease_pencil_display(),
     ])
index 68d1c17946269ff1500df9f15532ed0a6adc9978..9d2d6e927e9cc18969513975a3b9f04e78afd0ab 100644 (file)
@@ -616,24 +616,6 @@ class GPENCIL_MT_separate(Menu):
         layout.operator("gpencil.stroke_separate", text="Active Layer").mode = 'LAYER'
 
 
-class GPENCIL_MT_gpencil_draw_specials(Menu):
-    bl_label = "Draw Context Menu"
-
-    def draw(self, context):
-        layout = self.layout
-
-        layout.operator_context = 'INVOKE_REGION_WIN'
-
-        layout.operator("gpencil.blank_frame_add")
-        layout.operator("gpencil.frame_duplicate", text="Duplicate Active Frame")
-        layout.operator("gpencil.frame_duplicate", text="Duplicate Active Frame All Layers").mode = 'ALL'
-
-        layout.separator()
-
-        layout.operator("gpencil.active_frames_delete_all")
-        layout.operator("gpencil.delete", text="Delete Active Frame").type = 'FRAME'
-
-
 class GPENCIL_MT_gpencil_draw_delete(Menu):
     bl_label = "GPencil Draw Delete"
 
@@ -960,7 +942,6 @@ classes = (
     GPENCIL_MT_separate,
     GPENCIL_MT_cleanup,
 
-    GPENCIL_MT_gpencil_draw_specials,
     GPENCIL_MT_gpencil_draw_delete,
 
     GPENCIL_UL_annotation_layer,
index a2484a39281240da9a173eee7ce75aa6f593c775..472066702a4a3697ce32c7dedf67ff71229f4fc5 100644 (file)
@@ -5655,36 +5655,37 @@ class VIEW3D_MT_gpencil_edit_specials(Menu):
         layout.menu("VIEW3D_MT_edit_gpencil_delete")
 
 
-class VIEW3D_MT_gpencil_sculpt_specials(Menu):
+class VIEW3D_PT_gpencil_sculpt_specials(Panel):
+    bl_space_type = 'VIEW_3D'
+    bl_region_type = 'WINDOW'
     bl_label = "Sculpt Context Menu"
 
     def draw(self, context):
-        layout = self.layout
-
-        layout.operator_context = 'INVOKE_REGION_WIN'
-
-        # Add
-        layout.operator("gpencil.stroke_subdivide", text="Subdivide")
+        brush = context.tool_settings.gpencil_sculpt.brush
 
-        layout.separator()
+        layout = self.layout
 
-        # Modify
-        layout.menu("VIEW3D_MT_assign_material")
+        if context.mode == 'WEIGHT_GPENCIL':
+            layout.prop(brush, "weight")
+        layout.prop(brush, "size", slider=True)
+        layout.prop(brush, "strength")
 
-        layout.separator()
 
-        layout.operator("gpencil.frame_duplicate", text="Duplicate Active Frame")
-        layout.operator("gpencil.frame_duplicate", text="Duplicate Active Frame All Layers").mode = 'ALL'
+class VIEW3D_PT_gpencil_draw_specials(Panel):
+    bl_space_type = 'VIEW_3D'
+    bl_region_type = 'WINDOW'
+    bl_label = "Draw Context Menu"
 
-        if context.mode == 'WEIGHT_GPENCIL':
-            layout.separator()
-            layout.menu("VIEW3D_MT_gpencil_autoweights")
+    def draw(self, context):
+        brush = context.tool_settings.gpencil_paint.brush
+        gp_settings = brush.gpencil_settings
 
-        layout.separator()
+        layout = self.layout
 
-        # Remove
-        layout.operator("gpencil.stroke_simplify_fixed", text="Simplify")
-        layout.operator("gpencil.stroke_simplify", text="Simplify Adaptive")
+        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")
 
 
 class VIEW3D_PT_paint_vertex_specials(Panel):
@@ -5926,7 +5927,6 @@ classes = (
     VIEW3D_MT_gpencil_copy_layer,
     VIEW3D_MT_gpencil_autoweights,
     VIEW3D_MT_gpencil_edit_specials,
-    VIEW3D_MT_gpencil_sculpt_specials,
     VIEW3D_MT_edit_curve,
     VIEW3D_MT_edit_curve_ctrlpoints,
     VIEW3D_MT_edit_curve_segments,
@@ -5999,6 +5999,8 @@ classes = (
     VIEW3D_PT_paint_vertex_specials,
     VIEW3D_PT_paint_texture_specials,
     VIEW3D_PT_paint_weight_specials,
+    VIEW3D_PT_gpencil_sculpt_specials,
+    VIEW3D_PT_gpencil_draw_specials,
     VIEW3D_PT_sculpt_specials,
     TOPBAR_PT_gpencil_materials,
     TOPBAR_PT_annotation_layers,