postPaint() etc.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6514 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2003-03-16 00:45:31 +00:00
parent a1e4f55eb6
commit af2f39cc94
6 changed files with 139 additions and 71 deletions

View File

@ -1,3 +1,7 @@
2003-03-16 John Levon <levon@movementarian.org>
* insettext.C: remove unused s.refresh
2003-03-13 Angus Leeming <leeming@lyx.org> 2003-03-13 Angus Leeming <leeming@lyx.org>
* insettext.C (edit): replace Dialogs::updateParagraph with * insettext.C (edit): replace Dialogs::updateParagraph with

View File

@ -100,7 +100,6 @@ void InsetText::saveLyXTextState(LyXText * t) const
sstate.selendboundary = t->selection.end.boundary(); sstate.selendboundary = t->selection.end.boundary();
sstate.selection = t->selection.set(); sstate.selection = t->selection.set();
sstate.mark_set = t->selection.mark(); sstate.mark_set = t->selection.mark();
sstate.refresh = t->refresh_row != 0;
} else { } else {
sstate.lpar = 0; sstate.lpar = 0;
} }
@ -109,26 +108,24 @@ void InsetText::saveLyXTextState(LyXText * t) const
void InsetText::restoreLyXTextState(BufferView * bv, LyXText * t) const void InsetText::restoreLyXTextState(BufferView * bv, LyXText * t) const
{ {
if (sstate.lpar) { if (!sstate.lpar)
t->selection.set(true); return;
/* at this point just to avoid the Delete-Empty-Paragraph
* Mechanism when setting the cursor */ t->selection.set(true);
t->selection.mark(sstate.mark_set); /* at this point just to avoid the DEPM when setting the cursor */
if (sstate.selection) { t->selection.mark(sstate.mark_set);
t->setCursor(bv, sstate.selstartpar, sstate.selstartpos, if (sstate.selection) {
true, sstate.selstartboundary); t->setCursor(bv, sstate.selstartpar, sstate.selstartpos,
t->selection.cursor = t->cursor; true, sstate.selstartboundary);
t->setCursor(bv, sstate.selendpar, sstate.selendpos, t->selection.cursor = t->cursor;
true, sstate.selendboundary); t->setCursor(bv, sstate.selendpar, sstate.selendpos,
t->setSelection(bv); true, sstate.selendboundary);
t->setCursor(bv, sstate.lpar, sstate.pos); t->setSelection(bv);
} else { t->setCursor(bv, sstate.lpar, sstate.pos);
t->setCursor(bv, sstate.lpar, sstate.pos, true, sstate.boundary); } else {
t->selection.cursor = t->cursor; t->setCursor(bv, sstate.lpar, sstate.pos, true, sstate.boundary);
t->selection.set(false); t->selection.cursor = t->cursor;
} t->selection.set(false);
if (sstate.refresh) {
}
} }
} }

View File

@ -211,6 +211,22 @@ public:
/// Set the status to make a paint pending. /// Set the status to make a paint pending.
void status(BufferView *, text_status) const; void status(BufferView *, text_status) const;
/// clear any pending paints
void clearPaint();
/// post notice that we changed during a draw
void postChangedInDraw();
/**
* Mark position y as the starting point for a repaint
*/
void postPaint(BufferView & bv, int start_y);
/**
* Mark the given row at position y as needing a repaint.
*/
void postRowPaint(BufferView & bv, Row * row, int start_y);
/// ///
Inset::RESULT dispatch(FuncRequest const & cmd); Inset::RESULT dispatch(FuncRequest const & cmd);

View File

