Add _ViewWidth(), _ViewHeight(), _TextWidth(), _TextHeight()
private convenience methods to calculate the text view width and height with insets and the text rect width and height without insets respectively. Also add _ViewRect() and _TextRect() methods for completeness, but they are not currently used. Change-Id: I0582bc93a0a3a6820bbb2262a1d726457309ab9f Reviewed-on: https://review.haiku-os.org/c/haiku/+/7162 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
This commit is contained in:
parent
2af0f027cb
commit
64a2e73375
@ -418,6 +418,14 @@ private:
|
|||||||
|
|
||||||
void _UpdateInsets(const BRect& rect);
|
void _UpdateInsets(const BRect& rect);
|
||||||
|
|
||||||
|
float _ViewWidth();
|
||||||
|
float _ViewHeight();
|
||||||
|
BRect _ViewRect();
|
||||||
|
|
||||||
|
float _TextWidth();
|
||||||
|
float _TextHeight();
|
||||||
|
BRect _TextRect();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BPrivate::TextGapBuffer* fText;
|
BPrivate::TextGapBuffer* fText;
|
||||||
LineBuffer* fLines;
|
LineBuffer* fLines;
|
||||||
|
@ -816,8 +816,7 @@ BTextView::FrameResized(float newWidth, float newHeight)
|
|||||||
// don't recalculate line breaks,
|
// don't recalculate line breaks,
|
||||||
// move text rect into position and redraw.
|
// move text rect into position and redraw.
|
||||||
|
|
||||||
float dataWidth = fLayoutData->leftInset
|
float dataWidth = _TextWidth();
|
||||||
+ fTextRect.Width() + fLayoutData->rightInset;
|
|
||||||
newWidth = std::max(dataWidth, newWidth);
|
newWidth = std::max(dataWidth, newWidth);
|
||||||
|
|
||||||
// align rect
|
// align rect
|
||||||
@ -2810,8 +2809,7 @@ BTextView::_ValidateLayoutData()
|
|||||||
fLayoutData->min = min;
|
fLayoutData->min = min;
|
||||||
|
|
||||||
// compute our preferred size
|
// compute our preferred size
|
||||||
fLayoutData->preferred.height = fTextRect.Height()
|
fLayoutData->preferred.height = _TextHeight();
|
||||||
+ fLayoutData->topInset + fLayoutData->bottomInset;
|
|
||||||
|
|
||||||
if (fWrap)
|
if (fWrap)
|
||||||
fLayoutData->preferred.width = min.width + 5 * lineHeight;
|
fLayoutData->preferred.width = min.width + 5 * lineHeight;
|
||||||
@ -5050,8 +5048,7 @@ BTextView::_UpdateScrollbars()
|
|||||||
// do we have a horizontal scroll bar?
|
// do we have a horizontal scroll bar?
|
||||||
if (horizontalScrollBar != NULL) {
|
if (horizontalScrollBar != NULL) {
|
||||||
long viewWidth = bounds.IntegerWidth();
|
long viewWidth = bounds.IntegerWidth();
|
||||||
long dataWidth = (long)ceilf(fTextRect.IntegerWidth()
|
long dataWidth = (long)ceilf(_TextWidth());
|
||||||
+ fLayoutData->leftInset + fLayoutData->rightInset);
|
|
||||||
|
|
||||||
long maxRange = dataWidth - viewWidth;
|
long maxRange = dataWidth - viewWidth;
|
||||||
maxRange = std::max(maxRange, 0l);
|
maxRange = std::max(maxRange, 0l);
|
||||||
@ -5066,8 +5063,7 @@ BTextView::_UpdateScrollbars()
|
|||||||
// how about a vertical scroll bar?
|
// how about a vertical scroll bar?
|
||||||
if (verticalScrollBar != NULL) {
|
if (verticalScrollBar != NULL) {
|
||||||
long viewHeight = bounds.IntegerHeight();
|
long viewHeight = bounds.IntegerHeight();
|
||||||
long dataHeight = (long)ceilf(fLayoutData->topInset
|
long dataHeight = (long)ceilf(_TextHeight());
|
||||||
+ fTextRect.IntegerHeight() + fLayoutData->bottomInset);
|
|
||||||
|
|
||||||
long maxRange = dataHeight - viewHeight;
|
long maxRange = dataHeight - viewHeight;
|
||||||
maxRange = std::max(maxRange, 0l);
|
maxRange = std::max(maxRange, 0l);
|
||||||
@ -5122,8 +5118,7 @@ BTextView::_AutoResize(bool redraw)
|
|||||||
// NOTE: This container view thing is only used by Tracker.
|
// NOTE: This container view thing is only used by Tracker.
|
||||||
// move container view if not left aligned
|
// move container view if not left aligned
|
||||||
float oldWidth = Bounds().Width();
|
float oldWidth = Bounds().Width();
|
||||||
float newWidth = fLayoutData->leftInset + fTextRect.Width()
|
float newWidth = _TextWidth();
|
||||||
+ fLayoutData->rightInset;
|
|
||||||
float right = oldWidth - newWidth;
|
float right = oldWidth - newWidth;
|
||||||
|
|
||||||
if (fAlignment == B_ALIGN_CENTER)
|
if (fAlignment == B_ALIGN_CENTER)
|
||||||
@ -6041,6 +6036,68 @@ BTextView::_UpdateInsets(const BRect& rect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float
|
||||||
|
BTextView::_ViewWidth()
|
||||||
|
{
|
||||||
|
return Bounds().Width()
|
||||||
|
- fLayoutData->leftInset
|
||||||
|
- fLayoutData->rightInset;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float
|
||||||
|
BTextView::_ViewHeight()
|
||||||
|
{
|
||||||
|
return Bounds().Height()
|
||||||
|
- fLayoutData->topInset
|
||||||
|
- fLayoutData->bottomInset;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRect
|
||||||
|
BTextView::_ViewRect()
|
||||||
|
{
|
||||||
|
BRect rect(Bounds());
|
||||||
|
rect.left += fLayoutData->leftInset;
|
||||||
|
rect.top += fLayoutData->topInset;
|
||||||
|
rect.right -= fLayoutData->rightInset;
|
||||||
|
rect.bottom -= fLayoutData->bottomInset;
|
||||||
|
|
||||||
|
return rect;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float
|
||||||
|
BTextView::_TextWidth()
|
||||||
|
{
|
||||||
|
return fTextRect.Width()
|
||||||
|
+ fLayoutData->leftInset
|
||||||
|
+ fLayoutData->rightInset;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float
|
||||||
|
BTextView::_TextHeight()
|
||||||
|
{
|
||||||
|
return fTextRect.Height()
|
||||||
|
+ fLayoutData->topInset
|
||||||
|
+ fLayoutData->bottomInset;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRect
|
||||||
|
BTextView::_TextRect()
|
||||||
|
{
|
||||||
|
BRect rect(fTextRect);
|
||||||
|
rect.left -= fLayoutData->leftInset;
|
||||||
|
rect.top -= fLayoutData->topInset;
|
||||||
|
rect.right += fLayoutData->rightInset;
|
||||||
|
rect.bottom += fLayoutData->bottomInset;
|
||||||
|
|
||||||
|
return rect;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - BTextView::TextTrackState
|
// #pragma mark - BTextView::TextTrackState
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user