Fix bug #8258 (Zoom of editor doesn't zoom instant preview)

This commit is contained in:
Enrico Forestieri 2015-05-30 18:09:28 +02:00
parent 908ed2128d
commit 0e2ea9d48c
2 changed files with 19 additions and 5 deletions

View File

@ -245,6 +245,8 @@ private:
PreviewLoader & parent_; PreviewLoader & parent_;
/// ///
Buffer const & buffer_; Buffer const & buffer_;
///
mutable int font_scaling_factor_;
/// We don't own this /// We don't own this
static lyx::Converter const * pconverter_; static lyx::Converter const * pconverter_;
@ -389,6 +391,9 @@ namespace graphics {
PreviewLoader::Impl::Impl(PreviewLoader & p, Buffer const & b) PreviewLoader::Impl::Impl(PreviewLoader & p, Buffer const & b)
: parent_(p), buffer_(b) : parent_(p), buffer_(b)
{ {
font_scaling_factor_ = buffer_.isExporting()
? int(75.0 * buffer_.params().html_math_img_scale)
: int(0.01 * lyxrc.dpi * lyxrc.zoom * lyxrc.preview_scale_factor);
if (!pconverter_) if (!pconverter_)
pconverter_ = setConverter("lyxpreview"); pconverter_ = setConverter("lyxpreview");
} }
@ -407,6 +412,17 @@ PreviewLoader::Impl::~Impl()
PreviewImage const * PreviewImage const *
PreviewLoader::Impl::preview(string const & latex_snippet) const PreviewLoader::Impl::preview(string const & latex_snippet) const
{ {
int fs = buffer_.isExporting()
? int(75.0 * buffer_.params().html_math_img_scale)
: int(0.01 * lyxrc.dpi * lyxrc.zoom * lyxrc.preview_scale_factor);
if (font_scaling_factor_ != fs) {
font_scaling_factor_ = fs;
Cache::const_iterator cit = cache_.begin();
Cache::const_iterator cend = cache_.end();
while (cit != cend)
parent_.remove((cit++)->first);
buffer_.updatePreviews();
}
Cache::const_iterator it = cache_.find(latex_snippet); Cache::const_iterator it = cache_.find(latex_snippet);
return (it == cache_.end()) ? 0 : it->second.get(); return (it == cache_.end()) ? 0 : it->second.get();
} }
@ -577,16 +593,12 @@ void PreviewLoader::Impl::startLoading(bool wait)
<< "File was not closed properly."); << "File was not closed properly.");
return; return;
} }
double const font_scaling_factor =
buffer_.isExporting() ? 75.0 * buffer_.params().html_math_img_scale
: 0.01 * lyxrc.dpi * lyxrc.zoom * lyxrc.preview_scale_factor;
// The conversion command. // The conversion command.
ostringstream cs; ostringstream cs;
cs << pconverter_->command cs << pconverter_->command
<< " " << quoteName(latexfile.toFilesystemEncoding()) << " " << quoteName(latexfile.toFilesystemEncoding())
<< " --dpi " << int(font_scaling_factor); << " --dpi " << font_scaling_factor_;
if (lyxerr.debugging(Debug::GRAPHICS)) { if (lyxerr.debugging(Debug::GRAPHICS)) {
cs << " --verbose"; cs << " --verbose";
} }

View File

@ -74,6 +74,8 @@ What's new
- Clarify the function of Tools > Preferences > Look & Feel > Save Documents - Clarify the function of Tools > Preferences > Look & Feel > Save Documents
Compressed by Default (bug 7822). Compressed by Default (bug 7822).
- Update instant previews when modifying the screen zoom factor (bug 8258).
* DOCUMENTATION AND LOCALIZATION * DOCUMENTATION AND LOCALIZATION