commit de990f72e1ba856ed5f8e5c617c17cdf382ab3a7
Author: Jean-Marc Lasgouttes <[email protected]>
Date:   Fri Apr 28 15:06:30 2017 +0200

    Define new inPixels helper in BufferView
    
    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 |    7 +++++++
 src/BufferView.h   |    9 +++++++++
 src/Length.h       |    4 +++-
 src/VSpace.cpp     |    2 +-
 4 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 80bea84..77ab989 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -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;
diff --git a/src/BufferView.h b/src/BufferView.h
index ee2de82..92e8987 100644
--- a/src/BufferView.h
+++ b/src/BufferView.h
@@ -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;
 
diff --git a/src/Length.h b/src/Length.h
index c04a41f..8f192f8 100644
--- a/src/Length.h
+++ b/src/Length.h
@@ -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.
diff --git a/src/VSpace.cpp b/src/VSpace.cpp
index 3421057..6e06596 100644
--- a/src/VSpace.cpp
+++ b/src/VSpace.cpp
@@ -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);

Reply via email to