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

viewer: Fix viewer ratio lost when docking/undocking

Now ViewerContainer has direct access the project, without having to go
through `self.app.project_manager`.

This moves some functionality from the EditorPerspective, making it more
clear that the ViewerContainer is tightly integrated with the current
project.
parent e9a54e65
......@@ -644,8 +644,6 @@ class EditorPerspective(Perspective, Loggable):
def _connectToProject(self, project):
project.connect("project-changed", self._projectChangedCb)
project.connect("rendering-settings-changed",
self._rendering_settings_changed_cb)
project.ges_timeline.connect("notify::duration",
self._timelineDurationChangedCb)
......@@ -659,8 +657,6 @@ class EditorPerspective(Perspective, Loggable):
self.warning("Current project instance does not exist")
return False
self.viewer.setPipeline(project.pipeline)
self._reset_viewer_aspect_ratio(project)
self.clipconfig.project = project
# When creating a blank project there's no project URI yet.
......@@ -670,18 +666,8 @@ class EditorPerspective(Perspective, Loggable):
def _disconnectFromProject(self, project):
project.disconnect_by_func(self._projectChangedCb)
project.disconnect_by_func(self._rendering_settings_changed_cb)
project.ges_timeline.disconnect_by_func(self._timelineDurationChangedCb)
def _rendering_settings_changed_cb(self, project, unused_item):
"""Handles Project metadata changes."""
self._reset_viewer_aspect_ratio(project)
def _reset_viewer_aspect_ratio(self, project):
"""Resets the viewer aspect ratio."""
self.viewer.target.update_aspect_ratio(project)
self.viewer.timecode_entry.setFramerate(project.videorate)
def _timelineDurationChangedCb(self, timeline, unused_duration):
"""Updates the render button.
......
......@@ -84,6 +84,7 @@ class ViewerContainer(Gtk.Box, Loggable):
Loggable.__init__(self)
self.log("New ViewerContainer")
self.project = None
self.pipeline = None
self.docked = True
self.target = None
......@@ -104,6 +105,30 @@ class ViewerContainer(Gtk.Box, Loggable):
self.__cursor = None
self.__translation = None
pm = self.app.project_manager
pm.connect("new-project-loaded", self._project_manager_new_project_loaded_cb)
pm.connect("project-closed", self._projectManagerProjectClosedCb)
def _project_manager_new_project_loaded_cb(self, unused_project_manager, project):
project.connect("rendering-settings-changed",
self._project_rendering_settings_changed_cb)
self.project = project
self.setPipeline(project.pipeline)
def _projectManagerProjectClosedCb(self, unused_project_manager, project):
if self.project == project:
project.disconnect_by_func(self._project_rendering_settings_changed_cb)
self.project = None
def _project_rendering_settings_changed_cb(self, project, unused_item):
"""Handles Project metadata changes."""
self._reset_viewer_aspect_ratio(project)
def _reset_viewer_aspect_ratio(self, project):
"""Resets the viewer aspect ratio."""
self.target.update_aspect_ratio(project)
self.timecode_entry.setFramerate(project.videorate)
def setPipeline(self, pipeline, position=None):
"""Sets the displayed pipeline.
......@@ -139,6 +164,7 @@ class ViewerContainer(Gtk.Box, Loggable):
self.overlay_stack = OverlayStack(self.app, sink_widget)
self.target = ViewerWidget(self.overlay_stack)
self._reset_viewer_aspect_ratio(self.project)
if self.docked:
self.pack_start(self.target, expand=True, fill=True, padding=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