Brushstroke Tools: Initial Version #328

Merged
Simon Thommes merged 229 commits from SimonThommes/blender-studio-tools:brushstroke_tools-initial-version into main 2024-11-06 15:03:47 +01:00
2 changed files with 59 additions and 49 deletions
Showing only changes of commit 6774e208a4 - Show all commits

View File

@ -237,6 +237,12 @@ class BSBST_Settings(bpy.types.PropertyGroup):
('BRUSHSTROKES', 'Brushstrokes', 'Specify the style of the currently active brushstrokes', 'BRUSH_DATA', 1), ('BRUSHSTROKES', 'Brushstrokes', 'Specify the style of the currently active brushstrokes', 'BRUSH_DATA', 1),
('AUTO', 'Auto', 'Specify the style of either the active brushstrokes or the preset depending on the context', 'AUTO', 2), ('AUTO', 'Auto', 'Specify the style of either the active brushstrokes or the preset depending on the context', 'AUTO', 2),
]) ])
view_tab: bpy.props.EnumProperty(default='MODIFIERS',
name='Context',
items= [
('MODIFIERS', 'Modifiers', 'View Modifiers Settings', 'MODIFIER', 0),
('MATERIAL', 'Material', 'View Material Settings', 'MATERIAL', 1),
])
try: try:
gpv3 = bpy.context.preferences.experimental.use_grease_pencil_version3 gpv3 = bpy.context.preferences.experimental.use_grease_pencil_version3

View File

@ -306,64 +306,68 @@ class BSBST_PT_brushstroke_tools_panel(bpy.types.Panel):
row_edit.operator('brushstroke_tools.edit_brushstrokes', icon='GREASEPENCIL', text = text) row_edit.operator('brushstroke_tools.edit_brushstrokes', icon='GREASEPENCIL', text = text)
row_edit.prop(settings, 'edit_toggle', icon='RESTRICT_SELECT_OFF' if settings.edit_toggle else 'RESTRICT_SELECT_ON', icon_only=True) row_edit.prop(settings, 'edit_toggle', icon='RESTRICT_SELECT_OFF' if settings.edit_toggle else 'RESTRICT_SELECT_ON', icon_only=True)
if not settings.preset_object and is_preset: row = style_panel.row(align=True)
style_panel.operator("brushstroke_tools.init_preset", icon='MODIFIER') row.prop(settings, 'view_tab', expand=True)
else:
material_header, material_panel = style_panel.panel("brushstrokes_material", default_closed=False)
material_header.label(text='Material', icon='MATERIAL')
if material_panel:
material_row = material_panel.row(align=True)
material_row.template_ID(settings, 'context_material')
if settings.context_material: if settings.view_tab == 'MATERIAL':
if getattr(settings.context_material, '["BSBST"]', False): if not settings.preset_object and is_preset:
draw_material_settings(material_panel, settings.context_material) style_panel.operator("brushstroke_tools.init_preset", icon='MODIFIER')
else:
material_header, material_panel = style_panel.panel("brushstrokes_material", default_closed=False)
material_header.label(text='Material', icon='MATERIAL')
if material_panel:
material_row = material_panel.row(align=True)
material_row.template_ID(settings, 'context_material')
if style_object: if settings.context_material:
for mod in style_object.modifiers: if getattr(settings.context_material, '["BSBST"]', False):
mod_info = mod.id_data.modifier_info.get(mod.name) draw_material_settings(material_panel, settings.context_material)
if not mod_info: elif settings.view_tab == 'MODIFIERS':
continue if style_object:
if display_mode == 0: for mod in style_object.modifiers:
if mod_info.hide_ui: mod_info = mod.id_data.modifier_info.get(mod.name)
if not mod_info:
continue continue
if display_mode == 0:
mod_header, mod_panel = style_panel.panel(mod.name, default_closed = False) if mod_info.hide_ui:
row = mod_header.row(align=True) continue
row.label(text='', icon='GEOMETRY_NODES')
row.prop(mod_info, 'name', text='', emboss=False) mod_header, mod_panel = style_panel.panel(mod.name, default_closed = False)
row = mod_header.row(align=True)
row.label(text='', icon='GEOMETRY_NODES')
row.prop(mod_info, 'name', text='', emboss=False)
if display_mode != 0: if display_mode != 0:
mod_header.prop(mod_info, 'hide_ui', icon_only=True, icon='UNPINNED' if mod_info.hide_ui else 'PINNED', emboss=False) mod_header.prop(mod_info, 'hide_ui', icon_only=True, icon='UNPINNED' if mod_info.hide_ui else 'PINNED', emboss=False)
if is_preset: if is_preset:
op = row.operator('brushstroke_tools.preset_remove_mod', text='', icon='X') op = row.operator('brushstroke_tools.preset_remove_mod', text='', icon='X')
else: else:
op = row.operator('object.modifier_remove', text='', icon='X') op = row.operator('object.modifier_remove', text='', icon='X')
# TODO Implement operator to remove modifier on brushstroke object, even when not active # TODO Implement operator to remove modifier on brushstroke object, even when not active
op.modifier = mod.name op.modifier = mod.name
if not mod_panel: if not mod_panel:
continue continue
if not mod.type == 'NODES': if not mod.type == 'NODES':
mod_panel.label(text="Only 'Nodes' modifiers supported for preset interface") mod_panel.label(text="Only 'Nodes' modifiers supported for preset interface")
continue continue
# show settings for nodes modifiers # show settings for nodes modifiers
if mod.show_group_selector: if mod.show_group_selector:
mod_panel.prop(mod, 'node_group') mod_panel.prop(mod, 'node_group')
if not mod.node_group: if not mod.node_group:
continue continue
draw_panel_ui_recursive(mod_panel, draw_panel_ui_recursive(mod_panel,
'', '',
mod, mod,
mod.node_group.interface.items_tree.items(), mod.node_group.interface.items_tree.items(),
display_mode) display_mode)
# expose add modifier operator for preset context # expose add modifier operator for preset context
if is_preset: if is_preset:
style_panel.operator('brushstroke_tools.preset_add_mod', icon='ADD') style_panel.operator('brushstroke_tools.preset_add_mod', icon='ADD')
class BSBST_MT_PIE_brushstroke_data_marking(bpy.types.Menu): class BSBST_MT_PIE_brushstroke_data_marking(bpy.types.Menu):
bl_idname= "BSBST_MT_PIE_brushstroke_data_marking" bl_idname= "BSBST_MT_PIE_brushstroke_data_marking"