work on inset scrolling

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10222 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2005-07-15 16:44:41 +00:00
parent dc3e0ae6e0
commit 6100178a37
3 changed files with 12 additions and 32 deletions

View File

@ -1,5 +1,5 @@
2005-07-14 André Pönitz <poenitz@gmx.net>
2005-07-15 André Pönitz <poenitz@gmx.net>
* insetcollapsable.[Ch]:
* updatableinset.[Ch]: (scroll, setScroll)

View File

@ -1203,6 +1203,7 @@ int InsetTabular::getCellXPos(idx_type const cell) const
void InsetTabular::resetPos(LCursor & cur) const
{
//lyxerr << "InsetTabular::resetPos" << endl;
BufferView & bv = cur.bv();
int const maxwidth = bv.workWidth();
// col_type const actcol = tabular.column_of_cell(cur.idx());
@ -1218,12 +1219,12 @@ void InsetTabular::resetPos(LCursor & cur) const
// scx = 0;
// } else if (cursorx_ - offset > 20 &&
// cursorx_ - offset + col_width > maxwidth - 20) {
// setScroll(maxwidth, - col_width - 20);
// setScroll(maxwidth, - col_width - 20 - scx);
// } else if (cursorx_ - offset < 20) {
// setScroll(maxwidth, 20 - cursorx_ + offset);
// setScroll(maxwidth, 20 - cursorx_ + offset - scx);
// } else if (scroll() && xo() > 20 &&
// xo() + tabular.getWidthOfTabular() > maxwidth - 20) {
// setScroll(maxwidth, old_x - cursorx_);
// setScroll(maxwidth, old_x - cursorx_ - scx);
// }
if (&cur.inset() != this) {
@ -1232,13 +1233,15 @@ void InsetTabular::resetPos(LCursor & cur) const
int const X1 = 0;
int const X2 = maxwidth;
int const offset = ADD_TO_TABULAR_WIDTH + 2;
int const x1 = xo() + scroll() + getCellXPos(cur.idx()) + offset;
int const x1 = xo() + getCellXPos(cur.idx()) + offset;
int const x2 = x1 + tabular.getWidthOfColumn(cur.idx());
if (x1 < X1)
setScroll(maxwidth, X1 + 20 - x1);
scx = X1 + 20 - x1;
else if (x2 > X2)
setScroll(maxwidth, X2 - 20 - x2);
scx = X2 - 20 - x2;
else
scx = 0;
}
cur.needsUpdate();

View File

@ -41,32 +41,9 @@ int UpdatableInset::scroll(bool) const
}
void UpdatableInset::setScroll(int maxwidth, int offset) const
void UpdatableInset::setScroll(int maxwidth, int pos) const
{
lyxerr << "UpdatableInset::setScroll: (int) " << maxwidth << ' ' <<
offset<< std::endl;
int const xo_ = theCoords.getInsets().x(this);
if (offset > 0) {
if (!scx && xo_ >= 20)
return;
if (xo_ + offset > 20)
scx = 0;
// scx = - xo_;
else
scx += offset;
} else {
#ifdef WITH_WARNINGS
#warning metrics?
#endif
if (!scx && xo_ + width() < maxwidth - 20)
return;
if (xo_ - scx + offset + width() < maxwidth - 20)
scx += maxwidth - width() - xo_ - 20;
else
scx += offset;
}
scx = pos;
}