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/scripts/startup/bl_ui/properties_grease_pencil_common.py
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/scripts/startup/bl_ui/properties_grease_pencil_common.py')
-rw-r--r--release/scripts/startup/bl_ui/properties_grease_pencil_common.py34
1 files changed, 32 insertions, 2 deletions
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,