Commit 8b8dfa2e authored by Adam Moss's avatar Adam Moss
Browse files

EXT-1224 Inventory list uses ugly fake-italics

Reviewed by Richard.
parent b5936ec0
...@@ -72,11 +72,10 @@ class LLFontGL ...@@ -72,11 +72,10 @@ class LLFontGL
enum StyleFlags enum StyleFlags
{ {
// text style to render. May be combined (these are bit flags) // 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 = 0x00,
NORMAL = 0, BOLD = 0x01,
BOLD = 1, ITALIC = 0x02,
ITALIC = 2, UNDERLINE = 0x04
UNDERLINE = 4
}; };
enum ShadowType enum ShadowType
......
...@@ -213,7 +213,7 @@ LLFolderView::LLFolderView(const Params& p) ...@@ -213,7 +213,7 @@ LLFolderView::LLFolderView(const Params& p)
LLLineEditor::Params params; LLLineEditor::Params params;
params.name("ren"); params.name("ren");
params.rect(getRect()); params.rect(getRect());
params.font(sFont); params.font(getLabelFontForStyle(LLFontGL::NORMAL));
params.max_length_bytes(DB_INV_ITEM_NAME_STR_LEN); params.max_length_bytes(DB_INV_ITEM_NAME_STR_LEN);
params.commit_callback.function(boost::bind(&LLFolderView::commitRename, this, _2)); params.commit_callback.function(boost::bind(&LLFolderView::commitRename, this, _2));
params.prevalidate_callback(&LLLineEditor::prevalidatePrintableNotPipe); params.prevalidate_callback(&LLLineEditor::prevalidatePrintableNotPipe);
...@@ -832,6 +832,8 @@ void LLFolderView::draw() ...@@ -832,6 +832,8 @@ void LLFolderView::draw()
LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, S32_MAX, NULL, FALSE ); 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 // if cursor has moved off of me during drag and drop
// close all auto opened folders // close all auto opened folders
if (!mDragAndDropThisFrame) if (!mDragAndDropThisFrame)
...@@ -873,12 +875,12 @@ void LLFolderView::draw() ...@@ -873,12 +875,12 @@ void LLFolderView::draw()
if (gInventory.backgroundFetchActive() || mCompletedFilterGeneration < mFilter->getMinRequiredGeneration()) if (gInventory.backgroundFetchActive() || mCompletedFilterGeneration < mFilter->getMinRequiredGeneration())
{ {
mStatusText = LLTrans::getString("Searching"); 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 else
{ {
mStatusText = LLTrans::getString("InventoryNoMatchingItems"); 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 ...@@ -1814,7 +1816,7 @@ void LLFolderView::scrollToShowItem(LLFolderViewItem* item, const LLRect& constr
LLRect visible_doc_rect = mScrollContainer->getVisibleContentRect(); LLRect visible_doc_rect = mScrollContainer->getVisibleContentRect();
S32 icon_height = mIcon.isNull() ? 0 : mIcon->getHeight(); 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 // 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(); S32 max_height_to_show = mScrollContainer->hasFocus() ? (llmax( icon_height, label_height ) + ICON_PAD) : local_rect.getHeight();
...@@ -2123,8 +2125,10 @@ void LLFolderView::updateRenamerPosition() ...@@ -2123,8 +2125,10 @@ void LLFolderView::updateRenamerPosition()
{ {
if(mRenameItem) if(mRenameItem)
{ {
LLFontGL* font = getLabelFontForStyle(mLabelStyle);
S32 x = ARROW_SIZE + TEXT_PAD + ICON_WIDTH + ICON_PAD - 1 + mRenameItem->getIndentation(); 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 ); mRenameItem->localPointToScreen( x, y, &x, &y );
screenPointToLocal( x, y, &x, &y ); screenPointToLocal( x, y, &x, &y );
mRenamer->setOrigin( x, y ); mRenamer->setOrigin( x, y );
...@@ -2136,7 +2140,7 @@ void LLFolderView::updateRenamerPosition() ...@@ -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 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 ); mRenamer->reshape( width, height, TRUE );
} }
} }
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
///---------------------------------------------------------------------------- ///----------------------------------------------------------------------------
// statics // statics
const LLFontGL* LLFolderViewItem::sFont = NULL; std::map<U8, LLFontGL*> LLFolderViewItem::sFonts; // map of styles to fonts
const LLFontGL* LLFolderViewItem::sSmallFont = NULL; const LLFontGL* LLFolderViewItem::sSmallFont = NULL;
LLUIImagePtr LLFolderViewItem::sArrowImage; LLUIImagePtr LLFolderViewItem::sArrowImage;
LLUIImagePtr LLFolderViewItem::sBoxImage; LLUIImagePtr LLFolderViewItem::sBoxImage;
...@@ -62,10 +62,22 @@ const F32 LLFolderViewItem::FOLDER_OPEN_TIME_CONSTANT = 0.03f; ...@@ -62,10 +62,22 @@ const F32 LLFolderViewItem::FOLDER_OPEN_TIME_CONSTANT = 0.03f;
const LLColor4U DEFAULT_WHITE(255, 255, 255); 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 //static
void LLFolderViewItem::initClass() void LLFolderViewItem::initClass()
{ {
sFont = LLFontGL::getFontSansSerifSmall();
sSmallFont = LLFontGL::getFontMonospace(); sSmallFont = LLFontGL::getFontMonospace();
sArrowImage = LLUI::getUIImage("folder_arrow.tga"); sArrowImage = LLUI::getUIImage("folder_arrow.tga");
sBoxImage = LLUI::getUIImage("rounded_square.tga"); sBoxImage = LLUI::getUIImage("rounded_square.tga");
...@@ -74,6 +86,7 @@ void LLFolderViewItem::initClass() ...@@ -74,6 +86,7 @@ void LLFolderViewItem::initClass()
//static //static
void LLFolderViewItem::cleanupClass() void LLFolderViewItem::cleanupClass()
{ {
sFonts.clear();
sArrowImage = NULL; sArrowImage = NULL;
sBoxImage = NULL; sBoxImage = NULL;
} }
...@@ -365,7 +378,7 @@ S32 LLFolderViewItem::arrange( S32* width, S32* height, S32 filter_generation) ...@@ -365,7 +378,7 @@ S32 LLFolderViewItem::arrange( S32* width, S32* height, S32 filter_generation)
mIndentation = mParentFolder ? mParentFolder->getIndentation() + LEFT_INDENTATION : 0; mIndentation = mParentFolder ? mParentFolder->getIndentation() + LEFT_INDENTATION : 0;
if (mLabelWidthDirty) 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; mLabelWidthDirty = false;
} }
...@@ -377,7 +390,7 @@ S32 LLFolderViewItem::arrange( S32* width, S32* height, S32 filter_generation) ...@@ -377,7 +390,7 @@ S32 LLFolderViewItem::arrange( S32* width, S32* height, S32 filter_generation)
S32 LLFolderViewItem::getItemHeight() S32 LLFolderViewItem::getItemHeight()
{ {
S32 icon_height = mIcon->getHeight(); 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; return llmax( icon_height, label_height ) + ICON_PAD;
} }
...@@ -795,6 +808,8 @@ void LLFolderViewItem::draw() ...@@ -795,6 +808,8 @@ void LLFolderViewItem::draw()
F32 text_left = (F32)(ARROW_SIZE + TEXT_PAD + ICON_WIDTH + ICON_PAD + mIndentation); 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 // If we have keyboard focus, draw selection filled
BOOL show_context = getRoot()->getShowSelectionContext(); BOOL show_context = getRoot()->getShowSelectionContext();
BOOL filled = show_context || (getRoot()->getParentPanel()->hasFocus()); BOOL filled = show_context || (getRoot()->getParentPanel()->hasFocus());
...@@ -826,7 +841,7 @@ void LLFolderViewItem::draw() ...@@ -826,7 +841,7 @@ void LLFolderViewItem::draw()
0, 0,
getRect().getHeight(), getRect().getHeight(),
getRect().getWidth() - 2, getRect().getWidth() - 2,
llfloor(getRect().getHeight() - sFont->getLineHeight() - ICON_PAD), llfloor(getRect().getHeight() - font->getLineHeight() - ICON_PAD),
bg_color, filled); bg_color, filled);
if (mIsCurSelection) if (mIsCurSelection)
{ {
...@@ -834,14 +849,14 @@ void LLFolderViewItem::draw() ...@@ -834,14 +849,14 @@ void LLFolderViewItem::draw()
0, 0,
getRect().getHeight(), getRect().getHeight(),
getRect().getWidth() - 2, getRect().getWidth() - 2,
llfloor(getRect().getHeight() - sFont->getLineHeight() - ICON_PAD), llfloor(getRect().getHeight() - font->getLineHeight() - ICON_PAD),
sHighlightFgColor, FALSE); sHighlightFgColor, FALSE);
} }
if (getRect().getHeight() > llround(sFont->getLineHeight()) + ICON_PAD + 2) if (getRect().getHeight() > llround(font->getLineHeight()) + ICON_PAD + 2)
{ {
gl_rect_2d( gl_rect_2d(
0, 0,
llfloor(getRect().getHeight() - sFont->getLineHeight() - ICON_PAD) - 2, llfloor(getRect().getHeight() - font->getLineHeight() - ICON_PAD) - 2,
getRect().getWidth() - 2, getRect().getWidth() - 2,
2, 2,
sHighlightFgColor, FALSE); sHighlightFgColor, FALSE);
...@@ -849,7 +864,7 @@ void LLFolderViewItem::draw() ...@@ -849,7 +864,7 @@ void LLFolderViewItem::draw()
{ {
gl_rect_2d( gl_rect_2d(
0, 0,
llfloor(getRect().getHeight() - sFont->getLineHeight() - ICON_PAD) - 2, llfloor(getRect().getHeight() - font->getLineHeight() - ICON_PAD) - 2,
getRect().getWidth() - 2, getRect().getWidth() - 2,
2, 2,
sHighlightBgColor, TRUE); sHighlightBgColor, TRUE);
...@@ -863,14 +878,14 @@ void LLFolderViewItem::draw() ...@@ -863,14 +878,14 @@ void LLFolderViewItem::draw()
0, 0,
getRect().getHeight(), getRect().getHeight(),
getRect().getWidth() - 2, getRect().getWidth() - 2,
llfloor(getRect().getHeight() - sFont->getLineHeight() - ICON_PAD), llfloor(getRect().getHeight() - font->getLineHeight() - ICON_PAD),
sHighlightBgColor, FALSE); sHighlightBgColor, FALSE);
if (getRect().getHeight() > llround(sFont->getLineHeight()) + ICON_PAD + 2) if (getRect().getHeight() > llround(font->getLineHeight()) + ICON_PAD + 2)
{ {
gl_rect_2d( gl_rect_2d(
0, 0,
llfloor(getRect().getHeight() - sFont->getLineHeight() - ICON_PAD) - 2, llfloor(getRect().getHeight() - font->getLineHeight() - ICON_PAD) - 2,
getRect().getWidth() - 2, getRect().getWidth() - 2,
2, 2,
sHighlightBgColor, FALSE); sHighlightBgColor, FALSE);
...@@ -890,7 +905,7 @@ void LLFolderViewItem::draw() ...@@ -890,7 +905,7 @@ void LLFolderViewItem::draw()
BOOL debug_filters = getRoot()->getDebugFilters(); BOOL debug_filters = getRoot()->getDebugFilters();
LLColor4 color = ( (mIsSelected && filled) ? sHighlightFgColor : sFgColor ); LLColor4 color = ( (mIsSelected && filled) ? sHighlightFgColor : sFgColor );
F32 right_x; 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 (debug_filters)
{ {
...@@ -910,18 +925,18 @@ void LLFolderViewItem::draw() ...@@ -910,18 +925,18 @@ void LLFolderViewItem::draw()
if ( mIsLoading if ( mIsLoading
&& mTimeSinceRequestStart.getElapsedTimeF32() >= gSavedSettings.getF32("FolderLoadingMessageWaitTime") ) && mTimeSinceRequestStart.getElapsedTimeF32() >= gSavedSettings.getF32("FolderLoadingMessageWaitTime") )
{ {
sFont->renderUTF8(LLTrans::getString("LoadingData"), 0, text_left, y, sSearchStatusColor, font->renderUTF8(LLTrans::getString("LoadingData"), 0, text_left, y, sSearchStatusColor,
LLFontGL::LEFT, LLFontGL::BOTTOM, mLabelStyle, LLFontGL::NO_SHADOW, S32_MAX, S32_MAX, &right_x, FALSE); LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, S32_MAX, &right_x, FALSE);
text_left = right_x; text_left = right_x;
} }
sFont->renderUTF8( mLabel, 0, text_left, y, color, font->renderUTF8( mLabel, 0, text_left, y, color,
LLFontGL::LEFT, LLFontGL::BOTTOM, mLabelStyle, LLFontGL::NO_SHADOW, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW,
S32_MAX, S32_MAX, &right_x, FALSE ); S32_MAX, S32_MAX, &right_x, FALSE );
if (!mLabelSuffix.empty()) if (!mLabelSuffix.empty())
{ {
sFont->renderUTF8( mLabelSuffix, 0, right_x, y, sSuffixColor, font->renderUTF8( mLabelSuffix, 0, right_x, y, sSuffixColor,
LLFontGL::LEFT, LLFontGL::BOTTOM, mLabelStyle, LLFontGL::NO_SHADOW, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW,
S32_MAX, S32_MAX, &right_x, FALSE ); S32_MAX, S32_MAX, &right_x, FALSE );
} }
...@@ -932,17 +947,17 @@ void LLFolderViewItem::draw() ...@@ -932,17 +947,17 @@ void LLFolderViewItem::draw()
if (filter_string_length > 0) if (filter_string_length > 0)
{ {
std::string combined_string = mLabel + mLabelSuffix; std::string combined_string = mLabel + mLabelSuffix;
S32 left = llround(text_left) + sFont->getWidth(combined_string, 0, mStringMatchOffset) - 1; S32 left = llround(text_left) + font->getWidth(combined_string, 0, mStringMatchOffset) - 1;
S32 right = left + sFont->getWidth(combined_string, mStringMatchOffset, filter_string_length) + 2; S32 right = left + font->getWidth(combined_string, mStringMatchOffset, filter_string_length) + 2;
S32 bottom = llfloor(getRect().getHeight() - sFont->getLineHeight() - 3); S32 bottom = llfloor(getRect().getHeight() - font->getLineHeight() - 3);
S32 top = getRect().getHeight(); S32 top = getRect().getHeight();
LLRect box_rect(left, top, right, bottom); LLRect box_rect(left, top, right, bottom);
sBoxImage->draw(box_rect, sFilterBGColor); sBoxImage->draw(box_rect, sFilterBGColor);
F32 match_string_left = text_left + sFont->getWidthF32(combined_string, 0, mStringMatchOffset); F32 match_string_left = text_left + font->getWidthF32(combined_string, 0, mStringMatchOffset);
F32 y = (F32)getRect().getHeight() - sFont->getLineHeight() - (F32)TEXT_PAD; F32 y = (F32)getRect().getHeight() - font->getLineHeight() - (F32)TEXT_PAD;
sFont->renderUTF8( combined_string, mStringMatchOffset, match_string_left, y, font->renderUTF8( combined_string, mStringMatchOffset, match_string_left, y,
sFilterTextColor, LLFontGL::LEFT, LLFontGL::BOTTOM, mLabelStyle, LLFontGL::NO_SHADOW, sFilterTextColor, LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW,
filter_string_length, S32_MAX, &right_x, FALSE ); filter_string_length, S32_MAX, &right_x, FALSE );
} }
} }
......
...@@ -125,7 +125,6 @@ class LLFolderViewItem : public LLView ...@@ -125,7 +125,6 @@ class LLFolderViewItem : public LLView
LLFolderViewItem(Params p = LLFolderViewItem::Params()); LLFolderViewItem(Params p = LLFolderViewItem::Params());
static const LLFontGL* sFont;
static const LLFontGL* sSmallFont; static const LLFontGL* sSmallFont;
static LLUIImagePtr sArrowImage; static LLUIImagePtr sArrowImage;
static LLUIImagePtr sBoxImage; static LLUIImagePtr sBoxImage;
...@@ -169,6 +168,8 @@ class LLFolderViewItem : public LLView ...@@ -169,6 +168,8 @@ class LLFolderViewItem : public LLView
virtual BOOL addItem(LLFolderViewItem*) { return FALSE; } virtual BOOL addItem(LLFolderViewItem*) { return FALSE; }
virtual BOOL addFolder(LLFolderViewFolder*) { return FALSE; } virtual BOOL addFolder(LLFolderViewFolder*) { return FALSE; }
static LLFontGL* getLabelFontForStyle(U8 style);
public: public:
// This function clears the currently selected item, and records // This function clears the currently selected item, and records
// the specified selected item appropriately for display and use // the specified selected item appropriately for display and use
...@@ -322,6 +323,9 @@ class LLFolderViewItem : public LLView ...@@ -322,6 +323,9 @@ class LLFolderViewItem : public LLView
void* cargo_data, void* cargo_data,
EAcceptance* accept, EAcceptance* accept,
std::string& tooltip_msg); std::string& tooltip_msg);
private:
static std::map<U8, LLFontGL*> sFonts; // map of styles to fonts
}; };
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment