Ticket #13796: 0001-TextView-Reimplement-the-behavior-of-ScrollToOffset.patch

File 0001-TextView-Reimplement-the-behavior-of-ScrollToOffset.patch, 1.4 KB (added by hyche, 7 years ago)
  • src/kits/interface/TextView.cpp

    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)  
    20662066    BPoint point = PointAt(offset, &lineHeight);
    20672067
    20682068    // horizontal
    2069     float extraSpace = fAlignment == B_ALIGN_LEFT ?
    2070         ceilf(bounds.IntegerWidth() / 2) : 0.0;
    2071 
    20722069    if (point.x < bounds.left)
    2073         xDiff = point.x - bounds.left - extraSpace;
     2070        xDiff = point.x - bounds.right;
    20742071    else if (point.x > bounds.right)
    2075         xDiff = point.x - bounds.right + extraSpace;
     2072        xDiff = point.x - bounds.left;
    20762073
    20772074    // vertical
    20782075    if (point.y < bounds.top)