2021-08-23 14:50:00 +02:00
|
|
|
# from . import addon_updater_ops
|
2021-01-10 16:47:17 +01:00
|
|
|
from .utils import get_addon_prefs
|
|
|
|
import bpy
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
|
|
## UI in properties
|
|
|
|
|
|
|
|
### dataprop_panel not used --> transferred to sidebar
|
|
|
|
"""
|
|
|
|
class GPTB_PT_dataprop_panel(bpy.types.Panel):
|
|
|
|
bl_space_type = 'PROPERTIES'
|
|
|
|
bl_region_type = 'WINDOW'
|
|
|
|
# bl_space_type = 'VIEW_3D'
|
|
|
|
# bl_region_type = 'UI'
|
|
|
|
# bl_category = "Tool"
|
|
|
|
# bl_idname = "ADDONID_PT_panel_name"# identifier, if ommited, takes the name of the class.
|
|
|
|
bl_label = "Pseudo color"# title
|
|
|
|
bl_parent_id = "DATA_PT_gpencil_layers"#subpanel of this ID
|
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
layout.use_property_split = True
|
|
|
|
settings = context.scene.gptoolprops
|
|
|
|
|
|
|
|
col = layout.column(align = True)
|
|
|
|
row = col.split(align=False, factor=0.63)
|
|
|
|
row.prop(settings, 'autotint_offset')
|
|
|
|
row.prop(settings, 'autotint_namespace')
|
|
|
|
|
|
|
|
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
|
|
|
|
"""
|
|
|
|
|
|
|
|
## UI in Gpencil sidebar menu
|
|
|
|
|
|
|
|
class GPTB_PT_sidebar_panel(bpy.types.Panel):
|
2021-10-20 13:56:01 +02:00
|
|
|
bl_label = "GP Toolbox"
|
2021-01-10 16:47:17 +01:00
|
|
|
bl_space_type = "VIEW_3D"
|
|
|
|
bl_region_type = "UI"
|
|
|
|
bl_category = "Gpencil"
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
# layout.use_property_split = True
|
2021-08-23 14:50:00 +02:00
|
|
|
prefs = get_addon_prefs()
|
2021-01-10 16:47:17 +01:00
|
|
|
rd = context.scene.render
|
|
|
|
# check for update
|
2021-08-23 14:50:00 +02:00
|
|
|
# addon_updater_ops.check_for_update_background()
|
2021-01-10 16:47:17 +01:00
|
|
|
|
|
|
|
# layout.label(text='View options:')
|
2021-10-20 13:56:01 +02:00
|
|
|
col = layout.column()
|
2021-01-10 16:47:17 +01:00
|
|
|
## flip X cam
|
|
|
|
if context.scene.camera and context.scene.camera.scale.x < 0:
|
|
|
|
# layout.label(text='! Flipped !')
|
2021-10-20 13:56:01 +02:00
|
|
|
row = col.row(align=True)
|
2021-01-10 16:47:17 +01:00
|
|
|
|
|
|
|
row.operator('gp.mirror_flipx', text = 'Mirror flip', icon = 'MOD_MIRROR')# ARROW_LEFTRIGHT
|
|
|
|
row.label(text='',icon='LOOP_BACK')
|
|
|
|
else:
|
2021-10-20 13:56:01 +02:00
|
|
|
col.operator('gp.mirror_flipx', text = 'Mirror flip', icon = 'MOD_MIRROR')# ARROW_LEFTRIGHT
|
2021-01-10 16:47:17 +01:00
|
|
|
|
|
|
|
## draw/manipulation camera
|
|
|
|
if context.scene.camera and context.scene.camera.name.startswith(('draw', 'obj')):
|
|
|
|
row = col.row(align=True)
|
|
|
|
row.operator('gp.draw_cam_switch', text = 'Main cam', icon = 'OUTLINER_OB_CAMERA')
|
|
|
|
row.label(text='',icon='LOOP_BACK')
|
|
|
|
if context.scene.camera.name.startswith('draw'):
|
|
|
|
col.operator('gp.reset_cam_rot', text='reset rotation')#.swapmethod ? = CAM
|
|
|
|
else:
|
|
|
|
col.operator('gp.set_view_as_cam', text='set view')#.swapmethod ? = CAM
|
|
|
|
|
|
|
|
else:
|
|
|
|
row = col.row(align=True)
|
|
|
|
row.operator('gp.draw_cam_switch', text = 'Draw cam', icon = 'CON_CAMERASOLVER').cam_mode = 'draw'
|
|
|
|
row.operator('gp.draw_cam_switch', text = 'Object cam', icon = 'CON_CAMERASOLVER').cam_mode = 'object'
|
|
|
|
col.label(text='In main camera', icon = 'OUTLINER_OB_CAMERA')
|
|
|
|
|
|
|
|
# layout.operator('gp.overlay_presets', text = 'Toggle overlays', icon = 'OVERLAY')
|
|
|
|
|
|
|
|
if context.scene.camera:
|
|
|
|
row = layout.row(align=True)# .split(factor=0.5)
|
|
|
|
row.label(text='Passepartout')
|
2021-06-05 01:20:35 +02:00
|
|
|
if context.scene.camera.name == 'draw_cam':
|
|
|
|
row.prop(context.scene.gptoolprops, 'drawcam_passepartout', text='', icon ='OBJECT_HIDDEN')
|
|
|
|
else:
|
|
|
|
row.prop(context.scene.camera.data, 'show_passepartout', text='', icon ='OBJECT_HIDDEN')
|
2021-01-10 16:47:17 +01:00
|
|
|
row.prop(context.scene.camera.data, 'passepartout_alpha', text='')
|
|
|
|
row = layout.row(align=True)
|
2021-06-05 01:20:35 +02:00
|
|
|
row.operator('view3d.zoom_camera_1_to_1', text = 'Zoom 1:1', icon = 'ZOOM_PREVIOUS') # FULLSCREEN_EXIT
|
2021-01-10 16:47:17 +01:00
|
|
|
row.operator('view3d.view_center_camera', text = 'Zoom fit', icon = 'FULLSCREEN_ENTER')
|
|
|
|
|
|
|
|
## background images/videos
|
|
|
|
if context.scene.camera.data.background_images:
|
|
|
|
layout.separator()
|
|
|
|
icon_bg = 'RESTRICT_VIEW_OFF' if context.scene.camera.data.show_background_images else 'RESTRICT_VIEW_ON'# IMAGE_BACKGROUND#IMAGE_PLANE
|
|
|
|
# icon_bg = 'TRIA_DOWN' if context.scene.camera.data.show_background_images else 'IMAGE_BACKGROUND'
|
|
|
|
box = layout.box()
|
|
|
|
box.prop(context.scene.camera.data, 'show_background_images', text='Ref in cam', icon=icon_bg)
|
|
|
|
if context.scene.camera.data.show_background_images:
|
|
|
|
# box = layout.box()
|
|
|
|
for bg_img in context.scene.camera.data.background_images:
|
|
|
|
if bg_img.source == 'IMAGE' and bg_img.image:
|
|
|
|
row = box.row(align=True)
|
2021-03-31 01:38:17 +02:00
|
|
|
row.prop(bg_img, 'show_background_image', text='', icon='IMAGE_RGB')
|
|
|
|
row.prop(bg_img, 'alpha', text=bg_img.image.name) # options={'HIDDEN'}
|
|
|
|
# row.label(icon='IMAGE_RGB')
|
|
|
|
# icon = 'HIDE_OFF' if bg_img.show_background_image else 'HIDE_ON'
|
|
|
|
# row.prop(bg_img, 'show_background_image', text='', icon=icon)
|
|
|
|
|
2021-01-10 16:47:17 +01:00
|
|
|
if bg_img.source == 'MOVIE_CLIP' and bg_img.clip:
|
|
|
|
row = box.row(align=True)
|
2021-03-31 01:38:17 +02:00
|
|
|
row.prop(bg_img, 'show_background_image', text='', icon='FILE_MOVIE')
|
|
|
|
row.prop(bg_img, 'alpha', text=bg_img.clip.name) # options={'HIDDEN'}
|
|
|
|
# row.label(icon='FILE_MOVIE')
|
|
|
|
# icon = 'HIDE_OFF' if bg_img.show_background_image else 'HIDE_ON'
|
|
|
|
# row.prop(bg_img, 'show_background_image', text='', icon=icon)
|
2021-01-10 16:47:17 +01:00
|
|
|
|
|
|
|
else:
|
|
|
|
layout.label(text='No camera !', icon = 'ERROR')
|
|
|
|
|
2021-06-05 01:20:35 +02:00
|
|
|
## Straight line ops from official greasepencil_tools addon if enabled.
|
|
|
|
# if any(x in context.preferences.addons.keys() for x in ('greasepencil_tools', 'greasepencil-addon')): # check enabled addons
|
2021-06-06 21:30:46 +02:00
|
|
|
if hasattr(bpy.types, 'GP_OT_straight_stroke'): # check if operator exists : bpy.ops.gp.straight_stroke.idname()
|
2021-06-05 01:20:35 +02:00
|
|
|
layout.operator('gp.straight_stroke', icon ="CURVE_PATH")
|
|
|
|
|
2021-01-10 16:47:17 +01:00
|
|
|
## Options
|
2021-10-20 13:56:01 +02:00
|
|
|
col = layout.column()
|
|
|
|
col.label(text = 'Options:')
|
2021-05-02 23:14:38 +02:00
|
|
|
|
|
|
|
## Kf Jump filter
|
2021-10-20 13:56:01 +02:00
|
|
|
col.prop(context.scene.gptoolprops, 'keyframe_type', text='Jump On') # Keyframe Jump
|
2021-06-05 01:20:35 +02:00
|
|
|
# col.prop(context.space_data.overlay, 'use_gpencil_onion_skin') # not often used
|
2021-01-10 16:47:17 +01:00
|
|
|
|
|
|
|
if context.object and context.object.type == 'GPENCIL':
|
2021-06-05 01:20:35 +02:00
|
|
|
# col.prop(context.object.data, 'use_autolock_layers') # not often used
|
|
|
|
col.prop(context.object, 'show_in_front', text='X-ray') # default text "In Front"
|
2021-01-10 16:47:17 +01:00
|
|
|
|
|
|
|
## rename datablock temporary layout
|
|
|
|
if context.object.name != context.object.data.name:
|
2021-05-09 01:26:37 +02:00
|
|
|
box = col.box()
|
2021-01-10 16:47:17 +01:00
|
|
|
box.label(text='different name for object and data:', icon='INFO')
|
|
|
|
row = box.row(align=False)
|
|
|
|
row.operator('gp.rename_data_from_obj').rename_all = False
|
|
|
|
row.operator('gp.rename_data_from_obj', text='Rename all').rename_all = True
|
|
|
|
|
|
|
|
## Check base palette
|
2021-08-23 14:50:00 +02:00
|
|
|
if prefs.warn_base_palette and prefs.palette_path:
|
|
|
|
if not all(x in [m.name for m in context.object.data.materials if m] for x in ("line", "invisible")):
|
|
|
|
box = col.box()
|
|
|
|
box.label(text='Missing base material setup', icon='INFO')
|
|
|
|
box.operator('gp.load_default_palette')
|
2021-05-04 23:17:19 +02:00
|
|
|
|
2021-01-10 16:47:17 +01:00
|
|
|
else:
|
2021-05-09 01:26:37 +02:00
|
|
|
col.label(text='No GP object selected')
|
2021-01-10 16:47:17 +01:00
|
|
|
|
2021-05-09 01:26:37 +02:00
|
|
|
col.prop(context.scene.gptoolprops, 'edit_lines_opacity')
|
2021-06-05 01:20:35 +02:00
|
|
|
|
2021-01-10 16:47:17 +01:00
|
|
|
# Mention update as notice
|
2021-08-23 14:50:00 +02:00
|
|
|
# addon_updater_ops.update_notice_box_ui(self, context)
|
2021-01-10 16:47:17 +01:00
|
|
|
|
|
|
|
# row = layout.row(align=False)
|
|
|
|
# row.label(text='arrow choice')
|
|
|
|
# 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):
|
2021-10-20 13:56:01 +02:00
|
|
|
bl_label = "Animation Manager"
|
2021-01-10 16:47:17 +01:00
|
|
|
bl_space_type = "VIEW_3D"
|
|
|
|
bl_region_type = "UI"
|
|
|
|
bl_category = "Gpencil"
|
|
|
|
bl_parent_id = "GPTB_PT_sidebar_panel"
|
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
|
|
|
|
|
|
|
# def draw_header(self,context):
|
|
|
|
# self.layout.prop(context.scene.camera.data, "show_background_images", text="")
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
layout.use_property_split = True
|
2021-10-20 13:56:01 +02:00
|
|
|
col = layout.column()
|
2021-01-10 16:47:17 +01:00
|
|
|
## Animation enable disable anim (shift click to select) OP_helpers.GPTB_OT_toggle_mute_animation
|
2021-10-20 13:56:01 +02:00
|
|
|
|
|
|
|
col.operator('gp.list_disabled_anims')
|
2021-01-10 16:47:17 +01:00
|
|
|
## Objs ()
|
2021-10-20 13:56:01 +02:00
|
|
|
row = col.row(align=True)
|
2021-01-10 16:47:17 +01:00
|
|
|
row.label(text='Obj anims:')
|
|
|
|
ops = row.operator('gp.toggle_mute_animation', text = 'ON')#, icon = 'GRAPH'
|
|
|
|
ops.skip_gp = True
|
|
|
|
ops.skip_obj = False
|
|
|
|
ops.mute = False
|
|
|
|
|
|
|
|
ops = row.operator('gp.toggle_mute_animation', text = 'OFF')#, icon = 'GRAPH'
|
|
|
|
ops.skip_gp = True
|
|
|
|
ops.skip_obj = False
|
|
|
|
ops.mute = True
|
2021-10-20 21:17:37 +02:00
|
|
|
|
|
|
|
## GPs
|
2021-10-20 13:56:01 +02:00
|
|
|
row = col.row(align=True)
|
2021-01-10 16:47:17 +01:00
|
|
|
row.label(text='Gp anims:')
|
|
|
|
ops = row.operator('gp.toggle_mute_animation', text = 'ON')#, icon = 'GRAPH'
|
|
|
|
ops.skip_gp = False
|
|
|
|
ops.skip_obj = True
|
|
|
|
ops.mute = False
|
|
|
|
|
|
|
|
ops = row.operator('gp.toggle_mute_animation', text = 'OFF')#, icon = 'GRAPH'
|
|
|
|
ops.skip_gp = False
|
|
|
|
ops.skip_obj = True
|
|
|
|
ops.mute = True
|
2021-10-20 21:17:37 +02:00
|
|
|
|
|
|
|
## GP modifiers
|
|
|
|
row = col.row(align=True)
|
|
|
|
row.label(text='Gp modifiers:')
|
|
|
|
row.operator('gp.toggle_hide_gp_modifier', text = 'ON').show = True
|
|
|
|
row.operator('gp.toggle_hide_gp_modifier', text = 'OFF').show = False
|
2021-01-10 16:47:17 +01:00
|
|
|
|
2021-10-20 13:56:01 +02:00
|
|
|
## This can go in an extra category...
|
|
|
|
col = layout.column()
|
|
|
|
col.use_property_split = False
|
|
|
|
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)
|
|
|
|
|
2021-06-05 01:20:35 +02:00
|
|
|
class GPTB_PT_toolbox_playblast(bpy.types.Panel):
|
|
|
|
bl_label = "Playblast"
|
|
|
|
bl_space_type = "VIEW_3D"
|
|
|
|
bl_region_type = "UI"
|
|
|
|
bl_category = "Gpencil"
|
|
|
|
bl_parent_id = "GPTB_PT_sidebar_panel"
|
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
rd = context.scene.render
|
|
|
|
row = layout.row(align=False) # split(factor=0.6)
|
|
|
|
percent = context.scene.gptoolprops.resolution_percentage
|
|
|
|
row.label(text = f'{rd.resolution_x * percent // 100} x {rd.resolution_y * percent // 100}')
|
|
|
|
row.prop(context.scene.gptoolprops, 'resolution_percentage', text='')
|
|
|
|
# row.prop(rd, 'resolution_percentage', text='') # real percent scene percentage
|
|
|
|
|
|
|
|
row = layout.row(align=True)
|
|
|
|
row.operator('render.thread_playblast', text = 'Playblast', icon = 'RENDER_ANIMATION')# non blocking background render playblast
|
|
|
|
# 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
|
|
|
|
|
2021-01-10 16:47:17 +01:00
|
|
|
class GPTB_PT_tint_layers(bpy.types.Panel):
|
2021-10-20 13:56:01 +02:00
|
|
|
bl_label = "Tint Layers"
|
2021-01-10 16:47:17 +01:00
|
|
|
bl_space_type = "VIEW_3D"
|
|
|
|
bl_region_type = "UI"
|
|
|
|
bl_category = "Gpencil"
|
|
|
|
bl_parent_id = "GPTB_PT_sidebar_panel"
|
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
|
|
|
|
|
|
|
# def draw_header(self,context):
|
|
|
|
# self.layout.prop(context.scene.camera.data, "show_background_images", text="")
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
layout.use_property_split = True
|
|
|
|
## pseudo color layers
|
|
|
|
# layout.separator()
|
|
|
|
col = layout.column(align = True)
|
|
|
|
row = col.split(align=False, factor=0.63)
|
|
|
|
row.prop(context.scene.gptoolprops, 'autotint_offset')
|
|
|
|
row.prop(context.scene.gptoolprops, 'autotint_namespace')
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2021-10-20 13:56:01 +02:00
|
|
|
|
|
|
|
class GPTB_PT_checker(bpy.types.Panel):
|
|
|
|
bl_label = "Checker"
|
2021-01-10 16:47:17 +01:00
|
|
|
bl_space_type = "VIEW_3D"
|
|
|
|
bl_region_type = "UI"
|
|
|
|
bl_category = "Gpencil"
|
|
|
|
bl_parent_id = "GPTB_PT_sidebar_panel"
|
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
|
|
|
|
|
|
|
# def draw_header(self,context):
|
|
|
|
# self.layout.prop(context.scene.camera.data, "show_background_images", text="")
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2021-10-20 13:56:01 +02:00
|
|
|
col = layout.column()
|
|
|
|
row = col.row(align=True)
|
|
|
|
## realign / reproject
|
|
|
|
row.operator('gp.realign', icon='AXIS_FRONT')
|
|
|
|
## move in depth
|
|
|
|
row.operator('object.depth_proportional_move', text='Depth move', icon='TRANSFORM_ORIGINS')
|
2021-01-10 16:47:17 +01:00
|
|
|
|
2021-10-20 13:56:01 +02:00
|
|
|
## col.operator('gp.batch_reproject_all_frames') # text=Batch Reproject # added to context menu
|
|
|
|
## check drawing alignement
|
|
|
|
col.operator('gp.check_canvas_alignement', icon='DRIVER_ROTATIONAL_DIFFERENCE')
|
2021-01-10 16:47:17 +01:00
|
|
|
|
2021-10-20 13:56:01 +02:00
|
|
|
## File checker
|
|
|
|
row = col.row(align=True)
|
|
|
|
row.operator('gp.file_checker', text = 'Check file', icon = 'SCENE_DATA')
|
|
|
|
row.operator('gp.links_checker', text = 'Check links', icon = 'UNLINKED')
|
|
|
|
|
|
|
|
|
|
|
|
class GPTB_PT_color(bpy.types.Panel):
|
|
|
|
bl_label = "Color"
|
|
|
|
bl_space_type = "VIEW_3D"
|
|
|
|
bl_region_type = "UI"
|
|
|
|
bl_category = "Gpencil"
|
|
|
|
bl_parent_id = "GPTB_PT_sidebar_panel"
|
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
2021-06-05 01:20:35 +02:00
|
|
|
|
2021-10-20 13:56:01 +02:00
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2021-11-25 17:00:09 +01:00
|
|
|
col = layout.column()
|
2021-10-20 13:56:01 +02:00
|
|
|
## Create empty frame on layer
|
2021-11-25 17:00:09 +01:00
|
|
|
col.operator('gp.palette_linker', text=f'Link Materials Palette TO Object', icon='COLOR') ## ops
|
|
|
|
col.operator('gp.create_empty_frames', icon='DECORATE_KEYFRAME')
|
2021-01-10 16:47:17 +01:00
|
|
|
|
2021-10-20 13:56:01 +02:00
|
|
|
""" # unused : added in Animation Manager
|
|
|
|
class GPTB_PT_extra(bpy.types.Panel):
|
|
|
|
bl_label = "Extra"
|
|
|
|
bl_space_type = "VIEW_3D"
|
|
|
|
bl_region_type = "UI"
|
|
|
|
bl_category = "Gpencil"
|
|
|
|
bl_parent_id = "GPTB_PT_sidebar_panel"
|
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
col = layout.column()
|
|
|
|
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)
|
|
|
|
"""
|
2021-01-10 16:47:17 +01:00
|
|
|
|
|
|
|
"""
|
|
|
|
## unused -- (integrated in sidebar_panel)
|
|
|
|
class GPTB_PT_cam_ref_panel(bpy.types.Panel):
|
|
|
|
bl_label = "Background imgs"
|
|
|
|
bl_space_type = "VIEW_3D"
|
|
|
|
bl_region_type = "UI"
|
|
|
|
bl_category = "Gpencil"
|
|
|
|
bl_parent_id = "GPTB_PT_sidebar_panel"
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
return context.scene.camera
|
|
|
|
|
|
|
|
def draw_header(self,context):
|
|
|
|
self.layout.prop(context.scene.camera.data, "show_background_images", text="")
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
layout.use_property_split = True
|
|
|
|
|
|
|
|
if context.scene.camera.data.show_background_images:
|
|
|
|
for bg_img in context.scene.camera.data.background_images:
|
|
|
|
if bg_img.image:
|
|
|
|
row = layout.row(align=False)
|
|
|
|
row.label(text=bg_img.image.name, icon='IMAGE_RGB')
|
|
|
|
row.prop(bg_img, 'show_background_image', text='')# options={'HIDDEN'}
|
|
|
|
"""
|
|
|
|
|
|
|
|
def palette_manager_menu(self, context):
|
|
|
|
"""Palette menu to append in existing menu"""
|
|
|
|
# GPENCIL_MT_material_context_menu
|
|
|
|
layout = self.layout
|
|
|
|
# {'EDIT_GPENCIL', 'PAINT_GPENCIL','SCULPT_GPENCIL','WEIGHT_GPENCIL', 'VERTEX_GPENCIL'}
|
|
|
|
layout.separator()
|
|
|
|
prefs = get_addon_prefs()
|
|
|
|
|
2021-03-16 22:52:26 +01:00
|
|
|
layout.operator("gp.copy_active_to_selected_palette", text='Append Materials To Selected', icon='MATERIAL')
|
2021-01-10 16:47:17 +01:00
|
|
|
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
|
2021-06-07 19:07:37 +02:00
|
|
|
layout.operator("gp.clean_material_stack", text='Clean material Stack', icon='NODE_MATERIAL')
|
2021-01-10 16:47:17 +01:00
|
|
|
|
|
|
|
|
2021-10-28 14:33:37 +02:00
|
|
|
def expose_use_channel_color_pref(self, context):
|
|
|
|
# add in GreasePencilLayerDisplayPanel (gp dopesheet View > Display)
|
|
|
|
layout = self.layout
|
|
|
|
layout.use_property_split = True
|
|
|
|
layout.use_property_decorate = False
|
|
|
|
layout.label(text='Use Channel Colors (User preferences):')
|
|
|
|
layout.prop(context.preferences.edit, 'use_anim_channel_group_colors')
|
|
|
|
|
2021-11-25 17:00:09 +01:00
|
|
|
def asset_browser_ui(self, context):
|
|
|
|
'''Only shows in blender >= 3.0.0'''
|
|
|
|
|
|
|
|
layout = self.layout
|
|
|
|
asset_file_handle = context.asset_file_handle
|
|
|
|
if asset_file_handle is None:
|
|
|
|
# layout.label(text="No asset selected", icon='INFO')
|
|
|
|
layout.label(text='No object/material selected', icon='INFO')
|
|
|
|
return
|
|
|
|
if asset_file_handle.id_type not in ('OBJECT', 'MATERIAL'):
|
|
|
|
layout.label(text='No object/material selected', icon='INFO')
|
|
|
|
return
|
|
|
|
|
|
|
|
layout.use_property_split = True
|
|
|
|
layout.use_property_decorate = False
|
|
|
|
|
|
|
|
asset_library_ref = context.asset_library_ref
|
|
|
|
## Path to blend
|
|
|
|
asset_lib_path = bpy.types.AssetHandle.get_full_library_path(asset_file_handle, asset_library_ref)
|
|
|
|
path_to_obj = Path(asset_lib_path) / 'Objects' / asset_file_handle.name
|
|
|
|
|
|
|
|
## respect header choice ?
|
|
|
|
## import_type in (LINK, APPEND, APPEND_REUSE)
|
|
|
|
imp_type = context.space_data.params.import_type
|
|
|
|
if imp_type == 'APPEND':
|
|
|
|
imp_txt = 'Append'
|
|
|
|
elif imp_type == 'APPEND_REUSE':
|
|
|
|
imp_txt = 'Append (Reuse)'
|
|
|
|
else:
|
|
|
|
imp_txt = 'Link'
|
|
|
|
|
|
|
|
if asset_file_handle.id_type == 'MATERIAL':
|
|
|
|
layout.label(text=f'From Mat: {asset_file_handle.name}')
|
|
|
|
if asset_file_handle.id_type == 'OBJECT':
|
|
|
|
layout.label(text=f'From Obj: {asset_file_handle.name}')
|
|
|
|
layout.label(text=f'{imp_txt} Materials To GP Object')
|
|
|
|
layout.operator('gp.palette_linker', text=f'{imp_txt} Materials To GP Object') ## ops
|
|
|
|
|
|
|
|
# layout.label(text='Link Materials to GP Object')
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-01-10 16:47:17 +01:00
|
|
|
classes = (
|
|
|
|
GPTB_PT_sidebar_panel,
|
2021-10-20 13:56:01 +02:00
|
|
|
GPTB_PT_checker,
|
2021-01-10 16:47:17 +01:00
|
|
|
GPTB_PT_anim_manager,
|
2021-10-20 13:56:01 +02:00
|
|
|
GPTB_PT_color,
|
2021-01-10 16:47:17 +01:00
|
|
|
GPTB_PT_tint_layers,
|
2021-10-20 13:56:01 +02:00
|
|
|
GPTB_PT_toolbox_playblast,
|
|
|
|
# GPTB_PT_extra,
|
2021-01-10 16:47:17 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
def register():
|
|
|
|
for cls in classes:
|
|
|
|
bpy.utils.register_class(cls)
|
|
|
|
bpy.types.GPENCIL_MT_material_context_menu.append(palette_manager_menu)
|
2021-10-28 14:33:37 +02:00
|
|
|
bpy.types.DOPESHEET_PT_gpencil_layer_display.append(expose_use_channel_color_pref)
|
2021-01-10 16:47:17 +01:00
|
|
|
|
2021-11-25 17:00:09 +01:00
|
|
|
# if bpy.app.version >= (3,0,0):
|
|
|
|
# bpy.types.ASSETBROWSER_PT_metadata.append(asset_browser_ui)
|
|
|
|
|
|
|
|
|
2021-01-10 16:47:17 +01:00
|
|
|
def unregister():
|
2021-10-28 14:33:37 +02:00
|
|
|
bpy.types.DOPESHEET_PT_gpencil_layer_display.remove(expose_use_channel_color_pref)
|
2021-01-10 16:47:17 +01:00
|
|
|
bpy.types.GPENCIL_MT_material_context_menu.remove(palette_manager_menu)
|
2021-11-25 17:00:09 +01:00
|
|
|
# if bpy.app.version >= (3,0,0):
|
|
|
|
# bpy.types.ASSETBROWSER_PT_metadata.remove(asset_browser_ui)
|
|
|
|
|
2021-01-10 16:47:17 +01:00
|
|
|
for cls in reversed(classes):
|
|
|
|
bpy.utils.unregister_class(cls)
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
## direct panel def append (no submenu with arrow)
|
|
|
|
## need to use append and remove in register/unregister
|
|
|
|
# bpy.types.DATA_PT_gpencil_layers.append(UI_tools.GPdata_toolbox_panel)
|
|
|
|
# bpy.types.DATA_PT_gpencil_layers.remove(UI_tools.GPdata_toolbox_panel)
|
|
|
|
|
|
|
|
def GPdata_toolbox_panel(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
layout.use_property_split = True
|
|
|
|
settings = context.scene.gptoolprops
|
|
|
|
|
|
|
|
col = layout.column(align = True)
|
|
|
|
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
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### old
|
|
|
|
|
|
|
|
"""
|
|
|
|
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")
|
|
|
|
|
|
|
|
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")
|
|
|
|
|
|
|
|
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')
|
|
|
|
|
|
|
|
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")
|
|
|
|
|
|
|
|
if settings.extra_tools :
|
2021-06-05 01:20:35 +02:00
|
|
|
layout.operator_menu_enum("gpencil.stroke_arrange", text="Arrange Strokes...", property="direction")
|
|
|
|
"""
|