From: Angus Leeming Date: Thu, 20 Sep 2001 13:16:17 +0000 (+0000) Subject: Add LColor::graphicsbg and use it in the graphics and figure insets. X-Git-Tag: 1.6.10~20579 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=47b06816be86d751c29a4af4809b773baf79ceef;p=lyx.git Add LColor::graphicsbg and use it in the graphics and figure insets. Ensures that a figure with a transparent colour can be viewed easily if the LyX screen's background colour is dark. Prevent deletion of the image file if no conversion is required. This patch works like a charm with the (old) figinset. When testing the graphics inset, however, I find that colour "None" in an XPM file is displayed as black. I have no idea why. This appears to be true of some other graphics viewers also. E.g., KDE 2's pixie displays "None" as black but the venerable xv works fine. Maybe it's my version of the xpm library, but v3.4.11 appears to be right up to date. Can people test on their machines and/or offer suggestions here? Angus p.s. You can test with the XPM files in lib/images. They will no longer be deleted if you load them into LyX! A. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2777 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/ChangeLog b/src/ChangeLog index 3ba82da392..111fad893c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2001-09-18 Angus Leeming + + * LColor.[Ch]: added graphicsbg to color enum and to ColorEntry. + 2001-09-20 Michael Schmitt * several files: fix typos in user-visible strings diff --git a/src/LColor.C b/src/LColor.C index 7fa97fa3ca..775d4c87fa 100644 --- a/src/LColor.C +++ b/src/LColor.C @@ -72,6 +72,7 @@ LColor::LColor() { special, N_("special character"), "special", "RoyalBlue", "special" }, { math, N_("math"), "math", "DarkBlue", "math" }, { mathbg, N_("math background"), "mathbg", "linen", "mathbg" }, + { graphicsbg, N_("graphics background"), "graphicsbg", "linen", "graphicsbg" }, { mathmacrobg, N_("Math macro background"), "mathmacrobg", "linen", "mathmacrobg" }, { mathframe, N_("math frame"), "mathframe", "Magenta", "mathframe" }, { mathcursor, N_("math cursor"), "mathcursor", "black", "mathcursor" }, diff --git a/src/LColor.h b/src/LColor.h index a0fbe0d42f..8c16950edf 100644 --- a/src/LColor.h +++ b/src/LColor.h @@ -99,6 +99,8 @@ public: /// Special chars text color special, + /// Graphics inset background color + graphicsbg, /// Math inset text color math, /// Math inset background color diff --git a/src/graphics/GraphicsCacheItem.C b/src/graphics/GraphicsCacheItem.C index 44f5979950..9aef121984 100644 --- a/src/graphics/GraphicsCacheItem.C +++ b/src/graphics/GraphicsCacheItem.C @@ -129,7 +129,16 @@ GraphicsCacheItem::convertImage(string const & filename) string const to = findTargetFormat(from); if (to.empty()) return false; - + + if (from == to) { + // No conversion needed! + // Saves more than just time: prevents the deletion of + // the "to" file after loading when it's the same as the "from"! + tempfile = filename; + loadImage(); + return true; + } + // Take only the filename part of the file, without path or extension. string temp = OnlyFilename(filename); temp = ChangeExtension(filename, string()); diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index a94fe63421..e4dd04fd4b 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,9 @@ +2001-09-18 Angus Leeming + + * figinset.C (runqueue): + * insetgraphics.C (draw): set background colour of inset from + background to the user-configurable graphicsbg. + 2001-09-07 Jean-Marc Lasgouttes * insetquotes.C (InsetQuotes): when trying to decide the side of diff --git a/src/insets/figinset.C b/src/insets/figinset.C index ff49663893..e2e8c52032 100644 --- a/src/insets/figinset.C +++ b/src/insets/figinset.C @@ -469,7 +469,7 @@ void runqueue() { // This _have_ to be set before the fork! unsigned long background_pixel = - lyxColorHandler->colorPixel(LColor::background); + lyxColorHandler->colorPixel(LColor::graphicsbg); // run queued requests for ghostscript, if any if (!gsrunning && gs_color && !gs_xcolor) { diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 7db9d2a878..2285db34e0 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -284,6 +284,12 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font, // we draw just a rectangle. if (imageLoaded) { + // Draw a ractangle with the specified color. If the image is + // transparent, this will shine through. + paint.fillRectangle(old_x + 2, baseline - lascent, + lwidth - 4, lascent + ldescent, + LColor::graphicsbg); + paint.image(old_x + 2, baseline - lascent, lwidth - 4, lascent + ldescent, cacheHandle->getImage());