]> git.lyx.org Git - features.git/commitdiff
Make top/bottom margin value DPI-dependent
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 20 Apr 2017 16:05:04 +0000 (18:05 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 20 Apr 2017 16:07:50 +0000 (18:07 +0200)
One less hardcoded pixel value.

Use thisoccasion to set the left/right margin in inches too, since it
is easier to compute.

src/BufferView.cpp
src/TextMetrics.cpp

index a6ae1d40a3ff235c7cc23048e8f6fa6cf1d97796..80bea84ea2a0c1af582a62eef263923830eb725a 100644 (file)
@@ -351,8 +351,8 @@ BufferView::~BufferView()
 
 int BufferView::rightMargin() const
 {
-       // The value used to be hardcoded to 10, which is 2.5mm at 100dpi
-       int const default_margin = Length(2.5, Length::MM).inPixels(0);
+       // The value used to be hardcoded to 10, which is 0.1in at 100dpi
+       int const default_margin = Length(0.1, Length::IN).inPixels(0);
        // The additional test for the case the outliner is opened.
        if (!full_screen_ || !lyxrc.full_screen_limit
            || width_ < lyxrc.full_screen_width + 2 * default_margin)
index 475b8096f5600e239119722f318d29a66239594b..c577b47c400b50698a163a1a9ef1bec577c720df 100644 (file)
@@ -479,19 +479,21 @@ bool TextMetrics::redoParagraph(pit_type const pit)
        // specially tailored for the main text.
        // Top and bottom margin of the document (only at top-level)
        if (text_->isMainText()) {
+               // original value was 20px, which is 0.2in at 100dpi
+               int const margin = Length(0.2, Length::IN).inPixels(0);
                if (pit == 0) {
-                       pm.rows().front().dimension().asc += 20;
+                       pm.rows().front().dimension().asc += margin;
                        /* coverity thinks that we should update pm.dim().asc
                         * below, but all the rows heights are actually counted as
                         * part of the paragraph metric descent see loop above).
                         */
                        // coverity[copy_paste_error]
-                       pm.dim().des += 20;
+                       pm.dim().des += margin;
                }
                ParagraphList const & pars = text_->paragraphs();
                if (pit + 1 == pit_type(pars.size())) {
-                       pm.rows().back().dimension().des += 20;
-                       pm.dim().des += 20;
+                       pm.rows().back().dimension().des += margin;
+                       pm.dim().des += margin;
                }
        }