@ -1453,19 +1453,19 @@ void LyXText::breakParagraph(BufferView * bview,
cursorLeft(bview); cursorLeft(bview);
} }
status(bview, LyXText::NEED_MORE_REFRESH); int y = cursor.y() - cursor.row()->baseline();
refresh_row = cursor.row();
refresh_y = cursor.y() - cursor.row()->baseline();
// Do not forget the special right address boxes // Do not forget the special right address boxes
if (layout->margintype == MARGIN_RIGHT_ADDRESS_BOX) { if (layout->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
while (refresh_row->previous() && Row * r = cursor.row();
refresh_row->previous()->par() == refresh_row->par()) while (r->previous() && r->previous()->par() == r->par()) {
{ r = r->previous();
refresh_row = refresh_row->previous(); y -= r->height();
refresh_y -= refresh_row->height();
} }
} }
postPaint(*bview, y);
removeParagraph(cursor.row()); removeParagraph(cursor.row());
// set the dimensions of the cursor row // set the dimensions of the cursor row
@ -1660,9 +1660,8 @@ void LyXText::insertChar(BufferView * bview, char c)
setHeightOfRow(bview, row->previous()); setHeightOfRow(bview, row->previous());
y -= row->previous()->height(); y -= row->previous()->height();
refresh_y = y;
refresh_row = row->previous(); postPaint(*bview, y);
status(bview, LyXText::NEED_MORE_REFRESH);
breakAgainOneRow(bview, row); breakAgainOneRow(bview, row);
@ -1695,9 +1694,7 @@ void LyXText::insertChar(BufferView * bview, char c)
} }
if (c == Paragraph::META_INSET || row->fill() < 0) { if (c == Paragraph::META_INSET || row->fill() < 0) {
refresh_y = y; postPaint(*bview, y);
refresh_row = row;
status(bview, LyXText::NEED_MORE_REFRESH);
breakAgainOneRow(bview, row); breakAgainOneRow(bview, row);
// will the cursor be in another row now? // will the cursor be in another row now?
if (row->lastPos() <= cursor.pos() + 1 && row->next()) { if (row->lastPos() <= cursor.pos() + 1 && row->next()) {
@ -1720,15 +1717,16 @@ void LyXText::insertChar(BufferView * bview, char c)
else else
need_break_row = 0; need_break_row = 0;
} else { } else {
refresh_y = y; // FIXME: similar code is duplicated all over - make resetHeightOfRow
refresh_row = row;
int const tmpheight = row->height(); int const tmpheight = row->height();
setHeightOfRow(bview, row); setHeightOfRow(bview, row);
if (tmpheight == row->height())
status(bview, LyXText::NEED_VERY_LITTLE_REFRESH); if (tmpheight == row->height()) {
else postRowPaint(*bview, row, y);
status(bview, LyXText::NEED_MORE_REFRESH); } else {
postPaint(*bview, y);
}
current_font = rawtmpfont; current_font = rawtmpfont;
real_current_font = realtmpfont; real_current_font = realtmpfont;
@ -2344,11 +2342,9 @@ void LyXText::changeCase(BufferView & bview, LyXText::TextCase action)
++pos; ++pos;
} }
if (to.row() != from.row()) {
refresh_y = from.y() - from.row()->baseline(); if (to.row() != from.row())
refresh_row = from.row(); postPaint(bview, from.y() - from.row()->baseline());
status(&bview, LyXText::NEED_MORE_REFRESH);
}
} }
@ -2468,9 +2464,7 @@ void LyXText::backspace(BufferView * bview)
int const tmpheight = cursor.row()->height(); int const tmpheight = cursor.row()->height();
setHeightOfRow(bview, cursor.row()); setHeightOfRow(bview, cursor.row());
if (cursor.row()->height() != tmpheight) { if (cursor.row()->height() != tmpheight) {
refresh_y = cursor.y() - cursor.row()->baseline(); postPaint(*bview, cursor.y() - cursor.row()->baseline());
refresh_row = cursor.row();
status(bview, LyXText::NEED_MORE_REFRESH);
} }
return; return;
} }
@ -2524,9 +2518,7 @@ void LyXText::backspace(BufferView * bview)
if (cursor.pos()) if (cursor.pos())
cursor.pos(cursor.pos() - 1); cursor.pos(cursor.pos() - 1);
status(bview, LyXText::NEED_MORE_REFRESH); postPaint(*bview, cursor.y() - cursor.row()->baseline());
refresh_row = cursor.row();
refresh_y = cursor.y() - cursor.row()->baseline();
// remove the lost paragraph // remove the lost paragraph
// This one is not safe, since the paragraph that the tmprow and the // This one is not safe, since the paragraph that the tmprow and the
@ -2655,9 +2647,8 @@ void LyXText::backspace(BufferView * bview)
tmprow->fill(fill(*bview, *tmprow, workWidth(*bview))); tmprow->fill(fill(*bview, *tmprow, workWidth(*bview)));
setHeightOfRow(bview, tmprow); setHeightOfRow(bview, tmprow);
refresh_y = y; postPaint(*bview, y);
refresh_row = tmprow;
status(bview, LyXText::NEED_MORE_REFRESH);
setCursor(bview, cursor.par(), cursor.pos(), setCursor(bview, cursor.par(), cursor.pos(),
false, cursor.boundary()); false, cursor.boundary());
//current_font = rawtmpfont; //current_font = rawtmpfont;
@ -2683,9 +2674,7 @@ void LyXText::backspace(BufferView * bview)
if (row->lastPos() == row->par()->size() - 1) if (row->lastPos() == row->par()->size() - 1)
removeRow(row->next()); removeRow(row->next());
refresh_y = y; postPaint(*bview, y);
refresh_row = row;
status(bview, LyXText::NEED_MORE_REFRESH);
breakAgainOneRow(bview, row); breakAgainOneRow(bview, row);
// will the cursor be in another row now? // will the cursor be in another row now?
@ -2706,12 +2695,11 @@ void LyXText::backspace(BufferView * bview)
row->fill(fill(*bview, *row, workWidth(*bview))); row->fill(fill(*bview, *row, workWidth(*bview)));
int const tmpheight = row->height(); int const tmpheight = row->height();
setHeightOfRow(bview, row); setHeightOfRow(bview, row);
if (tmpheight == row->height()) if (tmpheight == row->height()) {
status(bview, LyXText::NEED_VERY_LITTLE_REFRESH); postRowPaint(*bview, row, y);
else } else {
status(bview, LyXText::NEED_MORE_REFRESH); postPaint(*bview, y);
refresh_y = y; }
refresh_row = row;
setCursor(bview, cursor.par(), cursor.pos(), false, cursor.boundary()); setCursor(bview, cursor.par(), cursor.pos(), false, cursor.boundary());
} }
} }

