change snap for nicer match when mouse outside box

This commit is contained in:
q
2025-08-28 15:21:54 +03:00
parent 68f060b204
commit 58a30724db
2 changed files with 13 additions and 1 deletions

View File

@@ -2,7 +2,7 @@ import argparse
from tsmark.video_annotator import Marker from tsmark.video_annotator import Marker
VERSION = "0.7.12" VERSION = "0.7.13"
class SmartFormatter(argparse.HelpFormatter): class SmartFormatter(argparse.HelpFormatter):

View File

@@ -506,6 +506,18 @@ class Marker:
"Return x0/x1/y1/y0 side depending which the xy coord is farthest" "Return x0/x1/y1/y0 side depending which the xy coord is farthest"
snap_map = {True: {True: "y1", False: "x0"}, False: {True: "x1", False: "y0"}} snap_map = {True: {True: "y1", False: "x0"}, False: {True: "x1", False: "y0"}}
if xy[1] > bbox["y0"] and xy[1] < bbox["y1"]:
if xy[0] < bbox["x0"]:
return "x1"
if xy[0] > bbox["x1"]:
return "x0"
if xy[0] > bbox["x0"] and xy[0] < bbox["x1"]:
if xy[1] < bbox["y0"]:
return "y1"
if xy[1] > bbox["y1"]:
return "y0"
x_diff = xy[0] - bbox["cx"] x_diff = xy[0] - bbox["cx"]
y_diff = xy[1] - bbox["cy"] y_diff = xy[1] - bbox["cy"]