Commits

Adam Moss  committed 7f16e79

EXT-1224 Inventory list uses ugly fake-italics

Reviewed by Richard.

  • Participants
  • Parent commits aadd57c
  • Tags alpha-4, fork to viewer-20qa

Comments (0)

Files changed (4)

File indra/llrender/llfontgl.h

 	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

File indra/newview/llfolderview.cpp

 	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);
 			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)
 		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 );
 		}
 	}
 
 		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(); 
 		
 {
 	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 );
 		}
 
 		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 );
 	}
 }

File indra/newview/llfolderviewitem.cpp

 ///----------------------------------------------------------------------------
 
 // 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;
 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");
 //static
 void LLFolderViewItem::cleanupClass()
 {
+	sFonts.clear();
 	sArrowImage = NULL;
 	sBoxImage = NULL;
 }
 	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;
 	}
 
 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;
 }
 
 
 	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());
 			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)
 		{
 				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);
 			{
 				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);
 			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);
 		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)
 		{
 		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 );
 		}
 
 			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 );
 			}
 		}

File indra/newview/llfolderviewitem.h

 
 	LLFolderViewItem(Params p = LLFolderViewItem::Params());
 
-	static const LLFontGL*		sFont;
 	static const LLFontGL*		sSmallFont;
 	static LLUIImagePtr			sArrowImage;
 	static LLUIImagePtr			sBoxImage;
 	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
 		void* cargo_data,
 		EAcceptance* accept,
 		std::string& tooltip_msg);
+
+ private:
+	static std::map<U8, LLFontGL*> sFonts; // map of styles to fonts
 };