]> git.lyx.org Git - features.git/commitdiff
Squash bug 1372: Misleading graphics label when deactivating lyx view.
authorAngus Leeming <leeming@lyx.org>
Mon, 5 Apr 2004 11:59:14 +0000 (11:59 +0000)
committerAngus Leeming <leeming@lyx.org>
Mon, 5 Apr 2004 11:59:14 +0000 (11:59 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8601 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/ChangeLog
src/insets/insetgraphics.C
src/insets/render_graphic.C

index b80fc0a0ebcce2e120e8a1a6fba4001b7e1b386f..a2c81c2ae66a59dcb0440f0d85569800cf8c1790 100644 (file)
@@ -1,3 +1,10 @@
+2004-05-04  Angus Leeming  <leeming@lyx.org>
+
+       * insetgraphics.C: remove unused header file "lyxrc.h".
+
+       * render_graphic.C: squash bug 1372: Misleading graphics label when
+       deactivating lyx view.
+
 2004-05-04  Angus Leeming  <leeming@lyx.org>
 
        * insetbibitem.C:
index 53a8a7f81733dc2da753615275838bb96d3f813a..730ddc4202becb06d4fa82c6b03cb1a8d5433177 100644 (file)
@@ -64,7 +64,6 @@ TODO
 #include "LaTeXFeatures.h"
 #include "lyx_main.h"
 #include "lyxlex.h"
-#include "lyxrc.h"
 #include "metricsinfo.h"
 #include "outputparams.h"
 
index 1da739124fb154372ac4763b441041d84f4154cd..72639def888fc6cd809a3552e895cb2c1c3f9e2e 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "gettext.h"
 #include "LColor.h"
+#include "lyxrc.h"
 #include "metricsinfo.h"
 
 #include "frontends/font_metrics.h"
@@ -82,8 +83,19 @@ boost::signals::connection RenderGraphic::connect(slot_type const & slot) const
 
 namespace {
 
-string const statusMessage(graphics::ImageStatus status)
+bool displayGraphic(graphics::Params const & params)
 {
+       return params.display != graphics::NoDisplay &&
+               lyxrc.display_graphics != graphics::NoDisplay;
+}
+       
+
+string const statusMessage(graphics::Params const & params,
+                          graphics::ImageStatus status)
+{
+       if (!displayGraphic(params))
+               return _("Not shown.");
+
        switch (status) {
        case graphics::WaitingToLoad:
                return _("Not shown.");
@@ -92,7 +104,7 @@ string const statusMessage(graphics::ImageStatus status)
        case graphics::Converting:
                return _("Converting to loadable format...");
        case graphics::Loaded:
-               return _("Loaded into memory. Must now generate pixmap.");
+               return _("Loaded into memory. Generating pixmap...");
        case graphics::ScalingEtc:
                return _("Scaling etc...");
        case graphics::Ready:
@@ -124,7 +136,7 @@ bool readyToDisplay(graphics::Loader const & loader)
 
 void RenderGraphic::metrics(MetricsInfo & mi, Dimension & dim) const
 {
-       bool image_ready = readyToDisplay(loader_);
+       bool image_ready = displayGraphic(params_) && readyToDisplay(loader_);
 
        dim.asc = image_ready ? loader_.image()->getHeight() : 50;
        dim.des = 0;
@@ -144,7 +156,7 @@ void RenderGraphic::metrics(MetricsInfo & mi, Dimension & dim) const
                        font_width = font_metrics::width(justname, msgFont);
                }
 
-               string const msg = statusMessage(loader_.status());
+               string const msg = statusMessage(params_, loader_.status());
                if (!msg.empty()) {
                        msgFont.setSize(LyXFont::SIZE_TINY);
                        font_width = std::max(font_width,
@@ -160,18 +172,17 @@ void RenderGraphic::metrics(MetricsInfo & mi, Dimension & dim) const
 
 void RenderGraphic::draw(PainterInfo & pi, int x, int y) const
 {
-       if (params_.display != graphics::NoDisplay &&
-           loader_.status() == graphics::WaitingToLoad)
-               loader_.startLoading();
-
-       if (params_.display != graphics::NoDisplay &&
-           !loader_.monitoring())
-               loader_.startMonitoring();
+       if (displayGraphic(params_)) {
+               if (loader_.status() == graphics::WaitingToLoad)
+                       loader_.startLoading();
+               if (!loader_.monitoring())
+                       loader_.startMonitoring();
+       }
 
        // This will draw the graphics. If the graphics has not been
        // loaded yet, we draw just a rectangle.
 
-       if (readyToDisplay(loader_)) {
+       if (displayGraphic(params_) && readyToDisplay(loader_)) {
                pi.pain.image(x + InsetOld::TEXT_TO_INSET_OFFSET,
                              y - dim_.asc,
                              dim_.wid - 2 * InsetOld::TEXT_TO_INSET_OFFSET,
@@ -198,7 +209,7 @@ void RenderGraphic::draw(PainterInfo & pi, int x, int y) const
                }
 
                // Print the message.
-               string const msg = statusMessage(loader_.status());
+               string const msg = statusMessage(params_, loader_.status());
                if (!msg.empty()) {
                        msgFont.setSize(LyXFont::SIZE_TINY);
                        pi.pain.text(x + InsetOld::TEXT_TO_INSET_OFFSET + 6,