From c7fc42d88c838da0e40ee82e397a3f7ab8c60aa1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Vigna?= Date: Mon, 11 Mar 2002 13:52:19 +0000 Subject: [PATCH] A hack fix for #268. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3707 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/ChangeLog | 2 ++ src/insets/insetgraphics.C | 28 ++++++++++++++++++++-------- src/insets/insetgraphics.h | 2 ++ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 99d3b66983..544e7fcebc 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,5 +1,7 @@ 2002-03-11 Juergen Vigna + * insetgraphics.C (draw): hack to fix the redrawing bug. + * insettext.C (updateInsetInInset): fixed for updates in insets inside this inset text (don't know why I missed this earlier). diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index fe4da9b701..9f2063250c 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -96,6 +96,7 @@ TODO Before initial production release: #include "graphics/GraphicsImage.h" #include "LyXView.h" +#include "lyxtext.h" #include "buffer.h" #include "BufferView.h" #include "converter.h" @@ -107,7 +108,6 @@ TODO Before initial production release: #include "LaTeXFeatures.h" #include "frontends/Dialogs.h" -#include "frontends/Alert.h" #include "frontends/controllers/helper_funcs.h" // getVectorFromString #include "support/LAssert.h" @@ -156,7 +156,7 @@ string const unique_id() InsetGraphics::InsetGraphics() : graphic_label(unique_id()), - cached_status_(grfx::ErrorUnknown), cache_filled_(false) + cached_status_(grfx::ErrorUnknown), cache_filled_(false), old_asc(0) {} @@ -165,7 +165,7 @@ InsetGraphics::InsetGraphics(InsetGraphics const & ig, bool same_id) : Inset(ig, same_id), SigC::Object(), graphic_label(unique_id()), - cached_status_(grfx::ErrorUnknown), cache_filled_(false) + cached_status_(grfx::ErrorUnknown), cache_filled_(false), old_asc(0) { setParams(ig.params()); if (same_id) @@ -249,10 +249,10 @@ bool InsetGraphics::drawImage() const int InsetGraphics::ascent(BufferView *, LyXFont const &) const { + old_asc = 50; if (drawImage()) - return cached_image_->getHeight(); - else - return 50; + old_asc = cached_image_->getHeight(); + return old_asc; } @@ -293,10 +293,22 @@ int InsetGraphics::width(BufferView *, LyXFont const & font) const void InsetGraphics::draw(BufferView * bv, LyXFont const & font, int baseline, float & x, bool) const { + int oasc = old_asc; + int ldescent = descent(bv, font); int lascent = ascent(bv, font); int lwidth = width(bv, font); + // we may have changed while someone other was drawing us so better + // to not draw anything as we surely call to redraw ourself soon. + // This is not a nice thing to do and should be fixed properly somehow. + // But I still don't know the best way to go. So let's do this like this + // for now (Jug 20020311) + if (lascent != oasc) { +// lyxerr << "IG(" << this << "): " << x << endl; + return; + } + // Make sure now that x is updated upon exit from this routine int old_x = int(x); x += lwidth; @@ -312,12 +324,12 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font, Painter & paint = bv->painter(); if (drawImage()) { - +// lyxerr << "IG(" << this << "): " << old_x << endl; paint.image(old_x + 2, baseline - lascent, lwidth - 4, lascent + ldescent, *cached_image_.get()); - } else { + } else { paint.rectangle(old_x + 2, baseline - lascent, lwidth - 4, diff --git a/src/insets/insetgraphics.h b/src/insets/insetgraphics.h index 7f5143981d..94effb1491 100644 --- a/src/insets/insetgraphics.h +++ b/src/insets/insetgraphics.h @@ -127,6 +127,8 @@ private: mutable grfx::ImagePtr cached_image_; /// mutable bool cache_filled_; + /// + mutable int old_asc; }; #endif -- 2.39.2