diff options
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/lliconctrl.cpp | 7 | ||||
-rw-r--r-- | indra/llui/lliconctrl.h | 5 | ||||
-rw-r--r-- | indra/llui/llscrollcontainer.cpp | 2 | ||||
-rw-r--r-- | indra/llui/lltextbase.cpp | 157 | ||||
-rw-r--r-- | indra/llui/lltextbase.h | 2 | ||||
-rw-r--r-- | indra/llui/lltexteditor.cpp | 2 | ||||
-rw-r--r-- | indra/llui/llui.cpp | 8 | ||||
-rw-r--r-- | indra/llui/llui.h | 8 |
8 files changed, 99 insertions, 92 deletions
diff --git a/indra/llui/lliconctrl.cpp b/indra/llui/lliconctrl.cpp index 0330a2b374..66c2ba682f 100644 --- a/indra/llui/lliconctrl.cpp +++ b/indra/llui/lliconctrl.cpp @@ -56,7 +56,8 @@ LLIconCtrl::Params::Params() LLIconCtrl::LLIconCtrl(const LLIconCtrl::Params& p) : LLUICtrl(p), mColor(p.color()), - mImagep(p.image) + mImagep(p.image), + mPriority(0) { if (mImagep.notNull()) { @@ -93,11 +94,11 @@ void LLIconCtrl::setValue(const LLSD& value ) LLUICtrl::setValue(tvalue); if (tvalue.isUUID()) { - mImagep = LLUI::getUIImageByID(tvalue.asUUID()); + mImagep = LLUI::getUIImageByID(tvalue.asUUID(), mPriority); } else { - mImagep = LLUI::getUIImage(tvalue.asString()); + mImagep = LLUI::getUIImage(tvalue.asString(), mPriority); } } diff --git a/indra/llui/lliconctrl.h b/indra/llui/lliconctrl.h index ff25b0d53e..90f1693060 100644 --- a/indra/llui/lliconctrl.h +++ b/indra/llui/lliconctrl.h @@ -72,10 +72,13 @@ public: std::string getImageName() const; void setColor(const LLColor4& color) { mColor = color; } + +protected: + S32 mPriority; private: LLUIColor mColor; - LLPointer<LLUIImage> mImagep; + LLPointer<LLUIImage> mImagep; }; #endif diff --git a/indra/llui/llscrollcontainer.cpp b/indra/llui/llscrollcontainer.cpp index d8606c6889..5e17372fe9 100644 --- a/indra/llui/llscrollcontainer.cpp +++ b/indra/llui/llscrollcontainer.cpp @@ -432,7 +432,7 @@ void LLScrollContainer::draw() LLLocalClipRect clip(LLRect(mInnerRect.mLeft, mInnerRect.mBottom + (show_h_scrollbar ? scrollbar_size : 0) + visible_height, - visible_width, + mInnerRect.mRight - (show_v_scrollbar ? scrollbar_size: 0), mInnerRect.mBottom + (show_h_scrollbar ? scrollbar_size : 0) )); drawChild(mScrolledView); diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 22cce755b0..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() @@ -538,10 +538,6 @@ void LLTextBase::drawText() next_start = getLineStart(cur_line + 1); line_end = next_start; } - if ( text[line_end-1] == '\n' ) - { - --line_end; - } LLRect text_rect(line.mRect.mLeft + mTextRect.mLeft - scrolled_view_rect.mLeft, line.mRect.mTop - scrolled_view_rect.mBottom + mTextRect.mBottom, @@ -944,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(); } @@ -957,10 +953,20 @@ void LLTextBase::draw() // then update scroll position, as cursor may have moved updateScrollFromCursor(); + LLRect doc_rect; + if (mScroller) + { + mScroller->localRectToOtherView(mScroller->getContentWindowRect(), &doc_rect, this); + } + else + { + doc_rect = getLocalRect(); + } + if (mBGVisible) { // clip background rect against extents, if we support scrolling - LLLocalClipRect clip(getLocalRect(), mScroller != NULL); + LLLocalClipRect clip(doc_rect, mScroller != NULL); LLColor4 bg_color = mReadOnly ? mReadOnlyBgColor.get() @@ -975,7 +981,7 @@ void LLTextBase::draw() { // only clip if we support scrolling (mScroller != NULL) - LLLocalClipRect clip(mTextRect, mScroller != NULL); + LLLocalClipRect clip(doc_rect, mScroller != NULL); drawSelectionBackground(); drawText(); drawCursor(); @@ -1154,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(); @@ -2075,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? @@ -2090,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); + } } @@ -2218,6 +2225,11 @@ F32 LLNormalTextSegment::drawClippedSegment(S32 seg_start, S32 seg_end, S32 sele const LLWString &text = mEditor.getWText(); + if ( text[seg_end-1] == '\n' ) + { + --seg_end; + } + F32 right_x = rect.mLeft; if (!mStyle->isVisible()) { @@ -2362,16 +2374,7 @@ void LLNormalTextSegment::getDimensions(S32 first_char, S32 num_chars, S32& widt { LLWString text = mEditor.getWText(); - // look for any printable character, then return the font height - height = 0; - for (S32 index = mStart + first_char; index < mStart + first_char + num_chars; ++index) - { - if (text[index] != '\n') - { - height = mFontHeight; - break; - } - } + height = mFontHeight; width = mStyle->getFont()->getWidth(text.c_str(), mStart + first_char, num_chars); } @@ -2393,7 +2396,11 @@ S32 LLNormalTextSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 lin S32 last_char = mStart + segment_offset; for (; last_char != mEnd; ++last_char) { - if (text[last_char] == '\n') break; + if (text[last_char] == '\n') + { + last_char++; + break; + } } // set max characters to length of segment, or to first newline @@ -2416,10 +2423,6 @@ S32 LLNormalTextSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 lin // include terminating NULL num_chars++; } - else if (text[mStart + segment_offset + num_chars] == '\n') - { - num_chars++; - } return num_chars; } diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index f0b8878491..d0787f001e 100644 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -294,7 +294,7 @@ protected: void endSelection(); // misc - void updateTextRect(); + void updateRects(); void needsReflow() { mReflowNeeded = TRUE; } void needsScroll() { mScrollNeeded = TRUE; } void replaceUrlLabel(const std::string &url, const std::string &label); diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index d507cf7ce4..0ca9a18e0c 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -273,7 +273,7 @@ LLTextEditor::LLTextEditor(const LLTextEditor::Params& p) : if (mShowLineNumbers) { mHPad += UI_TEXTEDITOR_LINE_NUMBER_MARGIN; - updateTextRect(); + updateRects(); } } diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index da9384f876..48504a1e54 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -1807,11 +1807,11 @@ void LLUI::glRectToScreen(const LLRect& gl, LLRect *screen) } //static -LLPointer<LLUIImage> LLUI::getUIImageByID(const LLUUID& image_id) +LLPointer<LLUIImage> LLUI::getUIImageByID(const LLUUID& image_id, S32 priority) { if (sImageProvider) { - return sImageProvider->getUIImageByID(image_id); + return sImageProvider->getUIImageByID(image_id, priority); } else { @@ -1820,10 +1820,10 @@ LLPointer<LLUIImage> LLUI::getUIImageByID(const LLUUID& image_id) } //static -LLPointer<LLUIImage> LLUI::getUIImage(const std::string& name) +LLPointer<LLUIImage> LLUI::getUIImage(const std::string& name, S32 priority) { if (!name.empty() && sImageProvider) - return sImageProvider->getUIImage(name); + return sImageProvider->getUIImage(name, priority); else return NULL; } diff --git a/indra/llui/llui.h b/indra/llui/llui.h index 6ab78ab3cd..efb1b0a36f 100644 --- a/indra/llui/llui.h +++ b/indra/llui/llui.h @@ -195,8 +195,8 @@ public: static void getMousePositionLocal(const LLView* viewp, S32 *x, S32 *y); static void setScaleFactor(const LLVector2& scale_factor); static void setLineWidth(F32 width); - static LLPointer<LLUIImage> getUIImageByID(const LLUUID& image_id); - static LLPointer<LLUIImage> getUIImage(const std::string& name); + static LLPointer<LLUIImage> getUIImageByID(const LLUUID& image_id, S32 priority = 0); + static LLPointer<LLUIImage> getUIImage(const std::string& name, S32 priority = 0); static LLVector2 getWindowSize(); static void screenPointToGL(S32 screen_x, S32 screen_y, S32 *gl_x, S32 *gl_y); static void glPointToScreen(S32 gl_x, S32 gl_y, S32 *screen_x, S32 *screen_y); @@ -241,8 +241,8 @@ protected: LLImageProviderInterface() {}; virtual ~LLImageProviderInterface() {}; public: - virtual LLPointer<LLUIImage> getUIImage(const std::string& name) = 0; - virtual LLPointer<LLUIImage> getUIImageByID(const LLUUID& id) = 0; + virtual LLPointer<LLUIImage> getUIImage(const std::string& name, S32 priority) = 0; + virtual LLPointer<LLUIImage> getUIImageByID(const LLUUID& id, S32 priority) = 0; virtual void cleanUp() = 0; }; |