mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-30 05:12:40 +00:00
* Bufferview::updateMetrics(): Separate out the SinglePar optimization.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21463 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
dd0c77d063
commit
f84080f01c
@ -532,7 +532,7 @@ void BufferView::processUpdateFlags(Update::flags flags)
|
||||
bool const fit_cursor = fitCursor();
|
||||
// tell the frontend to update the screen if needed.
|
||||
if (fit_cursor) {
|
||||
updateMetrics(false);
|
||||
updateMetrics();
|
||||
buffer_.changed();
|
||||
return;
|
||||
}
|
||||
@ -550,8 +550,9 @@ void BufferView::processUpdateFlags(Update::flags flags)
|
||||
if (flags & Update::MultiParSel)
|
||||
full_metrics |= multiParSel();
|
||||
|
||||
bool const single_par = !full_metrics;
|
||||
updateMetrics(single_par);
|
||||
if (full_metrics || singleParUpdate())
|
||||
// We have to update the full screen metrics.
|
||||
updateMetrics();
|
||||
|
||||
if (!(flags & Update::FitCursor)) {
|
||||
buffer_.changed();
|
||||
@ -569,7 +570,7 @@ void BufferView::processUpdateFlags(Update::flags flags)
|
||||
|
||||
// The screen has been recentered around the cursor position so
|
||||
// refresh it:
|
||||
updateMetrics(false);
|
||||
updateMetrics();
|
||||
buffer_.changed();
|
||||
}
|
||||
|
||||
@ -653,7 +654,7 @@ void BufferView::scrollDocView(int value)
|
||||
tm.redoParagraph(d->anchor_ref_);
|
||||
int const h = tm.parMetrics(d->anchor_ref_).height();
|
||||
d->offset_ref_ = int((bar * t.paragraphs().size() - d->anchor_ref_) * h);
|
||||
updateMetrics(false);
|
||||
updateMetrics();
|
||||
buffer_.changed();
|
||||
}
|
||||
|
||||
@ -1345,7 +1346,7 @@ Update::flags BufferView::dispatch(FuncRequest const & cmd)
|
||||
if (p.y_ < 0 || p.y_ > height_) {
|
||||
// The cursor is off-screen so recenter before proceeding.
|
||||
center();
|
||||
updateMetrics(false);
|
||||
updateMetrics();
|
||||
//FIXME: updateMetrics() does not update paragraph position
|
||||
// This is done at draw() time. So we need a redraw!
|
||||
buffer_.changed();
|
||||
@ -1430,7 +1431,7 @@ void BufferView::resize(int width, int height)
|
||||
width_ = width;
|
||||
height_ = height;
|
||||
|
||||
updateMetrics(false);
|
||||
updateMetrics();
|
||||
}
|
||||
|
||||
|
||||
@ -1584,7 +1585,7 @@ void BufferView::scrollDown(int offset)
|
||||
tm.newParMetricsDown();
|
||||
}
|
||||
d->offset_ref_ += offset;
|
||||
updateMetrics(false);
|
||||
updateMetrics();
|
||||
buffer_.changed();
|
||||
}
|
||||
|
||||
@ -1608,7 +1609,7 @@ void BufferView::scrollUp(int offset)
|
||||
tm.newParMetricsUp();
|
||||
}
|
||||
d->offset_ref_ -= offset;
|
||||
updateMetrics(false);
|
||||
updateMetrics();
|
||||
buffer_.changed();
|
||||
}
|
||||
|
||||
@ -1701,7 +1702,7 @@ bool BufferView::checkDepm(Cursor & cur, Cursor & old)
|
||||
|
||||
updateLabels(buffer_);
|
||||
|
||||
updateMetrics(false);
|
||||
updateMetrics();
|
||||
buffer_.changed();
|
||||
return true;
|
||||
}
|
||||
@ -1837,12 +1838,8 @@ bool BufferView::singleParUpdate()
|
||||
}
|
||||
|
||||
|
||||
void BufferView::updateMetrics(bool singlepar)
|
||||
void BufferView::updateMetrics()
|
||||
{
|
||||
if (singlepar && singleParUpdate())
|
||||
// No need to update the full screen metrics.
|
||||
return;
|
||||
|
||||
Text & buftext = buffer_.text();
|
||||
pit_type const npit = int(buftext.paragraphs().size());
|
||||
|
||||
@ -1993,7 +1990,7 @@ void BufferView::menuInsertLyXFile(string const & filenm)
|
||||
// emit message signal.
|
||||
message(bformat(res, disp_fn));
|
||||
buffer_.errors("Parse");
|
||||
updateMetrics(false);
|
||||
updateMetrics();
|
||||
}
|
||||
|
||||
|
||||
|
@ -201,8 +201,7 @@ public:
|
||||
/// \sa ViewMetricsInfo
|
||||
ViewMetricsInfo const & viewMetricsInfo();
|
||||
/// update the internal \c ViewMetricsInfo.
|
||||
/// \param singlepar indicates wether
|
||||
void updateMetrics(bool singlepar = false);
|
||||
void updateMetrics();
|
||||
|
||||
///
|
||||
TextMetrics const & textMetrics(Text const * t) const;
|
||||
|
@ -131,7 +131,7 @@ void WorkArea::redraw()
|
||||
// metrics are already up to date.
|
||||
if (lyx_view_ != theApp()->currentView()) {
|
||||
// FIXME: it would be nice to optimize for the off-screen case.
|
||||
buffer_view_->updateMetrics(false);
|
||||
buffer_view_->updateMetrics();
|
||||
buffer_view_->cursor().fixIfBroken();
|
||||
}
|
||||
|
||||
|
@ -297,7 +297,7 @@ void GuiParagraph::dispatchParams()
|
||||
return;
|
||||
}
|
||||
|
||||
bufferview()->updateMetrics(false);
|
||||
bufferview()->updateMetrics();
|
||||
bufferview()->buffer().changed();
|
||||
}
|
||||
|
||||
|
@ -810,7 +810,7 @@ WorkArea * GuiView::addWorkArea(Buffer & buffer)
|
||||
GuiWorkArea * wa = new GuiWorkArea(buffer, *this);
|
||||
wa->setUpdatesEnabled(false);
|
||||
d.tab_widget_->addTab(wa, toqstr(buffer.fileName().displayName(30)));
|
||||
wa->bufferView().updateMetrics(false);
|
||||
wa->bufferView().updateMetrics();
|
||||
if (d.stack_widget_)
|
||||
d.stack_widget_->setCurrentWidget(d.tab_widget_);
|
||||
// Hide tabbar if there's only one tab.
|
||||
|
@ -507,7 +507,7 @@ void GuiWorkArea::updateScreen()
|
||||
void GuiWorkArea::showCursor(int x, int y, int h, CursorShape shape)
|
||||
{
|
||||
if (schedule_redraw_) {
|
||||
buffer_view_->updateMetrics(false);
|
||||
buffer_view_->updateMetrics();
|
||||
updateScreen();
|
||||
viewport()->update(QRect(0, 0, viewport()->width(), viewport()->height()));
|
||||
schedule_redraw_ = false;
|
||||
@ -568,7 +568,7 @@ void GuiWorkArea::inputMethodEvent(QInputMethodEvent * e)
|
||||
}
|
||||
|
||||
GuiPainter pain(&screen_);
|
||||
buffer_view_->updateMetrics(false);
|
||||
buffer_view_->updateMetrics();
|
||||
buffer_view_->draw(pain);
|
||||
FontInfo font = buffer_view_->cursor().getFont().fontInfo();
|
||||
FontMetrics const & fm = theFontMetrics(font);
|
||||
@ -809,7 +809,7 @@ void TabWorkArea::on_currentTabChanged(int i)
|
||||
GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(widget(i));
|
||||
BOOST_ASSERT(wa);
|
||||
BufferView & bv = wa->bufferView();
|
||||
bv.updateMetrics(false);
|
||||
bv.updateMetrics();
|
||||
bv.cursor().fixIfBroken();
|
||||
wa->setUpdatesEnabled(true);
|
||||
wa->redraw();
|
||||
|
Loading…
Reference in New Issue
Block a user