summaryrefslogtreecommitdiff
path: root/indra/llui/llscrolllistctrl.cpp
diff options
context:
space:
mode:
authorJosh Bell <josh@lindenlab.com>2007-02-20 22:02:36 +0000
committerJosh Bell <josh@lindenlab.com>2007-02-20 22:02:36 +0000
commit7dada07dbaae3dfb9b1319453e51019bfff2717f (patch)
treea7f2b84ea65c39cee31474640dd5f265c0b2f432 /indra/llui/llscrolllistctrl.cpp
parent73bc0fb42b5bcd80030d9f30d5cb57ec2397ba08 (diff)
svn merge -r 57620:58007 svn+ssh://svn.lindenlab.com/svn/linden/branches/maintenance
Diffstat (limited to 'indra/llui/llscrolllistctrl.cpp')
-rw-r--r--indra/llui/llscrolllistctrl.cpp67
1 files changed, 44 insertions, 23 deletions
diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp
index 2b7cbe5cef..c168bbe5a8 100644
--- a/indra/llui/llscrolllistctrl.cpp
+++ b/indra/llui/llscrolllistctrl.cpp
@@ -137,10 +137,11 @@ BOOL LLScrollListCheck::handleClick()
//
U32 LLScrollListText::sCount = 0;
-LLScrollListText::LLScrollListText( const LLString& text, const LLFontGL* font, S32 width, U8 font_style, LLColor4& color, BOOL use_color, BOOL visible)
+LLScrollListText::LLScrollListText( const LLString& text, const LLFontGL* font, S32 width, U8 font_style, LLFontGL::HAlign font_alignment, LLColor4& color, BOOL use_color, BOOL visible)
: mText( text ),
mFont( font ),
mFontStyle( font_style ),
+ mFontAlignment( font_alignment ),
mWidth( width ),
mVisible( visible ),
mHighlightCount( 0 ),
@@ -163,10 +164,6 @@ LLScrollListText::LLScrollListText( const LLString& text, const LLFontGL* font,
{
mRoundedRectImage = LLUI::sImageProvider->getUIImageByID(LLUUID(LLUI::sAssetsGroup->getString("rounded_square.tga")));
}
-
- // Yes, that's four dots, because we want it to have a little
- // padding, in proportion to the font size.
- mEllipsisWidth = (S32)mFont->getWidth("....");
}
LLScrollListText::~LLScrollListText()
@@ -202,7 +199,19 @@ void LLScrollListText::drawToWidth(S32 width, const LLColor4& color, const LLCol
{
mRoundedRectImage->bind();
glColor4fv(highlight_color.mV);
- S32 left = mFont->getWidth(mText.getString(), 0, mHighlightOffset);
+ S32 left = 0;
+ switch(mFontAlignment)
+ {
+ case LLFontGL::LEFT:
+ left = mFont->getWidth(mText.getString(), 0, mHighlightOffset);
+ break;
+ case LLFontGL::RIGHT:
+ left = width - mFont->getWidth(mText.getString(), mHighlightOffset, S32_MAX);
+ break;
+ case LLFontGL::HCENTER:
+ left = (width - mFont->getWidth(mText.getString())) / 2;
+ break;
+ }
gl_segmented_rect_2d_tex(left - 2,
llround(mFont->getLineHeight()) + 1,
left + mFont->getWidth(mText.getString(), mHighlightOffset, mHighlightCount) + 1,
@@ -215,21 +224,28 @@ void LLScrollListText::drawToWidth(S32 width, const LLColor4& color, const LLCol
// Try to draw the entire string
F32 right_x;
U32 string_chars = mText.length();
- U32 drawn_chars = mFont->render(mText.getWString(), 0, 0, 2,
- *display_color,
- LLFontGL::LEFT,
- LLFontGL::BOTTOM,
- mFontStyle,
- string_chars,
- width - mEllipsisWidth,
- &right_x, FALSE);
-
- // If we didn't get the whole string, abbreviate
- if (drawn_chars < string_chars && drawn_chars)
- {
- mFont->renderUTF8("...", 0, right_x, 0.f, color, LLFontGL::LEFT, LLFontGL::BOTTOM, mFontStyle,
- S32_MAX, S32_MAX, NULL, FALSE);
- }
+ F32 start_x = 0.f;
+ switch(mFontAlignment)
+ {
+ case LLFontGL::LEFT:
+ start_x = 0.f;
+ break;
+ case LLFontGL::RIGHT:
+ start_x = (F32)width;
+ break;
+ case LLFontGL::HCENTER:
+ start_x = (F32)width * 0.5f;
+ break;
+ }
+ mFont->render(mText.getWString(), 0,
+ start_x, 2.f,
+ *display_color,
+ mFontAlignment,
+ LLFontGL::BOTTOM,
+ mFontStyle,
+ string_chars,
+ width,
+ &right_x, FALSE, TRUE);
}
@@ -2171,7 +2187,7 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac
NULL,
multi_select,
draw_border);
-
+
scroll_list->setDisplayHeading(draw_heading);
if (node->hasAttribute("heading_height"))
{
@@ -2226,6 +2242,8 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac
F32 columnrelwidth = 0.f;
child->getAttributeF32("relwidth", columnrelwidth);
+ LLFontGL::HAlign h_align = LLFontGL::LEFT;
+ h_align = LLView::selectFontHAlign(child);
columns[index]["name"] = columnname;
columns[index]["sort"] = sortname;
@@ -2234,6 +2252,7 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac
columns[index]["width"] = columnwidth;
columns[index]["relwidth"] = columnrelwidth;
columns[index]["dynamicwidth"] = columndynamicwidth;
+ columns[index]["halign"] = (S32)h_align;
index++;
}
}
@@ -2580,6 +2599,7 @@ LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& value, EAddPosition p
S32 index = column_itor->second.mIndex;
S32 width = column_itor->second.mWidth;
+ LLFontGL::HAlign font_alignment = column_itor->second.mFontAlignment;
LLSD value = (*itor)["value"];
LLString fontname = (*itor)["font"].asString();
@@ -2607,7 +2627,7 @@ LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& value, EAddPosition p
}
else
{
- new_item->setColumn(index, new LLScrollListText(value.asString(), font, width, font_style));
+ new_item->setColumn(index, new LLScrollListText(value.asString(), font, width, font_style, font_alignment));
}
}
@@ -2715,3 +2735,4 @@ void LLScrollListCtrl::onFocusLost()
}
}
}
+