From cdb223228479e97d9cfe7d80d0afef0d99179d24 Mon Sep 17 00:00:00 2001 From: richard Date: Wed, 25 Nov 2009 18:24:39 -0800 Subject: created container for LLFloaterView for future z-swapping with sidetray floaters can now overlap sidetray fixed text selection background color to be inverse of text fg color EXT-2713 Script editor automatically scrolls to the top of script text when text is longer than the window. reviewed by James --- indra/llui/llfloater.cpp | 5 ++--- indra/llui/llscrollcontainer.cpp | 5 +++-- indra/llui/llscrollcontainer.h | 2 +- indra/llui/lltextbase.cpp | 34 +++++++++++++++++----------------- indra/llui/lltooltip.cpp | 5 ++--- 5 files changed, 25 insertions(+), 26 deletions(-) (limited to 'indra/llui') diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 8cf65fe76a..36a9e0a650 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -2347,8 +2347,7 @@ void LLFloaterView::adjustToFitScreen(LLFloater* floater, BOOL allow_partial_out } LLRect::tCoordType screen_width = getSnapRect().getWidth(); LLRect::tCoordType screen_height = getSnapRect().getHeight(); - // convert to local coordinate frame - LLRect snap_rect_local = getLocalSnapRect(); + // only automatically resize non-minimized, resizable floaters if( floater->isResizable() && !floater->isMinimized() ) @@ -2388,7 +2387,7 @@ void LLFloaterView::adjustToFitScreen(LLFloater* floater, BOOL allow_partial_out } // move window fully onscreen - if (floater->translateIntoRect( snap_rect_local, allow_partial_outside )) + if (floater->translateIntoRect( getLocalRect(), allow_partial_outside )) { floater->clearSnapTarget(); } diff --git a/indra/llui/llscrollcontainer.cpp b/indra/llui/llscrollcontainer.cpp index 5e17372fe9..53c5a8d07d 100644 --- a/indra/llui/llscrollcontainer.cpp +++ b/indra/llui/llscrollcontainer.cpp @@ -584,8 +584,9 @@ LLRect LLScrollContainer::getVisibleContentRect() return visible_rect; } -LLRect LLScrollContainer::getContentWindowRect() const +LLRect LLScrollContainer::getContentWindowRect() { + updateScroll(); LLRect scroller_view_rect; S32 visible_width = 0; S32 visible_height = 0; @@ -625,7 +626,7 @@ void LLScrollContainer::scrollToShowRect(const LLRect& rect, const LLRect& const rect_to_constrain.mTop - constraint.mTop); // translate from allowable region for lower left corner to upper left corner - allowable_scroll_rect.translate(0, content_window_rect.getHeight()); + allowable_scroll_rect.translate(0, content_window_rect.getHeight() - 1); S32 vert_pos = llclamp(mScrollbar[VERTICAL]->getDocPos(), mScrollbar[VERTICAL]->getDocSize() - allowable_scroll_rect.mTop, // min vertical scroll diff --git a/indra/llui/llscrollcontainer.h b/indra/llui/llscrollcontainer.h index ac8ffe5258..25dcd071ab 100644 --- a/indra/llui/llscrollcontainer.h +++ b/indra/llui/llscrollcontainer.h @@ -96,7 +96,7 @@ public: void setReserveScrollCorner( BOOL b ) { mReserveScrollCorner = b; } LLRect getVisibleContentRect(); - LLRect getContentWindowRect() const; + LLRect getContentWindowRect(); const LLRect& getScrolledViewRect() const { return mScrolledView ? mScrolledView->getRect() : LLRect::null; } void pageUp(S32 overlap = 0); void pageDown(S32 overlap = 0); diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 7bf10d774c..6f9f98187c 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -379,10 +379,10 @@ void LLTextBase::drawSelectionBackground() // Draw the selection box (we're using a box instead of reversing the colors on the selected text). gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - const LLColor4& color = mReadOnly ? mReadOnlyBgColor.get() : mWriteableBgColor.get(); + const LLColor4& color = mReadOnly ? mReadOnlyFgColor.get() : mFgColor.get(); F32 alpha = hasFocus() ? 0.7f : 0.3f; alpha *= getDrawContext().mAlpha; - gGL.color4f( 1.f - color.mV[0], 1.f - color.mV[1], 1.f - color.mV[2], alpha ); + LLColor4 selection_color(color.mV[VRED], color.mV[VGREEN], color.mV[VBLUE], alpha); for (std::vector::iterator rect_it = selection_rects.begin(); rect_it != selection_rects.end(); @@ -390,7 +390,7 @@ void LLTextBase::drawSelectionBackground() { LLRect selection_rect = *rect_it; selection_rect.translate(mTextRect.mLeft - content_display_rect.mLeft, mTextRect.mBottom - content_display_rect.mBottom); - gl_rect_2d(selection_rect); + gl_rect_2d(selection_rect, selection_color); } } } @@ -1080,6 +1080,8 @@ void LLTextBase::reflow(S32 start_index) mScrollIndex = mLineInfoList[first_line].mDocIndexStart; } LLRect first_char_rect = getLocalRectFromDocIndex(mScrollIndex); + // subtract off effect of horizontal scrollbar from local position of first char + first_char_rect.translate(-mTextRect.mLeft, -mTextRect.mBottom); S32 cur_top = 0; @@ -1195,7 +1197,6 @@ void LLTextBase::reflow(S32 start_index) // apply scroll constraints after reflowing text if (!hasMouseCapture() && mScroller) { - LLRect visible_content_rect = getVisibleDocumentRect(); if (scrolled_to_bottom && mTrackEnd) { // keep bottom of text buffer visible @@ -1204,18 +1205,16 @@ void LLTextBase::reflow(S32 start_index) else if (hasSelection() && follow_selection) { // keep cursor in same vertical position on screen when selecting text - LLRect new_cursor_rect_doc = getLocalRectFromDocIndex(mCursorPos); - new_cursor_rect_doc.translate(visible_content_rect.mLeft, visible_content_rect.mBottom); - mScroller->scrollToShowRect(new_cursor_rect_doc, old_cursor_rect); - //llassert_always(getLocalRectFromDocIndex(mCursorPos).mBottom == old_cursor_rect.mBottom); + LLRect new_cursor_rect_doc = getDocRectFromDocIndex(mCursorPos); + LLRect old_cursor_rect_scroller = old_cursor_rect; + old_cursor_rect.translate(-mTextRect.mLeft, -mTextRect.mBottom); + mScroller->scrollToShowRect(new_cursor_rect_doc, old_cursor_rect_scroller); } else { // keep first line of text visible - LLRect new_first_char_rect = getLocalRectFromDocIndex(mScrollIndex); - new_first_char_rect.translate(visible_content_rect.mLeft, visible_content_rect.mBottom); + LLRect new_first_char_rect = getDocRectFromDocIndex(mScrollIndex); mScroller->scrollToShowRect(new_first_char_rect, first_char_rect); - //llassert_always(getLocalRectFromDocIndex(mScrollIndex).mBottom == first_char_rect.mBottom); } } @@ -1464,14 +1463,16 @@ void LLTextBase::setText(const LLStringExplicit &utf8str ,const LLStyle::Params& clearSegments(); // createDefaultSegment(); - startOfDoc(); deselect(); // append the new text (supports Url linking) std::string text(utf8str); LLStringUtil::removeCRLF(text); + // appendText modifies mCursorPos... appendText(text, false, input_params); + // ...so move cursor to top after appending text + startOfDoc(); onValueChange(0, getLength()); } @@ -2065,16 +2066,15 @@ void LLTextBase::updateRects() mContentsRect.unionWith(line_iter->mRect); } - S32 delta_pos_x = -mContentsRect.mLeft; mContentsRect.mTop += mVPad; S32 delta_pos = -mContentsRect.mBottom; // move line segments to fit new document rect for (line_list_t::iterator it = mLineInfoList.begin(); it != mLineInfoList.end(); ++it) { - it->mRect.translate(delta_pos_x, delta_pos); + it->mRect.translate(0, delta_pos); } - mContentsRect.translate(delta_pos_x, delta_pos); + mContentsRect.translate(0, delta_pos); } // update document container dimensions according to text contents @@ -2281,7 +2281,7 @@ F32 LLNormalTextSegment::drawClippedSegment(S32 seg_start, S32 seg_end, S32 sele LLFontGL::LEFT, LLFontGL::TOP, 0, LLFontGL::NO_SHADOW, - length, rect.mRight, + length, rect.getWidth(), &right_x, mEditor.getUseEllipses()); } @@ -2298,7 +2298,7 @@ F32 LLNormalTextSegment::drawClippedSegment(S32 seg_start, S32 seg_end, S32 sele LLFontGL::LEFT, LLFontGL::TOP, 0, mStyle->getShadowType(), - length, rect.mRight, + length, rect.getWidth(), &right_x, mEditor.getUseEllipses()); } diff --git a/indra/llui/lltooltip.cpp b/indra/llui/lltooltip.cpp index 959313a5b6..cf135997b2 100644 --- a/indra/llui/lltooltip.cpp +++ b/indra/llui/lltooltip.cpp @@ -300,9 +300,8 @@ void LLToolTip::initFromParams(const LLToolTip::Params& p) mTextBox->setText(p.message()); } - LLRect text_contents_rect = mTextBox->getContentsRect(); - S32 text_width = llmin(p.max_width(), text_contents_rect.getWidth()); - S32 text_height = text_contents_rect.getHeight(); + S32 text_width = llmin(p.max_width(), mTextBox->getTextPixelWidth()); + S32 text_height = mTextBox->getTextPixelHeight(); mTextBox->reshape(text_width, text_height); // reshape tooltip panel to fit text box -- cgit v1.2.3