Make top/bottom margin value DPI-dependent

One less hardcoded pixel value.

Use thisoccasion to set the left/right margin in inches too, since it
is easier to compute.
This commit is contained in:
Jean-Marc Lasgouttes 2017-04-20 18:05:04 +02:00
parent df6b2f4470
commit b2e759d8b2
2 changed files with 8 additions and 6 deletions

View File

@ -351,8 +351,8 @@ BufferView::~BufferView()
int BufferView::rightMargin() const int BufferView::rightMargin() const
{ {
// The value used to be hardcoded to 10, which is 2.5mm at 100dpi // The value used to be hardcoded to 10, which is 0.1in at 100dpi
int const default_margin = Length(2.5, Length::MM).inPixels(0); int const default_margin = Length(0.1, Length::IN).inPixels(0);
// The additional test for the case the outliner is opened. // The additional test for the case the outliner is opened.
if (!full_screen_ || !lyxrc.full_screen_limit if (!full_screen_ || !lyxrc.full_screen_limit
|| width_ < lyxrc.full_screen_width + 2 * default_margin) || width_ < lyxrc.full_screen_width + 2 * default_margin)

View File

@ -479,19 +479,21 @@ bool TextMetrics::redoParagraph(pit_type const pit)
// specially tailored for the main text. // specially tailored for the main text.
// Top and bottom margin of the document (only at top-level) // Top and bottom margin of the document (only at top-level)
if (text_->isMainText()) { 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) { if (pit == 0) {
pm.rows().front().dimension().asc += 20; pm.rows().front().dimension().asc += margin;
/* coverity thinks that we should update pm.dim().asc /* coverity thinks that we should update pm.dim().asc
* below, but all the rows heights are actually counted as * below, but all the rows heights are actually counted as
* part of the paragraph metric descent see loop above). * part of the paragraph metric descent see loop above).
*/ */
// coverity[copy_paste_error] // coverity[copy_paste_error]
pm.dim().des += 20; pm.dim().des += margin;
} }
ParagraphList const & pars = text_->paragraphs(); ParagraphList const & pars = text_->paragraphs();
if (pit + 1 == pit_type(pars.size())) { if (pit + 1 == pit_type(pars.size())) {
pm.rows().back().dimension().des += 20; pm.rows().back().dimension().des += margin;
pm.dim().des += 20; pm.dim().des += margin;
} }
} }