First pass expose inventory item settings in XML (folder_view_item.xml)

Optimized LLFolderViewItem constructor by passing param block as
const ref to avoid copies.
Removed per-item arrow and background images, use defaults.
Removed unneeded static image pointers.
Removed hard-coded rounded_square.tga, replaced with Rounded_Square
Ditto for folder_arrow.tga
Reviewed with Richard.
master
James Cook 2010-01-08 17:26:47 -08:00
parent 6a1a93be1a
commit 9ffaacc47e
14 changed files with 71 additions and 70 deletions

View File

@ -180,7 +180,7 @@ void LLConsole::draw()
// draw remaining lines
F32 y_pos = 0.f;
LLUIImagePtr imagep = LLUI::getUIImage("rounded_square.tga");
LLUIImagePtr imagep = LLUI::getUIImage("Rounded_Square");
// F32 console_opacity = llclamp(gSavedSettings.getF32("ConsoleBackgroundOpacity"), 0.f, 1.f);
F32 console_opacity = llclamp(LLUI::sSettingGroups["config"]->getF32("ConsoleBackgroundOpacity"), 0.f, 1.f);

View File

@ -490,7 +490,7 @@ void LLMultiSlider::draw()
F32 opacity = getEnabled() ? 1.f : 0.3f;
// Track
LLUIImagePtr thumb_imagep = LLUI::getUIImage("rounded_square.tga");
LLUIImagePtr thumb_imagep = LLUI::getUIImage("Rounded_Square");
static LLUICachedControl<S32> multi_track_height ("UIMultiTrackHeight", 0);
S32 height_offset = (getRect().getHeight() - multi_track_height) / 2;

View File

@ -188,7 +188,7 @@ LLScrollListText::LLScrollListText(const LLScrollListCell::Params& p)
// initialize rounded rect image
if (!mRoundedRectImage)
{
mRoundedRectImage = LLUI::getUIImage("rounded_square.tga");
mRoundedRectImage = LLUI::getUIImage("Rounded_Square");
}
}

View File

@ -3257,17 +3257,6 @@
<key>Value</key>
<real>0.75</real>
</map>
<key>FolderIndentation</key>
<map>
<key>Comment</key>
<string>Number of pixels to indent subfolders in inventory</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>S32</string>
<key>Value</key>
<integer>8</integer>
</map>
<key>FolderLoadingMessageWaitTime</key>
<map>
<key>Comment</key>

View File

@ -314,7 +314,7 @@ void LLFastTimerView::draw()
S32 left, top, right, bottom;
S32 x, y, barw, barh, dx, dy;
S32 texth, textw;
LLPointer<LLUIImage> box_imagep = LLUI::getUIImage("rounded_square.tga");
LLPointer<LLUIImage> box_imagep = LLUI::getUIImage("Rounded_Square");
// Draw the window background
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);

View File

