diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llrender/llfontgl.h | 9 | ||||
-rw-r--r-- | indra/newview/llfolderview.cpp | 16 | ||||
-rw-r--r-- | indra/newview/llfolderviewitem.cpp | 67 | ||||
-rw-r--r-- | indra/newview/llfolderviewitem.h | 6 |
4 files changed, 60 insertions, 38 deletions
diff --git a/indra/llrender/llfontgl.h b/indra/llrender/llfontgl.h index af8e0909af..ad84b6d641 100644 --- a/indra/llrender/llfontgl.h +++ b/indra/llrender/llfontgl.h @@ -72,11 +72,10 @@ public: enum StyleFlags { // text style to render. May be combined (these are bit flags) - // TODO:: Maybe change the value to 0x01 << 0 for 1 0x01 << 1 for 2, 0x01 << 2 for 4 - NORMAL = 0, - BOLD = 1, - ITALIC = 2, - UNDERLINE = 4 + NORMAL = 0x00, + BOLD = 0x01, + ITALIC = 0x02, + UNDERLINE = 0x04 }; enum ShadowType diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp index c8eb696134..3fd0875709 100644 --- a/indra/newview/llfolderview.cpp +++ b/indra/newview/llfolderview.cpp @@ -213,7 +213,7 @@ LLFolderView::LLFolderView(const Params& p) LLLineEditor::Params params; params.name("ren"); params.rect(getRect()); - params.font(sFont); + params.font(getLabelFontForStyle(LLFontGL::NORMAL)); params.max_length_bytes(DB_INV_ITEM_NAME_STR_LEN); params.commit_callback.function(boost::bind(&LLFolderView::commitRename, this, _2)); params.prevalidate_callback(&LLLineEditor::prevalidatePrintableNotPipe); @@ -832,6 +832,8 @@ void LLFolderView::draw() LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, S32_MAX, NULL, FALSE ); } + LLFontGL* font = getLabelFontForStyle(mLabelStyle); + // if cursor has moved off of me during drag and drop // close all auto opened folders if (!mDragAndDropThisFrame) @@ -873,12 +875,12 @@ void LLFolderView::draw() if (gInventory.backgroundFetchActive() || mCompletedFilterGeneration < mFilter->getMinRequiredGeneration()) { mStatusText = LLTrans::getString("Searching"); - sFont->renderUTF8(mStatusText, 0, 2, 1, sSearchStatusColor, LLFontGL::LEFT, LLFontGL::TOP, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, S32_MAX, NULL, FALSE ); + font->renderUTF8(mStatusText, 0, 2, 1, sSearchStatusColor, LLFontGL::LEFT, LLFontGL::TOP, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, S32_MAX, NULL, FALSE ); } else { mStatusText = LLTrans::getString("InventoryNoMatchingItems"); - sFont->renderUTF8(mStatusText, 0, 2, 1, sSearchStatusColor, LLFontGL::LEFT, LLFontGL::TOP, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, S32_MAX, NULL, FALSE ); + font->renderUTF8(mStatusText, 0, 2, 1, sSearchStatusColor, LLFontGL::LEFT, LLFontGL::TOP, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, S32_MAX, NULL, FALSE ); } } @@ -1814,7 +1816,7 @@ void LLFolderView::scrollToShowItem(LLFolderViewItem* item, const LLRect& constr LLRect visible_doc_rect = mScrollContainer->getVisibleContentRect(); S32 icon_height = mIcon.isNull() ? 0 : mIcon->getHeight(); - S32 label_height = llround(sFont->getLineHeight()); + S32 label_height = llround(getLabelFontForStyle(mLabelStyle)->getLineHeight()); // when navigating with keyboard, only move top of folders on screen, otherwise show whole folder S32 max_height_to_show = mScrollContainer->hasFocus() ? (llmax( icon_height, label_height ) + ICON_PAD) : local_rect.getHeight(); @@ -2123,8 +2125,10 @@ void LLFolderView::updateRenamerPosition() { if(mRenameItem) { + LLFontGL* font = getLabelFontForStyle(mLabelStyle); + S32 x = ARROW_SIZE + TEXT_PAD + ICON_WIDTH + ICON_PAD - 1 + mRenameItem->getIndentation(); - S32 y = llfloor(mRenameItem->getRect().getHeight()-sFont->getLineHeight()-2); + S32 y = llfloor(mRenameItem->getRect().getHeight() - font->getLineHeight()-2); mRenameItem->localPointToScreen( x, y, &x, &y ); screenPointToLocal( x, y, &x, &y ); mRenamer->setOrigin( x, y ); @@ -2136,7 +2140,7 @@ void LLFolderView::updateRenamerPosition() } S32 width = llmax(llmin(mRenameItem->getRect().getWidth() - x, scroller_rect.getWidth() - x - getRect().mLeft), MINIMUM_RENAMER_WIDTH); - S32 height = llfloor(sFont->getLineHeight() + RENAME_HEIGHT_PAD); + S32 height = llfloor(font->getLineHeight() + RENAME_HEIGHT_PAD); mRenamer->reshape( width, height, TRUE ); } } diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp index ef54ee7d4a..ee5fba5ace 100644 --- a/indra/newview/llfolderviewitem.cpp +++ b/indra/newview/llfolderviewitem.cpp @@ -51,7 +51,7 @@ ///---------------------------------------------------------------------------- // statics -const LLFontGL* LLFolderViewItem::sFont = NULL; +std::map<U8, LLFontGL*> LLFolderViewItem::sFonts; // map of styles to fonts const LLFontGL* LLFolderViewItem::sSmallFont = NULL; LLUIImagePtr LLFolderViewItem::sArrowImage; LLUIImagePtr LLFolderViewItem::sBoxImage; @@ -63,9 +63,21 @@ const F32 LLFolderViewItem::FOLDER_OPEN_TIME_CONSTANT = 0.03f; const LLColor4U DEFAULT_WHITE(255, 255, 255); //static +LLFontGL* LLFolderViewItem::getLabelFontForStyle(U8 style) +{ + LLFontGL* rtn = sFonts[style]; + if (!rtn) // grab label font with this style, lazily + { + LLFontDescriptor labelfontdesc("SansSerif", "Small", style); + rtn = LLFontGL::getFont(labelfontdesc); + sFonts[style] = rtn; + } + return rtn; +} + +//static void LLFolderViewItem::initClass() { - sFont = LLFontGL::getFontSansSerifSmall(); sSmallFont = LLFontGL::getFontMonospace(); sArrowImage = LLUI::getUIImage("folder_arrow.tga"); sBoxImage = LLUI::getUIImage("rounded_square.tga"); @@ -74,6 +86,7 @@ void LLFolderViewItem::initClass() //static void LLFolderViewItem::cleanupClass() { + sFonts.clear(); sArrowImage = NULL; sBoxImage = NULL; } @@ -365,7 +378,7 @@ S32 LLFolderViewItem::arrange( S32* width, S32* height, S32 filter_generation) mIndentation = mParentFolder ? mParentFolder->getIndentation() + LEFT_INDENTATION : 0; if (mLabelWidthDirty) { - mLabelWidth = ARROW_SIZE + TEXT_PAD + ICON_WIDTH + ICON_PAD + sFont->getWidth(mSearchableLabel); + mLabelWidth = ARROW_SIZE + TEXT_PAD + ICON_WIDTH + ICON_PAD + getLabelFontForStyle(mLabelStyle)->getWidth(mSearchableLabel); mLabelWidthDirty = false; } @@ -377,7 +390,7 @@ S32 LLFolderViewItem::arrange( S32* width, S32* height, S32 filter_generation) S32 LLFolderViewItem::getItemHeight() { S32 icon_height = mIcon->getHeight(); - S32 label_height = llround(sFont->getLineHeight()); + S32 label_height = llround(getLabelFontForStyle(mLabelStyle)->getLineHeight()); return llmax( icon_height, label_height ) + ICON_PAD; } @@ -795,6 +808,8 @@ void LLFolderViewItem::draw() F32 text_left = (F32)(ARROW_SIZE + TEXT_PAD + ICON_WIDTH + ICON_PAD + mIndentation); + LLFontGL* font = getLabelFontForStyle(mLabelStyle); + // If we have keyboard focus, draw selection filled BOOL show_context = getRoot()->getShowSelectionContext(); BOOL filled = show_context || (getRoot()->getParentPanel()->hasFocus()); @@ -826,7 +841,7 @@ void LLFolderViewItem::draw() 0, getRect().getHeight(), getRect().getWidth() - 2, - llfloor(getRect().getHeight() - sFont->getLineHeight() - ICON_PAD), + llfloor(getRect().getHeight() - font->getLineHeight() - ICON_PAD), bg_color, filled); if (mIsCurSelection) { @@ -834,14 +849,14 @@ void LLFolderViewItem::draw() 0, getRect().getHeight(), getRect().getWidth() - 2, - llfloor(getRect().getHeight() - sFont->getLineHeight() - ICON_PAD), + llfloor(getRect().getHeight() - font->getLineHeight() - ICON_PAD), sHighlightFgColor, FALSE); } - if (getRect().getHeight() > llround(sFont->getLineHeight()) + ICON_PAD + 2) + if (getRect().getHeight() > llround(font->getLineHeight()) + ICON_PAD + 2) { gl_rect_2d( 0, - llfloor(getRect().getHeight() - sFont->getLineHeight() - ICON_PAD) - 2, + llfloor(getRect().getHeight() - font->getLineHeight() - ICON_PAD) - 2, getRect().getWidth() - 2, 2, sHighlightFgColor, FALSE); @@ -849,7 +864,7 @@ void LLFolderViewItem::draw() { gl_rect_2d( 0, - llfloor(getRect().getHeight() - sFont->getLineHeight() - ICON_PAD) - 2, + llfloor(getRect().getHeight() - font->getLineHeight() - ICON_PAD) - 2, getRect().getWidth() - 2, 2, sHighlightBgColor, TRUE); @@ -863,14 +878,14 @@ void LLFolderViewItem::draw() 0, getRect().getHeight(), getRect().getWidth() - 2, - llfloor(getRect().getHeight() - sFont->getLineHeight() - ICON_PAD), + llfloor(getRect().getHeight() - font->getLineHeight() - ICON_PAD), sHighlightBgColor, FALSE); - if (getRect().getHeight() > llround(sFont->getLineHeight()) + ICON_PAD + 2) + if (getRect().getHeight() > llround(font->getLineHeight()) + ICON_PAD + 2) { gl_rect_2d( 0, - llfloor(getRect().getHeight() - sFont->getLineHeight() - ICON_PAD) - 2, + llfloor(getRect().getHeight() - font->getLineHeight() - ICON_PAD) - 2, getRect().getWidth() - 2, 2, sHighlightBgColor, FALSE); @@ -890,7 +905,7 @@ void LLFolderViewItem::draw() BOOL debug_filters = getRoot()->getDebugFilters(); LLColor4 color = ( (mIsSelected && filled) ? sHighlightFgColor : sFgColor ); F32 right_x; - F32 y = (F32)getRect().getHeight() - sFont->getLineHeight() - (F32)TEXT_PAD; + F32 y = (F32)getRect().getHeight() - font->getLineHeight() - (F32)TEXT_PAD; if (debug_filters) { @@ -910,18 +925,18 @@ void LLFolderViewItem::draw() if ( mIsLoading && mTimeSinceRequestStart.getElapsedTimeF32() >= gSavedSettings.getF32("FolderLoadingMessageWaitTime") ) { - sFont->renderUTF8(LLTrans::getString("LoadingData"), 0, text_left, y, sSearchStatusColor, - LLFontGL::LEFT, LLFontGL::BOTTOM, mLabelStyle, LLFontGL::NO_SHADOW, S32_MAX, S32_MAX, &right_x, FALSE); + font->renderUTF8(LLTrans::getString("LoadingData"), 0, text_left, y, sSearchStatusColor, + LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, S32_MAX, &right_x, FALSE); text_left = right_x; } - sFont->renderUTF8( mLabel, 0, text_left, y, color, - LLFontGL::LEFT, LLFontGL::BOTTOM, mLabelStyle, LLFontGL::NO_SHADOW, + font->renderUTF8( mLabel, 0, text_left, y, color, + LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, S32_MAX, &right_x, FALSE ); if (!mLabelSuffix.empty()) { - sFont->renderUTF8( mLabelSuffix, 0, right_x, y, sSuffixColor, - LLFontGL::LEFT, LLFontGL::BOTTOM, mLabelStyle, LLFontGL::NO_SHADOW, + font->renderUTF8( mLabelSuffix, 0, right_x, y, sSuffixColor, + LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, S32_MAX, &right_x, FALSE ); } @@ -932,17 +947,17 @@ void LLFolderViewItem::draw() if (filter_string_length > 0) { std::string combined_string = mLabel + mLabelSuffix; - S32 left = llround(text_left) + sFont->getWidth(combined_string, 0, mStringMatchOffset) - 1; - S32 right = left + sFont->getWidth(combined_string, mStringMatchOffset, filter_string_length) + 2; - S32 bottom = llfloor(getRect().getHeight() - sFont->getLineHeight() - 3); + S32 left = llround(text_left) + font->getWidth(combined_string, 0, mStringMatchOffset) - 1; + S32 right = left + font->getWidth(combined_string, mStringMatchOffset, filter_string_length) + 2; + S32 bottom = llfloor(getRect().getHeight() - font->getLineHeight() - 3); S32 top = getRect().getHeight(); LLRect box_rect(left, top, right, bottom); sBoxImage->draw(box_rect, sFilterBGColor); - F32 match_string_left = text_left + sFont->getWidthF32(combined_string, 0, mStringMatchOffset); - F32 y = (F32)getRect().getHeight() - sFont->getLineHeight() - (F32)TEXT_PAD; - sFont->renderUTF8( combined_string, mStringMatchOffset, match_string_left, y, - sFilterTextColor, LLFontGL::LEFT, LLFontGL::BOTTOM, mLabelStyle, LLFontGL::NO_SHADOW, + F32 match_string_left = text_left + font->getWidthF32(combined_string, 0, mStringMatchOffset); + F32 y = (F32)getRect().getHeight() - font->getLineHeight() - (F32)TEXT_PAD; + font->renderUTF8( combined_string, mStringMatchOffset, match_string_left, y, + sFilterTextColor, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, filter_string_length, S32_MAX, &right_x, FALSE ); } } diff --git a/indra/newview/llfolderviewitem.h b/indra/newview/llfolderviewitem.h index 32134670c8..e9aab560c8 100644 --- a/indra/newview/llfolderviewitem.h +++ b/indra/newview/llfolderviewitem.h @@ -125,7 +125,6 @@ protected: LLFolderViewItem(Params p = LLFolderViewItem::Params()); - static const LLFontGL* sFont; static const LLFontGL* sSmallFont; static LLUIImagePtr sArrowImage; static LLUIImagePtr sBoxImage; @@ -169,6 +168,8 @@ protected: virtual BOOL addItem(LLFolderViewItem*) { return FALSE; } virtual BOOL addFolder(LLFolderViewFolder*) { return FALSE; } + static LLFontGL* getLabelFontForStyle(U8 style); + public: // This function clears the currently selected item, and records // the specified selected item appropriately for display and use @@ -322,6 +323,9 @@ public: void* cargo_data, EAcceptance* accept, std::string& tooltip_msg); + + private: + static std::map<U8, LLFontGL*> sFonts; // map of styles to fonts }; |