diff options
author | richard <none@none> | 2009-12-11 13:51:42 -0800 |
---|---|---|
committer | richard <none@none> | 2009-12-11 13:51:42 -0800 |
commit | d5a58c20a8e266d71bf039a77911571480c63780 (patch) | |
tree | 6dbca954bf92ca0ef9d05ce362d65d38a05b1bba /indra | |
parent | c400132f02542379a42ade5e065be5f7c661d508 (diff) | |
parent | 401a51cac130a317204c2df9dd571fca92a861c3 (diff) |
merge
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llrender/llfontfreetype.h | 3 | ||||
-rw-r--r-- | indra/llrender/llfontgl.cpp | 16 | ||||
-rw-r--r-- | indra/llui/lldraghandle.cpp | 1 | ||||
-rw-r--r-- | indra/llui/llfloater.cpp | 1 | ||||
-rw-r--r-- | indra/llui/lltextbase.cpp | 55 | ||||
-rw-r--r-- | indra/newview/llexpandabletextbox.cpp | 23 | ||||
-rw-r--r-- | indra/newview/llviewerwindow.cpp | 74 | ||||
-rw-r--r-- | indra/newview/llviewerwindow.h | 5 |
8 files changed, 94 insertions, 84 deletions
diff --git a/indra/llrender/llfontfreetype.h b/indra/llrender/llfontfreetype.h index 1325b4995b..7a5d029038 100644 --- a/indra/llrender/llfontfreetype.h +++ b/indra/llrender/llfontfreetype.h @@ -58,9 +58,8 @@ private: ~LLFontManager(); }; -class LLFontGlyphInfo +struct LLFontGlyphInfo { -public: LLFontGlyphInfo(U32 index); U32 mGlyphIndex; diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index 19afa997fa..db1f019a81 100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -235,7 +235,8 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, cons if (use_ellipses) { // check for too long of a string - if (getWidthF32(wstr.c_str(), begin_offset, max_chars) * sScaleX > scaled_max_pixels) + S32 string_width = llround(getWidthF32(wstr.c_str(), begin_offset, max_chars) * sScaleX); + if (string_width > scaled_max_pixels) { // use four dots for ellipsis width to generate padding const LLWString dots(utf8str_to_wstring(std::string("...."))); @@ -490,6 +491,7 @@ S32 LLFontGL::maxDrawableChars(const llwchar* wchars, F32 max_pixels, S32 max_ch // avoid S32 overflow when max_pixels == S32_MAX by staying in floating point F32 scaled_max_pixels = ceil(max_pixels * sScaleX); + F32 width_padding = 0.f; S32 i; for (i=0; (i < max_chars); i++) @@ -533,9 +535,17 @@ S32 LLFontGL::maxDrawableChars(const llwchar* wchars, F32 max_pixels, S32 max_ch } } - cur_x += mFontFreetype->getXAdvance(wch); + LLFontGlyphInfo* fgi = mFontFreetype->getGlyphInfo(wch); + + // account for glyphs that run beyond the starting point for the next glyphs + width_padding = llmax( 0.f, // always use positive padding amount + width_padding - fgi->mXAdvance, // previous padding left over after advance of current character + (F32)(fgi->mWidth + fgi->mXBearing) - fgi->mXAdvance); // difference between width of this character and advance to next character + + cur_x += fgi->mXAdvance; - if (scaled_max_pixels < cur_x) + // clip if current character runs past scaled_max_pixels (using width_padding) + if (scaled_max_pixels < cur_x + width_padding) { clip = TRUE; break; diff --git a/indra/llui/lldraghandle.cpp b/indra/llui/lldraghandle.cpp index d9b98b1c28..a93c666648 100644 --- a/indra/llui/lldraghandle.cpp +++ b/indra/llui/lldraghandle.cpp @@ -112,6 +112,7 @@ void LLDragHandleTop::setTitle(const std::string& title) params.font(font); params.follows.flags(FOLLOWS_TOP | FOLLOWS_LEFT | FOLLOWS_RIGHT); params.font_shadow(LLFontGL::DROP_SHADOW_SOFT); + params.use_ellipses = true; mTitleBox = LLUICtrlFactory::create<LLTextBox> (params); addChild( mTitleBox ); } diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index e822b4843c..5fd707fea3 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -1649,6 +1649,7 @@ void LLFloater::draw() } else { + //FIXME: get rid of this hack // draw children LLView* focused_child = dynamic_cast<LLView*>(gFocusMgr.getKeyboardFocus()); BOOL focused_child_visible = FALSE; diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index e0503a0844..d50abaa83a 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -561,14 +561,14 @@ void LLTextBase::drawText() S32 clipped_end = llmin( line_end, cur_segment->getEnd() ) - cur_segment->getStart(); - if (mUseEllipses - && clipped_end == line_end - && next_line == last_line - && last_line < (S32)mLineInfoList.size()) + if (mUseEllipses // using ellipses + && clipped_end == line_end // last segment on line + && next_line == last_line // this is the last visible line + && last_line < (S32)mLineInfoList.size()) // and there is more text to display { - // more text to go, but we can't fit it - // so attempt to draw one extra character to force ellipses - clipped_end++; + // more lines of text to go, but we can't fit them + // so shrink text rect to force ellipses + text_rect.mRight -= 2; } text_rect.mLeft = (S32)(cur_segment->draw(seg_start - cur_segment->getStart(), clipped_end, selection_left, selection_right, text_rect)); @@ -1071,7 +1071,7 @@ void LLTextBase::reflow(S32 start_index) while(mReflowNeeded) { - mReflowNeeded = FALSE; + mReflowNeeded = false; // shrink document to minimum size (visible portion of text widget) // to force inlined widgets with follows set to shrink @@ -1101,8 +1101,8 @@ void LLTextBase::reflow(S32 start_index) segment_set_t::iterator seg_iter = mSegments.begin(); S32 seg_offset = 0; S32 line_start_index = 0; - const S32 text_width = mTextRect.getWidth() - mHPad; // reserve room for margin - S32 remaining_pixels = text_width; + const S32 text_available_width = mTextRect.getWidth() - mHPad; // reserve room for margin + S32 remaining_pixels = text_available_width; LLWString text(getWText()); S32 line_count = 0; @@ -1142,10 +1142,11 @@ void LLTextBase::reflow(S32 start_index) S32 last_segment_char_on_line = segment->getStart() + seg_offset; - S32 text_left = getLeftOffset(text_width - remaining_pixels); + S32 text_actual_width = text_available_width - remaining_pixels; + S32 text_left = getLeftOffset(text_actual_width); LLRect line_rect(text_left, cur_top, - text_left + (text_width - remaining_pixels), + text_left + text_actual_width, cur_top - line_height); // if we didn't finish the current segment... @@ -1160,7 +1161,7 @@ void LLTextBase::reflow(S32 start_index) line_start_index = segment->getStart() + seg_offset; cur_top -= llround((F32)line_height * mLineSpacingMult) + mLineSpacingPixels; - remaining_pixels = text_width; + remaining_pixels = text_available_width; line_height = 0; } // ...just consumed last segment.. @@ -1188,7 +1189,7 @@ void LLTextBase::reflow(S32 start_index) line_start_index = segment->getStart() + seg_offset; cur_top -= llround((F32)line_height * mLineSpacingMult) + mLineSpacingPixels; line_height = 0; - remaining_pixels = text_width; + remaining_pixels = text_available_width; } ++seg_iter; seg_offset = 0; @@ -2096,7 +2097,13 @@ void LLTextBase::updateRects() LLRect doc_rect = mContentsRect; // use old mTextRect constraint document to width of viewable region doc_rect.mLeft = 0; - doc_rect.mRight = llmax(mTextRect.getWidth(), mContentsRect.mRight); + + // allow horizontal scrolling? + // if so, use entire width of text contents (sans scrollbars) + // otherwise, stop at width of mTextRect + doc_rect.mRight = mScroller + ? llmax(mScroller->getRect().mRight - mScroller->getBorderWidth(), mContentsRect.mRight) + : mTextRect.getWidth(); mDocumentView->setShape(doc_rect); @@ -2115,8 +2122,10 @@ void LLTextBase::updateRects() needsReflow(); } - // update document container again, using new mTextRect - doc_rect.mRight = llmax(mTextRect.getWidth(), mContentsRect.mRight); + // update document container again, using new mTextRect (that has scrollbars enabled as needed) + doc_rect.mRight = mScroller + ? llmax(mTextRect.getWidth(), mContentsRect.mRight) + : mTextRect.getWidth(); mDocumentView->setShape(doc_rect); } @@ -2413,10 +2422,18 @@ bool LLNormalTextSegment::getDimensions(S32 first_char, S32 num_chars, S32& widt if (num_chars > 0) { LLWString text = mEditor.getWText(); - width = mStyle->getFont()->getWidth(text.c_str(), mStart + first_char, num_chars); // if last character is a newline, then return true, forcing line break llwchar last_char = text[mStart + first_char + num_chars - 1]; - force_newline = (last_char == '\n'); + if (last_char == '\n') + { + force_newline = true; + // don't count newline in font width + width = mStyle->getFont()->getWidth(text.c_str(), mStart + first_char, num_chars - 1); + } + else + { + width = mStyle->getFont()->getWidth(text.c_str(), mStart + first_char, num_chars); + } } else { diff --git a/indra/newview/llexpandabletextbox.cpp b/indra/newview/llexpandabletextbox.cpp index bd6936f05c..9c37c953fe 100644 --- a/indra/newview/llexpandabletextbox.cpp +++ b/indra/newview/llexpandabletextbox.cpp @@ -51,8 +51,16 @@ public: /*virtual*/ bool getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const { // more label always spans width of text box - width = mEditor.getTextRect().getWidth() - mEditor.getHPad(); - height = llceil(mStyle->getFont()->getLineHeight()); + if (num_chars == 0) + { + width = 0; + height = 0; + } + else + { + width = mEditor.getDocumentView()->getRect().getWidth() - mEditor.getHPad(); + height = llceil(mStyle->getFont()->getLineHeight()); + } return true; } /*virtual*/ S32 getOffset(S32 segment_local_x_coord, S32 start_offset, S32 num_chars, bool round) const @@ -104,7 +112,8 @@ private: LLExpandableTextBox::LLTextBoxEx::Params::Params() : more_label("more_label") -{} +{ +} LLExpandableTextBox::LLTextBoxEx::LLTextBoxEx(const Params& p) : LLTextBox(p), @@ -117,16 +126,13 @@ LLExpandableTextBox::LLTextBoxEx::LLTextBoxEx(const Params& p) void LLExpandableTextBox::LLTextBoxEx::reshape(S32 width, S32 height, BOOL called_from_parent) { + hideExpandText(); LLTextBox::reshape(width, height, called_from_parent); if (getTextPixelHeight() > getRect().getHeight()) { showExpandText(); } - else - { - hideExpandText(); - } } void LLExpandableTextBox::LLTextBoxEx::setText(const LLStringExplicit& text,const LLStyle::Params& input_params) @@ -317,7 +323,8 @@ void LLExpandableTextBox::expandTextBox() mTextBox->hideExpandText(); S32 text_delta = mTextBox->getVerticalTextDelta(); - text_delta += mTextBox->getVPad() * 2 + mScroll->getBorderWidth() * 2; + text_delta += mTextBox->getVPad() * 2; + text_delta += mScroll->getBorderWidth() * 2; // no need to expand if(text_delta <= 0) { diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 8529a93527..6028819127 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -259,19 +259,21 @@ public: virtual void recordMessage(LLError::ELevel level, const std::string& message) { - // only log warnings to chat console - if (level == LLError::LEVEL_WARN) - { - LLFloaterChat* chat_floater = LLFloaterReg::findTypedInstance<LLFloaterChat>("chat"); - if (chat_floater && gSavedSettings.getBOOL("WarningsAsChat")) - { - LLChat chat; - chat.mText = message; - chat.mSourceType = CHAT_SOURCE_SYSTEM; + //FIXME: this is NOT thread safe, and will do bad things when a warning is issued from a non-UI thread - chat_floater->addChat(chat, FALSE, FALSE); - } - } + // only log warnings to chat console + //if (level == LLError::LEVEL_WARN) + //{ + //LLFloaterChat* chat_floater = LLFloaterReg::findTypedInstance<LLFloaterChat>("chat"); + //if (chat_floater && gSavedSettings.getBOOL("WarningsAsChat")) + //{ + // LLChat chat; + // chat.mText = message; + // chat.mSourceType = CHAT_SOURCE_SYSTEM; + + // chat_floater->addChat(chat, FALSE, FALSE); + //} + //} } }; @@ -3140,7 +3142,6 @@ void LLViewerWindow::pickAsync(S32 x, S32 y_from_bot, MASK mask, void (*callback return; } - // push back pick info object BOOL in_build_mode = LLFloaterReg::instanceVisible("build"); if (in_build_mode || LLDrawPoolAlpha::sShowDebugAlpha) { @@ -3149,27 +3150,7 @@ void LLViewerWindow::pickAsync(S32 x, S32 y_from_bot, MASK mask, void (*callback pick_transparent = TRUE; } - // center initial pick frame buffer region under mouse cursor - // since that area is guaranteed to be onscreen and hence a valid - // part of the framebuffer - if (mPicks.empty()) - { - mPickScreenRegion.setCenterAndSize(x, y_from_bot, PICK_DIAMETER, PICK_DIAMETER); - - if (mPickScreenRegion.mLeft < mWorldViewRectScaled.mLeft) mPickScreenRegion.translate(mWorldViewRectScaled.mLeft - mPickScreenRegion.mLeft, 0); - if (mPickScreenRegion.mBottom < mWorldViewRectScaled.mBottom) mPickScreenRegion.translate(0, mWorldViewRectScaled.mBottom - mPickScreenRegion.mBottom); - if (mPickScreenRegion.mRight > mWorldViewRectScaled.mRight ) mPickScreenRegion.translate(mWorldViewRectScaled.mRight - mPickScreenRegion.mRight, 0); - if (mPickScreenRegion.mTop > mWorldViewRectScaled.mTop ) mPickScreenRegion.translate(0, mWorldViewRectScaled.mTop - mPickScreenRegion.mTop); - } - - // set frame buffer region for picking results - // stack multiple picks left to right - LLRect screen_region = mPickScreenRegion; - screen_region.translate(mPicks.size() * PICK_DIAMETER, 0); - - LLPickInfo pick(LLCoordGL(x, y_from_bot), screen_region, mask, pick_transparent, TRUE, callback); - - schedulePick(pick); + schedulePick(LLPickInfo(LLCoordGL(x, y_from_bot), mask, pick_transparent, TRUE, callback)); } void LLViewerWindow::schedulePick(LLPickInfo& pick_info) @@ -3184,10 +3165,11 @@ void LLViewerWindow::schedulePick(LLPickInfo& pick_info) return; } - llassert_always(pick_info.mScreenRegion.notEmpty()); mPicks.push_back(pick_info); // delay further event processing until we receive results of pick + // only do this for async picks so that handleMouseUp won't be called + // until the pick triggered in handleMouseDown has been processed, for example mWindow->delayInputProcessing(); } @@ -3235,20 +3217,18 @@ LLPickInfo LLViewerWindow::pickImmediate(S32 x, S32 y_from_bot, BOOL pick_trans return LLPickInfo(); } - pickAsync(x, y_from_bot, gKeyboard->currentMask(TRUE), NULL, pick_transparent); - // assume that pickAsync put the results in the back of the mPicks list - if(mPicks.size() != 0) - { - mLastPick = mPicks.back(); - mLastPick.fetchResults(); - mPicks.pop_back(); - } - else + BOOL in_build_mode = LLFloaterReg::instanceVisible("build"); + if (in_build_mode || LLDrawPoolAlpha::sShowDebugAlpha) { - lldebugs << "List of last picks is empty: Using stub pick" << llendl; - mLastPick = LLPickInfo(); + // build mode allows interaction with all transparent objects + // "Show Debug Alpha" means no object actually transparent + pick_transparent = TRUE; } + // shortcut queueing in mPicks and just update mLastPick in place + mLastPick = LLPickInfo(LLCoordGL(x, y_from_bot), gKeyboard->currentMask(TRUE), pick_transparent, TRUE, NULL); + mLastPick.fetchResults(); + return mLastPick; } @@ -4895,13 +4875,11 @@ LLPickInfo::LLPickInfo() } LLPickInfo::LLPickInfo(const LLCoordGL& mouse_pos, - const LLRect& screen_region, MASK keyboard_mask, BOOL pick_transparent, BOOL pick_uv_coords, void (*pick_callback)(const LLPickInfo& pick_info)) : mMousePt(mouse_pos), - mScreenRegion(screen_region), mKeyMask(keyboard_mask), mPickCallback(pick_callback), mPickType(PICK_INVALID), diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index 1d564a1338..766c66ed0f 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -88,7 +88,6 @@ public: public: LLPickInfo(); LLPickInfo(const LLCoordGL& mouse_pos, - const LLRect& screen_region, MASK keyboard_mask, BOOL pick_transparent, BOOL pick_surface_info, @@ -120,7 +119,6 @@ public: LLVector3 mNormal; LLVector3 mBinormal; BOOL mPickTransparent; - LLRect mScreenRegion; void getSurfaceInfo(); private: @@ -345,7 +343,6 @@ public: void performPick(); void returnEmptyPicks(); - void pickAsync(S32 x, S32 y_from_bot, MASK mask, void (*callback)(const LLPickInfo& pick_info), BOOL pick_transparent = FALSE); LLPickInfo pickImmediate(S32 x, S32 y, BOOL pick_transparent); LLHUDIcon* cursorIntersectIcon(S32 mouse_x, S32 mouse_y, F32 depth, @@ -397,7 +394,7 @@ public: private: bool shouldShowToolTipFor(LLMouseHandler *mh); static bool onAlert(const LLSD& notify); - + void switchToolByMask(MASK mask); void destroyWindow(); void drawMouselookInstructions(); |