mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-07 02:28:35 +00:00
Fixup 824d1c99
: do not change the semantics of leftMargin(pit_type)
In the row painter, when painting a centered label, one wants to get the left/right margin of the non-first rows (without indent). It was a bad idea to change leftMargin(pit) to do that, because its semantics are unclear and the the code depends on the fact that this function does strange things when the paragraph is empty... Fixes bug #12118.
This commit is contained in:
parent
37392dcc72
commit
3f093dd103
@ -457,14 +457,16 @@ void RowPainter::paintTopLevelLabel() const
|
||||
|
||||
double x = x_;
|
||||
if (layout.labeltype == LABEL_CENTERED) {
|
||||
// The 'size + 1' is weird, but it makes sure that we get the
|
||||
// left margin of non-first row.
|
||||
int leftm = tm_.leftMargin(row_.pit(), par_.size() + 1);
|
||||
int rightm = tm_.rightMargin(row_.pit());
|
||||
if (row_.isRTL())
|
||||
swap(leftm, rightm);
|
||||
/* Currently, x points at row_.left_margin (which contains the
|
||||
* indent). First remove that, and then center the title with
|
||||
* respect to the left and right margins.
|
||||
*/
|
||||
int const leftm = row_.isRTL() ? tm_.rightMargin(row_.pit())
|
||||
: tm_.leftMargin(row_.pit());
|
||||
int const rightm = row_.isRTL() ? tm_.leftMargin(row_.pit())
|
||||
: tm_.rightMargin(row_.pit());
|
||||
x += leftm - row_.left_margin + (tm_.width() - leftm -rightm) / 2
|
||||
- fm.width(str) / 2;
|
||||
} else if (row_.isRTL()) {
|
||||
|
@ -1621,8 +1621,9 @@ void TextMetrics::deleteLineForward(Cursor & cur)
|
||||
|
||||
int TextMetrics::leftMargin(pit_type pit) const
|
||||
{
|
||||
// the + 1 is useful when the paragraph is empty
|
||||
return leftMargin(pit, text_->paragraphs()[pit].size() + 1);
|
||||
// FIXME: what is the semantics? It depends on whether the
|
||||
// paragraph is empty!
|
||||
return leftMargin(pit, text_->paragraphs()[pit].size());
|
||||
}
|
||||
|
||||
|
||||
@ -1635,7 +1636,7 @@ int TextMetrics::leftMargin(pit_type const pit, pos_type const pos) const
|
||||
Paragraph const & par = pars[pit];
|
||||
LASSERT(pos >= 0, return 0);
|
||||
// We do not really care whether pos > par.size(), since we do not
|
||||
// access the data. It can be actially useful, when querying the
|
||||
// access the data. It can be actually useful, when querying the
|
||||
// margin without indentation (see leftMargin(pit_type).
|
||||
|
||||
Buffer const & buffer = bv_->buffer();
|
||||
|
Loading…
Reference in New Issue
Block a user