GPencil Tools: timeline scrub frame snapping option
Add an addon-preference option to always snap on keyframes while scrubbing (Disabled by defaut). Invert the behavior of the snap modifier key. Disabled if there isn't any keyframe. fix: carriage return at the end of rotate_canvas.py
This commit is contained in:
parent
32adcd8c59
commit
393c978bad
|
@ -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": "",
|
||||
|
|
|
@ -258,4 +258,4 @@ def register():
|
|||
|
||||
def unregister():
|
||||
for cls in reversed(classes):
|
||||
bpy.utils.unregister_class(cls)
|
||||
bpy.utils.unregister_class(cls)
|
||||
|
|
|
@ -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')
|
||||
|
||||
|
|
Loading…
Reference in New Issue