>>>>> "Jean-Marc" == Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes:
Jean-Marc> This is because the rowpainter code sets Wide() on these Jean-Marc> insets, because they are alone on a row. The following Jean-Marc> patches test additionally that the inset is not the last Jean-Marc> element of the paragraph. It seems to work for me, but I am Jean-Marc> not sure it is the right condition to test. Here is an updated version of these patches. What is new here is - I decreased the right margin from 30 to 10 (this is independent and can go in now, I think). - openinlined_ can only be set to true when the inset contains only one row. This was a cause for some strange behaviors. What I _really_ wanted to do is to force the text inset width to be mi.base.textwidth_ when openinlined_ is false (the width is currently the natural width of the inset, and I do not like that, since it changes when typing). However, I failed to find how this can be done. I am sure it is possible (the main text inset enforces its width, for example). Martin, do you know how to do that? I'd really appreciate testing of this patches. JMarc
Index: src/insets/insetcollapsable.C =================================================================== --- src/insets/insetcollapsable.C (revision 14252) +++ src/insets/insetcollapsable.C (working copy) @@ -138,7 +138,9 @@ void InsetCollapsable::metrics(MetricsIn dim = dimensionCollapsed(); if (status() == Open) { InsetText::metrics(mi, textdim_); - openinlined_ = textdim_.wid + 2 * dim.wid <= mi.base.textwidth; + bool const hasOneRow = text_.paragraphs().size() == 1 + && text_.paragraphs().front().rows().size() == 1; + openinlined_ = hasOneRow && textdim_.wid + 2 * dim.wid <= mi.base.textwidth; if (openinlined_) { // Correct for button width, and re-fit mi.base.textwidth -= dim.wid; Index: src/rowpainter.C =================================================================== --- src/rowpainter.C (revision 14252) +++ src/rowpainter.C (working copy) @@ -763,8 +763,9 @@ bool CursorOnRow(PainterInfo & pi, pit_t bool innerCursorOnRow(PainterInfo & pi, pit_type pit, RowList::const_iterator rit, LyXText const & text) { - // Is there a cursor inside an inset on this row, and is this inset - // the only "character" on this row + // Is there a cursor inside an inset on this row, and is this + // inset the only "character" on this row, but not the last of + // the paragraph. LCursor & cur = pi.base.bv->cursor(); if (rit->pos() + 1 != rit->endpos()) return false; @@ -772,7 +773,8 @@ bool innerCursorOnRow(PainterInfo & pi, CursorSlice const & sl = cur[d]; if (sl.text() == &text && sl.pit() == pit - && sl.pos() == rit->pos()) + && sl.pos() == rit->pos() + && sl.pos() < sl.lastpos() - 1) return d < cur.depth() - 1; } return false; Index: src/rowpainter.h =================================================================== --- src/rowpainter.h (revision 14252) +++ src/rowpainter.h (working copy) @@ -35,7 +35,7 @@ inline int nestMargin() { return 15; } inline int changebarMargin() { return 10; } /// right margin -inline int rightMargin() { return 30; } +inline int rightMargin() { return 10; } #endif // ROWPAINTER_H
Index: src/insets/insetcollapsable.C =================================================================== --- src/insets/insetcollapsable.C (revision 14252) +++ src/insets/insetcollapsable.C (working copy) @@ -138,7 +138,11 @@ void InsetCollapsable::metrics(MetricsIn dim = dimensionCollapsed(); if (status() == Open) { InsetText::metrics(mi, textdim_); - openinlined_ = textdim_.wid + 2 * dim.wid <= mi.base.textwidth; + bool const hasOneRow = text_.paragraphs().size() == 1 + && text_.paragraphs().front().rows().size() == 1; + openinlined_ = hasOneRow + && textdim_.wid + 2 * dim.wid <= mi.base.textwidth; + if (openinlined_) { // Correct for button width, and re-fit mi.base.textwidth -= dim.wid; Index: src/rowpainter.C =================================================================== --- src/rowpainter.C (revision 14252) +++ src/rowpainter.C (working copy) @@ -766,8 +766,9 @@ bool CursorOnRow(PainterInfo & pi, pit_t bool innerCursorOnRow(PainterInfo & pi, pit_type pit, RowList::const_iterator rit, LyXText const & text) { - // Is there a cursor inside an inset on this row, and is this inset - // the only "character" on this row + // Is there a cursor inside an inset on this row, and is this + // inset the only "character" on this row, but not the last of + // the paragraph. LCursor & cur = pi.base.bv->cursor(); if (rit->pos() + 1 != rit->endpos()) return false; @@ -775,7 +776,8 @@ bool innerCursorOnRow(PainterInfo & pi, CursorSlice const & sl = cur[d]; if (sl.text() == &text && sl.pit() == pit - && sl.pos() == rit->pos()) + && sl.pos() == rit->pos() + && sl.pos() < sl.lastpos() - 1) return d < cur.depth() - 1; } return false; Index: src/rowpainter.h =================================================================== --- src/rowpainter.h (revision 14252) +++ src/rowpainter.h (working copy) @@ -35,7 +35,7 @@ inline int nestMargin() { return 15; } inline int changebarMargin() { return 10; } /// right margin -inline int rightMargin() { return 30; } +inline int rightMargin() { return 10; } #endif // ROWPAINTER_H