removing update calls

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8076 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Alfredo Braunstein 2003-11-11 13:17:28 +00:00
parent 49cbe77634
commit faa37a30d4
10 changed files with 53 additions and 23 deletions

View File

@ -616,8 +616,6 @@ void BufferView::Pimpl::update()
// check needed to survive LyX startup
if (bv_->getLyXText()) {
bv_->getLyXText()->redoCursor();
// update all 'visible' paragraphs
ParagraphList::iterator beg;
ParagraphList::iterator end;
@ -625,7 +623,7 @@ void BufferView::Pimpl::update()
top_y(), top_y() + workarea().workHeight(),
beg, end);
bv_->text->redoParagraphs(beg, end);
bv_->getLyXText()->redoCursor();
updateScrollbar();
}
screen().redraw(*bv_);
@ -962,8 +960,10 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
cmd2.x -= inset->x();
cmd2.y -= inset->y();
res = inset->dispatch(cmd2);
if (res.update())
if (res.update()) {
bv_->update();
bv_->cursor().updatePos();
}
res.update(false);
switch (res.val()) {
case FINISHED:
@ -973,6 +973,7 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
theTempCursor.pop();
bv_->cursor() = theTempCursor;
bv_->cursor().innerText()->setCursorFromCoordinates(cmd.x, top_y() + cmd.y);
bv_->cursor().updatePos();
bv_->fitCursor();
return true;
default:
@ -987,12 +988,12 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
lyxerr << "dispatching " << cmd1
<< " to surrounding LyXText "
<< bv_->cursor().innerText() << endl;
cursor_ = theTempCursor;
bv_->cursor() = theTempCursor;
theTempCursor.dispatch(cmd1);
bv_->update();
bv_->cursor().updatePos();
//return DispatchResult(true, true);
}
bv_->update();
// see workAreaKeyPress
cursor_timeout.restart();
screen().showCursor(*bv_);

View File

@ -1,3 +1,9 @@
2003-11-11 Alfredo Braunstein <abraunst@lyx.org>
* cursor.[Ch] (updatePos): new function for updating the y
position of the tip inset
* bufferview_funcs.C (put_selection_at):
* BufferView_pimpl.C (workAreaDispatch): rationalise update calls
2003-11-11 André Pönitz <poenitz@gmx.net>

View File

