From 21f59b816bfb72f1d524f41fce662982b45e8f1b Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Fri, 6 Jun 2008 12:34:27 +0000 Subject: [PATCH] RenderGraphic::metrics(): return early. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25164 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/RenderGraphic.cpp | 45 +++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/src/insets/RenderGraphic.cpp b/src/insets/RenderGraphic.cpp index 07185ccdfe..392ac1f122 100644 --- a/src/insets/RenderGraphic.cpp +++ b/src/insets/RenderGraphic.cpp @@ -135,34 +135,37 @@ void RenderGraphic::metrics(MetricsInfo & mi, Dimension & dim) const { bool image_ready = displayGraphic(params_) && readyToDisplay(loader_); + if (image_ready) { + dim.wid = loader_.image()->width() + 2 * Inset::TEXT_TO_INSET_OFFSET; + dim.asc = loader_.image()->height(); + dim_ = dim; + return; + } + dim.asc = image_ready ? loader_.image()->height() : 50; dim.des = 0; - if (image_ready) { - dim.wid = loader_.image()->width() + 2 * Inset::TEXT_TO_INSET_OFFSET; - } else { - int font_width = 0; + int font_width = 0; - FontInfo msgFont(mi.base.font); - msgFont.setFamily(SANS_FAMILY); + FontInfo msgFont(mi.base.font); + msgFont.setFamily(SANS_FAMILY); - // FIXME UNICODE - docstring const justname = from_utf8(params_.filename.onlyFileName()); - if (!justname.empty()) { - msgFont.setSize(FONT_SIZE_FOOTNOTE); - font_width = theFontMetrics(msgFont).width(justname); - } - - docstring const msg = statusMessage(params_, loader_.status()); - if (!msg.empty()) { - msgFont.setSize(FONT_SIZE_TINY); - font_width = max(font_width, - theFontMetrics(msgFont).width(msg)); - } - - dim.wid = max(50, font_width + 15); + // FIXME UNICODE + docstring const justname = from_utf8(params_.filename.onlyFileName()); + if (!justname.empty()) { + msgFont.setSize(FONT_SIZE_FOOTNOTE); + font_width = theFontMetrics(msgFont).width(justname); } + docstring const msg = statusMessage(params_, loader_.status()); + if (!msg.empty()) { + msgFont.setSize(FONT_SIZE_TINY); + font_width = max(font_width, + theFontMetrics(msgFont).width(msg)); + } + + dim.wid = max(50, font_width + 15); + dim_ = dim; }