]> git.lyx.org Git - features.git/commitdiff
simplification
authorAndré Pönitz <poenitz@gmx.net>
Fri, 23 Nov 2007 22:57:11 +0000 (22:57 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Fri, 23 Nov 2007 22:57:11 +0000 (22:57 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21752 a592a061-630c-0410-9148-cb99ea01b6c8

src/graphics/PreviewImage.cpp
src/graphics/PreviewImage.h

index 47b30a4d339e1e43f7f78f6f0078c6cc8e3ba3bb..d99f0ee51f992787281b177dd49a15ea05c6a577 100644 (file)
@@ -74,31 +74,17 @@ string const & PreviewImage::snippet() const
 }
 
 
-int PreviewImage::ascent() const
+Dimension PreviewImage::dim() const
 {
+       Dimension dim;
        Image const * const image = pimpl_->iloader_.image();
        if (!image)
-               return 0;
+               return dim;
 
-       return int(pimpl_->ascent_frac_ * double(image->height()));
-}
-
-
-int PreviewImage::descent() const
-{
-       Image const * const image = pimpl_->iloader_.image();
-       if (!image)
-               return 0;
-
-       // Avoids rounding errors.
-       return image->height() - ascent();
-}
-
-
-int PreviewImage::width() const
-{
-       Image const * const image = pimpl_->iloader_.image();
-       return image ? image->width() : 0;
+       dim.asc = int(pimpl_->ascent_frac_ * double(image->height()));
+       dim.des = image->height() - dim.asc;
+       dim.wid = image->width();
+       return dim;
 }
 
 
index 6ec29a36badd1dbb3b84b009d59e12967f9c17a3..2a112b76a169e1e6818eb699b0de323e4504f4bf 100644 (file)
@@ -18,6 +18,8 @@ namespace lyx {
 
 namespace support { class FileName; }
 
+class Dimension;
+
 namespace graphics {
 
 class PreviewLoader;
@@ -38,11 +40,7 @@ public:
        ///
        std::string const & snippet() const;
        ///
-       int ascent() const;
-       ///
-       int descent() const;
-       ///
-       int width() const;
+       Dimension dim() const;
 
        /** If the image is not yet loaded (WaitingToLoad), then this method
         *  triggers that.