From 26be9e7289ef05818daed7c74d4099d3fcc3bf5e Mon Sep 17 00:00:00 2001
From: hy che <cvghy116@gmail.com>
Date: Fri, 24 Nov 2017 19:19:08 +0100
Subject: [PATCH 1/2] TextView: Reimplement the behavior of ScrollToOffset
function..
According to the document: "Scroll the text so that the character at offset is visible", this is
not true in case of deleting characters when texts grow more than the bounding view with text
alignment B_ALIGN_RIGHT or B_ALIGN_CENTER set.
The new implementation changes the position of text (at offset) when it grows more than the bounding
view, so it is either at the start or last of the view.
---
src/kits/interface/TextView.cpp | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/src/kits/interface/TextView.cpp b/src/kits/interface/TextView.cpp
index 765bc5f..bc4b970 100644
a
|
b
|
BTextView::ScrollToOffset(int32 offset)
|
2066 | 2066 | BPoint point = PointAt(offset, &lineHeight); |
2067 | 2067 | |
2068 | 2068 | // horizontal |
2069 | | float extraSpace = fAlignment == B_ALIGN_LEFT ? |
2070 | | ceilf(bounds.IntegerWidth() / 2) : 0.0; |
2071 | | |
2072 | 2069 | if (point.x < bounds.left) |
2073 | | xDiff = point.x - bounds.left - extraSpace; |
| 2070 | xDiff = point.x - bounds.right; |
2074 | 2071 | else if (point.x > bounds.right) |
2075 | | xDiff = point.x - bounds.right + extraSpace; |
| 2072 | xDiff = point.x - bounds.left; |
2076 | 2073 | |
2077 | 2074 | // vertical |
2078 | 2075 | if (point.y < bounds.top) |