]> git.lyx.org Git - lyx.git/commitdiff
Add LColor::graphicsbg and use it in the graphics and figure insets.
authorAngus Leeming <leeming@lyx.org>
Thu, 20 Sep 2001 13:16:17 +0000 (13:16 +0000)
committerAngus Leeming <leeming@lyx.org>
Thu, 20 Sep 2001 13:16:17 +0000 (13:16 +0000)
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

src/ChangeLog
src/LColor.C
src/LColor.h
src/graphics/GraphicsCacheItem.C
src/insets/ChangeLog
src/insets/figinset.C
src/insets/insetgraphics.C

index 3ba82da3925616da4eb451a2212317cce441b70f..111fad893cd3858c8bf91974a3d227ea974de50c 100644 (file)
@@ -1,3 +1,7 @@
+2001-09-18  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * LColor.[Ch]: added graphicsbg to color enum and to ColorEntry.
+
 2001-09-20  Michael Schmitt  <Michael.Schmitt@teststep.org>
 
        * several files: fix typos in user-visible strings
index 7fa97fa3cae692e76d452d579d8093ef44c125b8..775d4c87faff52501211facdc70486992b8a7b65 100644 (file)
@@ -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" },
index a0fbe0d42f7ea797cdda3fc3fca0b0dc080ab640..8c16950edf5eba4e1cd3be939a339a28402b4592 100644 (file)
@@ -99,6 +99,8 @@ public:
                /// Special chars text color
                special,
 
+               /// Graphics inset background color
+               graphicsbg,
                /// Math inset text color
                math,
                /// Math inset background color
index 44f5979950ae4185c910d8d25b4984aae4189baf..9aef12198455c02c1e5c86de554057cbe6dd7c86 100644 (file)
@@ -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());
index a94fe6342194c6a7e5b329c78f3f7a36514dcd9a..e4dd04fd4b37e36d1bbaa71d73b99159fa88b65d 100644 (file)
@@ -1,3 +1,9 @@
+2001-09-18  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * figinset.C (runqueue):
+       * insetgraphics.C (draw): set background colour of inset from
+       background to the user-configurable graphicsbg.
+
 2001-09-07  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * insetquotes.C (InsetQuotes): when trying to decide the side of
index ff49663893252d656dac1a8ba15a43281bdd366e..e2e8c52032b3537475e145d028b2467e71dc4091 100644 (file)
@@ -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) {
index 7db9d2a8789759fbff4cd85f58520235e379078b..2285db34e011e4863c522576c0d072df13b214f8 100644 (file)
@@ -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());