diff options
6 files changed, 165 insertions, 211 deletions
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 542f02f1a6d..d0cfb5c5e72 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -1613,7 +1613,8 @@ class CYCLES_MATERIAL_PT_preview(CyclesButtonsPanel, Panel): @classmethod def poll(cls, context): - return context.material and CyclesButtonsPanel.poll(context) + mat = context.material + return mat and (not mat.grease_pencil) and CyclesButtonsPanel.poll(context) def draw(self, context): self.layout.template_preview(context.material) @@ -1625,7 +1626,8 @@ class CYCLES_MATERIAL_PT_surface(CyclesButtonsPanel, Panel): @classmethod def poll(cls, context): - return context.material and CyclesButtonsPanel.poll(context) + mat = context.material + return mat and (not mat.grease_pencil) and CyclesButtonsPanel.poll(context) def draw(self, context): layout = self.layout @@ -1643,7 +1645,7 @@ class CYCLES_MATERIAL_PT_volume(CyclesButtonsPanel, Panel): @classmethod def poll(cls, context): mat = context.material - return mat and mat.node_tree and CyclesButtonsPanel.poll(context) + return mat and (not mat.grease_pencil) and mat.node_tree and CyclesButtonsPanel.poll(context) def draw(self, context): layout = self.layout @@ -1661,7 +1663,7 @@ class CYCLES_MATERIAL_PT_displacement(CyclesButtonsPanel, Panel): @classmethod def poll(cls, context): mat = context.material - return mat and mat.node_tree and CyclesButtonsPanel.poll(context) + return mat and (not mat.grease_pencil) and mat.node_tree and CyclesButtonsPanel.poll(context) def draw(self, context): layout = self.layout @@ -1677,7 +1679,8 @@ class CYCLES_MATERIAL_PT_settings(CyclesButtonsPanel, Panel): @classmethod def poll(cls, context): - return context.material and CyclesButtonsPanel.poll(context) + mat = context.material + return mat and (not mat.grease_pencil) and CyclesButtonsPanel.poll(context) @staticmethod def draw_shared(self, mat): diff --git a/release/scripts/startup/bl_ui/properties_data_gpencil.py b/release/scripts/startup/bl_ui/properties_data_gpencil.py index a5e526ed670..c6626b555fb 100644 --- a/release/scripts/startup/bl_ui/properties_data_gpencil.py +++ b/release/scripts/startup/bl_ui/properties_data_gpencil.py @@ -35,7 +35,7 @@ class DataButtonsPanel: @classmethod def poll(cls, context): - return context.gpencil_data + return context.gpencil class ObjectButtonsPanel: @@ -45,7 +45,8 @@ class ObjectButtonsPanel: @classmethod def poll(cls, context): - return context.object and context.object.type == 'GPENCIL' + ob = context.object + return ob and ob.type == 'GPENCIL' class LayerDataButtonsPanel: @@ -55,24 +56,28 @@ class LayerDataButtonsPanel: @classmethod def poll(cls, context): - return (context.gpencil_data and - context.active_gpencil_layer) + gpencil = context.gpencil + return gpencil and gpencil.layers.active ############################### # GP Object Properties Panels and Helper Classes -class DATA_PT_gpencil(DataButtonsPanel, Panel): +class DATA_PT_context_gpencil(DataButtonsPanel, Panel): bl_label = "" bl_options = {'HIDE_HEADER'} def draw(self, context): layout = self.layout - # Grease Pencil data selector - gpd_owner = context.gpencil_data_owner + ob = context.object + gpencil = context.gpencil + space = context.space_data - layout.template_ID(gpd_owner, "data") + if ob: + layout.template_ID(ob, "data") + else: + layout.template_ID(space, "pin_id") class GPENCIL_MT_layer_specials(Menu): @@ -80,7 +85,7 @@ class GPENCIL_MT_layer_specials(Menu): def draw(self, context): layout = self.layout - gpd = context.gpencil_data + gpd = context.gpencil layout.operator("gpencil.layer_duplicate", icon='ADD') # XXX: needs a dedicated icon @@ -103,23 +108,15 @@ class GPENCIL_MT_layer_specials(Menu): layout.menu("VIEW3D_MT_gpencil_copy_layer") -class DATA_PT_gpencil_datapanel(Panel): - bl_space_type = 'PROPERTIES' - bl_region_type = 'WINDOW' - bl_context = "data" +class DATA_PT_gpencil_layers(DataButtonsPanel, Panel): bl_label = "Layers" - @classmethod - def poll(cls, context): - return context.gpencil_data - - @staticmethod def draw(self, context): layout = self.layout #layout.use_property_split = True layout.use_property_decorate = False - gpd = context.gpencil_data + gpd = context.gpencil # Grease Pencil data... if (gpd is None) or (not gpd.layers): @@ -136,7 +133,8 @@ class DATA_PT_gpencil_datapanel(Panel): col.template_list("GPENCIL_UL_layer", "", gpd, "layers", gpd.layers, "active_index", rows=layer_rows, sort_reverse=True, sort_lock=True) - gpl = context.active_gpencil_layer + gpl = gpd.layers.active + if gpl: srow = col.row(align=True) srow.prop(gpl, "blend_mode", text="Blend") @@ -172,12 +170,9 @@ class DATA_PT_gpencil_datapanel(Panel): sub.operator("gpencil.layer_isolate", icon='RESTRICT_VIEW_ON', text="").affect_visibility = True -class DATA_PT_gpencil_layer_optionpanel(LayerDataButtonsPanel, Panel): - bl_space_type = 'PROPERTIES' - bl_region_type = 'WINDOW' - bl_context = "data" +class DATA_PT_gpencil_layer_adjustments(LayerDataButtonsPanel, Panel): bl_label = "Adjustments" - bl_parent_id = 'DATA_PT_gpencil_datapanel' + bl_parent_id = 'DATA_PT_gpencil_layers' bl_options = {'DEFAULT_CLOSED'} def draw(self, context): @@ -185,7 +180,8 @@ class DATA_PT_gpencil_layer_optionpanel(LayerDataButtonsPanel, Panel): layout.use_property_split = True scene = context.scene - gpl = context.active_gpencil_layer + gpd = context.gpencil + gpl = gpd.layers.active layout.active = not gpl.lock # Layer options @@ -209,12 +205,9 @@ class DATA_PT_gpencil_layer_optionpanel(LayerDataButtonsPanel, Panel): col.prop(gpl, "lock_material") -class DATA_PT_gpencil_parentpanel(LayerDataButtonsPanel, Panel): - bl_space_type = 'PROPERTIES' - bl_region_type = 'WINDOW' - bl_context = "data" +class DATA_PT_gpencil_layer_relations(LayerDataButtonsPanel, Panel): bl_label = "Relations" - bl_parent_id = 'DATA_PT_gpencil_datapanel' + bl_parent_id = 'DATA_PT_gpencil_layers' bl_options = {'DEFAULT_CLOSED'} def draw(self, context): @@ -222,7 +215,9 @@ class DATA_PT_gpencil_parentpanel(LayerDataButtonsPanel, Panel): layout.use_property_split = True layout.use_property_decorate = False - gpl = context.active_gpencil_layer + gpd = context.gpencil + gpl = gpd.layers.active + col = layout.column() col.active = not gpl.lock col.prop(gpl, "parent") @@ -233,19 +228,12 @@ class DATA_PT_gpencil_parentpanel(LayerDataButtonsPanel, Panel): col.prop_search(gpl, "parent_bone", parent.data, "bones", text="Bone") -class DATA_PT_gpencil_onionpanel(Panel): - bl_space_type = 'PROPERTIES' - bl_region_type = 'WINDOW' - bl_context = "data" +class DATA_PT_gpencil_onion_skinning(DataButtonsPanel, Panel): bl_label = "Onion Skinning" bl_options = {'DEFAULT_CLOSED'} - @classmethod - def poll(cls, context): - return bool(context.active_gpencil_layer) - def draw(self, context): - gpd = context.gpencil_data + gpd = context.gpencil layout = self.layout layout.use_property_split = True @@ -268,21 +256,18 @@ class DATA_PT_gpencil_onionpanel(Panel): col.prop(gpd, "ghost_after_range", text="Keyframes After") -class DATA_PT_gpencil_onionpanel_custom_colors(Panel): - bl_space_type = 'PROPERTIES' - bl_region_type = 'WINDOW' - bl_context = "data" - bl_parent_id = "DATA_PT_gpencil_onionpanel" +class DATA_PT_gpencil_onion_skinning_custom_colors(DataButtonsPanel, Panel): + bl_parent_id = "DATA_PT_gpencil_onion_skinning" bl_label = "Custom Colors" bl_options = {'DEFAULT_CLOSED'} def draw_header(self, context): - gpd = context.gpencil_data + gpd = context.gpencil self.layout.prop(gpd, "use_ghost_custom_colors", text="") def draw(self, context): - gpd = context.gpencil_data + gpd = context.gpencil layout = self.layout layout.use_property_split = True @@ -292,16 +277,13 @@ class DATA_PT_gpencil_onionpanel_custom_colors(Panel): layout.prop(gpd, "after_color", text="After") -class DATA_PT_gpencil_onionpanel_display(Panel): - bl_space_type = 'PROPERTIES' - bl_region_type = 'WINDOW' - bl_context = "data" - bl_parent_id = "DATA_PT_gpencil_onionpanel" +class DATA_PT_gpencil_onion_skinning_display(DataButtonsPanel, Panel): + bl_parent_id = "DATA_PT_gpencil_onion_skinning" bl_label = "Display" bl_options = {'DEFAULT_CLOSED'} def draw(self, context): - gpd = context.gpencil_data + gpd = context.gpencil layout = self.layout layout.use_property_split = True @@ -354,10 +336,7 @@ class GPENCIL_UL_vgroups(UIList): layout.label(text="", icon_value=icon) -class DATA_PT_gpencil_vertexpanel(ObjectButtonsPanel, Panel): - bl_space_type = 'PROPERTIES' - bl_region_type = 'WINDOW' - bl_context = "data" +class DATA_PT_gpencil_vertex_groups(ObjectButtonsPanel, Panel): bl_label = "Vertex Groups" bl_options = {'DEFAULT_CLOSED'} @@ -402,12 +381,13 @@ class DATA_PT_gpencil_strokes(DataButtonsPanel, Panel): layout.use_property_decorate = False ob = context.object - - gpd = context.gpencil_data + gpd = context.gpencil col = layout.column(align=True) col.prop(gpd, "stroke_depth_order") - col.enabled = not ob.show_in_front + + if ob: + col.enabled = not ob.show_in_front col = layout.column(align=True) col.prop(gpd, "stroke_thickness_space") @@ -419,7 +399,7 @@ class DATA_PT_gpencil_strokes(DataButtonsPanel, Panel): layout.prop(gpd, "use_adaptive_uv", text="Adaptive UVs") -class DATA_PT_gpencil_display(ObjectButtonsPanel, Panel): +class DATA_PT_gpencil_display(DataButtonsPanel, Panel): bl_label = "Viewport Display" bl_options = {'DEFAULT_CLOSED'} @@ -428,10 +408,8 @@ class DATA_PT_gpencil_display(ObjectButtonsPanel, Panel): layout.use_property_split = True layout.use_property_decorate = False - ob = context.object - - gpd = context.gpencil_data - gpl = context.active_gpencil_layer + gpd = context.gpencil + gpl = gpd.layers.active layout.prop(gpd, "edit_line_color", text="Edit Line Color") if gpl: @@ -447,7 +425,7 @@ class DATA_PT_gpencil_canvas(DataButtonsPanel, Panel): layout = self.layout layout.use_property_split = True layout.use_property_decorate = False - gpd = context.gpencil_data + gpd = context.gpencil grid = gpd.grid row = layout.row(align=True) @@ -468,14 +446,14 @@ class DATA_PT_custom_props_gpencil(DataButtonsPanel, PropertyPanel, Panel): classes = ( - DATA_PT_gpencil, - DATA_PT_gpencil_datapanel, - DATA_PT_gpencil_onionpanel, - DATA_PT_gpencil_onionpanel_custom_colors, - DATA_PT_gpencil_onionpanel_display, - DATA_PT_gpencil_layer_optionpanel, - DATA_PT_gpencil_parentpanel, - DATA_PT_gpencil_vertexpanel, + DATA_PT_context_gpencil, + DATA_PT_gpencil_layers, + DATA_PT_gpencil_onion_skinning, + DATA_PT_gpencil_onion_skinning_custom_colors, + DATA_PT_gpencil_onion_skinning_display, + DATA_PT_gpencil_layer_adjustments, + DATA_PT_gpencil_layer_relations, + DATA_PT_gpencil_vertex_groups, DATA_PT_gpencil_strokes, DATA_PT_gpencil_display, DATA_PT_gpencil_canvas, 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 82677192590..d65d494630a 100644 --- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py +++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py @@ -860,65 +860,70 @@ class GreasePencilMaterialsPanel: @classmethod def poll(cls, context): ob = context.object - return ob and ob.type == 'GPENCIL' + ma = context.material + return (ob and ob.type == 'GPENCIL') or (ma and ma.grease_pencil) @staticmethod def draw(self, context): layout = self.layout show_full_ui = (self.bl_space_type == 'PROPERTIES') - gpd = context.gpencil_data - ob = context.object - - is_sortable = len(ob.material_slots) > 1 - rows = 7 + gpd = context.gpencil + space = context.space_data row = layout.row() - row.template_list("GPENCIL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=rows) + if ob: + is_sortable = len(ob.material_slots) > 1 + rows = 7 - col = row.column(align=True) - if show_full_ui: - col.operator("object.material_slot_add", icon='ADD', text="") - col.operator("object.material_slot_remove", icon='REMOVE', text="") + row.template_list("GPENCIL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=rows) - col.menu("GPENCIL_MT_color_specials", icon='DOWNARROW_HLT', text="") + col = row.column(align=True) + if show_full_ui: + col.operator("object.material_slot_add", icon='ADD', text="") + col.operator("object.material_slot_remove", icon='REMOVE', text="") - if is_sortable: - col.separator() + col.menu("GPENCIL_MT_color_specials", icon='DOWNARROW_HLT', text="") - col.operator("object.material_slot_move", icon='TRIA_UP', text="").direction = 'UP' - col.operator("object.material_slot_move", icon='TRIA_DOWN', text="").direction = 'DOWN' + if is_sortable: + col.separator() - col.separator() + col.operator("object.material_slot_move", icon='TRIA_UP', text="").direction = 'UP' + col.operator("object.material_slot_move", icon='TRIA_DOWN', text="").direction = 'DOWN' - sub = col.column(align=True) - sub.operator("gpencil.color_isolate", icon='LOCKED', text="").affect_visibility = False - sub.operator("gpencil.color_isolate", icon='RESTRICT_VIEW_ON', text="").affect_visibility = True + col.separator() + + sub = col.column(align=True) + sub.operator("gpencil.color_isolate", icon='LOCKED', text="").affect_visibility = False + sub.operator("gpencil.color_isolate", icon='RESTRICT_VIEW_ON', text="").affect_visibility = True - if show_full_ui: - row = layout.row() + if show_full_ui: + row = layout.row() - row.template_ID(ob, "active_material", new="material.new", live_icon=True) + row.template_ID(ob, "active_material", new="material.new", live_icon=True) - slot = context.material_slot - if slot: - icon_link = 'MESH_DATA' if slot.link == 'DATA' else 'OBJECT_DATA' - row.prop(slot, "link", icon=icon_link, icon_only=True) + slot = context.material_slot + if slot: + icon_link = 'MESH_DATA' if slot.link == 'DATA' else 'OBJECT_DATA' + row.prop(slot, "link", icon=icon_link, icon_only=True) - if gpd.use_stroke_edit_mode: - row = layout.row(align=True) - row.operator("gpencil.stroke_change_color", text="Assign") - row.operator("gpencil.color_select", text="Select").deselect = False - row.operator("gpencil.color_select", text="Deselect").deselect = True + if gpd and gpd.use_stroke_edit_mode: + row = layout.row(align=True) + row.operator("gpencil.stroke_change_color", text="Assign") + row.operator("gpencil.color_select", text="Select").deselect = False + row.operator("gpencil.color_select", text="Deselect").deselect = True + + else: + row.template_ID(space, "pin_id") class GPENCIL_UL_layer(UIList): def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index): # assert(isinstance(item, bpy.types.GPencilLayer) gpl = item - gpd = context.gpencil_data + gpd = context.gpencil if self.layout_type in {'DEFAULT', 'COMPACT'}: if gpl.lock: diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py index 8d7e7ac266d..07c94c90738 100644 --- a/release/scripts/startup/bl_ui/properties_material.py +++ b/release/scripts/startup/bl_ui/properties_material.py @@ -60,7 +60,8 @@ class MaterialButtonsPanel: @classmethod def poll(cls, context): - return context.material and (context.engine in cls.COMPAT_ENGINES) + mat = context.material + return mat and (context.engine in cls.COMPAT_ENGINES) and not mat.grease_pencil class MATERIAL_PT_preview(MaterialButtonsPanel, Panel): @@ -86,11 +87,8 @@ class EEVEE_MATERIAL_PT_context_material(MaterialButtonsPanel, Panel): @classmethod def poll(cls, context): - if context.active_object and context.active_object.type == 'GPENCIL': - return False - else: - engine = context.engine - return (context.material or context.object) and (engine in cls.COMPAT_ENGINES) + mat = context.material + return (context.object or mat) and (context.engine in cls.COMPAT_ENGINES) and not mat.grease_pencil def draw(self, context): layout = self.layout @@ -161,11 +159,6 @@ class EEVEE_MATERIAL_PT_surface(MaterialButtonsPanel, Panel): bl_context = "material" COMPAT_ENGINES = {'BLENDER_EEVEE'} - @classmethod - def poll(cls, context): - engine = context.engine - return context.material and (engine in cls.COMPAT_ENGINES) - def draw(self, context): layout = self.layout @@ -194,7 +187,7 @@ class EEVEE_MATERIAL_PT_volume(MaterialButtonsPanel, Panel): def poll(cls, context): engine = context.engine mat = context.material - return mat and mat.use_nodes and (engine in cls.COMPAT_ENGINES) + return mat and mat.use_nodes and (engine in cls.COMPAT_ENGINES) and not mat.grease_pencil def draw(self, context): layout = self.layout @@ -209,11 +202,6 @@ class EEVEE_MATERIAL_PT_settings(MaterialButtonsPanel, Panel): bl_context = "material" COMPAT_ENGINES = {'BLENDER_EEVEE'} - @classmethod - def poll(cls, context): - engine = context.engine - return context.material and (engine in cls.COMPAT_ENGINES) - @staticmethod def draw_shared(self, mat): layout = self.layout @@ -247,7 +235,8 @@ class MATERIAL_PT_viewport(MaterialButtonsPanel, Panel): @classmethod def poll(cls, context): - return context.material + mat = context.material + return mat and not mat.grease_pencil @staticmethod def draw_shared(self, mat): 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): diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 10c0a6f4a57..152442f8671 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -494,7 +494,6 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma wmWindow *window = CTX_wm_window(C); Scene *scene = WM_window_get_active_scene(window); ViewLayer *view_layer = WM_window_get_active_view_layer(window); - Object *ob = OBACT(view_layer); ID *id; int found; @@ -562,14 +561,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma found = buttons_context_path_particle(path); break; case BCONTEXT_MATERIAL: - /* NOTE: Grease Pencil materials use different panels... */ - if (ob && ob->type == OB_GPENCIL) { - /* XXX: Why path_data? */ - found = buttons_context_path_data(path, -1); - } - else { - found = buttons_context_path_material(path); - } + found = buttons_context_path_material(path); break; case BCONTEXT_TEXTURE: found = buttons_context_path_texture(C, path, sbuts->texuser); @@ -708,7 +700,7 @@ const char *buttons_context_dir[] = { "texture", "texture_user", "texture_user_property", "bone", "edit_bone", "pose_bone", "particle_system", "particle_system_editable", "particle_settings", "cloth", "soft_body", "fluid", "smoke", "collision", "brush", "dynamic_paint", - "line_style", "collection", NULL, + "line_style", "collection", "gpencil", NULL, }; int buttons_context(const bContext *C, const char *member, bContextDataResult *result) @@ -981,6 +973,10 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r set_pointer_type(path, result, &RNA_FreestyleLineStyle); return 1; } + else if (CTX_data_equals(member, "gpencil")) { + set_pointer_type(path, result, &RNA_GreasePencil); + return 1; + } else { return 0; /* not found */ } |