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
|
|
|
|
2019-03-11 23:59:57 +00:00
|
|
|
class GPENCIL_MT_color_context_menu(Menu):
|
2018-07-31 08:22:19 +00:00
|
|
|
bl_label = "Layer"
|
|
|
|
|
2019-04-19 05:32:24 +00:00
|
|
|
def draw(self, _context):
|
2018-07-31 08:22:19 +00:00
|
|
|
layout = self.layout
|
|
|
|
|
2018-10-01 08:45:50 +00:00
|
|
|
layout.operator("gpencil.color_reveal", icon='RESTRICT_VIEW_OFF', text="Show All")
|
|
|
|
layout.operator("gpencil.color_hide", icon='RESTRICT_VIEW_ON', text="Hide Others").unselected = True
|
2018-07-31 08:22:19 +00:00
|
|
|
|
|
|
|
layout.separator()
|
|
|
|
|
|
|
|
layout.operator("gpencil.color_lock_all", icon='LOCKED', text="Lock All")
|
|
|
|
layout.operator("gpencil.color_unlock_all", icon='UNLOCKED', text="UnLock All")
|
|
|
|
|
2018-09-27 20:05:32 +00:00
|
|
|
layout.operator("gpencil.stroke_lock_color", text="Lock Unselected")
|
|
|
|
layout.operator("gpencil.lock_layer", text="Lock Unused")
|
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)
|
|
|
|
row.prop(gpcolor, "lock", text="", emboss=False)
|
|
|
|
row.prop(gpcolor, "hide", text="", emboss=False)
|
|
|
|
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)
|
|
|
|
|
|
|
|
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")
|
|
|
|
|
|
|
|
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")
|
2019-04-15 14:07:56 +00:00
|
|
|
if gpcolor.mode == 'LINE':
|
|
|
|
col.prop(gpcolor, "pixel_size", text="UV Factor")
|
|
|
|
|
2019-06-30 07:30:05 +00:00
|
|
|
col.prop(gpcolor, "use_stroke_pattern", text="Use As Stencil Mask")
|
2019-04-18 12:19:00 +00:00
|
|
|
if gpcolor.use_stroke_pattern is False:
|
|
|
|
col.prop(gpcolor, "use_stroke_texture_mix", text="Mix Color")
|
|
|
|
if gpcolor.use_stroke_texture_mix is True:
|
|
|
|
col.prop(gpcolor, "mix_stroke_factor", text="Factor")
|
|
|
|
|
2019-05-21 14:27:01 +00:00
|
|
|
if (
|
|
|
|
gpcolor.stroke_style == 'SOLID' or
|
|
|
|
gpcolor.use_stroke_pattern or
|
|
|
|
gpcolor.use_stroke_texture_mix
|
|
|
|
):
|
2018-07-31 08:22:19 +00:00
|
|
|
col.prop(gpcolor, "color", text="Color")
|
|
|
|
|
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
|
|
|
|
2019-08-09 09:04:14 +00:00
|
|
|
if gpcolor.mode == 'LINE':
|
|
|
|
col.prop(gpcolor, "use_overlap_strokes")
|
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
|
|
|
|
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
|
|
|
if gpcolor.fill_style == 'GRADIENT':
|
|
|
|
col.prop(gpcolor, "gradient_type")
|
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
|
|
|
if gpcolor.fill_style != 'TEXTURE':
|
|
|
|
col.prop(gpcolor, "fill_color", text="Color")
|
2018-07-31 08:22:19 +00:00
|
|
|
|
2019-07-07 03:43:42 +00:00
|
|
|
if gpcolor.fill_style in {'GRADIENT', 'CHECKER'}:
|
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, "mix_color", text="Secondary Color")
|
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
|
|
|
if gpcolor.fill_style == 'GRADIENT':
|
|
|
|
col.prop(gpcolor, "mix_factor", text="Mix Factor", slider=True)
|
2018-07-31 08:22:19 +00:00
|
|
|
|
2019-07-07 03:43:42 +00:00
|
|
|
if gpcolor.fill_style in {'GRADIENT', 'CHECKER'}:
|
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, "flip", text="Flip Colors")
|
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
|
|
|
col.prop(gpcolor, "pattern_shift", text="Location")
|
|
|
|
col.prop(gpcolor, "pattern_scale", text="Scale")
|
2018-07-31 08:22:19 +00:00
|
|
|
|
2019-07-07 03:43:42 +00:00
|
|
|
if gpcolor.gradient_type == 'RADIAL' and gpcolor.fill_style not in {'SOLID', 'CHECKER'}:
|
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, "pattern_radius", text="Radius")
|
|
|
|
else:
|
|
|
|
if gpcolor.fill_style != 'SOLID':
|
|
|
|
col.prop(gpcolor, "pattern_angle", text="Angle")
|
2018-07-31 08:22:19 +00:00
|
|
|
|
2019-07-07 03:43:42 +00:00
|
|
|
if gpcolor.fill_style == 'CHECKER':
|
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, "pattern_gridsize", text="Box Size")
|
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
|
|
|
# Texture
|
2019-04-18 12:19:00 +00:00
|
|
|
if gpcolor.fill_style == 'TEXTURE' or (gpcolor.use_fill_texture_mix is True and gpcolor.fill_style == 'SOLID'):
|
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
|
|
|
|
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
|
|
|
if gpcolor.fill_style == 'TEXTURE':
|
2019-07-01 06:40:18 +00:00
|
|
|
col.prop(gpcolor, "use_fill_pattern", text="Use As Stencil Mask")
|
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
|
|
|
if gpcolor.use_fill_pattern is True:
|
|
|
|
col.prop(gpcolor, "fill_color", text="Color")
|
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
|
|
|
col.prop(gpcolor, "texture_offset", text="Offset")
|
|
|
|
col.prop(gpcolor, "texture_scale", text="Scale")
|
|
|
|
col.prop(gpcolor, "texture_angle")
|
|
|
|
col.prop(gpcolor, "texture_opacity")
|
|
|
|
col.prop(gpcolor, "texture_clamp", text="Clip Image")
|
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
|
|
|
if gpcolor.use_fill_pattern is False:
|
2019-04-18 12:19:00 +00:00
|
|
|
col.prop(gpcolor, "use_fill_texture_mix", text="Mix With Color")
|
2018-07-31 08:22:19 +00:00
|
|
|
|
2019-04-18 12:19:00 +00:00
|
|
|
if gpcolor.use_fill_texture_mix is 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
|
|
|
col.prop(gpcolor, "fill_color", text="Mix Color")
|
|
|
|
col.prop(gpcolor, "mix_factor", text="Mix Factor", slider=True)
|
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
|
|
|
|
|
|
|
classes = (
|
|
|
|
GPENCIL_UL_matslots,
|
2019-03-11 23:59:57 +00:00
|
|
|
GPENCIL_MT_color_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,
|
|
|
|
MATERIAL_PT_gpencil_custom_props,
|
|
|
|
)
|
|
|
|
|
|
|
|
if __name__ == "__main__": # only for live edit.
|
|
|
|
from bpy.utils import register_class
|
|
|
|
for cls in classes:
|
|
|
|
register_class(cls)
|