mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-21 23:09:40 +00:00
Fix multipar selection drawing. The problem was that the row selection status was only updated for full metrics update. A simple transfer of the relevant code from TextMetrics::redoParagraph() to TextMetrics::drawParagraph() solved the problem.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23408 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
ffc4554815
commit
a837d22ab9
@ -61,7 +61,7 @@ void Row::endpos(pos_type p)
|
||||
}
|
||||
|
||||
|
||||
void Row::setSelection(pos_type beg, pos_type end)
|
||||
void Row::setSelection(pos_type beg, pos_type end) const
|
||||
{
|
||||
if (pos_ >= beg && pos_ <= end)
|
||||
sel_beg = pos_;
|
||||
|
12
src/Row.h
12
src/Row.h
@ -39,8 +39,12 @@ public:
|
||||
void setChanged(bool c) { changed_ = c; }
|
||||
///
|
||||
void setCrc(size_type crc) const;
|
||||
///
|
||||
void setSelection(pos_type sel_beg, pos_type sel_end);
|
||||
/// Set the selection begin and end.
|
||||
/**
|
||||
* This is const because we update the selection status only at draw()
|
||||
* time.
|
||||
*/
|
||||
void setSelection(pos_type sel_beg, pos_type sel_end) const;
|
||||
|
||||
///
|
||||
void pos(pos_type p);
|
||||
@ -73,9 +77,9 @@ public:
|
||||
/// the x position of the row
|
||||
double x;
|
||||
///
|
||||
pos_type sel_beg;
|
||||
mutable pos_type sel_beg;
|
||||
///
|
||||
pos_type sel_end;
|
||||
mutable pos_type sel_end;
|
||||
private:
|
||||
/// has the Row appearance changed since last drawing?
|
||||
mutable bool changed_;
|
||||
|
@ -423,28 +423,6 @@ bool TextMetrics::redoParagraph(pit_type const pit)
|
||||
changed |= (old_dim != dim);
|
||||
}
|
||||
|
||||
Cursor const & cur = bv_->cursor();
|
||||
DocIterator sel_beg = cur.selectionBegin();
|
||||
DocIterator sel_end = cur.selectionEnd();
|
||||
bool selection = cur.selection()
|
||||
// This is out text.
|
||||
&& cur.text() == text_
|
||||
// if the anchor is outside, this is not our selection
|
||||
&& cur.anchor().text() == text_
|
||||
&& pit >= sel_beg.pit() && pit <= sel_end.pit();
|
||||
|
||||
// We care only about visible selection.
|
||||
if (selection) {
|
||||
if (pit != sel_beg.pit()) {
|
||||
sel_beg.pit() = pit;
|
||||
sel_beg.pos() = 0;
|
||||
}
|
||||
if (pit != sel_end.pit()) {
|
||||
sel_end.pit() = pit;
|
||||
sel_end.pos() = sel_end.lastpos();
|
||||
}
|
||||
}
|
||||
|
||||
par.setBeginOfBody();
|
||||
pos_type first = 0;
|
||||
size_t row_index = 0;
|
||||
@ -467,10 +445,6 @@ bool TextMetrics::redoParagraph(pit_type const pit)
|
||||
row.setChanged(false);
|
||||
row.pos(first);
|
||||
row.endpos(end);
|
||||
if (selection)
|
||||
row.setSelection(sel_beg.pos(), sel_end.pos());
|
||||
else
|
||||
row.setSelection(-1, -1);
|
||||
row.setDimension(dim);
|
||||
int const max_row_width = max(dim_.wid, dim.wid);
|
||||
computeRowMetrics(pit, row, max_row_width);
|
||||
@ -1961,6 +1935,28 @@ void TextMetrics::drawParagraph(PainterInfo & pi, pit_type pit, int x, int y) co
|
||||
int const ww = bv_->workHeight();
|
||||
size_t const nrows = pm.rows().size();
|
||||
|
||||
Cursor const & cur = bv_->cursor();
|
||||
DocIterator sel_beg = cur.selectionBegin();
|
||||
DocIterator sel_end = cur.selectionEnd();
|
||||
bool selection = cur.selection()
|
||||
// This is our text.
|
||||
&& cur.text() == text_
|
||||
// if the anchor is outside, this is not our selection
|
||||
&& cur.anchor().text() == text_
|
||||
&& pit >= sel_beg.pit() && pit <= sel_end.pit();
|
||||
|
||||
// We care only about visible selection.
|
||||
if (selection) {
|
||||
if (pit != sel_beg.pit()) {
|
||||
sel_beg.pit() = pit;
|
||||
sel_beg.pos() = 0;
|
||||
}
|
||||
if (pit != sel_end.pit()) {
|
||||
sel_end.pit() = pit;
|
||||
sel_end.pos() = sel_end.lastpos();
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i != nrows; ++i) {
|
||||
|
||||
Row const & row = pm.rows()[i];
|
||||
@ -1973,6 +1969,11 @@ void TextMetrics::drawParagraph(PainterInfo & pi, pit_type pit, int x, int y) co
|
||||
pi.pain.setDrawingEnabled(inside && original_drawing_state);
|
||||
RowPainter rp(pi, *text_, pit, row, bidi, x, y);
|
||||
|
||||
if (selection)
|
||||
row.setSelection(sel_beg.pos(), sel_end.pos());
|
||||
else
|
||||
row.setSelection(-1, -1);
|
||||
|
||||
// Row signature; has row changed since last paint?
|
||||
row.setCrc(pm.computeRowSignature(row, bparams));
|
||||
bool row_has_changed = row.changed();
|
||||
|
Loading…
x
Reference in New Issue
Block a user