gp_interpolate/ui.py

111 lines
4.3 KiB
Python
Raw Permalink Normal View History

2023-11-30 15:08:32 +01:00
import bpy
class GP_PT_interpolate(bpy.types.Panel):
bl_label = "Interpolate"
bl_category = "Gpencil"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
# @classmethod
# def poll(cls, context):
# return context.object
2023-11-30 15:08:32 +01:00
def draw(self, context):
settings = bpy.context.scene.gp_interpo_settings
layout = self.layout
2023-11-30 19:03:20 +01:00
layout.use_property_split = True
layout.use_property_decorate = False
2023-11-30 15:08:32 +01:00
col = layout.column(align=False)
## Interpolation buttons
2023-11-30 15:08:32 +01:00
if settings.mode == 'FRAME':
prev_icon, next_icon = 'FRAME_PREV', 'FRAME_NEXT'
else:
prev_icon, next_icon = 'PREV_KEYFRAME', 'NEXT_KEYFRAME'
prev_text = next_text = ''
scn = context.scene
if settings.use_animation:
prev_icon, next_icon = 'PLAY_REVERSE', 'PLAY'
## Show animation range:
prev_text = f'{scn.frame_preview_start if scn.use_preview_range else scn.frame_start} < {scn.frame_current}'
next_text = f'{scn.frame_current} > {scn.frame_preview_end if scn.use_preview_range else scn.frame_end}'
2023-11-30 15:08:32 +01:00
row = col.row(align=True)
row.scale_y = 1.2
direction_button_row = row.row(align=True)
direction_button_row.scale_x = 3
2024-07-23 17:25:13 +02:00
ops_id = "gp.interpolate_stroke_tri" if settings.method == 'TRI' else "gp.interpolate_stroke"
direction_button_row.operator(ops_id, text=prev_text, icon=prev_icon).next = False
direction_button_row.operator(ops_id, text=next_text, icon=next_icon).next = True
2024-07-24 17:33:31 +02:00
## Button for interactive mode (icons: SNAP_INCREMENT, ACTION_TWEAK, CON_ACTION, CENTER_ONLY)
interactive_mode_row = row.row()
interactive_mode_row.operator(ops_id, text='', icon='ACTION_TWEAK').interactive = True
2023-11-30 15:08:32 +01:00
col.prop(settings, 'use_animation', text='Animation')
2024-01-12 17:02:46 +01:00
col.prop(settings, 'method', text='Method')
2023-11-30 19:03:20 +01:00
if settings.method == 'BONE':
col = layout.column(align=True)
col.prop_search(settings, 'target_rig', context.scene, 'objects', text='Rig')
if settings.target_rig:
# col.prop_search(ob.rig_picker, 'name', settings.target_rig.pose, 'bones', text='Bone')
col.prop_search(settings, 'target_bone', settings.target_rig.pose, 'bones', text='Bone')
2023-12-05 11:27:48 +01:00
col.prop(settings, 'use_bone_rotation', text='Use Bone Rotation')
2023-11-30 19:03:20 +01:00
elif settings.method == 'GEOMETRY':
col.prop(settings, 'search_range')
col.prop(settings, 'remove_occluded')
2024-02-06 15:57:35 +01:00
elif settings.method == 'OBJECT':
col.prop(settings, 'search_range')
2024-02-06 15:57:35 +01:00
col.prop(settings, 'target_object', text='Object')
2023-11-30 19:03:20 +01:00
col.separator()
col = layout.column(align=True)
2023-11-30 15:08:32 +01:00
row = col.row(align=True)
row.prop(settings, 'mode', expand=True)
if settings.mode == 'FRAME':
2024-07-23 17:25:13 +02:00
col.prop(settings, 'step', text='Step')
if settings.mode == 'RIGKEY':
col.prop(settings, 'target_collection', text='Collection')
2024-01-12 17:02:46 +01:00
## Parent still full WIP
# col = layout.column()
# col.label(text='Layer Parent')
# col.operator('gp.parent_layer', text='Direct Parent').direct_parent = True
# col.operator('gp.parent_layer', text='Empty Parent').direct_parent = False
2023-11-30 15:08:32 +01:00
2024-07-15 15:47:24 +02:00
if context.scene.gp_interpo_settings.method in ('GEOMETRY', 'OBJECT'):
col.separator()
row = col.row(align=True)
row.operator('gp.debug_geometry_interpolation_targets', text='Debug points')
row.operator('gp.debug_geometry_interpolation_targets', text='', icon='X').clear = True
if context.scene.gp_interpo_settings.method == 'TRI':
col.separator()
row=layout.row(align=True)
wm = bpy.context.window_manager
binded = context.object and context.object.type == 'GPENCIL' and wm.get(f'tri_{context.object.name}')
txt = 'Show Tri Points' if binded else 'Bind Tri Points'
row.operator('gp.bind_points', text=txt, icon='MESH_DATA')
if binded:
row.operator('gp.bind_points', text='', icon='TRASH').clear = True
2024-07-15 15:47:24 +02:00
2023-11-30 15:08:32 +01:00
classes = (
GP_PT_interpolate,
)
def register():
for c in classes:
bpy.utils.register_class(c)
def unregister():
for c in reversed(classes) :
bpy.utils.unregister_class(c)