Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Vazquez <blendergit@gmail.com>2020-04-30 17:12:34 +0300
committerAntonio Vazquez <blendergit@gmail.com>2020-04-30 17:13:23 +0300
commit6a7e9f2b7647fb1883fc77f72c3d411c0a692cf7 (patch)
treed4de80b3a153a5dea35b669e39912917b6ebb95d /release
parentdc0a564c0616e181e06cd4f38b6c0920ea9e2348 (diff)
GPencil: Add material selector to context menus
Now it's possible to select the material in context menu and new menu to select material. The patch and workflow has been tested in greasepencil-object branch. * New Material selector in Draw mode Context menu: {F8499259} * Pressing `U`key in Draw mode display material menu. {F8503224} Reviewed By: mendio, pepeland Differential Revision: https://developer.blender.org/D7554
Diffstat (limited to 'release')
-rw-r--r--release/scripts/presets/keyconfig/keymap_data/blender_default.py2
-rw-r--r--release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py2
-rw-r--r--release/scripts/startup/bl_ui/properties_grease_pencil_common.py34
-rw-r--r--release/scripts/startup/bl_ui/space_view3d.py15
4 files changed, 50 insertions, 3 deletions
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 35ec4257976..604c5231df2 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -3226,6 +3226,8 @@ def km_grease_pencil_stroke_paint_mode(params):
{"properties": [("unselected", True)]}),
# Active layer
op_menu("GPENCIL_MT_layer_active", {"type": 'Y', "value": 'PRESS'}),
+ # Active material
+ op_menu("GPENCIL_MT_material_active", {"type": 'U', "value": 'PRESS'}),
# Keyframe menu
op_menu("VIEW3D_MT_gpencil_animation", {"type": 'I', "value": 'PRESS'}),
# Draw context menu
diff --git a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
index a640c9e8ee3..842a12ed249 100644
--- a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
+++ b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
@@ -2374,7 +2374,7 @@ def km_grease_pencil_stroke_paint_mode(params):
op_tool_cycle("builtin.cutter", {"type": 'K', "value": 'PRESS'}),
op_tool_cycle("builtin.cursor", {"type": 'C', "value": 'PRESS'}),
# Active layer
- op_menu("GPENCIL_MT_layer_active", {"type": 'M', "value": 'PRESS'}),
+ op_menu("GPENCIL_MT_layer_active", {"type": 'Y', "value": 'PRESS'}),
# Keyframe menu
op_menu("VIEW3D_MT_gpencil_animation", {"type": 'I', "value": 'PRESS'}),
])
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 0f6a51ad2d0..fea4406cb8c 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -361,6 +361,35 @@ class GPENCIL_MT_layer_active(Menu):
layout.operator("gpencil.layer_add", text="New Layer", icon='ADD')
+class GPENCIL_MT_material_active(Menu):
+ bl_label = "Change Active Material"
+
+ @classmethod
+ def poll(cls, context):
+ ob = context.active_object
+ tool_settings = context.scene.tool_settings
+ mode = tool_settings.gpencil_paint.color_mode
+ if mode != 'MATERIAL':
+ return False
+
+ if ob is None or len(ob.material_slots) == 0:
+ return False
+
+ return True
+
+ def draw(self, context):
+ layout = self.layout
+ layout.operator_context = 'INVOKE_REGION_WIN'
+ ob = context.active_object
+ mat_active = ob.active_material
+
+ for slot in ob.material_slots:
+ mat = slot.material
+ if mat:
+ icon = mat.id_data.preview.icon_id
+ layout.operator("gpencil.material_set", text=mat.name, icon_value=icon).slot = mat.name
+
+
class GPENCIL_MT_gpencil_draw_delete(Menu):
bl_label = "Delete"
@@ -632,8 +661,8 @@ class GreasePencilMaterialsPanel:
if ob.data.use_stroke_edit_mode:
row = layout.row(align=True)
row.operator("gpencil.stroke_change_color", text="Assign")
- row.operator("gpencil.select_material", text="Select").deselect = False
- row.operator("gpencil.select_material", text="Deselect").deselect = True
+ row.operator("gpencil.material_select", text="Select").deselect = False
+ row.operator("gpencil.material_select", text="Deselect").deselect = True
# stroke color
ma = None
if is_view3d and brush is not None:
@@ -931,6 +960,7 @@ classes = (
GPENCIL_MT_cleanup,
GPENCIL_MT_move_to_layer,
GPENCIL_MT_layer_active,
+ GPENCIL_MT_material_active,
GPENCIL_MT_gpencil_draw_delete,
GPENCIL_MT_layer_mask_menu,
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index d7a063d09d1..3e4a3f5de4c 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -7060,6 +7060,18 @@ def draw_gpencil_layer_active(context, layout):
row.operator("gpencil.layer_remove", text="", icon='X')
+def draw_gpencil_material_active(context, layout):
+ ob = context.active_object
+ if ob and len(ob.material_slots) > 0 and ob.active_material_index >= 0:
+ ma = ob.material_slots[ob.active_material_index].material
+ if ma:
+ layout.label(text="Active Material")
+ row = layout.row(align=True)
+ row.operator_context = 'EXEC_REGION_WIN'
+ row.operator_menu_enum("gpencil.material_set", "slot", text="", icon='MATERIAL')
+ row.prop(ma, "name", text="")
+
+
class VIEW3D_PT_gpencil_sculpt_context_menu(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'WINDOW'
@@ -7133,6 +7145,9 @@ class VIEW3D_PT_gpencil_draw_context_menu(Panel):
# Layers
draw_gpencil_layer_active(context, layout)
+ # Material
+ if not is_vertex:
+ draw_gpencil_material_active(context, layout)
class VIEW3D_PT_gpencil_vertex_context_menu(Panel):