mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-13 09:15:50 +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());
|
cur.reset(buffer_.inset());
|
||||||
updateMetrics();
|
updateMetrics();
|
||||||
buffer_.changed();
|
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()?
|
//FIXME: what to do with cur.x_target()?
|
||||||
bool update = false;
|
bool update = false;
|
||||||
if (in_texted)
|
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];
|
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)
|
for (; rit != rlast; yy += rit->height(), ++rit)
|
||||||
if (yy + rit->height() > y)
|
if (yy + rit->height() > y)
|
||||||
break;
|
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;
|
return *rit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// x,y are absolute screen coordinates
|
// x,y are absolute screen coordinates
|
||||||
// sets cursor recursively descending into nested editable insets
|
// 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)) {
|
if (lyxerr.debugging(Debug::WORKAREA)) {
|
||||||
LYXERR0("TextMetrics::editXY(cur, " << x << ", " << y << ")");
|
LYXERR0("TextMetrics::editXY(cur, " << x << ", " << y << ")");
|
||||||
@ -1397,7 +1422,7 @@ Inset * TextMetrics::editXY(Cursor & cur, int x, int y)
|
|||||||
pit_type pit = getPitNearY(y);
|
pit_type pit = getPitNearY(y);
|
||||||
LASSERT(pit != -1, return 0);
|
LASSERT(pit != -1, return 0);
|
||||||
|
|
||||||
Row const & row = getRowNearY(y, pit);
|
Row const & row = getPitAndRowNearY(y, pit, assert_in_view, up);
|
||||||
bool bound = false;
|
bool bound = false;
|
||||||
|
|
||||||
int xx = x; // is modified by getColumnNearX
|
int xx = x; // is modified by getColumnNearX
|
||||||
|
@ -176,11 +176,11 @@ public:
|
|||||||
// FIXME: is there a need for this?
|
// FIXME: is there a need for this?
|
||||||
//int pos2x(pit_type pit, pos_type pos) const;
|
//int pos2x(pit_type pit, pos_type pos) const;
|
||||||
|
|
||||||
/** returns row near the specified
|
/// returns the row near the specified y-coordinate in a given paragraph
|
||||||
* y-coordinate in given paragraph (relative to the screen).
|
/// (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 & getRowNearY(int y,
|
Row const & getPitAndRowNearY(int y, pit_type & pit,
|
||||||
pit_type pit) const;
|
bool assert_in_view, bool up);
|
||||||
|
|
||||||
/// returns the paragraph number closest to screen y-coordinate.
|
/// returns the paragraph number closest to screen y-coordinate.
|
||||||
/// This method uses the BufferView CoordCache to locate the
|
/// 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
|
\return the inset pointer if x,y is covering that inset
|
||||||
\param x,y are absolute screen coordinates.
|
\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
|
\retval inset is non-null if the cursor is positionned inside
|
||||||
*/
|
*/
|
||||||
/// FIXME: cleanup to use BufferView::getCoveringInset() and
|
/// FIXME: cleanup to use BufferView::getCoveringInset() and
|
||||||
/// setCursorFromCoordinates() instead of checkInsetHit().
|
/// 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.
|
/// sets cursor only within this Text.
|
||||||
/// x,y are screen coordinates
|
/// x,y are screen coordinates
|
||||||
|
@ -216,6 +216,11 @@ What's new
|
|||||||
- Remove empty paragraphs and superfluous spaces when leaving an inset
|
- Remove empty paragraphs and superfluous spaces when leaving an inset
|
||||||
(bug 5435).
|
(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
|
* DOCUMENTATION AND LOCALIZATION
|
||||||
|
|
||||||
- Fix icon image files so that they appear correctly when the
|
- Fix icon image files so that they appear correctly when the
|
||||||
|
Loading…
Reference in New Issue
Block a user