@ -206,7 +206,9 @@ LLFolderView::LLFolderView(const Params& p)
mAutoOpenCandidate = NULL;
mAutoOpenTimer.stop();
mKeyboardSelection = FALSE;
static LLUICachedControl<S32> indentation("FolderIndentation", 0);
const LLFolderViewItem::Params& item_params =
LLUICtrlFactory::getDefaultParams<LLFolderViewItem>();
S32 indentation = item_params.folder_indentation();
mIndentation = -indentation; // children start at indentation 0
gIdleCallbacks.addFunction(idle, this);
@ -395,7 +397,7 @@ S32 LLFolderView::arrange( S32* unused_width, S32* unused_height, S32 filter_gen
getRoot()->getFilter()->getShowFolderState();
S32 total_width = LEFT_PAD;
S32 running_height = mDebugFilters ? llceil(sSmallFont->getLineHeight()) : 0;
S32 running_height = mDebugFilters ? llceil(LLFontGL::getFontMonospace()->getLineHeight()) : 0;
S32 target_height = running_height;
S32 parent_item_height = getRect().getHeight();
@ -866,8 +868,8 @@ void LLFolderView::draw()
{
std::string current_filter_string = llformat("Current Filter: %d, Least Filter: %d, Auto-accept Filter: %d",
mFilter->getCurrentGeneration(), mFilter->getMinRequiredGeneration(), mFilter->getMustPassGeneration());
sSmallFont->renderUTF8(current_filter_string, 0, 2,
getRect().getHeight() - sSmallFont->getLineHeight(), LLColor4(0.5f, 0.5f, 0.8f, 1.f),
LLFontGL::getFontMonospace()->renderUTF8(current_filter_string, 0, 2,
getRect().getHeight() - LLFontGL::getFontMonospace()->getLineHeight(), LLColor4(0.5f, 0.5f, 0.8f, 1.f),
LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, S32_MAX, NULL, FALSE );
}

View File

@ -51,11 +51,10 @@
/// Class LLFolderViewItem
///----------------------------------------------------------------------------
static LLDefaultChildRegistry::Register<LLFolderViewItem> r("folder_view_item");
// statics
std::map<U8, LLFontGL*> LLFolderViewItem::sFonts; // map of styles to fonts
const LLFontGL* LLFolderViewItem::sSmallFont = NULL;
LLUIImagePtr LLFolderViewItem::sArrowImage;
LLUIImagePtr LLFolderViewItem::sBoxImage;
// only integers can be initialized in header
const F32 LLFolderViewItem::FOLDER_CLOSE_TIME_CONSTANT = 0.02f;
@ -84,33 +83,34 @@ LLFontGL* LLFolderViewItem::getLabelFontForStyle(U8 style)
//static
void LLFolderViewItem::initClass()
{
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;
}
// NOTE: Optimize this, we call it a *lot* when opening a large inventory
LLFolderViewItem::Params::Params()
: icon("icon"),
folder_arrow_image("folder_arrow_image", LLUI::getUIImage("folder_arrow.tga")),
selection_image("selection_image", LLUI::getUIImage("rounded_square.tga"))
: icon(),
icon_open(),
root(),
listener(),
folder_arrow_image("folder_arrow_image"),
folder_indentation("folder_indentation"),
selection_image("selection_image"),
font("font"),
item_height("item_height"),
creation_date()
{
mouse_opaque(true);
follows.flags(FOLLOWS_LEFT|FOLLOWS_TOP|FOLLOWS_RIGHT);
// JAMESDEBUG tab_stop(false);
}
// Default constructor
LLFolderViewItem::LLFolderViewItem(LLFolderViewItem::Params p)
LLFolderViewItem::LLFolderViewItem(const LLFolderViewItem::Params& p)
: LLView(p),
mLabelWidth(0),
mLabelWidthDirty(false),
@ -121,6 +121,7 @@ LLFolderViewItem::LLFolderViewItem(LLFolderViewItem::Params p)
mLabelStyle( LLFontGL::NORMAL ),
mHasVisibleChildren(FALSE),
mIndentation(0),
mItemHeight(p.item_height),
mNumDescendantsSelected(0),
mPassedFilter(FALSE),
mLastFilterGeneration(-1),
@ -134,8 +135,6 @@ LLFolderViewItem::LLFolderViewItem(LLFolderViewItem::Params p)
mIcon(p.icon),
mIconOpen(p.icon_open),
mListener(p.listener),
mArrowImage(p.folder_arrow_image),
mBoxImage(p.selection_image),
mHidden(false),
mShowLoadStatus(false)
{
@ -392,10 +391,11 @@ BOOL LLFolderViewItem::addToFolder(LLFolderViewFolder* folder, LLFolderView* roo
// makes sure that this view and it's children are the right size.
S32 LLFolderViewItem::arrange( S32* width, S32* height, S32 filter_generation)
{
static LLUICachedControl<S32> indentation("FolderIndentation", 0);
const Params& p = LLUICtrlFactory::getDefaultParams<LLFolderViewItem>();
S32 indentation = p.folder_indentation();
// Only indent deeper items in hierarchy
mIndentation = (getParentFolder()
&& getParentFolder()->getParentFolder()
&& getParentFolder()->getParentFolder()->getParentFolder())
&& getParentFolder()->getParentFolder() )
? mParentFolder->getIndentation() + indentation
: 0;
if (mLabelWidthDirty)
@ -421,9 +421,10 @@ S32 LLFolderViewItem::getItemHeight()
{
if (mHidden) return 0;
S32 icon_height = mIcon->getHeight();
S32 label_height = llround(getLabelFontForStyle(mLabelStyle)->getLineHeight());
return llmax( icon_height, label_height ) + ICON_PAD;
//S32 icon_height = mIcon->getHeight();
//S32 label_height = llround(getLabelFontForStyle(mLabelStyle)->getLineHeight());
//return llmax( icon_height, label_height ) + ICON_PAD;
return mItemHeight;
}
void LLFolderViewItem::filter( LLInventoryFilter& filter)
@ -834,6 +835,8 @@ void LLFolderViewItem::draw()
static LLUIColor sSuffixColor = LLUIColorTable::instance().getColor("InventoryItemSuffixColor", DEFAULT_WHITE);
static LLUIColor sSearchStatusColor = LLUIColorTable::instance().getColor("InventorySearchStatusColor", DEFAULT_WHITE);
const Params& default_params = LLUICtrlFactory::getDefaultParams<LLFolderViewItem>();
bool possibly_has_children = false;
bool up_to_date = mListener && mListener->isUpToDate();
if((up_to_date && hasVisibleChildren() ) || // we fetched our children and some of them have passed the filter...
@ -843,11 +846,9 @@ void LLFolderViewItem::draw()
}
if(/*mControlLabel[0] != '\0' && */possibly_has_children)
{
if (sArrowImage)
{
gl_draw_scaled_rotated_image(mIndentation, getRect().getHeight() - ARROW_SIZE - TEXT_PAD,
ARROW_SIZE, ARROW_SIZE, mControlLabelRotation, sArrowImage->getImage(), sFgColor);
}
LLUIImage* arrow_image = default_params.folder_arrow_image;
gl_draw_scaled_rotated_image(mIndentation, getRect().getHeight() - ARROW_SIZE - TEXT_PAD,
ARROW_SIZE, ARROW_SIZE, mControlLabelRotation, arrow_image->getImage(), sFgColor);
}
F32 text_left = (F32)(ARROW_SIZE + TEXT_PAD + ICON_WIDTH + ICON_PAD + mIndentation);
@ -885,7 +886,7 @@ void LLFolderViewItem::draw()
0,
getRect().getHeight(),
getRect().getWidth() - 2,
llfloor(getRect().getHeight() - font->getLineHeight() - ICON_PAD),
llfloor(getRect().getHeight() - mItemHeight),
bg_color, filled);
if (mIsCurSelection)
{
@ -893,14 +894,14 @@ void LLFolderViewItem::draw()
0,
getRect().getHeight(),
getRect().getWidth() - 2,
llfloor(getRect().getHeight() - font->getLineHeight() - ICON_PAD),
llfloor(getRect().getHeight() - mItemHeight),
sHighlightFgColor, FALSE);
}
if (getRect().getHeight() > llround(font->getLineHeight()) + ICON_PAD + 4)
if (getRect().getHeight() > mItemHeight + 4)
{
gl_rect_2d(
0,
llfloor(getRect().getHeight() - font->getLineHeight() - ICON_PAD) - 4,
llfloor(getRect().getHeight() - mItemHeight) - 4,
getRect().getWidth() - 2,
2,
sHighlightFgColor, FALSE);
@ -908,7 +909,7 @@ void LLFolderViewItem::draw()
{
gl_rect_2d(
0,
llfloor(getRect().getHeight() - font->getLineHeight() - ICON_PAD) - 4,
llfloor(getRect().getHeight() - mItemHeight) - 4,
getRect().getWidth() - 2,
2,
sHighlightBgColor, TRUE);
@ -963,7 +964,8 @@ void LLFolderViewItem::draw()
}
LLColor4 filter_color = mLastFilterGeneration >= getRoot()->getFilter()->getCurrentGeneration() ? LLColor4(0.5f, 0.8f, 0.5f, 1.f) : LLColor4(0.8f, 0.5f, 0.5f, 1.f);
sSmallFont->renderUTF8(mStatusText, 0, text_left, y, filter_color,
LLFontGL::getFontMonospace()->renderUTF8(
mStatusText, 0, text_left, y, filter_color,
LLFontGL::LEFT, LLFontGL::BOTTOM, LLFontGL::NORMAL, LLFontGL::NO_SHADOW,
S32_MAX, S32_MAX, &right_x, FALSE );
text_left = right_x;
@ -1004,7 +1006,7 @@ void LLFolderViewItem::draw()
S32_MAX, S32_MAX, &right_x, FALSE );
}
if (sBoxImage.notNull() && mStringMatchOffset != std::string::npos)
if (mStringMatchOffset != std::string::npos)
{
// don't draw backgrounds for zero-length strings
S32 filter_string_length = getRoot()->getFilterSubString().size();
@ -1015,9 +1017,10 @@ void LLFolderViewItem::draw()
S32 right = left + font->getWidth(combined_string, mStringMatchOffset, filter_string_length) + 2;
S32 bottom = llfloor(getRect().getHeight() - font->getLineHeight() - 3);
S32 top = getRect().getHeight();
LLUIImage* box_image = default_params.selection_image;
LLRect box_rect(left, top, right, bottom);
sBoxImage->draw(box_rect, sFilterBGColor);
box_image->draw(box_rect, sFilterBGColor);
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,

View File

@ -101,7 +101,10 @@ public:
Optional<LLFolderViewEventListener*> listener;
Optional<LLUIImage*> folder_arrow_image;
Optional<S32> folder_indentation; // pixels
Optional<LLUIImage*> selection_image;
Optional<const LLFontGL*> font;
Optional<S32> item_height; // pixels
Optional<S32> creation_date; //UTC seconds
@ -110,7 +113,7 @@ public:
// layout constants
static const S32 LEFT_PAD = 5;
// LEFT_INDENTATION is set via settings.xml FolderIndentation
// LEFT_INDENTATION is set via folder_indentation above
static const S32 ICON_PAD = 2;
static const S32 ICON_WIDTH = 16;
static const S32 TEXT_PAD = 1;
@ -127,11 +130,7 @@ protected:
friend class LLUICtrlFactory;
friend class LLFolderViewEventListener;
LLFolderViewItem(Params p = LLFolderViewItem::Params());
static const LLFontGL* sSmallFont;
static LLUIImagePtr sArrowImage;
static LLUIImagePtr sBoxImage;
LLFolderViewItem(const Params& p);
std::string mLabel;
std::string mSearchableLabel;
@ -150,6 +149,7 @@ protected:
LLUIImagePtr mIconOpen;
BOOL mHasVisibleChildren;
S32 mIndentation;
S32 mItemHeight;
S32 mNumDescendantsSelected;
BOOL mPassedFilter;
S32 mLastFilterGeneration;
@ -157,8 +157,6 @@ protected:
F32 mControlLabelRotation;
LLFolderView* mRoot;
BOOL mDragAndDropTarget;
LLUIImagePtr mArrowImage;
LLUIImagePtr mBoxImage;
BOOL mIsLoading;
LLTimer mTimeSinceRequestStart;
bool mHidden;

View File

@ -287,7 +287,7 @@ void LLHUDText::renderText(BOOL for_select)
mOffsetY = lltrunc(mHeight * ((mVertAlignment == ALIGN_VERT_CENTER) ? 0.5f : 1.f));
// *TODO: cache this image
LLUIImagePtr imagep = LLUI::getUIImage("rounded_square.tga");
LLUIImagePtr imagep = LLUI::getUIImage("Rounded_Square");
// *TODO: make this a per-text setting
LLColor4 bg_color = LLUIColorTable::instance().getColor("BackgroundChatColor");

View File

@ -436,7 +436,7 @@ void LLManip::renderXYZ(const LLVector3 &vec)
glPushMatrix();
{
LLUIImagePtr imagep = LLUI::getUIImage("rounded_square.tga");
LLUIImagePtr imagep = LLUI::getUIImage("Rounded_Square");
gViewerWindow->setup2DRender();
const LLVector2& display_scale = gViewerWindow->getDisplayScale();
glScalef(display_scale.mV[VX], display_scale.mV[VY], 1.f);

View File

@ -167,6 +167,7 @@ with the same filename but different name
<texture name="Flag" file_name="navbar/Flag.png" preload="false" />
<texture name="Folder_Arrow" file_name="folder_arrow.tga" preload="false" />
<texture name="ForSale_Badge" file_name="icons/ForSale_Badge.png" preload="false" />
<texture name="ForwardArrow_Off" file_name="icons/ForwardArrow_Off.png" preload="false" />
<texture name="ForwardArrow_Press" file_name="icons/ForwardArrow_Press.png" preload="false" />
@ -439,6 +440,7 @@ with the same filename but different name
<texture name="Resize_Corner" file_name="windows/Resize_Corner.png" preload="true" />
<texture name="Rounded_Square" file_name="rounded_square.j2c" preload="true" scale.left="16" scale.top="16" scale.right="112" scale.bottom="16" />
<texture name="Row_Selection" file_name="navbar/Row_Selection.png" preload="false" />
<texture name="ScrollArrow_Down" file_name="widgets/ScrollArrow_Down.png" preload="true" scale.left="2" scale.top="13" scale.right="13" scale.bottom="2" />
@ -676,7 +678,6 @@ with the same filename but different name
<texture name="toggle_button_selected" file_name="toggle_button_selected.png" preload="true" />
<texture name="sm_rounded_corners_simple.tga" scale.left="4" scale.top="4" scale.bottom="4" scale.right="4" />
<texture name="rounded_square.tga" file_name="rounded_square.j2c" preload="true" scale.left="16" scale.top="16" scale.right="112" scale.bottom="16" />
<texture name="color_swatch_alpha.tga" preload="true" />
<texture name="button_anim_pause.tga" />

View File

@ -76,7 +76,7 @@
<icon
color="0.12 0.12 0.12 1"
height="14"
image_name="rounded_square.tga"
image_name="Rounded_Square"
layout="topleft"
left="128"
name="LowGraphicsDivet"
@ -85,7 +85,7 @@
<icon
color="0.12 0.12 0.12 1"
height="14"
image_name="rounded_square.tga"
image_name="Rounded_Square"
layout="topleft"
left_pad="83"
name="MidGraphicsDivet"
@ -94,7 +94,7 @@
<icon
color="0.12 0.12 0.12 1"
height="14"
image_name="rounded_square.tga"
image_name="Rounded_Square"
layout="topleft"
left_pad="85"
name="HighGraphicsDivet"
@ -103,7 +103,7 @@
<icon
color="0.12 0.12 0.12 1"
height="14"
image_name="rounded_square.tga"
image_name="Rounded_Square"
layout="topleft"
left_pad="83"
name="UltraGraphicsDivet"

View File

@ -54,7 +54,7 @@
color="LoginProgressBoxCenterColor"
follows="left|right|bottom|top"
height="250"
image_name="rounded_square.tga"
image_name="Rounded_Square"
layout="topleft"
left="0"
top="0"

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<folder_view_item
folder_arrow_image="Folder_Arrow"
folder_indentation="15"
font="SansSerifSmall"
item_height="30"
selection_image="Rounded_Square"
/>