IK: align BTextView text rect/fix alignment
Preserve passed in text rect in fTextRext (unless in layout) and create an internal version fAlignedTextRect which is used in place of fTextRect. fAlignedTextRext is aligned to fit the text rect bounds and grows to fit. fAlignedTextRect always grows vertically but only grows horizontally if wrap is off. Left-aligned text view's grow right, right-aligned ones grow left, and center center aligned ones grow out. Set fTextRect to bounds in _DoLayout(). Reduce left and right padding inside text views from full label spacing to half label spacing. Unify padding between BTextControl and BTextView. Fixing padding also fixes right and center-aligned BTextViews. Undo extra scrolling for non-left text views from hrev24130 fixing a scrolling left and right with mouse bug when it shouldn't. Replace max_c and min_c with std::max and std::min respectively. Remove scrolling from one instance of BTextView::SetText as it produced undesired results while editing a scrolled text view. Set text rect in BTextControl::DoLayout() and ScreenSaver PreviewView::AddPreview(). Don't add padding if BTextView::SetInsets() is called. Set insets to 0 in Tracker "Edit name" setting which prevents default padding from being added. This is so that when you rename a file in Tracker the TextView appears on top of the file name text with no padding. 80 char limit fixes. Fixes #1651 #12608 #13796 #15189 #15688 Change-Id: I8c6106effc612f49aff374f29742471628b5df86 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3054 Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
committed by
Adrien Destugues
parent
a8ea8cd1d4
commit
a9b301871d
@@ -1,11 +1,12 @@
|
||||
/*
|
||||
* Copyright 2001-2015, Haiku Inc.
|
||||
* Copyright 2001-2020 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Frans van Nispen ([email protected])
|
||||
* Stephan Aßmus <[email protected]>
|
||||
* Ingo Weinhold <[email protected]>
|
||||
* John Scipione <[email protected]>
|
||||
*/
|
||||
|
||||
|
||||
@@ -637,7 +638,6 @@ void
|
||||
BTextControl::SetAlignment(alignment labelAlignment, alignment textAlignment)
|
||||
{
|
||||
fText->SetAlignment(textAlignment);
|
||||
fText->AlignTextRect();
|
||||
|
||||
if (fLabelAlign != labelAlignment) {
|
||||
fLabelAlign = labelAlignment;
|
||||
@@ -911,6 +911,7 @@ BTextControl::DoLayout()
|
||||
// place the text view and set the divider
|
||||
textFrame.InsetBy(kFrameMargin, kFrameMargin);
|
||||
BLayoutUtils::AlignInFrame(fText, textFrame);
|
||||
fText->SetTextRect(textFrame.OffsetToCopy(B_ORIGIN));
|
||||
|
||||
fDivider = divider;
|
||||
|
||||
@@ -1115,7 +1116,6 @@ BTextControl::_InitText(const char* initialText, const BMessage* archive)
|
||||
|
||||
SetText(initialText);
|
||||
fText->SetAlignment(B_ALIGN_LEFT);
|
||||
fText->AlignTextRect();
|
||||
}
|
||||
|
||||
// Although this is not strictly initializing the text view,
|
||||
@@ -1171,7 +1171,6 @@ BTextControl::_LayoutTextView()
|
||||
frame.InsetBy(kFrameMargin, kFrameMargin);
|
||||
fText->MoveTo(frame.left, frame.top);
|
||||
fText->ResizeTo(frame.Width(), frame.Height());
|
||||
fText->AlignTextRect();
|
||||
|
||||
TRACE("width: %.2f, height: %.2f\n", Frame().Width(), Frame().Height());
|
||||
TRACE("fDivider: %.2f\n", fDivider);
|
||||
|
||||
Reference in New Issue
Block a user