mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Make sure that rows are repainted when they get (un)selected
The bug is the following: when selecting several paragraphs quickly
enough, some rows do not get selected.This is a consequence of the
removal of row crc, which lead to not taking into account the
selection status of the row in the decision to repaint.
The solution chosen here is to add a Row::change() helper function to
modify row members. This will set the Row changed status whenever the
value of the member changes.
(cherry picked from commit ae60749f89
)
This commit is contained in:
parent
9c8e3df86b
commit
8af3077753
16
src/Row.cpp
16
src/Row.cpp
@ -203,8 +203,8 @@ void Row::setSelectionAndMargins(DocIterator const & beg,
|
||||
setSelection(beg.pos(), end.pos());
|
||||
|
||||
if (selection()) {
|
||||
end_margin_sel = isMarginSelected(false, beg, end);
|
||||
begin_margin_sel = isMarginSelected(true, beg, end);
|
||||
change(end_margin_sel, isMarginSelected(false, beg, end));
|
||||
change(begin_margin_sel, isMarginSelected(true, beg, end));
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,18 +212,18 @@ void Row::setSelectionAndMargins(DocIterator const & beg,
|
||||
void Row::setSelection(pos_type beg, pos_type end) const
|
||||
{
|
||||
if (pos_ >= beg && pos_ <= end)
|
||||
sel_beg = pos_;
|
||||
change(sel_beg, pos_);
|
||||
else if (beg > pos_ && beg <= end_)
|
||||
sel_beg = beg;
|
||||
change(sel_beg, beg);
|
||||
else
|
||||
sel_beg = -1;
|
||||
change(sel_beg, -1);
|
||||
|
||||
if (end_ >= beg && end_ <= end)
|
||||
sel_end = end_;
|
||||
change(sel_end,end_);
|
||||
else if (end < end_ && end >= pos_)
|
||||
sel_end = end;
|
||||
change(sel_end, end);
|
||||
else
|
||||
sel_end = -1;
|
||||
change(sel_end, -1);
|
||||
}
|
||||
|
||||
|
||||
|
23
src/Row.h
23
src/Row.h
@ -136,6 +136,29 @@ public:
|
||||
|
||||
///
|
||||
Row();
|
||||
/**
|
||||
* Helper function: set variable \c var to value \c val, and mark
|
||||
* row as changed is the values were different. This is intended
|
||||
* for use when changing members of the row object.
|
||||
*/
|
||||
template<class T1, class T2>
|
||||
void change(T1 & var, T2 const val) {
|
||||
if (var != val)
|
||||
changed(true);
|
||||
var = val;
|
||||
}
|
||||
/**
|
||||
* Helper function: set variable \c var to value \c val, and mark
|
||||
* row as changed is the values were different. This is intended
|
||||
* for use when changing members of the row object.
|
||||
* This is the const version, useful for mutable members.
|
||||
*/
|
||||
template<class T1, class T2>
|
||||
void change(T1 & var, T2 const val) const {
|
||||
if (var != val)
|
||||
changed(true);
|
||||
var = val;
|
||||
}
|
||||
///
|
||||
bool changed() const { return changed_; }
|
||||
///
|
||||
|
@ -1884,9 +1884,9 @@ void TextMetrics::drawParagraph(PainterInfo & pi, pit_type const pit, int const
|
||||
// whether this row is the first or last and update the margins.
|
||||
if (row.selection()) {
|
||||
if (row.sel_beg == 0)
|
||||
row.begin_margin_sel = sel_beg.pit() < pit;
|
||||
row.change(row.begin_margin_sel, sel_beg.pit() < pit);
|
||||
if (row.sel_end == sel_end_par.lastpos())
|
||||
row.end_margin_sel = sel_end.pit() > pit;
|
||||
row.change(row.end_margin_sel, sel_end.pit() > pit);
|
||||
}
|
||||
|
||||
// has row changed since last paint?
|
||||
|
Loading…
Reference in New Issue
Block a user