mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 19:25:39 +00:00
make updateRowPositions() a bit faster.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7926 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
506844eca2
commit
9ed14b41fa
@ -3,6 +3,16 @@
|
||||
* lyxfunc.C (getStatus): also set flag disabled if it is a unknown
|
||||
action.
|
||||
|
||||
2003-10-16 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* lyxrow.[Ch]:
|
||||
* paragraph.h:
|
||||
* rowpainter.C:
|
||||
* text.C:
|
||||
* text2.C:
|
||||
* text3.C: speed up by storing y positions per paragraph plus per-row
|
||||
offset instead of having a 'full' y position in the row.
|
||||
|
||||
2003-10-15 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* iterators.[Ch]:
|
||||
|
@ -23,14 +23,14 @@ using lyx::pos_type;
|
||||
|
||||
|
||||
Row::Row()
|
||||
: pos_(0), end_(0), fill_(0), height_(0), width_(0), y_(0),
|
||||
: pos_(0), end_(0), fill_(0), height_(0), width_(0), y_offset_(0),
|
||||
ascent_of_text_(0), baseline_(0),
|
||||
x_(0), fill_separator_(0), fill_hfill_(0), fill_label_hfill_(0)
|
||||
{}
|
||||
|
||||
|
||||
Row::Row(pos_type pos)
|
||||
: pos_(pos), end_(0), fill_(0), height_(0), width_(0), y_(0),
|
||||
: pos_(pos), end_(0), fill_(0), height_(0), width_(0), y_offset_(0),
|
||||
ascent_of_text_(0), baseline_(0),
|
||||
x_(0), fill_separator_(0), fill_hfill_(0), fill_label_hfill_(0)
|
||||
{}
|
||||
@ -181,6 +181,6 @@ void Row::dump(const char * s) const
|
||||
<< " fill: " << fill_
|
||||
<< " ascent_of_text: " << ascent_of_text_
|
||||
<< " top_of_text: " << top_of_text_
|
||||
<< " y: " << y_ << std::endl;
|
||||
<< " y_offset: " << y_offset_ << std::endl;
|
||||
}
|
||||
|
||||
|
@ -59,9 +59,9 @@ public:
|
||||
/// return true if this row is the start of a paragraph
|
||||
bool isParStart() const;
|
||||
/// return the cached y position
|
||||
unsigned int y() const { return y_; }
|
||||
unsigned int y_offset() const { return y_offset_; }
|
||||
/// cache the y position
|
||||
void y(unsigned int newy) { y_ = newy; }
|
||||
void y_offset(unsigned int newy) { y_offset_ = newy; }
|
||||
///
|
||||
float x() const;
|
||||
///
|
||||
@ -93,7 +93,7 @@ private:
|
||||
///
|
||||
unsigned int width_;
|
||||
/// cached y position
|
||||
unsigned int y_;
|
||||
unsigned int y_offset_;
|
||||
/// ascent from baseline including prelude space
|
||||
unsigned short ascent_of_text_;
|
||||
/// the top of the real text in the row
|
||||
|
@ -52,7 +52,7 @@ using std::ostringstream;
|
||||
|
||||
|
||||
Paragraph::Paragraph()
|
||||
: y(0), pimpl_(new Paragraph::Pimpl(this))
|
||||
: y(0), height(0), pimpl_(new Paragraph::Pimpl(this))
|
||||
{
|
||||
itemdepth = 0;
|
||||
params().clear();
|
||||
@ -60,7 +60,7 @@ Paragraph::Paragraph()
|
||||
|
||||
|
||||
Paragraph::Paragraph(Paragraph const & lp)
|
||||
: y(0), text_(lp.text_), pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this))
|
||||
: y(0), height(0), text_(lp.text_), pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this))
|
||||
{
|
||||
itemdepth = 0;
|
||||
// this is because of the dummy layout of the paragraphs that
|
||||
|
@ -302,6 +302,8 @@ public:
|
||||
mutable RowList rows;
|
||||
/// last draw y position (baseline of top row)
|
||||
int y;
|
||||
///
|
||||
int height;
|
||||
|
||||
private:
|
||||
///
|
||||
|
@ -1089,7 +1089,7 @@ int paintText(BufferView & bv)
|
||||
int const topy = bv.top_y();
|
||||
ParagraphList::iterator pit;
|
||||
RowList::iterator rit = bv.text->getRowNearY(topy, pit);
|
||||
int y = rit->y() - topy;
|
||||
int const y = pit->y + rit->y_offset() - topy;
|
||||
return paintRows(bv, *bv.text, pit, rit, 0, y, y, 0);
|
||||
}
|
||||
|
||||
|
14
src/text.C
14
src/text.C
@ -93,12 +93,8 @@ void LyXText::updateRowPositions()
|
||||
ParagraphList::iterator pit = ownerParagraphs().begin();
|
||||
ParagraphList::iterator end = ownerParagraphs().end();
|
||||
for (height = 0; pit != end; ++pit) {
|
||||
RowList::iterator rit = pit->rows.begin();
|
||||
RowList::iterator rend = pit->rows.end();
|
||||
for ( ; rit != rend ; ++rit) {
|
||||
rit->y(height);
|
||||
height += rit->height();
|
||||
}
|
||||
pit->y = height;
|
||||
height += pit->height;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2021,8 +2017,8 @@ RowList::iterator LyXText::cursorIRow() const
|
||||
}
|
||||
|
||||
|
||||
RowList::iterator LyXText::getRowNearY(int y,
|
||||
ParagraphList::iterator & pit) const
|
||||
RowList::iterator LyXText::getRowNearY(int y, ParagraphList::iterator & pit)
|
||||
const
|
||||
{
|
||||
//lyxerr << "getRowNearY: y " << y << endl;
|
||||
|
||||
@ -2031,7 +2027,7 @@ RowList::iterator LyXText::getRowNearY(int y,
|
||||
RowList::iterator rit = lastRow();
|
||||
RowList::iterator rbegin = firstRow();
|
||||
|
||||
while (rit != rbegin && static_cast<int>(rit->y()) > y)
|
||||
while (rit != rbegin && pit->y + rit->y_offset() > y)
|
||||
previousRow(pit, rit);
|
||||
|
||||
return rit;
|
||||
|
@ -575,6 +575,7 @@ int LyXText::redoParagraphInternal(ParagraphList::iterator pit)
|
||||
int par_width = 0;
|
||||
// set height and fill and width of rows
|
||||
int const ww = workWidth();
|
||||
pit->height = 0;
|
||||
for (rit = pit->rows.begin(); rit != end; ++rit) {
|
||||
int const f = fill(pit, rit, ww);
|
||||
int const w = ww - f;
|
||||
@ -583,8 +584,10 @@ int LyXText::redoParagraphInternal(ParagraphList::iterator pit)
|
||||
rit->width(w);
|
||||
prepareToPrint(pit, rit);
|
||||
setHeightOfRow(pit, rit);
|
||||
height += rit->height();
|
||||
rit->y_offset(pit->height);
|
||||
pit->height += rit->height();
|
||||
}
|
||||
height += pit->height;
|
||||
|
||||
//lyxerr << "redoParagraph: " << pit->rows.size() << " rows\n";
|
||||
return par_width;
|
||||
@ -1404,7 +1407,7 @@ void LyXText::setCursor(LyXCursor & cur, paroffset_type par,
|
||||
|
||||
ParagraphList::iterator pit = getPar(par);
|
||||
RowList::iterator row = getRow(pit, pos);
|
||||
int y = row->y();
|
||||
int y = pit->y + row->y_offset();
|
||||
|
||||
// y is now the beginning of the cursor row
|
||||
y += row->baseline();
|
||||
@ -1661,7 +1664,7 @@ void LyXText::setCursorFromCoordinates(LyXCursor & cur, int x, int y)
|
||||
// Get the row first.
|
||||
ParagraphList::iterator pit;
|
||||
RowList::iterator rit = getRowNearY(y, pit);
|
||||
y = rit->y();
|
||||
y = pit->y + rit->y_offset();
|
||||
|
||||
bool bound = false;
|
||||
pos_type const column = getColumnNearX(pit, rit, x, bound);
|
||||
|
@ -313,7 +313,8 @@ void LyXText::cursorNext()
|
||||
}
|
||||
|
||||
ParagraphList::iterator dummypit;
|
||||
y = getRowNearY(y, dummypit)->y();
|
||||
RowList::iterator rr = getRowNearY(y, dummypit);
|
||||
y = dummypit->y + rr->y_offset();
|
||||
|
||||
setCursorFromCoordinates(cursor.x_fix(), y);
|
||||
// + bv->workHeight());
|
||||
|
Loading…
Reference in New Issue
Block a user