diff --git a/greasepencil_tools/__init__.py b/greasepencil_tools/__init__.py index 330a985604877f0d8cf6641c2e119db61cdbdbfa..334cd44f4f22224184299c971cc8dec826ee1f2a 100644 --- a/greasepencil_tools/__init__.py +++ b/greasepencil_tools/__init__.py @@ -21,7 +21,7 @@ bl_info = { "name": "Grease Pencil Tools", "description": "Extra tools for Grease Pencil", "author": "Samuel Bernou, Antonio Vazquez, Daniel Martinez Lara, Matias Mendiola", -"version": (1, 3, 2), +"version": (1, 3, 3), "blender": (2, 91, 0), "location": "Sidebar > Grease Pencil > Grease Pencil Tools", "warning": "", diff --git a/greasepencil_tools/rotate_canvas.py b/greasepencil_tools/rotate_canvas.py index b1b9e19a056510d45056f38022c7659973cae28d..12a71670bd8e64a724a18e988f5d281f084d7795 100644 --- a/greasepencil_tools/rotate_canvas.py +++ b/greasepencil_tools/rotate_canvas.py @@ -258,4 +258,4 @@ def register(): def unregister(): for cls in reversed(classes): - bpy.utils.unregister_class(cls) \ No newline at end of file + bpy.utils.unregister_class(cls) diff --git a/greasepencil_tools/timeline_scrub.py b/greasepencil_tools/timeline_scrub.py index 56485e070cdde6b9ec7375b3983e81beb1b0f148..c2ead228d044243285e6551b87b722b60aee0508 100644 --- a/greasepencil_tools/timeline_scrub.py +++ b/greasepencil_tools/timeline_scrub.py @@ -122,6 +122,7 @@ class GPTS_OT_time_scrub(bpy.types.Operator): self.current_area = context.area self.key = prefs.keycode self.evaluate_gp_obj_key = prefs.evaluate_gp_obj_key + self.always_snap = prefs.always_snap self.dpi = context.preferences.system.dpi self.ui_scale = context.preferences.system.ui_scale @@ -191,13 +192,14 @@ class GPTS_OT_time_scrub(bpy.types.Operator): if frame.frame_number not in self.pos: self.pos.append(frame.frame_number) - - # Add start and end to snap on - + if not ob or not self.pos: + # Disable inverted behavior if no frame to snap + self.always_snap = False # Also snap on play bounds (sliced off for keyframe display) self.pos += [self.f_start, self.f_end] + # Disable Onion skin self.active_space_data = context.space_data self.onion_skin = None @@ -389,8 +391,14 @@ class GPTS_OT_time_scrub(bpy.types.Operator): if self.snap_alt and event.alt: mod_snap = True - if self.snap_on or mod_snap: - self.new_frame = nearest(self.pos, self.new_frame) + ## Snapping + if self.always_snap: + # inverted snapping behavior + if not self.snap_on and not mod_snap: + self.new_frame = nearest(self.pos, self.new_frame) + else: + if self.snap_on or mod_snap: + self.new_frame = nearest(self.pos, self.new_frame) # frame range restriction if self.lock_range: @@ -492,6 +500,11 @@ class GPTS_timeline_settings(bpy.types.PropertyGroup): description="Shortcut to trigger the scrub in viewport during press", default="MIDDLEMOUSE") + always_snap: BoolProperty( + name="Always Snap", + description="Always snap to keys if any, modifier is used deactivate the snapping\nDisabled if no keyframe found", + default=False) + use_in_timeline_editor: BoolProperty( name="Shortcut in timeline editors", description="Add the same shortcut to scrub in timeline editor windows", @@ -649,7 +662,11 @@ def draw_ts_pref(prefs, layout): else: box.label(text='[ NOW TYPE KEY OR CLICK TO USE, WITH MODIFIER ]') - snap_text = 'Snap to keyframes: ' + if prefs.always_snap: + snap_text = 'Disable keyframes snap: ' + else: + snap_text = 'Keyframes snap: ' + snap_text += 'Left Mouse' if prefs.keycode == 'RIGHTMOUSE' else 'Right Mouse' if not prefs.use_ctrl: snap_text += ' or Ctrl' @@ -662,6 +679,7 @@ def draw_ts_pref(prefs, layout): box.label( text="Recommended to choose at least one modifier to combine with clicks (default: Ctrl+Alt)", icon="ERROR") + box.prop(prefs, 'always_snap') box.prop(prefs, 'use_in_timeline_editor', text='Add same shortcut to scrub within timeline editors')