2018-07-31 08:22:19 +00:00
|
|
|
# ##### BEGIN GPL LICENSE BLOCK #####
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software Foundation,
|
|
|
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
#
|
|
|
|
# ##### END GPL LICENSE BLOCK #####
|
|
|
|
|
|
|
|
# <pep8 compliant>
|
|
|
|
import bpy
|
|
|
|
from bpy.types import Menu, Panel, UIList
|
|
|
|
from rna_prop_ui import PropertyPanel
|
2019-03-13 01:41:22 +00:00
|
|
|
from bl_ui.utils import PresetPanel
|
2018-07-31 08:22:19 +00:00
|
|
|
|
2019-06-11 06:08:32 +00:00
|
|
|
from bl_ui.properties_grease_pencil_common import (
|
2018-12-02 02:26:10 +00:00
|
|
|
GreasePencilMaterialsPanel,
|
|
|
|
)
|
|
|
|
|
2018-07-31 08:22:19 +00:00
|
|
|
|
2020-03-17 17:29:18 +00:00
|
|
|
class GPENCIL_MT_material_context_menu(Menu):
|
2019-11-18 13:33:14 +00:00
|
|
|
bl_label = "Material Specials"
|
2018-07-31 08:22:19 +00:00
|
|
|
|
2019-04-19 05:32:24 +00:00
|
|
|
def draw(self, _context):
|
2018-07-31 08:22:19 +00:00
|
|
|
layout = self.layout
|
|
|
|
|
2020-03-17 17:29:18 +00:00
|
|
|
layout.operator("gpencil.material_reveal", icon='RESTRICT_VIEW_OFF', text="Show All")
|
|
|
|
layout.operator("gpencil.material_hide", icon='RESTRICT_VIEW_ON', text="Hide Others").unselected = True
|
2018-07-31 08:22:19 +00:00
|
|
|
|
|
|
|
layout.separator()
|
|
|
|
|
2020-03-17 17:29:18 +00:00
|
|
|
layout.operator("gpencil.material_lock_all", icon='LOCKED', text="Lock All")
|
|
|
|
layout.operator("gpencil.material_unlock_all", icon='UNLOCKED', text="UnLock All")
|
2018-07-31 08:22:19 +00:00
|
|
|
|
2020-03-17 17:29:18 +00:00
|
|
|
layout.operator("gpencil.material_lock_unused", text="Lock Unselected")
|
2018-09-27 20:05:32 +00:00
|
|
|
layout.operator("gpencil.lock_layer", text="Lock Unused")
|
2018-07-31 08:22:19 +00:00
|
|
|
|
2019-08-20 16:11:16 +00:00
|
|
|
layout.separator()
|
|
|
|
|
|
|
|
layout.operator("object.material_slot_remove_unused")
|
2020-03-09 15:27:24 +00:00
|
|
|
layout.operator("gpencil.stroke_merge_material", text="Merge Similar")
|
|
|
|
|
|
|
|
layout.separator()
|
|
|
|
layout.operator("gpencil.material_to_vertex_color", text="Convert Materials to Vertex Color")
|
|
|
|
layout.operator("gpencil.extract_palette_vertex", text="Extract Palette from Vertex Color")
|
2018-07-31 08:22:19 +00:00
|
|
|
|
2019-09-09 20:11:52 +00:00
|
|
|
|
2018-07-31 08:22:19 +00:00
|
|
|
class GPENCIL_UL_matslots(UIList):
|
2019-04-19 05:32:24 +00:00
|
|
|
def draw_item(self, _context, layout, _data, item, icon, _active_data, _active_propname, _index):
|
2018-07-31 08:22:19 +00:00
|
|
|
slot = item
|
|
|
|
ma = slot.material
|
|
|
|
if (ma is not None) and (ma.grease_pencil is not None):
|
|
|
|
gpcolor = ma.grease_pencil
|
|
|
|
|
|
|
|
if self.layout_type in {'DEFAULT', 'COMPACT'}:
|
|
|
|
if gpcolor.lock:
|
|
|
|
layout.active = False
|
|
|
|
|
|
|
|
row = layout.row(align=True)
|
|
|
|
row.enabled = not gpcolor.lock
|
|
|
|
row.prop(ma, "name", text="", emboss=False, icon_value=icon)
|
|
|
|
|
|
|
|
row = layout.row(align=True)
|
|
|
|
if gpcolor.ghost is True:
|
2018-10-01 08:45:50 +00:00
|
|
|
icon = 'ONIONSKIN_OFF'
|
2018-07-31 08:22:19 +00:00
|
|
|
else:
|
2018-10-01 08:45:50 +00:00
|
|
|
icon = 'ONIONSKIN_ON'
|
2018-07-31 08:22:19 +00:00
|
|
|
row.prop(gpcolor, "ghost", text="", icon=icon, emboss=False)
|
2019-12-04 13:13:21 +00:00
|
|
|
row.prop(gpcolor, "hide", text="", emboss=False)
|
|
|
|
row.prop(gpcolor, "lock", text="", emboss=False)
|
2018-07-31 08:22:19 +00:00
|
|
|
|
|
|
|
elif self.layout_type == 'GRID':
|
|
|
|
layout.alignment = 'CENTER'
|
|
|
|
layout.label(text="", icon_value=icon)
|
|
|
|
|
|
|
|
|
|
|
|
class GPMaterialButtonsPanel:
|
|
|
|
bl_space_type = 'PROPERTIES'
|
|
|
|
bl_region_type = 'WINDOW'
|
|
|
|
bl_context = "material"
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
Properties Editor: Grease Pencil and pinning fixes
The UI was trying to use screen_context.c for its poll and draw
functions. So the active object and active object data and active layer
was used in the UI, instead of the context one.
Besides, for the material, the wrong context path was used altogether
when the active object was a greasepencil.
This would lead to all sort of pinning problems:
* A Mesh panel is pinned, but the active object is a grease pencil, the
grease pencil panels would show.
* If a Grease Pencil (data) panel is pinned, but the active object is not
the one pinned, nothing would show.
* Material panels and pinning were totally broken, showing the material
context for pinned mesh data panels even.
I also sanitized the name of the panels, their inheritance and poll
functions.
Reviewers: antoniov, brecht
Subscribers: billrey
Differential Revision: https://developer.blender.org/D4470
2019-03-07 14:55:03 +00:00
|
|
|
ma = context.material
|
|
|
|
return ma and ma.grease_pencil
|
2018-07-31 08:22:19 +00:00
|
|
|
|
|
|
|
|
2019-03-09 15:50:10 +00:00
|
|
|
class MATERIAL_PT_gpencil_slots(GreasePencilMaterialsPanel, Panel):
|
2018-07-31 08:22:19 +00:00
|
|
|
bl_label = "Grease Pencil Material Slots"
|
|
|
|
bl_space_type = 'PROPERTIES'
|
|
|
|
bl_region_type = 'WINDOW'
|
|
|
|
bl_context = "material"
|
|
|
|
bl_options = {'HIDE_HEADER'}
|
|
|
|
|
2019-03-09 15:50:10 +00:00
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
ob = context.object
|
|
|
|
ma = context.material
|
|
|
|
|
|
|
|
return (ma and ma.grease_pencil) or (ob and ob.type == 'GPENCIL')
|
|
|
|
|
2018-07-31 08:22:19 +00:00
|
|
|
|
|
|
|
# Used as parent for "Stroke" and "Fill" panels
|
|
|
|
class MATERIAL_PT_gpencil_surface(GPMaterialButtonsPanel, Panel):
|
|
|
|
bl_label = "Surface"
|
|
|
|
|
2019-04-19 05:32:24 +00:00
|
|
|
def draw_header_preset(self, _context):
|
2018-08-16 09:24:28 +00:00
|
|
|
MATERIAL_PT_gpencil_material_presets.draw_panel_header(self.layout)
|
|
|
|
|
2019-04-19 05:32:24 +00:00
|
|
|
def draw(self, _context):
|
2018-07-31 08:22:19 +00:00
|
|
|
layout = self.layout
|
|
|
|
layout.use_property_split = True
|
|
|
|
|
|
|
|
|
|
|
|
class MATERIAL_PT_gpencil_strokecolor(GPMaterialButtonsPanel, Panel):
|
|
|
|
bl_label = "Stroke"
|
|
|
|
bl_parent_id = 'MATERIAL_PT_gpencil_surface'
|
|
|
|
|
2018-11-03 07:46:21 +00:00
|
|
|
def draw_header(self, context):
|
Properties Editor: Grease Pencil and pinning fixes
The UI was trying to use screen_context.c for its poll and draw
functions. So the active object and active object data and active layer
was used in the UI, instead of the context one.
Besides, for the material, the wrong context path was used altogether
when the active object was a greasepencil.
This would lead to all sort of pinning problems:
* A Mesh panel is pinned, but the active object is a grease pencil, the
grease pencil panels would show.
* If a Grease Pencil (data) panel is pinned, but the active object is not
the one pinned, nothing would show.
* Material panels and pinning were totally broken, showing the material
context for pinned mesh data panels even.
I also sanitized the name of the panels, their inheritance and poll
functions.
Reviewers: antoniov, brecht
Subscribers: billrey
Differential Revision: https://developer.blender.org/D4470
2019-03-07 14:55:03 +00:00
|
|
|
ma = context.material
|
2018-11-03 07:46:21 +00:00
|
|
|
if ma is not None and ma.grease_pencil is not None:
|
|
|
|
gpcolor = ma.grease_pencil
|
2019-07-20 20:57:47 +00:00
|
|
|
self.layout.enabled = not gpcolor.lock
|
2018-11-03 07:46:21 +00:00
|
|
|
self.layout.prop(gpcolor, "show_stroke", text="")
|
|
|
|
|
2018-07-31 08:22:19 +00:00
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
layout.use_property_split = True
|
|
|
|
|
Properties Editor: Grease Pencil and pinning fixes
The UI was trying to use screen_context.c for its poll and draw
functions. So the active object and active object data and active layer
was used in the UI, instead of the context one.
Besides, for the material, the wrong context path was used altogether
when the active object was a greasepencil.
This would lead to all sort of pinning problems:
* A Mesh panel is pinned, but the active object is a grease pencil, the
grease pencil panels would show.
* If a Grease Pencil (data) panel is pinned, but the active object is not
the one pinned, nothing would show.
* Material panels and pinning were totally broken, showing the material
context for pinned mesh data panels even.
I also sanitized the name of the panels, their inheritance and poll
functions.
Reviewers: antoniov, brecht
Subscribers: billrey
Differential Revision: https://developer.blender.org/D4470
2019-03-07 14:55:03 +00:00
|
|
|
ma = context.material
|
2018-07-31 08:22:19 +00:00
|
|
|
if ma is not None and ma.grease_pencil is not None:
|
|
|
|
gpcolor = ma.grease_pencil
|
|
|
|
|
|
|
|
col = layout.column()
|
2019-07-20 20:57:47 +00:00
|
|
|
col.enabled = not gpcolor.lock
|
2018-07-31 08:22:19 +00:00
|
|
|
|
|
|
|
col.prop(gpcolor, "mode")
|
|
|
|
|
|
|
|
col.prop(gpcolor, "stroke_style", text="Style")
|
|
|
|
|
2020-03-09 15:27:24 +00:00
|
|
|
row = col.row()
|
|
|
|
row.prop(gpcolor, "color", text="Base Color")
|
|
|
|
|
2018-07-31 08:22:19 +00:00
|
|
|
if gpcolor.stroke_style == 'TEXTURE':
|
|
|
|
row = col.row()
|
|
|
|
row.enabled = not gpcolor.lock
|
|
|
|
col = row.column(align=True)
|
|
|
|
col.template_ID(gpcolor, "stroke_image", open="image.open")
|
2020-03-09 15:27:24 +00:00
|
|
|
|
|
|
|
if gpcolor.stroke_style == 'TEXTURE':
|
|
|
|
row = col.row()
|
|
|
|
row.prop(gpcolor, "mix_stroke_factor", text="Blend", slider=True)
|
2019-04-15 14:07:56 +00:00
|
|
|
if gpcolor.mode == 'LINE':
|
|
|
|
col.prop(gpcolor, "pixel_size", text="UV Factor")
|
|
|
|
|
2019-04-15 08:32:06 +00:00
|
|
|
if gpcolor.mode in {'DOTS', 'BOX'}:
|
2019-05-14 15:28:31 +00:00
|
|
|
col.prop(gpcolor, "alignment_mode")
|
2019-04-15 08:32:06 +00:00
|
|
|
|
2020-03-09 15:27:24 +00:00
|
|
|
if gpcolor.mode == 'LINE':
|
2019-08-09 09:04:14 +00:00
|
|
|
col.prop(gpcolor, "use_overlap_strokes")
|
2018-07-31 08:22:19 +00:00
|
|
|
|
2019-09-09 20:11:52 +00:00
|
|
|
|
2018-07-31 08:22:19 +00:00
|
|
|
class MATERIAL_PT_gpencil_fillcolor(GPMaterialButtonsPanel, Panel):
|
|
|
|
bl_label = "Fill"
|
|
|
|
bl_parent_id = 'MATERIAL_PT_gpencil_surface'
|
|
|
|
|
2018-11-03 07:46:21 +00:00
|
|
|
def draw_header(self, context):
|
Properties Editor: Grease Pencil and pinning fixes
The UI was trying to use screen_context.c for its poll and draw
functions. So the active object and active object data and active layer
was used in the UI, instead of the context one.
Besides, for the material, the wrong context path was used altogether
when the active object was a greasepencil.
This would lead to all sort of pinning problems:
* A Mesh panel is pinned, but the active object is a grease pencil, the
grease pencil panels would show.
* If a Grease Pencil (data) panel is pinned, but the active object is not
the one pinned, nothing would show.
* Material panels and pinning were totally broken, showing the material
context for pinned mesh data panels even.
I also sanitized the name of the panels, their inheritance and poll
functions.
Reviewers: antoniov, brecht
Subscribers: billrey
Differential Revision: https://developer.blender.org/D4470
2019-03-07 14:55:03 +00:00
|
|
|
ma = context.material
|
|
|
|
gpcolor = ma.grease_pencil
|
2019-07-20 20:57:47 +00:00
|
|
|
self.layout.enabled = not gpcolor.lock
|
Properties Editor: Grease Pencil and pinning fixes
The UI was trying to use screen_context.c for its poll and draw
functions. So the active object and active object data and active layer
was used in the UI, instead of the context one.
Besides, for the material, the wrong context path was used altogether
when the active object was a greasepencil.
This would lead to all sort of pinning problems:
* A Mesh panel is pinned, but the active object is a grease pencil, the
grease pencil panels would show.
* If a Grease Pencil (data) panel is pinned, but the active object is not
the one pinned, nothing would show.
* Material panels and pinning were totally broken, showing the material
context for pinned mesh data panels even.
I also sanitized the name of the panels, their inheritance and poll
functions.
Reviewers: antoniov, brecht
Subscribers: billrey
Differential Revision: https://developer.blender.org/D4470
2019-03-07 14:55:03 +00:00
|
|
|
self.layout.prop(gpcolor, "show_fill", text="")
|
2018-11-03 07:46:21 +00:00
|
|
|
|
2018-07-31 08:22:19 +00:00
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
layout.use_property_split = True
|
|
|
|
|
Properties Editor: Grease Pencil and pinning fixes
The UI was trying to use screen_context.c for its poll and draw
functions. So the active object and active object data and active layer
was used in the UI, instead of the context one.
Besides, for the material, the wrong context path was used altogether
when the active object was a greasepencil.
This would lead to all sort of pinning problems:
* A Mesh panel is pinned, but the active object is a grease pencil, the
grease pencil panels would show.
* If a Grease Pencil (data) panel is pinned, but the active object is not
the one pinned, nothing would show.
* Material panels and pinning were totally broken, showing the material
context for pinned mesh data panels even.
I also sanitized the name of the panels, their inheritance and poll
functions.
Reviewers: antoniov, brecht
Subscribers: billrey
Differential Revision: https://developer.blender.org/D4470
2019-03-07 14:55:03 +00:00
|
|
|
ma = context.material
|
|
|
|
gpcolor = ma.grease_pencil
|
2018-07-31 08:22:19 +00:00
|
|
|
|
Properties Editor: Grease Pencil and pinning fixes
The UI was trying to use screen_context.c for its poll and draw
functions. So the active object and active object data and active layer
was used in the UI, instead of the context one.
Besides, for the material, the wrong context path was used altogether
when the active object was a greasepencil.
This would lead to all sort of pinning problems:
* A Mesh panel is pinned, but the active object is a grease pencil, the
grease pencil panels would show.
* If a Grease Pencil (data) panel is pinned, but the active object is not
the one pinned, nothing would show.
* Material panels and pinning were totally broken, showing the material
context for pinned mesh data panels even.
I also sanitized the name of the panels, their inheritance and poll
functions.
Reviewers: antoniov, brecht
Subscribers: billrey
Differential Revision: https://developer.blender.org/D4470
2019-03-07 14:55:03 +00:00
|
|
|
# color settings
|
|
|
|
col = layout.column()
|
2019-07-20 20:57:47 +00:00
|
|
|
col.enabled = not gpcolor.lock
|
Properties Editor: Grease Pencil and pinning fixes
The UI was trying to use screen_context.c for its poll and draw
functions. So the active object and active object data and active layer
was used in the UI, instead of the context one.
Besides, for the material, the wrong context path was used altogether
when the active object was a greasepencil.
This would lead to all sort of pinning problems:
* A Mesh panel is pinned, but the active object is a grease pencil, the
grease pencil panels would show.
* If a Grease Pencil (data) panel is pinned, but the active object is not
the one pinned, nothing would show.
* Material panels and pinning were totally broken, showing the material
context for pinned mesh data panels even.
I also sanitized the name of the panels, their inheritance and poll
functions.
Reviewers: antoniov, brecht
Subscribers: billrey
Differential Revision: https://developer.blender.org/D4470
2019-03-07 14:55:03 +00:00
|
|
|
col.prop(gpcolor, "fill_style", text="Style")
|
2018-07-31 08:22:19 +00:00
|
|
|
|
2020-03-09 15:27:24 +00:00
|
|
|
if gpcolor.fill_style == 'SOLID':
|
|
|
|
col.prop(gpcolor, "fill_color", text="Base Color")
|
2018-07-31 08:22:19 +00:00
|
|
|
|
2020-03-09 15:27:24 +00:00
|
|
|
elif gpcolor.fill_style == 'GRADIENT':
|
|
|
|
col.prop(gpcolor, "gradient_type")
|
2018-07-31 08:22:19 +00:00
|
|
|
|
2020-03-09 15:27:24 +00:00
|
|
|
col.prop(gpcolor, "fill_color", text="Base Color")
|
|
|
|
col.prop(gpcolor, "mix_color", text="Secondary Color")
|
2020-03-27 15:38:15 +00:00
|
|
|
col.prop(gpcolor, "mix_factor", text="Blend", slider=True)
|
2020-03-09 15:27:24 +00:00
|
|
|
col.prop(gpcolor, "flip", text="Flip Colors")
|
2018-07-31 08:22:19 +00:00
|
|
|
|
2020-03-09 15:27:24 +00:00
|
|
|
col.prop(gpcolor, "texture_offset", text="Location")
|
2020-03-27 15:38:15 +00:00
|
|
|
|
|
|
|
row = col.row()
|
|
|
|
row.enabled = gpcolor.gradient_type == 'LINEAR'
|
|
|
|
row.prop(gpcolor, "texture_angle", text="Rotation")
|
|
|
|
|
2020-03-09 15:27:24 +00:00
|
|
|
col.prop(gpcolor, "texture_scale", text="Scale")
|
2018-07-31 08:22:19 +00:00
|
|
|
|
2020-03-09 15:27:24 +00:00
|
|
|
elif gpcolor.fill_style == 'TEXTURE':
|
2020-03-27 15:38:15 +00:00
|
|
|
col.prop(gpcolor, "fill_color", text="Base Color")
|
|
|
|
|
Properties Editor: Grease Pencil and pinning fixes
The UI was trying to use screen_context.c for its poll and draw
functions. So the active object and active object data and active layer
was used in the UI, instead of the context one.
Besides, for the material, the wrong context path was used altogether
when the active object was a greasepencil.
This would lead to all sort of pinning problems:
* A Mesh panel is pinned, but the active object is a grease pencil, the
grease pencil panels would show.
* If a Grease Pencil (data) panel is pinned, but the active object is not
the one pinned, nothing would show.
* Material panels and pinning were totally broken, showing the material
context for pinned mesh data panels even.
I also sanitized the name of the panels, their inheritance and poll
functions.
Reviewers: antoniov, brecht
Subscribers: billrey
Differential Revision: https://developer.blender.org/D4470
2019-03-07 14:55:03 +00:00
|
|
|
col.template_ID(gpcolor, "fill_image", open="image.open")
|
2018-07-31 08:22:19 +00:00
|
|
|
|
2020-03-27 15:38:15 +00:00
|
|
|
col.prop(gpcolor, "mix_factor", text="Blend", slider=True)
|
2018-07-31 08:22:19 +00:00
|
|
|
|
2020-03-09 15:27:24 +00:00
|
|
|
col.prop(gpcolor, "texture_offset", text="Location")
|
|
|
|
col.prop(gpcolor, "texture_angle", text="Rotation")
|
Properties Editor: Grease Pencil and pinning fixes
The UI was trying to use screen_context.c for its poll and draw
functions. So the active object and active object data and active layer
was used in the UI, instead of the context one.
Besides, for the material, the wrong context path was used altogether
when the active object was a greasepencil.
This would lead to all sort of pinning problems:
* A Mesh panel is pinned, but the active object is a grease pencil, the
grease pencil panels would show.
* If a Grease Pencil (data) panel is pinned, but the active object is not
the one pinned, nothing would show.
* Material panels and pinning were totally broken, showing the material
context for pinned mesh data panels even.
I also sanitized the name of the panels, their inheritance and poll
functions.
Reviewers: antoniov, brecht
Subscribers: billrey
Differential Revision: https://developer.blender.org/D4470
2019-03-07 14:55:03 +00:00
|
|
|
col.prop(gpcolor, "texture_scale", text="Scale")
|
|
|
|
col.prop(gpcolor, "texture_clamp", text="Clip Image")
|
2018-07-31 08:22:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
class MATERIAL_PT_gpencil_preview(GPMaterialButtonsPanel, Panel):
|
|
|
|
bl_label = "Preview"
|
|
|
|
COMPAT_ENGINES = {'BLENDER_EEVEE'}
|
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
|
|
|
|
|
|
|
def draw(self, context):
|
Properties Editor: Grease Pencil and pinning fixes
The UI was trying to use screen_context.c for its poll and draw
functions. So the active object and active object data and active layer
was used in the UI, instead of the context one.
Besides, for the material, the wrong context path was used altogether
when the active object was a greasepencil.
This would lead to all sort of pinning problems:
* A Mesh panel is pinned, but the active object is a grease pencil, the
grease pencil panels would show.
* If a Grease Pencil (data) panel is pinned, but the active object is not
the one pinned, nothing would show.
* Material panels and pinning were totally broken, showing the material
context for pinned mesh data panels even.
I also sanitized the name of the panels, their inheritance and poll
functions.
Reviewers: antoniov, brecht
Subscribers: billrey
Differential Revision: https://developer.blender.org/D4470
2019-03-07 14:55:03 +00:00
|
|
|
ma = context.material
|
2018-08-28 02:34:51 +00:00
|
|
|
self.layout.label(text=ma.name)
|
2018-07-31 08:22:19 +00:00
|
|
|
self.layout.template_preview(ma)
|
|
|
|
|
|
|
|
|
|
|
|
class MATERIAL_PT_gpencil_custom_props(GPMaterialButtonsPanel, PropertyPanel, Panel):
|
2018-11-26 18:00:01 +00:00
|
|
|
COMPAT_ENGINES = {'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
|
2018-07-31 08:22:19 +00:00
|
|
|
_context_path = "object.active_material"
|
|
|
|
_property_type = bpy.types.Material
|
|
|
|
|
|
|
|
|
|
|
|
class MATERIAL_PT_gpencil_options(GPMaterialButtonsPanel, Panel):
|
|
|
|
bl_label = "Options"
|
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
layout.use_property_split = True
|
|
|
|
|
Properties Editor: Grease Pencil and pinning fixes
The UI was trying to use screen_context.c for its poll and draw
functions. So the active object and active object data and active layer
was used in the UI, instead of the context one.
Besides, for the material, the wrong context path was used altogether
when the active object was a greasepencil.
This would lead to all sort of pinning problems:
* A Mesh panel is pinned, but the active object is a grease pencil, the
grease pencil panels would show.
* If a Grease Pencil (data) panel is pinned, but the active object is not
the one pinned, nothing would show.
* Material panels and pinning were totally broken, showing the material
context for pinned mesh data panels even.
I also sanitized the name of the panels, their inheritance and poll
functions.
Reviewers: antoniov, brecht
Subscribers: billrey
Differential Revision: https://developer.blender.org/D4470
2019-03-07 14:55:03 +00:00
|
|
|
ma = context.material
|
|
|
|
gpcolor = ma.grease_pencil
|
|
|
|
layout.prop(gpcolor, "pass_index")
|
2018-07-31 08:22:19 +00:00
|
|
|
|
2018-08-28 11:00:25 +00:00
|
|
|
|
2019-03-13 01:41:22 +00:00
|
|
|
class MATERIAL_PT_gpencil_material_presets(PresetPanel, Panel):
|
2018-08-16 09:24:28 +00:00
|
|
|
"""Material settings"""
|
|
|
|
bl_label = "Material Presets"
|
|
|
|
preset_subdir = "gpencil_material"
|
|
|
|
preset_operator = "script.execute_preset"
|
|
|
|
preset_add_operator = "scene.gpencil_material_preset_add"
|
|
|
|
|
2018-07-31 08:22:19 +00:00
|
|
|
|
2019-09-09 20:11:52 +00:00
|
|
|
classes = (
|
|
|
|
GPENCIL_UL_matslots,
|
2020-03-17 17:29:18 +00:00
|
|
|
GPENCIL_MT_material_context_menu,
|
2018-07-31 08:22:19 +00:00
|
|
|
MATERIAL_PT_gpencil_slots,
|
|
|
|
MATERIAL_PT_gpencil_preview,
|
2018-08-16 09:24:28 +00:00
|
|
|
MATERIAL_PT_gpencil_material_presets,
|
2018-07-31 08:22:19 +00:00
|
|
|
MATERIAL_PT_gpencil_surface,
|
|
|
|
MATERIAL_PT_gpencil_strokecolor,
|
|
|
|
MATERIAL_PT_gpencil_fillcolor,
|
|
|
|
MATERIAL_PT_gpencil_options,
|
2019-09-09 20:11:52 +00:00
|
|
|
MATERIAL_PT_gpencil_custom_props,
|
|
|
|
)
|
2018-07-31 08:22:19 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__": # only for live edit.
|
|
|
|
from bpy.utils import register_class
|
2020-03-09 15:27:24 +00:00
|
|
|
|
2018-07-31 08:22:19 +00:00
|
|
|
for cls in classes:
|
|
|
|
register_class(cls)
|