BTextView::_ScrollToOffset() just didn't work correctly most of the
times, since xdiff and ydiff didn't take the point returned by PointAt() into account. Thanks to Andrea Anzani for noticing this. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22977 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1909,6 +1909,7 @@ BTextView::ScrollToOffset(int32 inOffset)
|
|||||||
_ScrollToOffset(inOffset, ScrollBar(B_HORIZONTAL) != NULL, ScrollBar(B_VERTICAL) != NULL);
|
_ScrollToOffset(inOffset, ScrollBar(B_HORIZONTAL) != NULL, ScrollBar(B_VERTICAL) != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BTextView::_ScrollToOffset(int32 inOffset, bool useHorz, bool useVert)
|
BTextView::_ScrollToOffset(int32 inOffset, bool useHorz, bool useVert)
|
||||||
{
|
{
|
||||||
@@ -1917,25 +1918,19 @@ BTextView::_ScrollToOffset(int32 inOffset, bool useHorz, bool useVert)
|
|||||||
float xdiff = 0.0;
|
float xdiff = 0.0;
|
||||||
float ydiff = 0.0;
|
float ydiff = 0.0;
|
||||||
BPoint point = PointAt(inOffset, &lineHeight);
|
BPoint point = PointAt(inOffset, &lineHeight);
|
||||||
|
|
||||||
if (useHorz) {
|
if (useHorz) {
|
||||||
if (point.x < bounds.left) {
|
if (point.x < bounds.left)
|
||||||
xdiff = -1 * (bounds.IntegerWidth() / 2);
|
xdiff = point.x - bounds.left - bounds.IntegerWidth() / 2;
|
||||||
// normalize scroll value to prevent scrolling past left boundary of view
|
else if (point.x >= bounds.right)
|
||||||
if (bounds.left < fabs(xdiff))
|
xdiff = point.x - bounds.right + bounds.IntegerWidth() / 2;
|
||||||
xdiff = -1 * bounds.left;
|
|
||||||
} else if (point.x >= bounds.right)
|
|
||||||
xdiff = bounds.IntegerWidth() / 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useVert) {
|
if (useVert) {
|
||||||
if (point.y < bounds.top) {
|
if (point.y < bounds.top)
|
||||||
ydiff = -1 * (bounds.IntegerHeight() / 2);
|
ydiff = point.y - bounds.top - bounds.IntegerHeight() / 2;
|
||||||
// normalize scroll value to prevent scrolling past top of view
|
else if (point.y >= bounds.bottom)
|
||||||
if (bounds.top < fabs(ydiff))
|
ydiff = point.y - bounds.bottom + bounds.IntegerHeight() / 2;
|
||||||
ydiff = -1 * bounds.top;
|
|
||||||
} else if (point.y >= bounds.bottom)
|
|
||||||
ydiff = bounds.IntegerHeight() / 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollBy(xdiff, ydiff);
|
ScrollBy(xdiff, ydiff);
|
||||||
|
|||||||
Reference in New Issue
Block a user