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),
('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:
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.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:
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')
row = style_panel.row(align=True)
row.prop(settings, 'view_tab', expand=True)
if settings.context_material:
if getattr(settings.context_material, '["BSBST"]', False):
draw_material_settings(material_panel, settings.context_material)
if settings.view_tab == 'MATERIAL':
if not settings.preset_object and is_preset:
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:
for mod in style_object.modifiers:
mod_info = mod.id_data.modifier_info.get(mod.name)
if not mod_info:
continue
if display_mode == 0:
if mod_info.hide_ui:
if settings.context_material:
if getattr(settings.context_material, '["BSBST"]', False):
draw_material_settings(material_panel, settings.context_material)
elif settings.view_tab == 'MODIFIERS':
if style_object:
for mod in style_object.modifiers:
mod_info = mod.id_data.modifier_info.get(mod.name)
if not mod_info:
continue
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 mod_info.hide_ui:
continue
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:
mod_header.prop(mod_info, 'hide_ui', icon_only=True, icon='UNPINNED' if mod_info.hide_ui else 'PINNED', emboss=False)
if is_preset:
op = row.operator('brushstroke_tools.preset_remove_mod', text='', icon='X')
else:
op = row.operator('object.modifier_remove', text='', icon='X')
# TODO Implement operator to remove modifier on brushstroke object, even when not active
op.modifier = mod.name
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)
if is_preset:
op = row.operator('brushstroke_tools.preset_remove_mod', text='', icon='X')
else:
op = row.operator('object.modifier_remove', text='', icon='X')
# TODO Implement operator to remove modifier on brushstroke object, even when not active
op.modifier = mod.name
if not mod_panel:
continue
if not mod_panel:
continue
if not mod.type == 'NODES':
mod_panel.label(text="Only 'Nodes' modifiers supported for preset interface")
continue
if not mod.type == 'NODES':
mod_panel.label(text="Only 'Nodes' modifiers supported for preset interface")
continue
# show settings for nodes modifiers
if mod.show_group_selector:
mod_panel.prop(mod, 'node_group')
if not mod.node_group:
continue
# show settings for nodes modifiers
if mod.show_group_selector:
mod_panel.prop(mod, 'node_group')
if not mod.node_group:
continue
draw_panel_ui_recursive(mod_panel,
'',
mod,
mod.node_group.interface.items_tree.items(),
display_mode)
draw_panel_ui_recursive(mod_panel,
'',
mod,
mod.node_group.interface.items_tree.items(),
display_mode)
# expose add modifier operator for preset context
if is_preset:
style_panel.operator('brushstroke_tools.preset_add_mod', icon='ADD')
# expose add modifier operator for preset context
if is_preset:
style_panel.operator('brushstroke_tools.preset_add_mod', icon='ADD')
class BSBST_MT_PIE_brushstroke_data_marking(bpy.types.Menu):
bl_idname= "BSBST_MT_PIE_brushstroke_data_marking"