mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 19:07:45 +00:00
Some fixups to row margins
In breakRow set left and right margin properly for RTL paragraphs. Remove corresponding code from ComputeRowMetrics. In row painter, check the use of left and right margin depending on context. The problem in the original text is that the various leftMargin() methods actually represent right margin for RTL paragraphs. This should be fixed eventually.
This commit is contained in:
parent
f750d9b5cf
commit
412a724aaf
@ -460,13 +460,10 @@ void RowPainter::paintLabel() const
|
||||
FontMetrics const & fm = theFontMetrics(font);
|
||||
double x = x_;
|
||||
|
||||
if (is_rtl) {
|
||||
x = width_ - row_.left_margin
|
||||
+ fm.width(layout.labelsep);
|
||||
} else {
|
||||
x = x_ - fm.width(layout.labelsep)
|
||||
- fm.width(str);
|
||||
}
|
||||
if (is_rtl)
|
||||
x = width_ - row_.right_margin + fm.width(layout.labelsep);
|
||||
else
|
||||
x = x_ - fm.width(layout.labelsep) - fm.width(str);
|
||||
|
||||
pi_.pain.text(int(x), yo_, str, font);
|
||||
}
|
||||
@ -500,12 +497,10 @@ void RowPainter::paintTopLevelLabel() const
|
||||
|
||||
double x = x_;
|
||||
if (layout.labeltype == LABEL_CENTERED) {
|
||||
if (is_rtl)
|
||||
x = row_.left_margin;
|
||||
x += (width_ - text_metrics_.rightMargin(pm_) - row_.left_margin) / 2;
|
||||
x = row_.left_margin + (width_ - row_.left_margin - row_.right_margin) / 2;
|
||||
x -= fm.width(str) / 2;
|
||||
} else if (is_rtl) {
|
||||
x = width_ - row_.left_margin - fm.width(str);
|
||||
x = width_ - row_.right_margin - fm.width(str);
|
||||
}
|
||||
pi_.pain.text(int(x), yo_ - maxdesc - labeladdon, str, font);
|
||||
}
|
||||
@ -580,7 +575,7 @@ void RowPainter::paintLast()
|
||||
int const y = yo_ - size;
|
||||
int const max_row_width = width_ - size - Inset::TEXT_TO_INSET_OFFSET;
|
||||
int x = is_rtl ? nestMargin() + changebarMargin()
|
||||
: max_row_width - text_metrics_.rightMargin(pm_);
|
||||
: max_row_width - row_.right_margin;
|
||||
|
||||
// If needed, move the box a bit to avoid overlapping with text.
|
||||
int const rem = max_row_width - row_.width();
|
||||
|
@ -569,12 +569,6 @@ void TextMetrics::computeRowMetrics(pit_type const pit,
|
||||
// FIXME: put back this assertion when the crash on new doc is solved.
|
||||
//LASSERT(w >= 0, /**/);
|
||||
|
||||
bool const is_rtl = text_->isRTL(par);
|
||||
if (is_rtl)
|
||||
row.left_margin = rightMargin(pit);
|
||||
else
|
||||
row.left_margin = leftMargin(max_width_, pit, row.pos());
|
||||
|
||||
// is there a manual margin with a manual label
|
||||
Layout const & layout = par.layout();
|
||||
|
||||
@ -617,7 +611,7 @@ void TextMetrics::computeRowMetrics(pit_type const pit,
|
||||
&& row.endpos() != par.size()) {
|
||||
setSeparatorWidth(row, double(w) / ns);
|
||||
row.dimension().wid = width;
|
||||
} else if (is_rtl) {
|
||||
} else if (text_->isRTL(par)) {
|
||||
row.dimension().wid = width;
|
||||
row.left_margin += w;
|
||||
}
|
||||
@ -785,13 +779,19 @@ void TextMetrics::breakRow(Row & row, int const right_margin, pit_type const pit
|
||||
Paragraph const & par = text_->getPar(pit);
|
||||
pos_type const end = par.size();
|
||||
pos_type const pos = row.pos();
|
||||
int const width = max_width_ - right_margin;
|
||||
pos_type const body_pos = par.beginOfBody();
|
||||
bool const is_rtl = text_->isRTL(par);
|
||||
|
||||
row.clear();
|
||||
// This make get changed in computeRowMetrics depending on RTL
|
||||
row.left_margin = leftMargin(max_width_, pit, pos);
|
||||
row.dimension().wid = row.left_margin;
|
||||
row.right_margin = right_margin;
|
||||
if (is_rtl)
|
||||
swap(row.left_margin, row.right_margin);
|
||||
// Remember that the row width takes into account the left_margin
|
||||
// but not the right_margin.
|
||||
row.dimension().wid = row.left_margin;
|
||||
// the width available for the row.
|
||||
int const width = max_width_ - row.right_margin;
|
||||
|
||||
if (pos >= end || row.width() > width) {
|
||||
row.endpos(end);
|
||||
@ -904,7 +904,7 @@ void TextMetrics::breakRow(Row & row, int const right_margin, pit_type const pit
|
||||
row.shortenIfNeeded(body_pos, width);
|
||||
|
||||
// make sure that the RTL elements are in reverse ordering
|
||||
row.reverseRTL(text_->isRTL(par));
|
||||
row.reverseRTL(is_rtl);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user