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:
authorDalai Felinto <dfelinto@gmail.com>2019-03-07 17:55:03 +0300
committerDalai Felinto <dfelinto@gmail.com>2019-03-07 23:28:25 +0300
commit92d185faebeac60ec2591c2a7c0f870e7726593d (patch)
tree4e49a15d3c4e3f0c45cd9089fdf4567084b4e26e /release/scripts/startup/bl_ui/properties_material_gpencil.py
parent81a09628c29d788affb0686e9ebdce7dc6a09d2d (diff)
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
Diffstat (limited to 'release/scripts/startup/bl_ui/properties_material_gpencil.py')
-rw-r--r--release/scripts/startup/bl_ui/properties_material_gpencil.py123
1 files changed, 53 insertions, 70 deletions
diff --git a/release/scripts/startup/bl_ui/properties_material_gpencil.py b/release/scripts/startup/bl_ui/properties_material_gpencil.py
index 282f8d77515..c8691d15cc4 100644
--- a/release/scripts/startup/bl_ui/properties_material_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_material_gpencil.py
@@ -81,10 +81,8 @@ class GPMaterialButtonsPanel:
@classmethod
def poll(cls, context):
- ob = context.object
- return (ob and ob.type == 'GPENCIL' and
- ob.active_material and
- ob.active_material.grease_pencil)
+ ma = context.material
+ return ma and ma.grease_pencil
class MATERIAL_PT_gpencil_slots(GreasePencilMaterialsPanel, Panel):
@@ -99,18 +97,6 @@ class MATERIAL_PT_gpencil_slots(GreasePencilMaterialsPanel, Panel):
class MATERIAL_PT_gpencil_surface(GPMaterialButtonsPanel, Panel):
bl_label = "Surface"
- @classmethod
- def poll(cls, context):
- ob = context.object
- if not (ob and ob.type == 'GPENCIL'):
- return False
-
- ma = ob.active_material
- if not (ma and ma.grease_pencil):
- return False
-
- return True
-
def draw_header_preset(self, context):
MATERIAL_PT_gpencil_material_presets.draw_panel_header(self.layout)
@@ -125,7 +111,7 @@ class MATERIAL_PT_gpencil_strokecolor(GPMaterialButtonsPanel, Panel):
bl_parent_id = 'MATERIAL_PT_gpencil_surface'
def draw_header(self, context):
- ma = context.object.active_material
+ ma = context.material
if ma is not None and ma.grease_pencil is not None:
gpcolor = ma.grease_pencil
self.layout.prop(gpcolor, "show_stroke", text="")
@@ -135,7 +121,7 @@ class MATERIAL_PT_gpencil_strokecolor(GPMaterialButtonsPanel, Panel):
layout = self.layout
layout.use_property_split = True
- ma = context.object.active_material
+ ma = context.material
if ma is not None and ma.grease_pencil is not None:
gpcolor = ma.grease_pencil
@@ -163,73 +149,71 @@ class MATERIAL_PT_gpencil_fillcolor(GPMaterialButtonsPanel, Panel):
bl_parent_id = 'MATERIAL_PT_gpencil_surface'
def draw_header(self, context):
- ma = context.object.active_material
- if ma is not None and ma.grease_pencil is not None:
- gpcolor = ma.grease_pencil
- self.layout.prop(gpcolor, "show_fill", text="")
+ ma = context.material
+ gpcolor = ma.grease_pencil
+ self.layout.prop(gpcolor, "show_fill", text="")
@staticmethod
def draw(self, context):
layout = self.layout
layout.use_property_split = True
- ma = context.object.active_material
- if ma is not None and ma.grease_pencil:
- gpcolor = ma.grease_pencil
+ ma = context.material
+ gpcolor = ma.grease_pencil
- # color settings
- col = layout.column()
- col.active = not gpcolor.lock
- col.prop(gpcolor, "fill_style", text="Style")
+ # color settings
+ col = layout.column()
+ col.active = not gpcolor.lock
+ col.prop(gpcolor, "fill_style", text="Style")
- if gpcolor.fill_style == 'GRADIENT':
- col.prop(gpcolor, "gradient_type")
+ if gpcolor.fill_style == 'GRADIENT':
+ col.prop(gpcolor, "gradient_type")
- if gpcolor.fill_style != 'TEXTURE':
- col.prop(gpcolor, "fill_color", text="Color")
+ if gpcolor.fill_style != 'TEXTURE':
+ col.prop(gpcolor, "fill_color", text="Color")
- if gpcolor.fill_style in {'GRADIENT', 'CHESSBOARD'}:
- col.prop(gpcolor, "mix_color", text="Secondary Color")
+ if gpcolor.fill_style in {'GRADIENT', 'CHESSBOARD'}:
+ col.prop(gpcolor, "mix_color", text="Secondary Color")
- if gpcolor.fill_style == 'GRADIENT':
- col.prop(gpcolor, "mix_factor", text="Mix Factor", slider=True)
+ if gpcolor.fill_style == 'GRADIENT':
+ col.prop(gpcolor, "mix_factor", text="Mix Factor", slider=True)
- if gpcolor.fill_style in {'GRADIENT', 'CHESSBOARD'}:
- col.prop(gpcolor, "flip", text="Flip Colors")
+ if gpcolor.fill_style in {'GRADIENT', 'CHESSBOARD'}:
+ col.prop(gpcolor, "flip", text="Flip Colors")
- col.prop(gpcolor, "pattern_shift", text="Location")
- col.prop(gpcolor, "pattern_scale", text="Scale")
+ col.prop(gpcolor, "pattern_shift", text="Location")
+ col.prop(gpcolor, "pattern_scale", text="Scale")
- if gpcolor.gradient_type == 'RADIAL' and gpcolor.fill_style not in {'SOLID', 'CHESSBOARD'}:
- col.prop(gpcolor, "pattern_radius", text="Radius")
- else:
- if gpcolor.fill_style != 'SOLID':
- col.prop(gpcolor, "pattern_angle", text="Angle")
+ if gpcolor.gradient_type == 'RADIAL' and gpcolor.fill_style not in {'SOLID', 'CHESSBOARD'}:
+ col.prop(gpcolor, "pattern_radius", text="Radius")
+ else:
+ if gpcolor.fill_style != 'SOLID':
+ col.prop(gpcolor, "pattern_angle", text="Angle")
- if gpcolor.fill_style == 'CHESSBOARD':
- col.prop(gpcolor, "pattern_gridsize", text="Box Size")
+ if gpcolor.fill_style == 'CHESSBOARD':
+ col.prop(gpcolor, "pattern_gridsize", text="Box Size")
- # Texture
- if gpcolor.fill_style == 'TEXTURE' or (gpcolor.texture_mix is True and gpcolor.fill_style == 'SOLID'):
- col.template_ID(gpcolor, "fill_image", open="image.open")
+ # Texture
+ if gpcolor.fill_style == 'TEXTURE' or (gpcolor.texture_mix is True and gpcolor.fill_style == 'SOLID'):
+ col.template_ID(gpcolor, "fill_image", open="image.open")
- if gpcolor.fill_style == 'TEXTURE':
- col.prop(gpcolor, "use_fill_pattern", text="Use As Pattern")
- if gpcolor.use_fill_pattern is True:
- col.prop(gpcolor, "fill_color", text="Color")
+ if gpcolor.fill_style == 'TEXTURE':
+ col.prop(gpcolor, "use_fill_pattern", text="Use As Pattern")
+ if gpcolor.use_fill_pattern is True:
+ col.prop(gpcolor, "fill_color", text="Color")
- 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")
+ 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")
- if gpcolor.use_fill_pattern is False:
- col.prop(gpcolor, "texture_mix", text="Mix With Color")
+ if gpcolor.use_fill_pattern is False:
+ col.prop(gpcolor, "texture_mix", text="Mix With Color")
- if gpcolor.texture_mix is True:
- col.prop(gpcolor, "fill_color", text="Mix Color")
- col.prop(gpcolor, "mix_factor", text="Mix Factor", slider=True)
+ if gpcolor.texture_mix is True:
+ col.prop(gpcolor, "fill_color", text="Mix Color")
+ col.prop(gpcolor, "mix_factor", text="Mix Factor", slider=True)
class MATERIAL_PT_gpencil_preview(GPMaterialButtonsPanel, Panel):
@@ -238,7 +222,7 @@ class MATERIAL_PT_gpencil_preview(GPMaterialButtonsPanel, Panel):
bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
- ma = context.object.active_material
+ ma = context.material
self.layout.label(text=ma.name)
self.layout.template_preview(ma)
@@ -258,10 +242,9 @@ class MATERIAL_PT_gpencil_options(GPMaterialButtonsPanel, Panel):
layout = self.layout
layout.use_property_split = True
- ma = context.object.active_material
- if ma is not None and ma.grease_pencil is not None:
- gpcolor = ma.grease_pencil
- layout.prop(gpcolor, "pass_index")
+ ma = context.material
+ gpcolor = ma.grease_pencil
+ layout.prop(gpcolor, "pass_index")
class MATERIAL_PT_gpencil_material_presets(PresetMenu):