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