mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-13 01:08:45 +00:00
branch: Fix bug #5944: Scrolling isn't predictable.
The row in editXY is corrected when we're scrolling with PgUp and PgDn to make sure that the row where the cursor is places, is completely in the view. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@30552 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
caf4e97175
commit
12cb76773d
@ -1462,7 +1462,8 @@ bool BufferView::dispatch(FuncRequest const & cmd)
|
||||
cur.reset(buffer_.inset());
|
||||
updateMetrics();
|
||||
buffer_.changed();
|
||||
d->text_metrics_[&buffer_.text()].editXY(cur, p.x_, p.y_);
|
||||
d->text_metrics_[&buffer_.text()].editXY(cur, p.x_, p.y_,
|
||||
true, cmd.action == LFUN_SCREEN_UP);
|
||||
//FIXME: what to do with cur.x_target()?
|
||||
bool update = false;
|
||||
if (in_texted)
|
||||
|
@ -1370,7 +1370,8 @@ pit_type TextMetrics::getPitNearY(int y)
|
||||
}
|
||||
|
||||
|
||||
Row const & TextMetrics::getRowNearY(int y, pit_type pit) const
|
||||
Row const & TextMetrics::getPitAndRowNearY(int y, pit_type & pit,
|
||||
bool assert_in_view, bool up)
|
||||
{
|
||||
ParagraphMetrics const & pm = par_metrics_[pit];
|
||||
|
||||
@ -1382,13 +1383,37 @@ Row const & TextMetrics::getRowNearY(int y, pit_type pit) const
|
||||
for (; rit != rlast; yy += rit->height(), ++rit)
|
||||
if (yy + rit->height() > y)
|
||||
break;
|
||||
|
||||
if (assert_in_view && yy + rit->height() != y) {
|
||||
if (!up) {
|
||||
if (rit != pm.rows().begin())
|
||||
--rit;
|
||||
else if (pit != 0) {
|
||||
--pit;
|
||||
newParMetricsUp();
|
||||
ParagraphMetrics const & pm2 = par_metrics_[pit];
|
||||
rit = pm2.rows().end();
|
||||
--rit;
|
||||
}
|
||||
} else {
|
||||
if (rit != rlast)
|
||||
++rit;
|
||||
else if (pit != int(par_metrics_.size())) {
|
||||
++pit;
|
||||
newParMetricsDown();
|
||||
ParagraphMetrics const & pm2 = par_metrics_[pit];
|
||||
rit = pm2.rows().begin();
|
||||
}
|
||||
}
|
||||
}
|
||||
return *rit;
|
||||
}
|
||||
|
||||
|
||||
// x,y are absolute screen coordinates
|
||||
// sets cursor recursively descending into nested editable insets
|
||||
Inset * TextMetrics::editXY(Cursor & cur, int x, int y)
|
||||
Inset * TextMetrics::editXY(Cursor & cur, int x, int y,
|
||||
bool assert_in_view, bool up)
|
||||
{
|
||||
if (lyxerr.debugging(Debug::WORKAREA)) {
|
||||
LYXERR0("TextMetrics::editXY(cur, " << x << ", " << y << ")");
|
||||
@ -1397,7 +1422,7 @@ Inset * TextMetrics::editXY(Cursor & cur, int x, int y)
|
||||
pit_type pit = getPitNearY(y);
|
||||
LASSERT(pit != -1, return 0);
|
||||
|
||||
Row const & row = getRowNearY(y, pit);
|
||||
Row const & row = getPitAndRowNearY(y, pit, assert_in_view, up);
|
||||
bool bound = false;
|
||||
|
||||
int xx = x; // is modified by getColumnNearX
|
||||
|
@ -176,11 +176,11 @@ public:
|
||||
// FIXME: is there a need for this?
|
||||
//int pos2x(pit_type pit, pos_type pos) const;
|
||||
|
||||
/** returns row near the specified
|
||||
* y-coordinate in given paragraph (relative to the screen).
|
||||
*/
|
||||
Row const & getRowNearY(int y,
|
||||
pit_type pit) const;
|
||||
/// returns the row near the specified y-coordinate in a given paragraph
|
||||
/// (relative to the screen). If assert_in_view is true, it is made sure
|
||||
/// that the row is on screen completely; this might change the given pit.
|
||||
Row const & getPitAndRowNearY(int y, pit_type & pit,
|
||||
bool assert_in_view, bool up);
|
||||
|
||||
/// returns the paragraph number closest to screen y-coordinate.
|
||||
/// This method uses the BufferView CoordCache to locate the
|
||||
@ -193,11 +193,16 @@ public:
|
||||
/**
|
||||
\return the inset pointer if x,y is covering that inset
|
||||
\param x,y are absolute screen coordinates.
|
||||
\param assert_in_view if true the cursor will be set on a row
|
||||
that is completely visible
|
||||
\param up whether we are going up or down (only used when
|
||||
assert_in_view is true
|
||||
\retval inset is non-null if the cursor is positionned inside
|
||||
*/
|
||||
/// FIXME: cleanup to use BufferView::getCoveringInset() and
|
||||
/// setCursorFromCoordinates() instead of checkInsetHit().
|
||||
Inset * editXY(Cursor & cur, int x, int y);
|
||||
Inset * editXY(Cursor & cur, int x, int y,
|
||||
bool assert_in_view = false, bool up = true);
|
||||
|
||||
/// sets cursor only within this Text.
|
||||
/// x,y are screen coordinates
|
||||
|
@ -216,6 +216,11 @@ What's new
|
||||
- Remove empty paragraphs and superfluous spaces when leaving an inset
|
||||
(bug 5435).
|
||||
|
||||
- Fix the scrolling problem that when scrolling with PgUp or PgDn, the
|
||||
cursor could end up on a row that is only partly visible. This causes
|
||||
the cursor to end up somewhere else when scrolling back (bug 5944).
|
||||
|
||||
|
||||
* DOCUMENTATION AND LOCALIZATION
|
||||
|
||||
- Fix icon image files so that they appear correctly when the
|
||||
|
Loading…
Reference in New Issue
Block a user