From 0b76c96175c6bef3886b0ee88205dc7a80dc6504 Mon Sep 17 00:00:00 2001 From: pullusb Date: Thu, 30 Nov 2023 15:08:32 +0100 Subject: [PATCH] complete first version --- __init__.py | 37 +++++++++++--- interpolate_strokes/__init__.py | 22 ++++++++ .../operators.py | 0 .../properties.py | 0 ui.py | 51 +++++++++++++++++++ 5 files changed, 103 insertions(+), 7 deletions(-) mode change 100644 => 100755 __init__.py create mode 100644 interpolate_strokes/__init__.py rename operators.py => interpolate_strokes/operators.py (100%) rename properties.py => interpolate_strokes/properties.py (100%) create mode 100755 ui.py diff --git a/__init__.py b/__init__.py old mode 100644 new mode 100755 index 8e29173..8db4f24 --- a/__init__.py +++ b/__init__.py @@ -1,19 +1,42 @@ -from gp_interpolate.interpolate_strokes import operators, properties +bl_info = { + "name": "gp interpolate", + "author": "Christophe Seux, Samuel Bernou", + "version": (0, 1, 0), + "blender": (3, 6, 0), + "location": "", + "description": "Interpolate Grease pencil strokes", + "warning": "", + "wiki_url": "", + "tracker_url": "", + "category": "Animation"} + + +import sys +from pathlib import Path +import importlib + +# Ensure the name of the module in python import +module_name = Path(__file__).parent.name +sys.modules.update({'gp_interpolate': importlib.import_module(module_name)}) + + +from gp_interpolate import interpolate_strokes, ui modules = ( - properties, - operators, + interpolate_strokes, + ui, ) -if "bpy" in locals(): - import importlib +# if "bpy" in locals(): +# import importlib - for mod in modules: - importlib.reload(mod) +# for mod in modules: +# importlib.reload(mod) import bpy def register(): + print('Register gp_interpolate') for mod in modules: mod.register() diff --git a/interpolate_strokes/__init__.py b/interpolate_strokes/__init__.py new file mode 100644 index 0000000..8e29173 --- /dev/null +++ b/interpolate_strokes/__init__.py @@ -0,0 +1,22 @@ +from gp_interpolate.interpolate_strokes import operators, properties + +modules = ( + properties, + operators, +) + +if "bpy" in locals(): + import importlib + + for mod in modules: + importlib.reload(mod) + +import bpy + +def register(): + for mod in modules: + mod.register() + +def unregister(): + for mod in reversed(modules): + mod.unregister() diff --git a/operators.py b/interpolate_strokes/operators.py similarity index 100% rename from operators.py rename to interpolate_strokes/operators.py diff --git a/properties.py b/interpolate_strokes/properties.py similarity index 100% rename from properties.py rename to interpolate_strokes/properties.py diff --git a/ui.py b/ui.py new file mode 100755 index 0000000..2124b98 --- /dev/null +++ b/ui.py @@ -0,0 +1,51 @@ +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 and context.object.type == 'GPENCIL' + + def draw(self, context): + settings = bpy.context.scene.gp_interpo_settings + + layout = self.layout + col = layout.column(align=False) + + if settings.mode == 'FRAME': + prev_icon, next_icon = 'FRAME_PREV', 'FRAME_NEXT' + else: + prev_icon, next_icon = 'PREV_KEYFRAME', 'NEXT_KEYFRAME' + + + row = col.row(align=True) + row.scale_x = 3 + row.operator("gp.interpolate_stroke", text="", icon=prev_icon).next = False + row.operator("gp.interpolate_stroke", text="", icon=next_icon).next = True + # col.separator() + + col.prop(settings, 'target_collection', text='Collection') + col.prop(settings, 'search_range') + col = layout.column(align=True) + + row = col.row(align=True) + row.prop(settings, 'mode', expand=True) + + if settings.mode == 'FRAME': + col.prop(settings, 'padding') + +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)