Tracker: Scroll text to beginning on edit name

... so that the full file name is shown.

Center the file name in the edit box a bit better, the edit box is still
off compared to the non-editable file name by a pixel sometimes.

Use be_plain_font instead of getting the font from the PoseView since
the PoseView font is set to be_plain_font.

Fixes #16476

Change-Id: Ibda9341593163cdde898a83c98bf5ccea37126be
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3399
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
John Scipione 2020-11-18 19:18:55 -05:00 committed by Adrien Destugues
parent b943b993c7
commit 30ecf636e0

View File

@ -373,12 +373,12 @@ BTextWidget::StartEdit(BRect bounds, BPoseView* view, BPose* pose)
BRect textRect(bounds);
// label offset
rect.OffsetBy(1, -2);
float hOffset = 0;
float vOffset = view->ViewMode() == kListMode ? -1 : -2;
rect.OffsetBy(hOffset, vOffset);
BFont font;
view->GetFont(&font);
BTextView* textView = new BTextView(rect, "WidgetTextView", textRect,
&font, 0, B_FOLLOW_ALL, B_WILL_DRAW);
be_plain_font, 0, B_FOLLOW_ALL, B_WILL_DRAW);
textView->SetWordWrap(false);
textView->SetInsets(2, 2, 2, 2);
@ -394,7 +394,7 @@ BTextWidget::StartEdit(BRect bounds, BPoseView* view, BPose* pose)
rect.InsetBy(-2, -2);
// undo label offset
textRect = rect.OffsetToCopy(-1, 2);
textRect = rect.OffsetToCopy(-hOffset, -vOffset);
textView->SetTextRect(textRect);
@ -436,6 +436,10 @@ BTextWidget::StartEdit(BRect bounds, BPoseView* view, BPose* pose)
// for widget
textView->SelectAll();
textView->ScrollToSelection();
// scroll to beginning so that text is visible
textView->ScrollBy(-1, -2);
// scroll in rect to center text
textView->MakeFocus();
// make this text widget invisible while we edit it