View File

@ -79,12 +79,11 @@ void LyXText::init(BufferView * bview, bool reinit)
} }
lastrow = 0; lastrow = 0;
refresh_row = 0;
need_break_row = 0; need_break_row = 0;
width = height = 0; width = height = 0;
copylayouttype.erase(); copylayouttype.erase();
top_y(refresh_y = 0); top_y(0);
status_ = LyXText::UNCHANGED; clearPaint();
} else if (firstrow) } else if (firstrow)
return; return;
@ -2494,6 +2493,72 @@ void LyXText::status(BufferView * bview, LyXText::text_status new_status) const
} }
void LyXText::clearPaint()
{
status_ = UNCHANGED;
refresh_row = 0;
refresh_y = 0;
}
void LyXText::postChangedInDraw()
{
status_ = CHANGED_IN_DRAW;
}
void LyXText::postPaint(BufferView & bv, int start_y)
{
status_ = NEED_MORE_REFRESH;
refresh_y = start_y;
refresh_row = 0;
if (!inset_owner)
return;
// We are an inset's lyxtext. Tell the top-level lyxtext
// it needs to update the row we're in.
LyXText * t = bv.text;
// FIXME: but what if this row is below ?
if (!t->refresh_row) {
t->refresh_row = t->cursor.row();
t->refresh_y = t->cursor.y() - t->cursor.row()->baseline();
}
}
// FIXME: we should probably remove this y parameter,
// make refresh_y be 0, and use row->y etc.
void LyXText::postRowPaint(BufferView & bv, Row * row, int start_y)
{
// FIXME: shouldn't this check that we're not updating
// above the existing refresh_y ??
if (status_ == NEED_MORE_REFRESH)
return;
status_ = NEED_VERY_LITTLE_REFRESH;
refresh_y = start_y;
refresh_row = row;
if (!inset_owner)
return;
// We are an inset's lyxtext. Tell the top-level lyxtext
// it needs to update the row we're in.
LyXText * t = bv.text;
// FIXME: but what if this new row is above ?
// Why the !t->refresh_row at all ?
if (!t->refresh_row) {
t->refresh_row = t->cursor.row();
t->refresh_y = t->cursor.y() - t->cursor.row()->baseline();
}
}
bool LyXText::isTopLevel() const bool LyXText::isTopLevel() const
{ {
/// only the top-level lyxtext has a non-null bv owner /// only the top-level lyxtext has a non-null bv owner

View File

@ -429,11 +429,9 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
par->params().startOfAppendix(start); par->params().startOfAppendix(start);
// we can set the refreshing parameters now // we can set the refreshing parameters now
status(cmd.view(), LyXText::NEED_MORE_REFRESH);
updateCounters(cmd.view()); updateCounters(cmd.view());
redoHeightOfParagraph(bv); redoHeightOfParagraph(bv);
refresh_y = 0; postPaint(*cmd.view(), 0);
refresh_row = 0;
setCursor(cmd.view(), cursor.par(), cursor.pos()); setCursor(cmd.view(), cursor.par(), cursor.pos());
update(bv); update(bv);
break; break;