diff options
author | richard <none@none> | 2009-10-26 14:25:45 -0700 |
---|---|---|
committer | richard <none@none> | 2009-10-26 14:25:45 -0700 |
commit | 977dd845346cae05eab2249945f083df47552c8f (patch) | |
tree | 2702cd5ea55ddb8a5492a88869ffdecadec5655e /indra/llui/lltextbase.cpp | |
parent | f31b0baff45fa32fb26ec96eb1a34f7debd7ef3e (diff) |
tweaked clipping rect for scroll containers to not overlap vertical scrollbar
fixed reflow logic when resizing text editors that contain widgets (would make text appear and disappear)
reviewed by James
Diffstat (limited to 'indra/llui/lltextbase.cpp')
-rw-r--r-- | indra/llui/lltextbase.cpp | 113 |
1 files changed, 57 insertions, 56 deletions
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 9b976466eb..0add3fb500 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -232,7 +232,7 @@ LLTextBase::LLTextBase(const LLTextBase::Params &p) createDefaultSegment(); - updateTextRect(); + updateRects(); } LLTextBase::~LLTextBase() @@ -940,7 +940,7 @@ void LLTextBase::reshape(S32 width, S32 height, BOOL called_from_parent) // do this first after reshape, because other things depend on // up-to-date mTextRect - updateTextRect(); + updateRects(); needsReflow(); } @@ -1160,60 +1160,8 @@ void LLTextBase::reflow(S32 start_index) } } - if (mLineInfoList.empty()) - { - mContentsRect = LLRect(0, mVPad, mHPad, 0); - } - else - { - - mContentsRect = mLineInfoList.begin()->mRect; - for (line_list_t::const_iterator line_iter = ++mLineInfoList.begin(); - line_iter != mLineInfoList.end(); - ++line_iter) - { - mContentsRect.unionWith(line_iter->mRect); - } - - mContentsRect.mRight += mHPad; - mContentsRect.mTop += mVPad; - // get around rounding errors when clipping text against rectangle - mContentsRect.stretch(1); - } - - // change mDocumentView size to accomodate reflowed text - LLRect document_rect; - if (mScroller) - { - // document is size of scroller or size of text contents, whichever is larger - document_rect.setOriginAndSize(0, 0, - mScroller->getContentWindowRect().getWidth(), - llmax(mScroller->getContentWindowRect().getHeight(), mContentsRect.getHeight())); - } - else - { - // document size is just extents of reflowed text, reset to origin 0,0 - document_rect.set(0, - getLocalRect().getHeight(), - getLocalRect().getWidth(), - llmin(0, getLocalRect().getHeight() - mContentsRect.getHeight())); - } - mDocumentView->setShape(document_rect); - - // after making document big enough to hold all the text, move the text to fit in the document - if (!mLineInfoList.empty()) - { - S32 delta_pos = mDocumentView->getRect().getHeight() - mLineInfoList.begin()->mRect.mTop - mVPad; - // move line segments to fit new document rect - for (line_list_t::iterator it = mLineInfoList.begin(); it != mLineInfoList.end(); ++it) - { - it->mRect.translate(0, delta_pos); - } - mContentsRect.translate(0, delta_pos); - } - // calculate visible region for diplaying text - updateTextRect(); + updateRects(); for (segment_set_t::iterator segment_it = mSegments.begin(); segment_it != mSegments.end(); @@ -2081,8 +2029,30 @@ S32 LLTextBase::getEditableIndex(S32 index, bool increasing_direction) } } -void LLTextBase::updateTextRect() +void LLTextBase::updateRects() { + if (mLineInfoList.empty()) + { + mContentsRect = LLRect(0, mVPad, mHPad, 0); + } + else + { + + mContentsRect = mLineInfoList.begin()->mRect; + for (line_list_t::const_iterator line_iter = ++mLineInfoList.begin(); + line_iter != mLineInfoList.end(); + ++line_iter) + { + mContentsRect.unionWith(line_iter->mRect); + } + + mContentsRect.mRight += mHPad; + mContentsRect.mTop += mVPad; + // get around rounding errors when clipping text against rectangle + mContentsRect.stretch(1); + } + + LLRect old_text_rect = mTextRect; mTextRect = mScroller ? mScroller->getContentWindowRect() : getLocalRect(); //FIXME: replace border with image? @@ -2096,6 +2066,37 @@ void LLTextBase::updateTextRect() { needsReflow(); } + + // change document rect size too + LLRect document_rect; + if (mScroller) + { + // document is size of scroller or size of text contents, whichever is larger + document_rect.setOriginAndSize(0, 0, + mScroller->getContentWindowRect().getWidth(), + llmax(mScroller->getContentWindowRect().getHeight(), mContentsRect.getHeight())); + } + else + { + // document size is just extents of reflowed text, reset to origin 0,0 + document_rect.set(0, + getLocalRect().getHeight(), + getLocalRect().getWidth(), + llmin(0, getLocalRect().getHeight() - mContentsRect.getHeight())); + } + mDocumentView->setShape(document_rect); + + // after making document big enough to hold all the text, move the text to fit in the document + if (!mLineInfoList.empty()) + { + S32 delta_pos = mDocumentView->getRect().getHeight() - mLineInfoList.begin()->mRect.mTop - mVPad; + // move line segments to fit new document rect + for (line_list_t::iterator it = mLineInfoList.begin(); it != mLineInfoList.end(); ++it) + { + it->mRect.translate(0, delta_pos); + } + mContentsRect.translate(0, delta_pos); + } } |