@ -19,6 +19,7 @@
#include "buffer.h"
#include "bufferparams.h"
#include "BufferView.h"
#include "cursor.h"
#include "gettext.h"
#include "language.h"
#include "LColor.h"
@ -263,6 +264,20 @@ void replaceSelection(LyXText * text)
}
/*
if the fitCursor call refers to some point in never-explored-land, then we
don't have y information in insets there, then we cannot even do an update
to get it (because we need the y infomation for setting top_y first). So
this is solved in put_selection_at with:
- setting top_y to the y of the outerPar (that has good info)
- calling update
- calling cursor().updatePos()
- then call fitCursor()
Ab.
*/
void put_selection_at(BufferView * bv, PosIterator const & cur,
int length, bool backwards)
{
@ -272,8 +287,12 @@ void put_selection_at(BufferView * bv, PosIterator const & cur,
LyXText * text = par.text(bv);
par.lockPath(bv);
//hack for the chicken and egg problem
if (par.inset())
bv->top_y(par.outerPar()->y);
bv->update();
text->setCursor(cur.pit(), cur.pos());
bv->cursor().updatePos();
if (length) {
text->setSelectionRange(length);
@ -281,7 +300,7 @@ void put_selection_at(BufferView * bv, PosIterator const & cur,
if (backwards)
text->cursor = text->selection.start;
}
bv->fitCursor();
bv->update();
}

View File

@ -113,7 +113,7 @@ void LCursor::push(UpdatableInset * inset)
{
lyxerr << "LCursor::push() inset: " << inset << endl;
data_.push_back(CursorItem(inset));
cached_y_ = bv_->top_y() + inset->y();
cached_y_ = bv_->top_y() + innerInset()->y();
}
@ -157,6 +157,13 @@ LyXText * LCursor::innerText() const
}
void LCursor::updatePos()
{
if (!data_.empty())
cached_y_ = bv_->top_y() + innerInset()->y();
}
void LCursor::getPos(int & x, int & y) const
{
if (data_.empty()) {

View File

@ -75,6 +75,8 @@ public:
LyXText * innerText() const;
/// returns x,y position
void getPos(int & x, int & y) const;
/// cache the absolute coordinate from the top inset
void updatePos();
///
friend std::ostream & operator<<(std::ostream &, LCursor const &);
public:

View File

@ -51,9 +51,9 @@ public:
DispatchResult(bool dis)
: dispatched_(dis), update_(false), val_(NONE) {}
DispatchResult(bool dis, bool update)
: dispatched_(dis), update_(true), val_(NONE) {}
: dispatched_(dis), update_(update), val_(NONE) {}
DispatchResult(bool dis, dispatch_result_t val)
: dispatched_(dis), update_(false), val_(val) {}
: dispatched_(dis), update_(true), val_(val) {}
dispatch_result_t val() const { return val_; }
void val(dispatch_result_t drt) {
val_ = drt;

View File

@ -1,3 +1,8 @@
2003-11-11 Alfredo Braunstein <abraunst@lyx.org>
* insettext.C: remove all update calls
* insetcollapsable.C: remove all update calls
2003-11-11 Alfredo Braunstein <abraunst@libero.it>
* insettext.C (updateLocal, insertInset, setFont): remove

View File

@ -205,8 +205,6 @@ DispatchResult InsetCollapsable::lfunMouseRelease(FuncRequest const & cmd)
lyxerr << "InsetCollapsable::lfunMouseRelease 1" << endl;
collapsed_ = false;
edit(bv, true);
bv->buffer()->markDirty();
bv->update();
return DispatchResult(true, true);
}
@ -214,12 +212,9 @@ DispatchResult InsetCollapsable::lfunMouseRelease(FuncRequest const & cmd)
if (!collapsed_) {
collapsed_ = true;
lyxerr << "InsetCollapsable::lfunMouseRelease 2" << endl;
bv->update();
return DispatchResult(false, FINISHED_RIGHT);
}
collapsed_ = false;
bv->update();
bv->buffer()->markDirty();
lyxerr << "InsetCollapsable::lfunMouseRelease 3" << endl;
} else if (!collapsed_ && cmd.y > button_dim.y2) {
lyxerr << "InsetCollapsable::lfunMouseRelease 4" << endl;
@ -281,8 +276,6 @@ void InsetCollapsable::edit(BufferView * bv, int x, int y)
collapsed_ = false;
// set this only here as it should be recollapsed only if
// it was already collapsed!
bv->update();
bv->buffer()->markDirty();
inset.edit(bv, x, y);
} else {
if (y <= button_dim.y2)
@ -398,7 +391,6 @@ void InsetCollapsable::open(BufferView * bv)
return;
collapsed_ = false;
bv->update();
}
@ -408,7 +400,6 @@ void InsetCollapsable::close(BufferView * bv) const
return;
collapsed_ = true;
bv->update();
}

View File

@ -290,7 +290,6 @@ void InsetText::updateLocal(BufferView * bv, bool /*mark_dirty*/)
text_.selection.cursor = text_.cursor;
// bv->fitCursor();
bv->update();
bv->owner()->view_state_changed();
bv->owner()->updateMenubar();
bv->owner()->updateToolbar();

View File

@ -628,6 +628,6 @@ void getParsInRange(ParagraphList & pl,
for (--beg; beg != begpar && beg->y > ystart; --beg)
;
for (end = beg ; end != endpar && end->y < yend; ++end)
for (end = beg ; end != endpar && end->y <= yend; ++end)
;
}