very nice
This commit is contained in:
@@ -176,6 +176,24 @@ class FramesPanel(Gtk.Box):
|
||||
self._selected = None
|
||||
self.emit("selection-changed")
|
||||
|
||||
def highlight_nearest(self, timestamp: float) -> None:
|
||||
"""Scroll to and briefly highlight the frame closest to *timestamp*."""
|
||||
if not self._order:
|
||||
return
|
||||
best_id = None
|
||||
best_dist = float("inf")
|
||||
for fid, ts in self._timestamps.items():
|
||||
d = abs(ts - timestamp)
|
||||
if d < best_dist:
|
||||
best_dist = d
|
||||
best_id = fid
|
||||
if not best_id or best_id not in self._widgets:
|
||||
return
|
||||
widget = self._widgets[best_id]
|
||||
widget.add_css_class("frame-highlight")
|
||||
self._scroll_to(widget)
|
||||
GLib.timeout_add(400, lambda: widget.remove_css_class("frame-highlight") or False)
|
||||
|
||||
def clear(self):
|
||||
"""Remove all items and reset state."""
|
||||
self._selected = None
|
||||
|
||||
Reference in New Issue
Block a user