Commit 187ecc8b authored by Alexandru Băluț's avatar Alexandru Băluț
Browse files

clipproperties: Update widgets when switching clips

The speed widgets were not being updated when selecting a different
clip.
parent 776d354e
Pipeline #259332 failed with stages
in 38 minutes and 6 seconds
......@@ -362,6 +362,10 @@ class TimeProperties(Gtk.Expander, Loggable):
@rate.setter # type: ignore
def rate(self, value: float) -> None:
self._set_rate(value)
# We assume the "rate" has been set as an effect of the binding between
# the self._speed_adjustment and the "rate" property.
# Signal the "rate_linear" property is updated so
# self._speed_scale_adjustment is also updated.
self.notify("rate_linear")
@GObject.Property(type=float)
......@@ -373,6 +377,10 @@ class TimeProperties(Gtk.Expander, Loggable):
def rate_linear(self, linear: float) -> None:
value = self._linear_to_rate(linear)
self._set_rate(value)
# We assume the "rate_linear" has been set as an effect of the binding
# between the self._speed_scale_adjustment and the "rate" property.
# Signal the "rate" property is updated so the self._speed_adjustment
# is also updated.
self.notify("rate")
def _set_rate(self, value: float):
......@@ -475,6 +483,11 @@ class TimeProperties(Gtk.Expander, Loggable):
self._time_effects = self.__get_time_effects(self._clip)
if self._clip:
# Signal the properties changed so the Adjustments bound to them
# and the widgets using these are updated.
self.notify("rate")
self.notify("rate_linear")
self._clip.connect("deep-notify", self.__child_property_changed_cb)
self.show_all()
else:
......
......@@ -522,6 +522,27 @@ class SpeedPropertiesTest(common.TestCase):
def test_clip_speed_v(self):
self._check_clip_speed(video=True)
@common.setup_project_with_clips(assets_names=["mp3_sample.mp3", "30fps_numeroted_frames_blue.webm"])
@common.setup_clipproperties
def test_widgets_updated_when_switching_clips(self):
clip1, clip2 = self.layer.get_clips()
clip1_duration = clip1.props.duration
clip2_duration = clip2.props.duration
self.timeline_container.timeline.selection.select([clip1])
self.assertIs(self.speed_box._clip, clip1)
self.assert_applied_rate(0, 1.0, clip1_duration)
self.speed_box._speed_adjustment.props.value = 2.0
self.assert_applied_rate(1, 2.0, clip1_duration / 2)
self.timeline_container.timeline.selection.select([clip2])
self.assertIs(self.speed_box._clip, clip2)
self.assert_applied_rate(0, 1.0, clip2_duration)
self.timeline_container.timeline.selection.select([clip1])
self.assert_applied_rate(1, 2.0, clip1_duration / 2)
@common.setup_project_with_clips
@common.setup_clipproperties
def test_load_project_clip_speed(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment