]> git.lyx.org Git - features.git/commitdiff
Define new inPixels helper in BufferView
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 28 Apr 2017 13:06:30 +0000 (15:06 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 28 Apr 2017 13:06:30 +0000 (15:06 +0200)
Length::inPixels(MetricsBase const &) and VSpace::inPixels(BufferView
const &) should be moved respectuvely to MetricsBase and BufferView:
core file are not supposed to use GUI files.

src/BufferView.cpp
src/BufferView.h
src/Length.h
src/VSpace.cpp

index 80bea84ea2a0c1af582a62eef263923830eb725a..77ab989d193962f602d96435b8c0fbc1f41e0128 100644 (file)
@@ -368,6 +368,13 @@ int BufferView::leftMargin() const
 }
 
 
+int BufferView::inPixels(Length const & len) const
+{
+       Font const font = buffer().params().getFont();
+       return len.inPixels(workWidth(), theFontMetrics(font).em());
+}
+
+
 bool BufferView::isTopScreen() const
 {
        return 0 == d->scrollbarParameters_.min;
index ee2de8276e3a597c258d14ea65d8de435068b6ea..92e898735065ac2f8146fbb7b14fd8a3f43fac80 100644 (file)
@@ -41,6 +41,7 @@ class FuncRequest;
 class FuncStatus;
 class Intl;
 class Inset;
+class Length;
 class PainterInfo;
 class ParIterator;
 class ParagraphMetrics;
@@ -105,6 +106,14 @@ public:
        /// left margin
        int leftMargin() const;
 
+       /// return the on-screen size of this length
+       /*
+        *  This is a wrapper around Length::inPixels that uses the
+        *  bufferview width as width and the EM value of the default
+        *  document font.
+        */
+       int inPixels(Length const & len) const;
+
        /// \return true if the BufferView is at the top of the document.
        bool isTopScreen() const;
 
index c04a41f394e3f73f7b863b70f0f6f02ec39a84f3..8f192f85c6730d05a68a2102b20b06b8f06371fb 100644 (file)
@@ -97,9 +97,11 @@ public:
         *      FontMetrics::em() to get this value.
         */
        int inPixels(int text_width, int em_width = 0) const;
+
        /** return the on-screen size of this length
         *
-        *  This version of the function uses the right EM definition.
+        *  This version of the function uses the current inset width as
+        *  width and the EM value of the current font.
         */
        int inPixels(MetricsBase const &) const;
        /// return the value in Big Postscript points.
index 342105727f849ad12049763529d034437660b423..6e065964039e7ca6e1d3f02da613f81e795b0230 100644 (file)
@@ -228,7 +228,7 @@ int VSpace::inPixels(BufferView const & bv) const
                return 3 * default_height;
 
        case LENGTH:
-               return len_.len().inPixels(bv.workWidth());
+               return bv.inPixels(len_.len());
 
        default:
                LATTEST(false);