Dear all,

The attached patch adds a 'pin' icon to the left top corner of
embedded figures (see attached test-pin.png). Because I am not
familiar with lyx graphics, I need an OK to proceed.

To test, please apply pin.diff, and add pin.png to lib/images. Note
that the icon is not updated correctly right now with the changing of
embedding status.

Cheers,
Bo

<<attachment: test-pin.png>>

<<attachment: pin.png>>

Index: development/scons/scons_manifest.py
===================================================================
--- development/scons/scons_manifest.py	(revision 22418)
+++ development/scons/scons_manifest.py	(working copy)
@@ -1428,6 +1428,7 @@
     note-next.png
     paste.png
     promote.png
+    pin.png
     psnfss1.png
     psnfss2.png
     psnfss3.png
Index: src/insets/InsetGraphicsParams.cpp
===================================================================
--- src/insets/InsetGraphicsParams.cpp	(revision 22418)
+++ src/insets/InsetGraphicsParams.cpp	(working copy)
@@ -274,6 +274,7 @@
 {
 	graphics::Params pars;
 	pars.filename = filename.availableFile();
+	pars.icon = filename.embedded() ? "pin.png" : "";
 	pars.scale = lyxscale;
 	pars.angle = convert<double>(rotateAngle);
 
Index: src/insets/RenderGraphic.h
===================================================================
--- src/insets/RenderGraphic.h	(revision 22418)
+++ src/insets/RenderGraphic.h	(working copy)
@@ -45,6 +45,7 @@
 
 	/// The stored data.
 	graphics::Loader loader_;
+	graphics::Loader icon_;
 	graphics::Params params_;
 };
 
Index: src/insets/RenderGraphic.cpp
===================================================================
--- src/insets/RenderGraphic.cpp	(revision 22418)
+++ src/insets/RenderGraphic.cpp	(working copy)
@@ -14,6 +14,8 @@
 
 #include "insets/Inset.h"
 
+#include "support/FileName.h"
+#include "support/filetools.h"
 #include "support/gettext.h"
 #include "LyX.h"
 #include "LyXRC.h"
@@ -36,13 +38,16 @@
 RenderGraphic::RenderGraphic(Inset const * inset)
 {
 	loader_.connect(boost::bind(&Inset::updateFrontend, inset));
+	icon_.connect(boost::bind(&Inset::updateFrontend, inset));
 }
 
 
 RenderGraphic::RenderGraphic(RenderGraphic const & other, Inset const * inset)
-	: RenderBase(other), loader_(other.loader_), params_(other.params_)
+	: RenderBase(other), loader_(other.loader_), icon_(other.icon_),
+		params_(other.params_)
 {
 	loader_.connect(boost::bind(&Inset::updateFrontend, inset));
+	icon_.connect(boost::bind(&Inset::updateFrontend, inset));
 }
 
 
@@ -58,6 +63,12 @@
 
 	if (!params_.filename.empty())
 		loader_.reset(params_.filename, params_);
+	if (!params_.icon.empty()) {
+		support::FileName const icon = support::libFileSearch("images/",
+			params_.icon, "png");
+		if (!icon.empty()) // using an empty bounding box
+			icon_.reset(icon, graphics::Params());
+	}
 }
 
 
@@ -172,6 +183,10 @@
 			loader_.startLoading();
 		if (!loader_.monitoring())
 			loader_.startMonitoring();
+		if (icon_.status() == graphics::WaitingToLoad)
+			icon_.startLoading();
+		if (!icon_.monitoring())
+			icon_.startMonitoring();
 	}
 
 	// This will draw the graphics. If the graphics has not been
@@ -211,6 +226,9 @@
 				     y - 4, msg, msgFont);
 		}
 	}
+	if (!params_.icon.empty() && readyToDisplay(icon_))
+		pi.pain.image(x + Inset::TEXT_TO_INSET_OFFSET, y - dim_.asc, 
+			10, 10, *icon_.image());
 }
 
 
Index: src/graphics/GraphicsParams.h
===================================================================
--- src/graphics/GraphicsParams.h	(revision 22418)
+++ src/graphics/GraphicsParams.h	(working copy)
@@ -72,6 +72,12 @@
 	 */
 	/// Rotation angle.
 	double angle;
+
+	/** The icon to be displayed to the top-left corner of an image.
+	 *  It is mutable because an icon reflect a temporary status of
+	 *  the image, and is variable.
+	 */
+	mutable std::string icon;
 };
 
 bool operator==(Params const &, Params const &);
Index: lib/images/pin.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: lib/images/pin.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Reply via email to