Palette linker
1.8.0 - feat: palette linker (beta), with pop-up from material stack dropdown - feat: palette name fuzzy match - code: add an open addon preference ops
This commit is contained in:
+219
-36
@@ -2,13 +2,13 @@
|
||||
from .utils import get_addon_prefs
|
||||
import bpy
|
||||
from pathlib import Path
|
||||
|
||||
from bpy.types import Panel
|
||||
|
||||
## UI in properties
|
||||
|
||||
### dataprop_panel not used --> transferred to sidebar
|
||||
"""
|
||||
class GPTB_PT_dataprop_panel(bpy.types.Panel):
|
||||
class GPTB_PT_dataprop_panel(Panel):
|
||||
bl_space_type = 'PROPERTIES'
|
||||
bl_region_type = 'WINDOW'
|
||||
# bl_space_type = 'VIEW_3D'
|
||||
@@ -35,7 +35,7 @@ class GPTB_PT_dataprop_panel(bpy.types.Panel):
|
||||
|
||||
## UI in Gpencil sidebar menu
|
||||
|
||||
class GPTB_PT_sidebar_panel(bpy.types.Panel):
|
||||
class GPTB_PT_sidebar_panel(Panel):
|
||||
bl_label = "GP Toolbox"
|
||||
bl_space_type = "VIEW_3D"
|
||||
bl_region_type = "UI"
|
||||
@@ -165,7 +165,7 @@ class GPTB_PT_sidebar_panel(bpy.types.Panel):
|
||||
# row.operator("my_operator.multi_op", text='', icon='TRIA_LEFT').left = 1
|
||||
# row.operator("my_operator.multi_op", text='', icon='TRIA_RIGHT').left = 0
|
||||
|
||||
class GPTB_PT_anim_manager(bpy.types.Panel):
|
||||
class GPTB_PT_anim_manager(Panel):
|
||||
bl_label = "Animation Manager"
|
||||
bl_space_type = "VIEW_3D"
|
||||
bl_region_type = "UI"
|
||||
@@ -221,7 +221,7 @@ class GPTB_PT_anim_manager(bpy.types.Panel):
|
||||
text, icon = ('Cursor Follow On', 'PIVOT_CURSOR') if context.scene.gptoolprops.cursor_follow else ('Cursor Follow Off', 'CURSOR')
|
||||
col.prop(context.scene.gptoolprops, 'cursor_follow', text=text, icon=icon)
|
||||
|
||||
class GPTB_PT_toolbox_playblast(bpy.types.Panel):
|
||||
class GPTB_PT_toolbox_playblast(Panel):
|
||||
bl_label = "Playblast"
|
||||
bl_space_type = "VIEW_3D"
|
||||
bl_region_type = "UI"
|
||||
@@ -243,7 +243,7 @@ class GPTB_PT_toolbox_playblast(bpy.types.Panel):
|
||||
# row.operator('render.playblast_anim', text = 'Playblast', icon = 'RENDER_ANIMATION').use_view = False # old (but robust) blocking playblast
|
||||
row.operator('render.playblast_anim', text = 'Viewport').use_view = True
|
||||
|
||||
class GPTB_PT_tint_layers(bpy.types.Panel):
|
||||
class GPTB_PT_tint_layers(Panel):
|
||||
bl_label = "Tint Layers"
|
||||
bl_space_type = "VIEW_3D"
|
||||
bl_region_type = "UI"
|
||||
@@ -268,7 +268,7 @@ class GPTB_PT_tint_layers(bpy.types.Panel):
|
||||
col.operator("gp.auto_tint_gp_layers", text = "Reset tint", icon = "COLOR").reset = True
|
||||
|
||||
|
||||
class GPTB_PT_checker(bpy.types.Panel):
|
||||
class GPTB_PT_checker(Panel):
|
||||
bl_label = "Checker"
|
||||
bl_space_type = "VIEW_3D"
|
||||
bl_region_type = "UI"
|
||||
@@ -298,7 +298,7 @@ class GPTB_PT_checker(bpy.types.Panel):
|
||||
row.operator('gp.links_checker', text = 'Check links', icon = 'UNLINKED')
|
||||
|
||||
|
||||
class GPTB_PT_color(bpy.types.Panel):
|
||||
class GPTB_PT_color(Panel):
|
||||
bl_label = "Color"
|
||||
bl_space_type = "VIEW_3D"
|
||||
bl_region_type = "UI"
|
||||
@@ -310,11 +310,14 @@ class GPTB_PT_color(bpy.types.Panel):
|
||||
layout = self.layout
|
||||
col = layout.column()
|
||||
## Create empty frame on layer
|
||||
col.operator('gp.palette_linker', text=f'Link Materials Palette TO Object', icon='COLOR') ## ops
|
||||
|
||||
# Material panel as a pop-up (would work if palette dir is separated)
|
||||
# col.operator("wm.call_panel", text="Link Materials Palette", icon='COLOR').name = "GPTB_PT_palettes_linker_ui"
|
||||
col.operator('gp.create_empty_frames', icon='DECORATE_KEYFRAME')
|
||||
# col.operator("wm.call_panel", text="Link Material Palette", icon='COLOR').name = "GPTB_PT_palettes_list_popup"
|
||||
|
||||
""" # unused : added in Animation Manager
|
||||
class GPTB_PT_extra(bpy.types.Panel):
|
||||
class GPTB_PT_extra(Panel):
|
||||
bl_label = "Extra"
|
||||
bl_space_type = "VIEW_3D"
|
||||
bl_region_type = "UI"
|
||||
@@ -331,7 +334,7 @@ class GPTB_PT_extra(bpy.types.Panel):
|
||||
|
||||
"""
|
||||
## unused -- (integrated in sidebar_panel)
|
||||
class GPTB_PT_cam_ref_panel(bpy.types.Panel):
|
||||
class GPTB_PT_cam_ref_panel(Panel):
|
||||
bl_label = "Background imgs"
|
||||
bl_space_type = "VIEW_3D"
|
||||
bl_region_type = "UI"
|
||||
@@ -366,10 +369,13 @@ def palette_manager_menu(self, context):
|
||||
prefs = get_addon_prefs()
|
||||
|
||||
layout.operator("gp.copy_active_to_selected_palette", text='Append Materials To Selected', icon='MATERIAL')
|
||||
layout.operator("gp.clean_material_stack", text='Clean material Stack', icon='NODE_MATERIAL')
|
||||
layout.separator()
|
||||
layout.operator("wm.call_panel", text="Pop Palette Linker", icon='COLOR').name = "GPTB_PT_palettes_list_popup"
|
||||
layout.operator("gp.load_blend_palette", text='Load Mats From Single Blend', icon='RESTRICT_COLOR_ON').filepath = prefs.palette_path
|
||||
layout.separator()
|
||||
layout.operator("gp.load_palette", text='Load json Palette', icon='IMPORT').filepath = prefs.palette_path
|
||||
layout.operator("gp.save_palette", text='Save json Palette', icon='EXPORT').filepath = prefs.palette_path
|
||||
layout.operator("gp.load_blend_palette", text='Load color Palette', icon='COLOR').filepath = prefs.palette_path
|
||||
layout.operator("gp.clean_material_stack", text='Clean material Stack', icon='NODE_MATERIAL')
|
||||
|
||||
|
||||
def expose_use_channel_color_pref(self, context):
|
||||
@@ -380,6 +386,150 @@ def expose_use_channel_color_pref(self, context):
|
||||
layout.label(text='Use Channel Colors (User preferences):')
|
||||
layout.prop(context.preferences.edit, 'use_anim_channel_group_colors')
|
||||
|
||||
|
||||
#--- Palette Linker Panels
|
||||
|
||||
def palettes_path_ui(self, context):
|
||||
layout = self.layout
|
||||
scn = bpy.context.scene
|
||||
pl_prop = scn.bl_palettes_props
|
||||
col= layout.column()
|
||||
prefs = get_addon_prefs()
|
||||
## Here put the path thing (only to use a non-library)
|
||||
|
||||
# maybe in submenu...
|
||||
row = col.row()
|
||||
# expand_icon = 'TRIA_DOWN' if pl_prop.show_path else 'TRIA_RIGHT'
|
||||
# row.prop(pl_prop, 'show_path', text='', icon=expand_icon, emboss=False)
|
||||
row.prop(pl_prop, 'use_project_path', text='Use Project Palettes')
|
||||
# row.operator("gp.palettes_reload_blends", icon="FILE_REFRESH", text="")
|
||||
|
||||
if pl_prop.use_project_path:
|
||||
## gp toolbox addon prefs path
|
||||
if not prefs.palette_path:
|
||||
col.label(text='GP toolbox Palette Directory Needed', icon='INFO')
|
||||
col.operator('gptb.open_addon_prefs', icon='PREFERENCES')
|
||||
|
||||
# if not prefs.palette_path: # or pl_prop.show_path
|
||||
# col.prop(prefs, 'palette_path', text='Project Dir')
|
||||
#col.label(text='(saved with preferences)')
|
||||
else:
|
||||
## local path
|
||||
if not pl_prop.custom_dir:
|
||||
col.label(text='Need to specify directory')
|
||||
col.prop(pl_prop, 'custom_dir', text='Custom Dir')
|
||||
# if not pl_prop.custom_dir or pl_prop.show_path:
|
||||
# col.prop(pl_prop, 'custom_dir', text='Custom Dir')
|
||||
|
||||
|
||||
def palettes_lists_ui(self, context, popup=False):
|
||||
layout = self.layout
|
||||
scn = bpy.context.scene
|
||||
pl_prop = scn.bl_palettes_props
|
||||
col= layout.column()
|
||||
row=col.row()
|
||||
# refresh button
|
||||
txt = 'Project Palettes' if pl_prop.use_project_path else 'Custom Palettes'
|
||||
row.label(text=txt)
|
||||
row.operator("gp.palettes_reload_blends", icon="FILE_REFRESH", text="")
|
||||
|
||||
col= layout.column()
|
||||
row = col.row()
|
||||
|
||||
if popup:
|
||||
blends_minimum_row = 5
|
||||
objects_minimum_row = 25
|
||||
else:
|
||||
blends_minimum_row = 2
|
||||
objects_minimum_row = 4
|
||||
row.template_list("GPTB_UL_blend_list", "", pl_prop, "blends", pl_prop, "bl_idx",
|
||||
rows=blends_minimum_row)
|
||||
# side panel
|
||||
# subcol = row.column(align=True)
|
||||
# subcol.operator("gp.palettes_reload_blends", icon="FILE_REFRESH", text="")
|
||||
|
||||
## Show object UI list only once blend Uilist is filled ?
|
||||
if not len(pl_prop.blends) or (len(pl_prop.blends) == 1 and not bool(pl_prop.blends[0].blend_path)):
|
||||
col.label(text='Select blend refresh available objects')
|
||||
|
||||
row = col.row()
|
||||
row.template_list("GPTB_UL_object_list", "", pl_prop, "objects", pl_prop, "ob_idx",
|
||||
rows=objects_minimum_row)
|
||||
|
||||
## Show link button in the border of the UI list ?
|
||||
# col.prop(pl_prop, 'import_type')
|
||||
split = col.split(align=True, factor=0.4)
|
||||
split.prop(pl_prop, 'import_type', text='')
|
||||
|
||||
split.enabled = len(pl_prop.objects) and bool(pl_prop.objects[pl_prop.ob_idx].path)
|
||||
split.operator('gp.import_obj_palette', text='Palette')
|
||||
|
||||
# button to launch link with combined props (active only if the two items are valids)
|
||||
# str(Path(self.blends) / 'Object' / self.objects
|
||||
|
||||
|
||||
class GPTB_PT_palettes_linker_main_ui(Panel):
|
||||
bl_space_type = 'TOPBAR' # dummy
|
||||
bl_region_type = 'HEADER'
|
||||
# bl_space_type = "VIEW_3D"
|
||||
# bl_region_type = "UI"
|
||||
# bl_category = "Gpencil"
|
||||
bl_label = "Palettes Mat Linker"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
## link button for tests
|
||||
# layout.operator('gp.import_obj_palette', text='Palette')
|
||||
|
||||
# Subpanel are appended to this main UI
|
||||
|
||||
## Or just as One fat panel
|
||||
# palettes_path_ui(self, context)
|
||||
# palettes_lists_ui(self, context)
|
||||
|
||||
class GPTB_PT_palettes_path_ui(Panel):
|
||||
bl_space_type = "VIEW_3D"
|
||||
bl_region_type = "UI"
|
||||
bl_category = "Gpencil"
|
||||
bl_label = "Palettes Source" # Source Path
|
||||
# bl_parent_id = "GPTB_PT_palettes_linker_main_ui"
|
||||
bl_parent_id = "GPTB_PT_color"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
palettes_path_ui(self, context)
|
||||
# layout.label()
|
||||
|
||||
# pop-up version of object lists
|
||||
class GPTB_PT_palettes_list_popup(Panel):
|
||||
bl_space_type = 'TOPBAR' # dummy
|
||||
bl_region_type = 'HEADER'
|
||||
bl_category = "Gpencil"
|
||||
bl_label = "Palettes Lists"
|
||||
bl_ui_units_x = 18
|
||||
|
||||
def draw(self, context):
|
||||
palettes_lists_ui(self, context, popup=True)
|
||||
|
||||
class GPTB_PT_palettes_list_ui(Panel):
|
||||
bl_space_type = "VIEW_3D"
|
||||
bl_region_type = "UI"
|
||||
bl_category = "Gpencil"
|
||||
bl_label = "Palettes Lists"
|
||||
bl_parent_id = "GPTB_PT_color"
|
||||
bl_options = {'DEFAULT_CLOSED'}
|
||||
|
||||
def draw_header(self, context):
|
||||
layout = self.layout
|
||||
# layout.label(text="My Select Panel")
|
||||
layout.operator("wm.call_panel", text="", icon='COLOR').name = "GPTB_PT_palettes_list_popup"
|
||||
|
||||
def draw(self, context):
|
||||
palettes_lists_ui(self, context, popup=False)
|
||||
|
||||
|
||||
## bl 3+ UI
|
||||
def asset_browser_ui(self, context):
|
||||
'''Only shows in blender >= 3.0.0'''
|
||||
|
||||
@@ -429,6 +579,12 @@ GPTB_PT_anim_manager,
|
||||
GPTB_PT_color,
|
||||
GPTB_PT_tint_layers,
|
||||
GPTB_PT_toolbox_playblast,
|
||||
|
||||
# palettes linker
|
||||
GPTB_PT_palettes_linker_main_ui, # main panel
|
||||
GPTB_PT_palettes_list_popup, # popup (dummy region)
|
||||
GPTB_PT_palettes_path_ui, # subpanels
|
||||
GPTB_PT_palettes_list_ui, # subpanels
|
||||
# GPTB_PT_extra,
|
||||
)
|
||||
|
||||
@@ -467,34 +623,61 @@ def GPdata_toolbox_panel(self, context):
|
||||
col.prop(settings, 'autotint_offset')
|
||||
col.operator("gp.auto_tint_gp_layers", icon = "COLOR").reset = False
|
||||
col.operator("gp.auto_tint_gp_layers", text = "Reset tint", icon = "COLOR").reset = True
|
||||
"""
|
||||
"""
|
||||
|
||||
"""
|
||||
Put back UI for interpolate
|
||||
|
||||
|
||||
# Grease Pencil stroke interpolation tools native pop hover panel from 2.92
|
||||
class VIEW3D_PT_tools_grease_pencil_interpolate(Panel):
|
||||
bl_space_type = 'VIEW_3D'
|
||||
bl_region_type = 'HEADER'
|
||||
bl_label = "Interpolate"
|
||||
|
||||
### old
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
if context.gpencil_data is None:
|
||||
return False
|
||||
|
||||
"""
|
||||
col = layout.column(align = True)
|
||||
col.operator("gpencil.stroke_change_color", text="Move to Color",icon = "COLOR")
|
||||
col.operator("transform.shear", text="Shear")
|
||||
col.operator("gpencil.stroke_cyclical_set", text="Toggle Cyclic").type = 'TOGGLE'
|
||||
col.operator("gpencil.stroke_subdivide", text="Subdivide",icon = "OUTLINER_DATA_MESH")
|
||||
gpd = context.gpencil_data
|
||||
valid_mode = bool(gpd.use_stroke_edit_mode or gpd.is_stroke_paint_mode)
|
||||
return bool(context.editable_gpencil_strokes) and valid_mode
|
||||
|
||||
row = layout.row(align = True)
|
||||
row.operator("gpencil.stroke_join", text="Join").type = 'JOIN'
|
||||
row.operator("grease_pencil.stroke_separate", text = "Separate")
|
||||
col.operator("gpencil.stroke_flip", text="Flip Direction",icon = "ARROW_LEFTRIGHT")
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
settings = context.tool_settings.gpencil_interpolate
|
||||
|
||||
col = layout.column(align = True)
|
||||
col.operator("gptools.randomise",icon = 'RNDCURVE')
|
||||
col.operator("gptools.thickness",icon = 'LINE_DATA')
|
||||
col.operator("gptools.angle_split",icon = 'MOD_BEVEL',text='Angle Splitting')
|
||||
col.operator("gptools.stroke_uniform_density",icon = 'MESH_DATA',text = 'Density')
|
||||
col = layout.column(align=True)
|
||||
col.label(text="Interpolate Strokes")
|
||||
col.operator("gpencil.interpolate", text="Interpolate")
|
||||
col.operator("gpencil.interpolate_sequence", text="Sequence")
|
||||
col.operator("gpencil.interpolate_reverse", text="Remove Breakdowns")
|
||||
|
||||
row = layout.row(align = True)
|
||||
row.prop(settings,"extra_tools",text='',icon = "DOWNARROW_HLT" if settings.extra_tools else "RIGHTARROW",emboss = False)
|
||||
row.label("Extra tools")
|
||||
col = layout.column(align=True)
|
||||
col.label(text="Options:")
|
||||
col.prop(settings, "interpolate_all_layers")
|
||||
|
||||
if settings.extra_tools :
|
||||
layout.operator_menu_enum("gpencil.stroke_arrange", text="Arrange Strokes...", property="direction")
|
||||
"""
|
||||
gpd = context.gpencil_data
|
||||
if gpd.use_stroke_edit_mode:
|
||||
col.prop(settings, "interpolate_selected_only")
|
||||
|
||||
col = layout.column(align=True)
|
||||
col.label(text="Sequence Options:")
|
||||
col.prop(settings, "step")
|
||||
col.prop(settings, "type")
|
||||
if settings.type == 'CUSTOM':
|
||||
# TODO: Options for loading/saving curve presets?
|
||||
col.template_curve_mapping(settings, "interpolation_curve", brush=True,
|
||||
use_negative_slope=True)
|
||||
elif settings.type != 'LINEAR':
|
||||
col.prop(settings, "easing")
|
||||
|
||||
if settings.type == 'BACK':
|
||||
layout.prop(settings, "back")
|
||||
elif settings.type == 'ELASTIC':
|
||||
sub = layout.column(align=True)
|
||||
sub.prop(settings, "amplitude")
|
||||
sub.prop(settings, "period")
|
||||
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user