[pitivi] clipproperties: Bisect to find prev/next keyframe
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] clipproperties: Bisect to find prev/next keyframe
- Date: Sat, 26 Oct 2019 12:00:02 +0000 (UTC)
commit 35948ba6fba293394d7d01c50d4683198852969f
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Wed Oct 23 22:06:43 2019 +0200
clipproperties: Bisect to find prev/next keyframe
pitivi/clipproperties.py | 42 ++++++++++++------------------------------
pre-commit.hook | 1 -
2 files changed, 12 insertions(+), 31 deletions(-)
---
diff --git a/pitivi/clipproperties.py b/pitivi/clipproperties.py
index b6d7a625..a47223b4 100644
--- a/pitivi/clipproperties.py
+++ b/pitivi/clipproperties.py
@@ -17,6 +17,7 @@
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301, USA.
"""Widgets to control clips properties."""
+import bisect
import os
from gettext import gettext as _
@@ -49,10 +50,6 @@ from pitivi.utils.ui import SPACING
COL_TRACK_EFFECT) = list(range(6))
-class ClipPropertiesError(Exception):
- pass
-
-
class ClipProperties(Gtk.ScrolledWindow, Loggable):
"""Widget for configuring the selected clip.
@@ -161,7 +158,7 @@ class EffectProperties(Gtk.Expander, Loggable):
# Set the source index on the storemodel directly,
# to avoid issues with the selection_data API.
# FIXME: Work around
- # https://bugzilla.gnome.org/show_bug.cgi?id=737587
+ # https://gitlab.gnome.org/GNOME/pygobject/issues/90
self.source_index = None
def do_drag_data_get(self, path, unused_selection_data):
@@ -613,11 +610,11 @@ class TransformationProperties(Gtk.Expander, Loggable):
self._activate_keyframes_btn.connect("toggled", self.__show_keyframes_toggled_cb)
self._next_keyframe_btn = self.builder.get_object("next_keyframe_button")
- self._next_keyframe_btn.connect("clicked", self.__go_to_keyframe, True)
+ self._next_keyframe_btn.connect("clicked", self.__go_to_keyframe_cb, True)
self._next_keyframe_btn.set_sensitive(False)
self._prev_keyframe_btn = self.builder.get_object("prev_keyframe_button")
- self._prev_keyframe_btn.connect("clicked", self.__go_to_keyframe, False)
+ self._prev_keyframe_btn.connect("clicked", self.__go_to_keyframe_cb, False)
self._prev_keyframe_btn.set_sensitive(False)
self.__setup_spin_button("xpos_spinbtn", "posx")
@@ -634,34 +631,19 @@ class TransformationProperties(Gtk.Expander, Loggable):
return sorted(set(keyframes_ts))
- def __go_to_keyframe(self, unused_button, next_keyframe):
+ def __go_to_keyframe_cb(self, unused_button, next_keyframe):
assert self.__control_bindings
start = self.source.props.start
- duration = self.source.props.duration
in_point = self.source.props.in_point
pipeline = self._project.pipeline
position = pipeline.getPosition() - start + in_point
- seekval = start
-
- if in_point <= position <= in_point + duration:
- keyframes_ts = self.__get_keyframes_timestamps()
-
- for i in range(1, len(keyframes_ts)):
- if keyframes_ts[i - 1] <= position <= keyframes_ts[i]:
- prev_kf_ts = keyframes_ts[i - 1]
- kf_ts = keyframes_ts[i]
- if next_keyframe:
- if kf_ts == position:
- try:
- kf_ts = keyframes_ts[i + 1]
- except IndexError:
- pass
- seekval = kf_ts + start - in_point
- else:
- seekval = prev_kf_ts + start - in_point
- break
- if position > in_point + duration:
- seekval = start + duration
+ keyframes_ts = self.__get_keyframes_timestamps()
+ if next_keyframe:
+ i = bisect.bisect_right(keyframes_ts, position)
+ else:
+ i = bisect.bisect_left(keyframes_ts, position) - 1
+ i = max(0, min(i, len(keyframes_ts) - 1))
+ seekval = keyframes_ts[i] + start - in_point
pipeline.simple_seek(seekval)
def __show_keyframes_toggled_cb(self, unused_button):
diff --git a/pre-commit.hook b/pre-commit.hook
index 79861a73..f5e98f5b 100755
--- a/pre-commit.hook
+++ b/pre-commit.hook
@@ -13,7 +13,6 @@ bin/pitivi.in
pitivi/application.py
pitivi/autoaligner.py
pitivi/check.py
-pitivi/clipproperties.py
pitivi/configure.py
pitivi/dialogs/clipmediaprops.py
pitivi/dialogs/filelisterrordialog.py
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]