From fe70ed40faeab0dbde7b45c8130cf251a79d0793 Mon Sep 17 00:00:00 2001 From: Antoine Beyeler <49431240+abey79@users.noreply.github.com> Date: Sun, 16 Oct 2022 17:38:01 +0200 Subject: [PATCH] Fixed issue where fit to bounds would be lost when changing document (#564) This issue doesn't affect vpype per se as documents are never changed during the lifetime of a viewer, but it does affect vsketch in cases where sketches change their own page size (e.g. the `quick_draw` example. Fixes #458 --- CHANGELOG.md | 1 + poetry.lock | 12 ++++++------ vpype_viewer/engine.py | 5 +++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5101cc9e..41f598c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ Release date: UNRELEASED ### Bug fixes * Fixed a viewer issue where page width/height of 0 would lead to errors and a blank display (#555) +* Fixed a viewer issue where fitting the document bounds would be lost when bounds change (*vsketch* only) (#564) ### API changes diff --git a/poetry.lock b/poetry.lock index ac5a3f82..7832c220 100644 --- a/poetry.lock +++ b/poetry.lock @@ -897,7 +897,7 @@ python-versions = ">=3.6" [[package]] name = "sphinx" -version = "5.2.3" +version = "5.3.0" description = "Python documentation generator" category = "dev" optional = false @@ -1114,7 +1114,7 @@ python-versions = "*" [[package]] name = "types-setuptools" -version = "65.4.0.0" +version = "65.5.0.1" description = "Typing stubs for setuptools" category = "dev" optional = false @@ -2053,8 +2053,8 @@ soupsieve = [ {file = "soupsieve-2.3.2.post1.tar.gz", hash = "sha256:fc53893b3da2c33de295667a0e19f078c14bf86544af307354de5fcf12a3f30d"}, ] sphinx = [ - {file = "Sphinx-5.2.3.tar.gz", hash = "sha256:5b10cb1022dac8c035f75767799c39217a05fc0fe2d6fe5597560d38e44f0363"}, - {file = "sphinx-5.2.3-py3-none-any.whl", hash = "sha256:7abf6fabd7b58d0727b7317d5e2650ef68765bbe0ccb63c8795fa8683477eaa2"}, + {file = "Sphinx-5.3.0.tar.gz", hash = "sha256:51026de0a9ff9fc13c05d74913ad66047e104f56a129ff73e174eb5c3ee794b5"}, + {file = "sphinx-5.3.0-py3-none-any.whl", hash = "sha256:060ca5c9f7ba57a08a1219e547b269fadf125ae25b06b9fa7f66768efb652d6d"}, ] sphinx-autobuild = [ {file = "sphinx-autobuild-2021.3.14.tar.gz", hash = "sha256:de1ca3b66e271d2b5b5140c35034c89e47f263f2cd5db302c9217065f7443f05"}, @@ -2130,8 +2130,8 @@ types-cachetools = [ {file = "types_cachetools-5.2.1-py3-none-any.whl", hash = "sha256:b496b7e364ba050c4eaadcc6582f2c9fbb04f8ee7141eb3b311a8589dbd4506a"}, ] types-setuptools = [ - {file = "types-setuptools-65.4.0.0.tar.gz", hash = "sha256:d9021d6a70690b34e7bd2947e7ab10167c646fbf062508cb56581be2e2a1615e"}, - {file = "types_setuptools-65.4.0.0-py3-none-any.whl", hash = "sha256:ce178b3f7dbd6c0e67f8eee7ae29c1be280ade7e5188bdd9e620843de4060d85"}, + {file = "types-setuptools-65.5.0.1.tar.gz", hash = "sha256:5b297081c8f1fbd992cd8b305a97ed96ee6ffc765e9115124029597dd10b8a71"}, + {file = "types_setuptools-65.5.0.1-py3-none-any.whl", hash = "sha256:601d45b5e9979d2b931de5403aa11153626a1eadd1ce9727b21f24673ced5ceb"}, ] typing-extensions = [ {file = "typing_extensions-4.4.0-py3-none-any.whl", hash = "sha256:16fa4864408f655d35ec496218b85f79b3437c829e93320c7c9215ccfd92489e"}, diff --git a/vpype_viewer/engine.py b/vpype_viewer/engine.py index ab291c2e..79fe624b 100644 --- a/vpype_viewer/engine.py +++ b/vpype_viewer/engine.py @@ -126,6 +126,11 @@ def document(self) -> vp.Document | None: def document(self, document: vp.Document | None) -> None: self._document = document self._layer_visibility.clear() + + # keep fitted to the viewport + if self._fit_to_viewport_flag: + self.fit_to_viewport() + self._update() @property