From: Enrico Forestieri Date: Tue, 21 Apr 2015 21:57:53 +0000 (+0200) Subject: Fix bug #8258 (Zoom of editor doesn't zoom instant preview) X-Git-Tag: 2.2.0alpha1~980 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=b8f04ae29ad0e484ae010dd2364f61164cffca56;p=features.git Fix bug #8258 (Zoom of editor doesn't zoom instant preview) --- diff --git a/src/graphics/PreviewLoader.cpp b/src/graphics/PreviewLoader.cpp index addc6af224..649f4602f2 100644 --- a/src/graphics/PreviewLoader.cpp +++ b/src/graphics/PreviewLoader.cpp @@ -246,6 +246,8 @@ private: PreviewLoader & parent_; /// Buffer const & buffer_; + /// + mutable int font_scaling_factor_; /// We don't own this static lyx::Converter const * pconverter_; @@ -390,6 +392,7 @@ namespace graphics { PreviewLoader::Impl::Impl(PreviewLoader & p, Buffer const & b) : parent_(p), buffer_(b) { + font_scaling_factor_ = int(buffer_.fontScalingFactor()); if (!pconverter_) pconverter_ = setConverter("lyxpreview"); } @@ -408,6 +411,19 @@ PreviewLoader::Impl::~Impl() PreviewImage const * PreviewLoader::Impl::preview(string const & latex_snippet) const { + int fs = int(buffer_.fontScalingFactor()); + if (font_scaling_factor_ != fs) { + // Refresh all previews on zoom changes + font_scaling_factor_ = fs; + Cache::const_iterator cit = cache_.begin(); + Cache::const_iterator cend = cache_.end(); + while (cit != cend) { + string const snippet = (cit++)->first; + parent_.remove(snippet); + parent_.add(snippet); + } + parent_.startLoading(false); + } Cache::const_iterator it = cache_.find(latex_snippet); return (it == cache_.end()) ? 0 : it->second.get(); } @@ -616,13 +632,11 @@ void PreviewLoader::Impl::startLoading(bool wait) return; } - double const font_scaling_factor = buffer_.fontScalingFactor(); - // The conversion command. ostringstream cs; cs << pconverter_->command() << " " << quoteName(latexfile.toFilesystemEncoding()) - << " --dpi " << int(font_scaling_factor); + << " --dpi " << font_scaling_factor_; // FIXME XHTML // The colors should be customizable.