From 06254d11dfdf670fab3548dc2a2674e7a261262c Mon Sep 17 00:00:00 2001 From: Bo Peng Date: Tue, 8 Jan 2008 16:22:05 +0000 Subject: [PATCH] Embedding: display a pin at the top left corner of embedded figures git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22439 a592a061-630c-0410-9148-cb99ea01b6c8 --- development/scons/scons_manifest.py | 1 + lib/Makefile.am | 1 + lib/images/pin.png | Bin 0 -> 399 bytes src/graphics/GraphicsParams.cpp | 6 ++++-- src/graphics/GraphicsParams.h | 6 ++++++ src/insets/InsetGraphics.cpp | 2 +- src/insets/InsetGraphicsParams.cpp | 1 + src/insets/RenderGraphic.cpp | 23 ++++++++++++++++++++++- src/insets/RenderGraphic.h | 1 + 9 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 lib/images/pin.png diff --git a/development/scons/scons_manifest.py b/development/scons/scons_manifest.py index 5b4743c791..4abc860d7f 100644 --- a/development/scons/scons_manifest.py +++ b/development/scons/scons_manifest.py @@ -1428,6 +1428,7 @@ lib_images_files = Split(''' note-next.png paste.png promote.png + pin.png psnfss1.png psnfss2.png psnfss3.png diff --git a/lib/Makefile.am b/lib/Makefile.am index ac476b2708..262aee34d9 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -335,6 +335,7 @@ dist_images_DATA = \ images/note-insert.png \ images/note-next.png \ images/paste.png \ + images/pin.png \ images/promote.png \ images/psnfss1.png \ images/psnfss2.png \ diff --git a/lib/images/pin.png b/lib/images/pin.png new file mode 100644 index 0000000000000000000000000000000000000000..c1f9a75b72c9d2a6133b8f4ad3f9ef483f8ecd3c GIT binary patch literal 399 zcmV;A0dW3_P)5=452q5T>fiiqePA0D3JRU*QFrvC)Zaa)FrFqL98mQ}xs^{6gKo`b8kNSG$u z$xYdvDX^eYO8YLJU!8GWJ>hoFqm>FcZI^kTynGc!ghs0_zIRX1^9&#ZD5h+=28I`FsX76qp4)2m*ZHC$3NP)|pVq?V#E3Z#h}`r?wCyQU}+p;D(rotateAngle); diff --git a/src/insets/RenderGraphic.cpp b/src/insets/RenderGraphic.cpp index 05ce78a938..3520290a97 100644 --- a/src/insets/RenderGraphic.cpp +++ b/src/insets/RenderGraphic.cpp @@ -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 @@ namespace lyx { 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,15 @@ void RenderGraphic::update(graphics::Params const & params) if (!params_.filename.empty()) loader_.reset(params_.filename, params_); + // If icon is set to empty, icon_ will not be reset to empty + // but will not be displayed. This is to avoid repeated loading + // of the same icon when figure status changes. + 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 +186,10 @@ void RenderGraphic::draw(PainterInfo & pi, int x, int y) const 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 +229,9 @@ void RenderGraphic::draw(PainterInfo & pi, int x, int y) const 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()); } diff --git a/src/insets/RenderGraphic.h b/src/insets/RenderGraphic.h index 5edb7ce940..938322fad0 100644 --- a/src/insets/RenderGraphic.h +++ b/src/insets/RenderGraphic.h @@ -45,6 +45,7 @@ private: /// The stored data. graphics::Loader loader_; + graphics::Loader icon_; graphics::Params params_; }; -- 2.39.5