Commit 943cc4aa authored by Thibault Saunier's avatar Thibault Saunier

timeline: Respect the `allow_zoom_in` parameter in set_best_zoom_ratio

We used to not take in into account at all.
And make sure to allow zoom in in the following cases:
  - The user clicked the 'zoom fit button'
  - We start rendering, the progress bar being the playhead it is better
    to be zoom fitted to have the best overview.

Fixes T7684
Reviewed-by: Alexandru Băluț's avatarAlex Băluț <alexandru.balut@gmail.com>
Differential Revision: https://phabricator.freedesktop.org/D1656
parent 62d0993b
......@@ -988,7 +988,7 @@ class RenderDialog(Loggable):
self._factory_formats[encoder_string] = fmt
break
self.app.gui.timeline_ui.timeline.set_best_zoom_ratio()
self.app.gui.timeline_ui.timeline.set_best_zoom_ratio(allow_zoom_in=True)
self.project.set_rendering(True)
self._pipeline.set_render_settings(
self.outfile, self.project.container_profile)
......
......@@ -1054,7 +1054,7 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
zoom_ratio = self.layout.get_allocation().width / timeline_duration_s
nearest_zoom_level = Zoomable.computeZoomLevel(zoom_ratio)
if nearest_zoom_level >= Zoomable.getCurrentZoomLevel():
if nearest_zoom_level >= Zoomable.getCurrentZoomLevel() and not allow_zoom_in:
# This means if we continue we'll zoom in.
if not allow_zoom_in:
# For example when the user zoomed out and is adding clips
......@@ -1538,20 +1538,20 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
self.app.shortcuts.register_group("navigation", _("Timeline Navigation"), position=40)
self.zoom_in_action = Gio.SimpleAction.new("zoom-in", None)
self.zoom_in_action.connect("activate", self._zoomInCb)
self.zoom_in_action.connect("activate", self._zoom_in_cb)
navigation_group.add_action(self.zoom_in_action)
self.app.shortcuts.add("navigation.zoom-in",
["<Primary>plus", "<Primary>equal"],
_("Zoom in"))
self.zoom_out_action = Gio.SimpleAction.new("zoom-out", None)
self.zoom_out_action.connect("activate", self._zoomOutCb)
self.zoom_out_action.connect("activate", self._zoom_out_cb)
navigation_group.add_action(self.zoom_out_action)
self.app.shortcuts.add("navigation.zoom-out", ["<Primary>minus"],
_("Zoom out"))
self.zoom_fit_action = Gio.SimpleAction.new("zoom-fit", None)
self.zoom_fit_action.connect("activate", self._zoomFitCb)
self.zoom_fit_action.connect("activate", self._zoom_fit_cb)
navigation_group.add_action(self.zoom_fit_action)
self.app.shortcuts.add("navigation.zoom-fit", ["<Primary>0"],
_("Adjust zoom to fit the project to the window"))
......@@ -1829,16 +1829,16 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
self.ruler.zoomChanged()
self._renderingSettingsChangedCb(project, None, None)
self.timeline.set_best_zoom_ratio()
self.timeline.set_best_zoom_ratio(allow_zoom_in=True)
self.timeline.update_snapping_distance()
def _zoomInCb(self, unused_action, unused_parameter):
def _zoom_in_cb(self, unused_action, unused_parameter):
Zoomable.zoomIn()
def _zoomOutCb(self, unused_action, unused_parameter):
def _zoom_out_cb(self, unused_action, unused_parameter):
Zoomable.zoomOut()
def _zoomFitCb(self, unused_action, unused_parameter):
def _zoom_fit_cb(self, unused_action, unused_parameter):
self.app.write_action("zoom-fit", optional_action_type=True)
self.timeline.set_best_zoom_ratio(allow_zoom_in=True)
......
......@@ -1088,7 +1088,7 @@ class ZoomBox(Gtk.Grid, Zoomable):
self.timeline.timeline.scrollToPlayhead()
def _zoomFitCb(self, unused_button):
self.timeline.timeline.set_best_zoom_ratio()
self.timeline.timeline.set_best_zoom_ratio(allow_zoom_in=True)
def _zoomSliderScrollCb(self, unused, event):
delta = 0
......
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