Scroll List Classes Params

Params for LLScrollListCell, LLScrollListItem, and LLScrollListColumn
Moves code block for creating a LLScrollListCell out of LLScrollListCtrl::fromXML and into LLScrollListCell::create
Removes mDefaultListTextColor from LLScrollListCtrl, it is now used only in LLScrollListCell::create
Adds LLScrollListCtrl::addRow and LLScrollListCtrl::addColumn functions that take these Params
Separators are now built from an icon.. we may want to tweak it in the future, looks alright though

LLFloaterAvatarList::refreshAvatarList now builds elements with these Params instead of by LLSD
This commit is contained in:
Lirusaito
2013-07-16 09:33:26 -04:00
parent af15010c79
commit 1b734e190c
10 changed files with 487 additions and 352 deletions

View File

@@ -30,11 +30,44 @@
#include "llscrolllistcell.h" #include "llscrolllistcell.h"
#include "llcheckboxctrl.h" #include "llcheckboxctrl.h"
#include "llresmgr.h"
//static
LLScrollListCell* LLScrollListCell::create(LLScrollListCell::Params cell_p)
{
LLScrollListCell* cell = NULL;
if (cell_p.type() == "icon")
{
cell = new LLScrollListIcon(cell_p);
}
else if (cell_p.type() == "checkbox")
{
cell = new LLScrollListCheck(cell_p);
}
else if (cell_p.type() == "date")
{
if (!cell_p.color.isProvided()) cell_p.color = LLUI::sColorsGroup->getColor("DefaultListText");
cell = new LLScrollListDate(cell_p);
}
else // default is "text"
{
if (!cell_p.color.isProvided()) cell_p.color = LLUI::sColorsGroup->getColor("DefaultListText");
cell = new LLScrollListText(cell_p);
}
if (cell_p.value.isProvided())
{
cell->setValue(cell_p.value);
}
return cell;
}
LLScrollListCell::LLScrollListCell(S32 width) LLScrollListCell::LLScrollListCell(const LLScrollListCell::Params& p)
: mWidth(width), : mWidth(p.width),
mToolTip() mToolTip(p.tool_tip)
{} {}
// virtual // virtual
@@ -46,14 +79,15 @@ const LLSD LLScrollListCell::getValue() const
// //
// LLScrollListIcon // LLScrollListIcon
// //
LLScrollListIcon::LLScrollListIcon(const LLSD& value, S32 width) LLScrollListIcon::LLScrollListIcon(const LLScrollListCell::Params& p)
: LLScrollListCell(width), : LLScrollListCell(p),
// <edit> // <edit>
mCallback(NULL), mCallback(NULL),
// </edit> // </edit>
mColor(LLColor4::white) mColor(p.color),
mAlignment(p.font_halign)
{ {
setValue(value); setValue(p.value().asString());
} }
LLScrollListIcon::~LLScrollListIcon() LLScrollListIcon::~LLScrollListIcon()
@@ -115,7 +149,20 @@ void LLScrollListIcon::draw(const LLColor4& color, const LLColor4& highlight_col
{ {
if (mIcon) if (mIcon)
{ {
mIcon->draw(0, 0, mColor); switch(mAlignment)
{
case LLFontGL::LEFT:
mIcon->draw(0, 0, mColor);
break;
case LLFontGL::RIGHT:
mIcon->draw(getWidth() - mIcon->getWidth(), 0, mColor);
break;
case LLFontGL::HCENTER:
mIcon->draw((getWidth() - mIcon->getWidth()) / 2, 0, mColor);
break;
default:
break;
}
} }
} }
@@ -124,15 +171,15 @@ void LLScrollListIcon::draw(const LLColor4& color, const LLColor4& highlight_col
// //
U32 LLScrollListText::sCount = 0; U32 LLScrollListText::sCount = 0;
LLScrollListText::LLScrollListText(const std::string& text, const LLFontGL* font, S32 width, U8 font_style, LLFontGL::HAlign font_alignment, LLColor4& color, BOOL use_color, BOOL visible) LLScrollListText::LLScrollListText(const LLScrollListCell::Params& p)
: LLScrollListCell(width), : LLScrollListCell(p),
mText(text), mText(p.value().asString()),
mFont(font), mFont(p.font.isProvided() ? LLResMgr::getInstance()->getRes(p.font) : LLFontGL::getFontSansSerifSmall()),
mColor(color), mColor(p.color),
mUseColor(use_color), mUseColor(p.color.isProvided()),
mFontStyle(font_style), mFontStyle(LLFontGL::getStyleFromString(p.font_style)),
mFontAlignment(font_alignment), mFontAlignment(p.font_halign),
mVisible(visible), mVisible(p.visible),
mHighlightCount( 0 ), mHighlightCount( 0 ),
mHighlightOffset( 0 ) mHighlightOffset( 0 )
{ {
@@ -302,22 +349,25 @@ void LLScrollListText::draw(const LLColor4& color, const LLColor4& highlight_col
// //
// LLScrollListCheck // LLScrollListCheck
// //
LLScrollListCheck::LLScrollListCheck(LLCheckBoxCtrl* check_box, S32 width) LLScrollListCheck::LLScrollListCheck(const LLScrollListCell::Params& p)
: LLScrollListCell(width) : LLScrollListCell(p)
{ {
mCheckBox = check_box; mCheckBox = new LLCheckBoxCtrl("checkbox", LLRect(0, p.width, p.width, 0), "", NULL, NULL, p.value());
mCheckBox->setEnabled(p.enabled);
LLRect rect(mCheckBox->getRect()); LLRect rect(mCheckBox->getRect());
if (width) if (p.width)
{ {
rect.mRight = rect.mLeft + width; rect.mRight = rect.mLeft + p.width;
mCheckBox->setRect(rect); mCheckBox->setRect(rect);
setWidth(width); setWidth(p.width);
} }
else else
{ {
setWidth(rect.getWidth()); //check_box->getWidth(); setWidth(rect.getWidth()); //check_box->getWidth();
} }
mCheckBox->setColor(p.color);
} }
@@ -370,9 +420,9 @@ void LLScrollListCheck::setEnabled(BOOL enable)
// LLScrollListDate // LLScrollListDate
// //
LLScrollListDate::LLScrollListDate( const LLDate& date, const LLFontGL* font, S32 width, U8 font_style, LLFontGL::HAlign font_alignment, LLColor4& color, BOOL use_color, BOOL visible) LLScrollListDate::LLScrollListDate( const LLScrollListCell::Params& p)
: LLScrollListText(date.asRFC1123(), font, width, font_style, font_alignment, color, use_color, visible), : LLScrollListText(p),
mDate(date) mDate(p.value().asDate())
{} {}
void LLScrollListDate::setValue(const LLSD& value) void LLScrollListDate::setValue(const LLSD& value)

View File

@@ -33,6 +33,7 @@
#include "lluistring.h" #include "lluistring.h"
#include "v4color.h" #include "v4color.h"
#include "llui.h" #include "llui.h"
#include "llinitparam.h"
class LLCheckBoxCtrl; class LLCheckBoxCtrl;
class LLSD; class LLSD;
@@ -48,7 +49,48 @@ class LLSD;
class LLScrollListCell class LLScrollListCell
{ {
public: public:
LLScrollListCell(S32 width = 0); struct Params : public LLInitParam::Block<Params>
{
Optional<std::string> type,
column;
Optional<S32> width;
Optional<bool> enabled,
visible;
Optional<void*> userdata;
Optional<LLSD> value;
Optional<std::string> tool_tip;
Optional<std::string> font;
Optional<LLColor4> font_color;
Optional<LLFontGL::HAlign> font_halign;
Optional<std::string> font_style;
Optional<LLColor4> color;
Params()
: type("type", "text"),
column("column"),
width("width"),
enabled("enabled", true),
visible("visible", true),
value("value"),
tool_tip("tool_tip", ""),
font("font"/*, LLFontGL::getFontSansSerifSmall()*/),
font_color("font_color", LLColor4::black),
font_style("font-style"),
color("color", LLColor4::white),
font_halign("halign", LLFontGL::LEFT)
{
addSynonym(column, "name");
addSynonym(font_color, "font-color");
}
};
static LLScrollListCell* create(Params);
LLScrollListCell(const LLScrollListCell::Params&);
virtual ~LLScrollListCell() {}; virtual ~LLScrollListCell() {};
virtual void draw(const LLColor4& color, const LLColor4& highlight_color) const {}; // truncate to given width, if possible virtual void draw(const LLColor4& color, const LLColor4& highlight_color) const {}; // truncate to given width, if possible
@@ -74,6 +116,13 @@ private:
S32 mWidth; S32 mWidth;
std::string mToolTip; std::string mToolTip;
}; };
class LLScrollListSpacer : public LLScrollListCell
{
public:
LLScrollListSpacer(const LLScrollListCell::Params& p) : LLScrollListCell(p) {}
/*virtual*/ ~LLScrollListSpacer() {};
/*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const {}
}; };
/* /*
@@ -82,7 +131,7 @@ private:
class LLScrollListText : public LLScrollListCell class LLScrollListText : public LLScrollListCell
{ {
public: public:
LLScrollListText(const std::string& text, const LLFontGL* font, S32 width = 0, U8 font_style = LLFontGL::NORMAL, LLFontGL::HAlign font_alignment = LLFontGL::LEFT, LLColor4& color = LLColor4::black, BOOL use_color = FALSE, BOOL visible = TRUE); LLScrollListText(const LLScrollListCell::Params&);
/*virtual*/ ~LLScrollListText(); /*virtual*/ ~LLScrollListText();
/*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const; /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const;
@@ -128,8 +177,7 @@ private:
class LLScrollListIcon : public LLScrollListCell class LLScrollListIcon : public LLScrollListCell
{ {
public: public:
LLScrollListIcon( LLUIImagePtr icon, S32 width = 0); LLScrollListIcon(const LLScrollListCell::Params& p);
LLScrollListIcon(const LLSD& value, S32 width = 0);
/*virtual*/ ~LLScrollListIcon(); /*virtual*/ ~LLScrollListIcon();
/*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const; /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const;
/*virtual*/ S32 getWidth() const; /*virtual*/ S32 getWidth() const;
@@ -145,6 +193,7 @@ public:
private: private:
LLPointer<LLUIImage> mIcon; LLPointer<LLUIImage> mIcon;
LLColor4 mColor; LLColor4 mColor;
LLFontGL::HAlign mAlignment;
// <edit> // <edit>
boost::function<bool (void)> mCallback; boost::function<bool (void)> mCallback;
// </edit> // </edit>
@@ -156,7 +205,7 @@ private:
class LLScrollListCheck : public LLScrollListCell class LLScrollListCheck : public LLScrollListCell
{ {
public: public:
LLScrollListCheck( LLCheckBoxCtrl* check_box, S32 width = 0); LLScrollListCheck( const LLScrollListCell::Params&);
/*virtual*/ ~LLScrollListCheck(); /*virtual*/ ~LLScrollListCheck();
/*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const; /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const;
/*virtual*/ S32 getHeight() const { return 0; } /*virtual*/ S32 getHeight() const { return 0; }
@@ -176,7 +225,7 @@ private:
class LLScrollListDate : public LLScrollListText class LLScrollListDate : public LLScrollListText
{ {
public: public:
LLScrollListDate( const LLDate& date, const LLFontGL* font, S32 width=0, U8 font_style = LLFontGL::NORMAL, LLFontGL::HAlign font_alignment = LLFontGL::LEFT, LLColor4& color = LLColor4::black, BOOL use_color = FALSE, BOOL visible = TRUE); LLScrollListDate( const LLScrollListCell::Params& p );
virtual void setValue(const LLSD& value); virtual void setValue(const LLSD& value);
virtual const LLSD getValue() const; virtual const LLSD getValue() const;

View File

@@ -294,52 +294,46 @@ BOOL LLScrollColumnHeader::canResize()
return getVisible() && (mHasResizableElement || mColumn->mDynamicWidth); return getVisible() && (mHasResizableElement || mColumn->mDynamicWidth);
} }
void LLScrollListColumn::SortNames::declareValues()
{
declare("ascending", LLScrollListColumn::ASCENDING);
declare("descending", LLScrollListColumn::DESCENDING);
}
// //
// LLScrollListColumn // LLScrollListColumn
// //
// Default constructor /* Singu TODO: LLUICtrlFactory::getDefaultParams
LLScrollListColumn::LLScrollListColumn() : mName(), mSortingColumn(), mSortDirection(ASCENDING), mLabel(), mWidth(-1), mRelWidth(-1.0), mDynamicWidth(false), mMaxContentWidth(0), mIndex(-1), mParentCtrl(NULL), mHeader(NULL), mFontAlignment(LLFontGL::LEFT) //static
const LLScrollListColumn::Params& LLScrollListColumn::getDefaultParams()
{ {
} return LLUICtrlFactory::getDefaultParams<LLScrollListColumn>();
}*/
LLScrollListColumn::LLScrollListColumn(const LLSD& sd, LLScrollListCtrl* parent) LLScrollListColumn::LLScrollListColumn(const Params& p, LLScrollListCtrl* parent)
: mWidth(0), : mWidth(0),
mIndex (-1), mIndex (-1),
mParentCtrl(parent), mParentCtrl(parent),
mName(sd.get("name").asString()), mName(p.name),
mLabel(sd.get("label").asString()), mLabel(p.header.label),
mHeader(NULL), mHeader(NULL),
mMaxContentWidth(0), mMaxContentWidth(0),
mDynamicWidth(sd.has("dynamicwidth") && sd.get("dynamicwidth").asBoolean()), mDynamicWidth(p.width.dynamic_width),
mRelWidth(-1.f), mRelWidth(p.width.relative_width),
mFontAlignment(LLFontGL::LEFT), mFontAlignment(p.halign),
mSortingColumn(sd.has("sort") ? sd.get("sort").asString() : mName) mSortingColumn(p.sort_column)
{ {
if (sd.has("sort_ascending")) if (p.sort_ascending.isProvided())
{ {
mSortDirection = sd.get("sort_ascending").asBoolean() ? ASCENDING : DESCENDING; mSortDirection = p.sort_ascending() ? ASCENDING : DESCENDING;
} }
else else
{ {
mSortDirection = ASCENDING; mSortDirection = p.sort_direction;
} }
if (sd.has("relwidth") && sd.get("relwidth").asFloat() > 0) setWidth(p.width.pixel_width);
{
mRelWidth = sd.get("relwidth").asFloat();
if (mRelWidth > 1) mRelWidth = 1;
mDynamicWidth = false;
}
else if (!mDynamicWidth)
{
setWidth(sd.get("width").asInteger());
}
if (sd.has("halign"))
{
mFontAlignment = (LLFontGL::HAlign)llclamp(sd.get("halign").asInteger(), (S32)LLFontGL::LEFT, (S32)LLFontGL::HCENTER);
}
} }
void LLScrollListColumn::setWidth(S32 width) void LLScrollListColumn::setWidth(S32 width)

View File

@@ -31,6 +31,7 @@
#include "llrect.h" #include "llrect.h"
#include "lluistring.h" #include "lluistring.h"
#include "llbutton.h" #include "llbutton.h"
#include "llinitparam.h"
class LLScrollListColumn; class LLScrollListColumn;
class LLResizeBar; class LLResizeBar;
@@ -75,9 +76,73 @@ public:
ASCENDING ASCENDING
} ESortDirection; } ESortDirection;
struct SortNames
: public LLInitParam::TypeValuesHelper<LLScrollListColumn::ESortDirection, SortNames>
{
static void declareValues();
};
struct Params : public LLInitParam::Block<Params>
{
Optional<std::string> name,
tool_tip;
Optional<std::string> sort_column;
Optional<ESortDirection, SortNames> sort_direction;
Optional<bool> sort_ascending;
struct Width : public LLInitParam::ChoiceBlock<Width>
{
Alternative<bool> dynamic_width;
Alternative<S32> pixel_width;
Alternative<F32> relative_width;
Width()
: dynamic_width("dynamic_width", false),
pixel_width("width"),
relative_width("relative_width", -1.f)
{
addSynonym(dynamic_width, "dynamicwidth"); // Singu TODO: deprecate and remove
addSynonym(relative_width, "relwidth");
}
};
Optional<Width> width;
// either an image or label is used in column header
struct Header : public LLInitParam::ChoiceBlock<Header>
{
Alternative<std::string> label;
Alternative<std::string> image_overlay;
Alternative<std::string> image;
Header()
: label("label"),
image_overlay("image_overlay"),
image("image")
{}
};
Optional<Header> header;
Optional<LLFontGL::HAlign> halign;
Params()
: name("name"),
tool_tip("tool_tip"),
sort_column("sort_column"),
sort_direction("sort_direction"),
sort_ascending("sort_ascending", true),
halign("halign", LLFontGL::LEFT)
{
// default choice to "dynamic_width"
changeDefault(width.dynamic_width, true);
addSynonym(sort_column, "sort");
}
};
//static const Params& getDefaultParams();
//NOTE: this is default constructible so we can store it in a map. //NOTE: this is default constructible so we can store it in a map.
LLScrollListColumn(); LLScrollListColumn(const Params& p = Params(), LLScrollListCtrl* = NULL);
LLScrollListColumn(const LLSD& sd, LLScrollListCtrl* parent = NULL);
void setWidth(S32 width); void setWidth(S32 width);
S32 getWidth() const { return mWidth; } S32 getWidth() const { return mWidth; }

View File

@@ -51,6 +51,7 @@
#include "llwindow.h" #include "llwindow.h"
#include "llcontrol.h" #include "llcontrol.h"
#include "llkeyboard.h" #include "llkeyboard.h"
#include "llsdparam.h"
static LLRegisterWidget<LLScrollListCtrl> r("scroll_list"); static LLRegisterWidget<LLScrollListCtrl> r("scroll_list");
@@ -103,65 +104,6 @@ struct SortScrollListItem
const sort_order_t& mSortOrders; const sort_order_t& mSortOrders;
}; };
//Singu TODO: Get rid of these in favor of making separators out of normal LLScrollListItems like LL
//
// LLScrollListSeparator
//
/*
* Draws a horizontal line.
*/
class LLScrollListSeparator : public LLScrollListCell
{
public:
LLScrollListSeparator(S32 width) : LLScrollListCell(width) {}
virtual ~LLScrollListSeparator() {};
virtual void draw(const LLColor4& color, const LLColor4& highlight_color) const
{
// *FIXME: use dynamic item heights and make separators narrow, and inactive
gl_line_2d(5, 8, llmax(5, getWidth() - 5), 8, color);
}
virtual S32 getHeight() const { return 5; };
virtual BOOL isText() const { return FALSE; }
};
//---------------------------------------------------------------------------
// LLScrollListItemSeparator
//---------------------------------------------------------------------------
class LLScrollListItemSeparator : public LLScrollListItem
{
public:
LLScrollListItemSeparator() : LLScrollListItem(false)
{
LLScrollListSeparator* cell = new LLScrollListSeparator(0);
setNumColumns(1);
setColumn(0, cell);
}
/*virtual*/ void draw(const LLRect& rect, const LLColor4& fg_color, const LLColor4& bg_color, const LLColor4& highlight_color, S32 column_padding)
{
//TODO* move LLScrollListSeparator::draw into here and get rid of it
LLScrollListCell* cell = getColumn(0);
if (cell)
{
// Two ways a cell could be hidden
if (cell->getWidth() < 0
|| !cell->getVisible()) return;
LLUI::pushMatrix();
{
LLUI::translate((F32)rect.mLeft, (F32)rect.mBottom, 0.0f);
// force first cell to be width of entire item
cell->setWidth(rect.getWidth());
cell->draw( fg_color, highlight_color );
}
LLUI::popMatrix();
}
}
};
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// LLScrollListCtrl // LLScrollListCtrl
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@@ -182,7 +124,6 @@ LLScrollListCtrl::LLScrollListCtrl(const std::string& name, const LLRect& rect,
mColumnsDirty(false), mColumnsDirty(false),
mMaxItemCount(INT_MAX), mMaxItemCount(INT_MAX),
mMaxContentWidth(0), mMaxContentWidth(0),
mDefaultListTextColor(LLUI::sColorsGroup->getColor("DefaultListText")),
mBorderThickness( 2 ), mBorderThickness( 2 ),
mOnDoubleClickCallback( NULL ), mOnDoubleClickCallback( NULL ),
mOnMaximumSelectCallback( NULL ), mOnMaximumSelectCallback( NULL ),
@@ -583,11 +524,11 @@ BOOL LLScrollListCtrl::addItem( LLScrollListItem* item, EAddPosition pos, BOOL r
// create new column on demand // create new column on demand
if (mColumns.empty() && requires_column) if (mColumns.empty() && requires_column)
{ {
LLSD new_column; LLScrollListColumn::Params col_params;
new_column["name"] = "default_column"; col_params.name = "default_column";
new_column["label"] = ""; col_params.header.label = "";
new_column["dynamicwidth"] = TRUE; col_params.width.dynamic_width = true;
addColumn(new_column); addColumn(col_params);
} }
S32 num_cols = item->getNumColumns(); S32 num_cols = item->getNumColumns();
@@ -1182,13 +1123,20 @@ void LLScrollListCtrl::setCommentText(const std::string& comment_text)
LLScrollListItem* LLScrollListCtrl::addSeparator(EAddPosition pos) LLScrollListItem* LLScrollListCtrl::addSeparator(EAddPosition pos)
{ {
LLScrollListItem* item = new LLScrollListItemSeparator(); LLScrollListItem::Params separator_params;
addItem(item, pos, FALSE); separator_params.enabled(false);
return item; LLScrollListCell::Params column_params;
column_params.type = "icon";
column_params.value = "menu_separator.png";
column_params.color = LLColor4(0.f, 0.f, 0.f, 0.7f);
column_params.font_halign = LLFontGL::HCENTER;
separator_params.columns.add(column_params);
return addRow( separator_params, pos );
} }
// Selects first enabled item of the given name. // Selects first enabled item of the given name.
// Returns false if item not found. // Returns false if item not found.
// Calls getItemByLabel in order to combine functionality
BOOL LLScrollListCtrl::selectItemByLabel(const std::string& label, BOOL case_sensitive) BOOL LLScrollListCtrl::selectItemByLabel(const std::string& label, BOOL case_sensitive)
{ {
deselectAllItems(TRUE); // ensure that no stale items are selected, even if we don't find a match deselectAllItems(TRUE); // ensure that no stale items are selected, even if we don't find a match
@@ -1339,14 +1287,16 @@ const std::string LLScrollListCtrl::getSelectedItemLabel(S32 column) const
LLScrollListItem* LLScrollListCtrl::addStringUUIDItem(const std::string& item_text, const LLUUID& id, EAddPosition pos, BOOL enabled) LLScrollListItem* LLScrollListCtrl::addStringUUIDItem(const std::string& item_text, const LLUUID& id, EAddPosition pos, BOOL enabled)
{ {
LLScrollListItem* item = NULL;
if (getItemCount() < mMaxItemCount) if (getItemCount() < mMaxItemCount)
{ {
item = new LLScrollListItem(enabled, id); LLScrollListItem::Params item_p;
item->addColumn(item_text, LLResMgr::getInstance()->getRes(LLFONT_SANSSERIF_SMALL), column_width); item_p.enabled(enabled);
addItem( item, pos ); item_p.value(id);
item_p.columns.add().value(item_text).type("text");
return addRow( item_p, pos );
} }
return item; return NULL;
} }
// Select the line or lines that match this UUID // Select the line or lines that match this UUID
@@ -2608,38 +2558,44 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac
if (child->hasName("column")) if (child->hasName("column"))
{ {
std::string labelname(""); std::string labelname("");
child->getAttributeString("label", labelname); if (child->getAttributeString("label", labelname))
std::string columnname(labelname); columns[index]["label"] = labelname;
child->getAttributeString("name", columnname); else if (child->getAttributeString("image", labelname))
std::string sortname(columnname); columns[index]["image"] = labelname;
child->getAttributeString("sort", sortname); else if (child->getAttributeString("image_overlay", labelname))
BOOL sort_ascending = true; columns[index]["image_overlay"] = labelname;
child->getAttributeBOOL("sort_ascending", sort_ascending);
std::string imagename;
child->getAttributeString("image", imagename);
std::string imageoverlay;
child->getAttributeString("image_overlay", imageoverlay);
BOOL columndynamicwidth = false;
child->getAttributeBOOL("dynamicwidth", columndynamicwidth);
S32 columnwidth = -1;
child->getAttributeS32("width", columnwidth);
std::string tooltip;
child->getAttributeString("tool_tip", tooltip);
F32 columnrelwidth = 0.f;
child->getAttributeF32("relwidth", columnrelwidth);
LLFontGL::HAlign h_align = LLView::selectFontHAlign(child);
columns[index]["name"] = columnname; std::string columnname(labelname);
columns[index]["sort"] = sortname; if (child->getAttributeString("name", columnname))
columns[index]["sort_ascending"] = sort_ascending; columns[index]["name"] = columnname;
columns[index]["image"] = imagename;
columns[index]["image_overlay"] = imageoverlay; std::string sortname(columnname);
columns[index]["label"] = labelname; if (child->getAttributeString("sort", sortname))
columns[index]["width"] = columnwidth; columns[index]["sort"] = sortname;
columns[index]["relwidth"] = columnrelwidth;
columns[index]["dynamicwidth"] = columndynamicwidth; BOOL sort_ascending = true;
if (child->getAttributeBOOL("sort_ascending", sort_ascending))
columns[index]["sort_ascending"] = sort_ascending;
S32 columnwidth = -1;
if (child->getAttributeS32("width", columnwidth))
columns[index]["width"] = columnwidth;
F32 columnrelwidth = 0.f;
if (child->getAttributeF32("relwidth", columnrelwidth))
columns[index]["relwidth"] = columnrelwidth;
BOOL columndynamicwidth = false;
if (child->getAttributeBOOL("dynamic_width", columndynamicwidth)
|| child->getAttributeBOOL("dynamicwidth", columndynamicwidth)) // Singu TODO: Deprecate "dynamicwidth"
columns[index]["dynamic_width"] = columndynamicwidth;
LLFontGL::HAlign h_align = LLView::selectFontHAlign(child);
columns[index]["halign"] = (S32)h_align; columns[index]["halign"] = (S32)h_align;
columns[index]["tool_tip"] = tooltip;
std::string tooltip;
if (child->getAttributeString("tool_tip", tooltip))
columns[index]["tool_tip"] = tooltip;
++index; ++index;
} }
} }
@@ -2671,18 +2627,20 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac
if (row_child->hasName("column")) if (row_child->hasName("column"))
{ {
std::string value = row_child->getTextContents(); std::string value = row_child->getTextContents();
row["columns"][column_idx]["value"] = value;
std::string columnname(""); std::string columnname("");
row_child->getAttributeString("name", columnname); if (row_child->getAttributeString("name", columnname))
std::string font(""); row["columns"][column_idx]["column"] = columnname;
row_child->getAttributeString("font", font);
std::string font_style(""); std::string font("");
row_child->getAttributeString("font-style", font_style); if (row_child->getAttributeString("font", font))
row["columns"][column_idx]["font"] = font;
std::string font_style("");
if (row_child->getAttributeString("font-style", font_style))
row["columns"][column_idx]["font-style"] = font_style;
row["columns"][column_idx]["column"] = columnname;
row["columns"][column_idx]["value"] = value;
row["columns"][column_idx]["font"] = font;
row["columns"][column_idx]["font-style"] = font_style;
++column_idx; ++column_idx;
explicit_column = true; explicit_column = true;
} }
@@ -2778,7 +2736,17 @@ BOOL LLScrollListCtrl::canDeselect() const
void LLScrollListCtrl::addColumn(const LLSD& column, EAddPosition pos) void LLScrollListCtrl::addColumn(const LLSD& column, EAddPosition pos)
{ {
std::string name = column["name"].asString(); LLScrollListColumn::Params p;
LLParamSDParser parser;
parser.readSD(column, p);
addColumn(p, pos);
}
void LLScrollListCtrl::addColumn(const LLScrollListColumn::Params& column_params, EAddPosition pos)
{
if (!column_params.validateBlock()) return;
std::string name = column_params.name;
// if no column name provided, just use ordinal as name // if no column name provided, just use ordinal as name
if (name.empty()) if (name.empty())
{ {
@@ -2788,9 +2756,8 @@ void LLScrollListCtrl::addColumn(const LLSD& column, EAddPosition pos)
if (mColumns.find(name) == mColumns.end()) if (mColumns.find(name) == mColumns.end())
{ {
// Add column // Add column
mColumns[name] = new LLScrollListColumn(column, this); mColumns[name] = new LLScrollListColumn(column_params, this);
LLScrollListColumn* new_column = mColumns[name]; LLScrollListColumn* new_column = mColumns[name];
new_column->mParentCtrl = this;
new_column->mIndex = mColumns.size()-1; new_column->mIndex = mColumns.size()-1;
// Add button // Add button
@@ -2832,21 +2799,21 @@ void LLScrollListCtrl::addColumn(const LLSD& column, EAddPosition pos)
LLRect temp_rect = LLRect(left,top+mHeadingHeight,right,top); LLRect temp_rect = LLRect(left,top+mHeadingHeight,right,top);
new_column->mHeader = new LLScrollColumnHeader("btn_" + name, temp_rect, new_column); new_column->mHeader = new LLScrollColumnHeader("btn_" + name, temp_rect, new_column);
new_column->mHeader->setToolTip(column["tool_tip"].asString()); new_column->mHeader->setToolTip(column_params.tool_tip());
new_column->mHeader->setTabStop(false); new_column->mHeader->setTabStop(false);
new_column->mHeader->setVisible(mDisplayColumnHeaders); new_column->mHeader->setVisible(mDisplayColumnHeaders);
if(!column["image"].asString().empty()) if(column_params.header.image.isProvided())
{ {
new_column->mHeader->setImages(column["image"].asString(), column["image"].asString()); new_column->mHeader->setImages(column_params.header.image, column_params.header.image);
} }
else if(!column["image_overlay"].asString().empty()) else if(column_params.header.image_overlay.isProvided())
{ {
new_column->mHeader->setImageOverlay(column["image_overlay"].asString()); new_column->mHeader->setImageOverlay(column_params.header.image_overlay);
} }
else else
{ {
new_column->mHeader->setLabel(new_column->mLabel.getString()); new_column->mHeader->setLabel(column_params.header.label());
} }
addChild(new_column->mHeader); addChild(new_column->mHeader);
@@ -2981,29 +2948,39 @@ void LLScrollListCtrl::setColumnHeadings(const LLSD& headings)
"width" "width"
"dynamic_width" "dynamic_width"
*/ */
LLFastTimer::DeclareTimer FTM_ADD_SCROLLLIST_ELEMENT("Add Scroll List Item");
LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& element, EAddPosition pos, void* userdata) LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& element, EAddPosition pos, void* userdata)
{ {
LLScrollListItem *new_item = new LLScrollListItem(!element.has("enabled") || element["enabled"].asBoolean(), element["id"], userdata); LLFastTimer _(FTM_ADD_SCROLLLIST_ELEMENT);
LLScrollListItem::Params item_params;
LLParamSDParser parser;
parser.readSD(element, item_params);
item_params.userdata = userdata;
return addRow(item_params, pos);
}
if (!new_item) return NULL; LLScrollListItem* LLScrollListCtrl::addRow(const LLScrollListItem::Params& item_p, EAddPosition pos)
{
LLFastTimer _(FTM_ADD_SCROLLLIST_ELEMENT);
LLScrollListItem *new_item = new LLScrollListItem(item_p);
return addRow(new_item, item_p, pos);
}
LLScrollListItem* LLScrollListCtrl::addRow(LLScrollListItem *new_item, const LLScrollListItem::Params& item_p, EAddPosition pos)
{
LLFastTimer _(FTM_ADD_SCROLLLIST_ELEMENT);
if (!item_p.validateBlock() || !new_item) return NULL;
new_item->setNumColumns(mColumns.size()); new_item->setNumColumns(mColumns.size());
// Add any columns we don't already have // Add any columns we don't already have
S32 col_index = 0; S32 col_index = 0;
LLSD columns = element["columns"]; for(LLInitParam::ParamIterator<LLScrollListCell::Params>::const_iterator itor = item_p.columns.begin();
for (LLSD::array_const_iterator itor = columns.beginArray(); itor != item_p.columns.end();
itor != columns.endArray();
++itor) ++itor)
{ {
if (itor->isUndefined()) LLScrollListCell::Params cell_p = *itor;
{ std::string column = cell_p.column;
// skip unused columns in item passed in
continue;
}
std::string column = (*itor)["column"].asString();
LLScrollListColumn* columnp = NULL;
// empty columns strings index by ordinal // empty columns strings index by ordinal
if (column.empty()) if (column.empty())
@@ -3011,27 +2988,20 @@ LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& element, EAddPosition
column = llformat("%d", col_index); column = llformat("%d", col_index);
} }
column_map_t::iterator column_itor = mColumns.find(column); LLScrollListColumn* columnp = getColumn(column);
if (column_itor != mColumns.end())
{
columnp = column_itor->second;
}
// create new column on demand // create new column on demand
if (!columnp) if (!columnp)
{ {
LLSD new_column; LLScrollListColumn::Params new_column;
new_column["name"] = column; new_column.name = column;
new_column["label"] = column; new_column.header.label = column;
// if width supplied for column, use it, otherwise // if width supplied for column, use it, otherwise
// use adaptive width // use adaptive width
if (itor->has("width")) if (cell_p.width.isProvided())
{ {
new_column["width"] = (*itor)["width"]; new_column.width.pixel_width = cell_p.width;
}
else
{
new_column["dynamicwidth"] = true;
} }
addColumn(new_column); addColumn(new_column);
columnp = mColumns[column]; columnp = mColumns[column];
@@ -3039,89 +3009,20 @@ LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& element, EAddPosition
} }
S32 index = columnp->mIndex; S32 index = columnp->mIndex;
S32 width = columnp->getWidth(); if (!cell_p.width.isProvided())
LLFontGL::HAlign font_alignment = columnp->mFontAlignment; {
LLColor4 fcolor = LLColor4::black; cell_p.width = columnp->getWidth();
}
cell_p.font_halign = columnp->mFontAlignment;
LLSD value = (*itor)["value"]; LLScrollListCell* cell = LLScrollListCell::create(cell_p);
std::string fontname = (*itor)["font"].asString();
std::string fontstyle = (*itor)["font-style"].asString();
std::string type = (*itor)["type"].asString();
if ((*itor).has("font-color")) if (cell)
{ {
LLSD sd_color = (*itor)["font-color"];
fcolor.setValue(sd_color);
}
BOOL has_color = (*itor).has("color");
LLColor4 color = ((*itor)["color"]);
BOOL enabled = !(*itor).has("enabled") || (*itor)["enabled"].asBoolean() == true;
const LLFontGL *font = LLResMgr::getInstance()->getRes(fontname);
if (!font)
{
font = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF_SMALL );
}
U8 font_style = LLFontGL::getStyleFromString(fontstyle);
if (type == "icon")
{
LLScrollListIcon* cell = new LLScrollListIcon(value, width);
if (has_color)
{
cell->setColor(color);
}
new_item->setColumn(index, cell); new_item->setColumn(index, cell);
} if (columnp->mHeader
else if (type == "checkbox") && cell->isText()
{ && !cell->getValue().asString().empty())
LLCheckBoxCtrl* ctrl = new LLCheckBoxCtrl(std::string("check"),
LLRect(0, width, width, 0), std::string(" "));
ctrl->setEnabled(enabled);
ctrl->setValue(value);
LLScrollListCheck* cell = new LLScrollListCheck(ctrl,width);
if (has_color)
{
cell->setColor(color);
}
new_item->setColumn(index, cell);
}
else if (type == "separator")
{
LLScrollListSeparator* cell = new LLScrollListSeparator(width);
if (has_color)
{
cell->setColor(color);
}
new_item->setColumn(index, cell);
}
else if (type == "date")
{
LLScrollListDate* cell = new LLScrollListDate(value.asDate(), font, width, font_style, font_alignment);
if (has_color)
{
cell->setColor(color);
}
new_item->setColumn(index, cell);
if (columnp->mHeader && !value.asString().empty())
{
columnp->mHeader->setHasResizableElement(TRUE);
}
}
else
{
LLScrollListText* cell = new LLScrollListText(value.asString(), font, width, font_style, font_alignment, fcolor, TRUE);
if (has_color)
{
cell->setColor(color);
}
else
{
cell->setColor(mDefaultListTextColor);
}
new_item->setColumn(index, cell);
if (columnp->mHeader && !value.asString().empty())
{ {
columnp->mHeader->setHasResizableElement(TRUE); columnp->mHeader->setHasResizableElement(TRUE);
} }
@@ -3130,6 +3031,32 @@ LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& element, EAddPosition
col_index++; col_index++;
} }
if (item_p.columns.empty())
{
if (mColumns.empty())
{
LLScrollListColumn::Params new_column;
new_column.name = "0";
addColumn(new_column);
new_item->setNumColumns(mColumns.size());
}
LLScrollListCell* cell = LLScrollListCell::create(LLScrollListCell::Params().value(item_p.value));
if (cell)
{
LLScrollListColumn* columnp = mColumns.begin()->second;
new_item->setColumn(0, cell);
if (columnp->mHeader
&& cell->isText()
&& !cell->getValue().asString().empty())
{
columnp->mHeader->setHasResizableElement(TRUE);
}
}
}
// add dummy cells for missing columns // add dummy cells for missing columns
for (column_map_t::iterator column_it = mColumns.begin(); column_it != mColumns.end(); ++column_it) for (column_map_t::iterator column_it = mColumns.begin(); column_it != mColumns.end(); ++column_it)
{ {
@@ -3137,7 +3064,10 @@ LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& element, EAddPosition
if (new_item->getColumn(column_idx) == NULL) if (new_item->getColumn(column_idx) == NULL)
{ {
LLScrollListColumn* column_ptr = column_it->second; LLScrollListColumn* column_ptr = column_it->second;
new_item->setColumn(column_idx, new LLScrollListText(LLStringUtil::null, LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF_SMALL ), column_ptr->getWidth(), LLFontGL::NORMAL)); LLScrollListCell::Params cell_p;
cell_p.width = column_ptr->getWidth();
new_item->setColumn(column_idx, new LLScrollListSpacer(cell_p));
} }
} }
@@ -3147,14 +3077,20 @@ LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& element, EAddPosition
LLScrollListItem* LLScrollListCtrl::addSimpleElement(const std::string& value, EAddPosition pos, const LLSD& id) LLScrollListItem* LLScrollListCtrl::addSimpleElement(const std::string& value, EAddPosition pos, const LLSD& id)
{ {
LLScrollListItem* new_item = new LLScrollListItem(true, id.isUndefined() ? LLSD(value) : id); LLSD entry_id = id;
const LLFontGL *font = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF_SMALL ); if (id.isUndefined())
{
entry_id = value;
}
new_item->addColumn(value, font, getRect().getWidth()); LLScrollListItem::Params item_params;
item_params.value(entry_id);
item_params.columns.add()
.value(value)
/*.font(LLFontGL::getFontSansSerifSmall())*/;
addItem(new_item, pos); return addRow(item_params, pos);
return new_item;
} }
void LLScrollListCtrl::setValue(const LLSD& value ) void LLScrollListCtrl::setValue(const LLSD& value )

View File

@@ -42,8 +42,8 @@
#include "llframetimer.h" #include "llframetimer.h"
#include "llscrollbar.h" #include "llscrollbar.h"
#include "llscrolllistitem.h"
class LLScrollListColumn; #include "llscrolllistcolumn.h"
class LLScrollListCtrl : public LLUICtrl, public LLEditMenuHandler, class LLScrollListCtrl : public LLUICtrl, public LLEditMenuHandler,
public LLCtrlListInterface, public LLCtrlScrollInterface public LLCtrlListInterface, public LLCtrlScrollInterface
@@ -95,6 +95,7 @@ public:
// LLCtrlListInterface functions // LLCtrlListInterface functions
virtual S32 getItemCount() const; virtual S32 getItemCount() const;
// Adds a single column descriptor: ["name" : string, "label" : string, "width" : integer, "relwidth" : integer ] // Adds a single column descriptor: ["name" : string, "label" : string, "width" : integer, "relwidth" : integer ]
virtual void addColumn(const LLScrollListColumn::Params& column, EAddPosition pos = ADD_BOTTOM);
virtual void addColumn(const LLSD& column, EAddPosition pos = ADD_BOTTOM); virtual void addColumn(const LLSD& column, EAddPosition pos = ADD_BOTTOM);
virtual void clearColumns(); virtual void clearColumns();
virtual void setColumnLabel(const std::string& column, const std::string& label); virtual void setColumnLabel(const std::string& column, const std::string& label);
@@ -106,6 +107,8 @@ public:
// "columns" => [ "column" => column name, "value" => value, "type" => type, "font" => font, "font-style" => style ], "id" => uuid // "columns" => [ "column" => column name, "value" => value, "type" => type, "font" => font, "font-style" => style ], "id" => uuid
// Creates missing columns automatically. // Creates missing columns automatically.
virtual LLScrollListItem* addElement(const LLSD& element, EAddPosition pos = ADD_BOTTOM, void* userdata = NULL); virtual LLScrollListItem* addElement(const LLSD& element, EAddPosition pos = ADD_BOTTOM, void* userdata = NULL);
virtual LLScrollListItem* addRow(LLScrollListItem *new_item, const LLScrollListItem::Params& value, EAddPosition pos = ADD_BOTTOM);
virtual LLScrollListItem* addRow(const LLScrollListItem::Params& value, EAddPosition pos = ADD_BOTTOM);
// Simple add element. Takes a single array of: // Simple add element. Takes a single array of:
// [ "value" => value, "font" => font, "font-style" => style ] // [ "value" => value, "font" => font, "font-style" => style ]
virtual void clearRows(); // clears all elements virtual void clearRows(); // clears all elements
@@ -419,7 +422,6 @@ private:
LLColor4 mFgUnselectedColor; LLColor4 mFgUnselectedColor;
LLColor4 mFgDisabledColor; LLColor4 mFgDisabledColor;
LLColor4 mHighlightedColor; LLColor4 mHighlightedColor;
LLColor4 mDefaultListTextColor;
S32 mBorderThickness; S32 mBorderThickness;
callback_t mOnDoubleClickCallback; callback_t mOnDoubleClickCallback;

View File

@@ -34,11 +34,11 @@
// LLScrollListItem // LLScrollListItem
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
LLScrollListItem::LLScrollListItem( bool enabled, const LLSD& value, void* userdata ) LLScrollListItem::LLScrollListItem( const Params& p )
: mSelected(FALSE), : mSelected(FALSE),
mEnabled(enabled), mEnabled(p.enabled),
mUserdata(userdata), mUserdata(p.userdata),
mItemValue(value), mItemValue(p.value),
mColumns() mColumns()
{ {
} }
@@ -49,9 +49,9 @@ LLScrollListItem::~LLScrollListItem()
std::for_each(mColumns.begin(), mColumns.end(), DeletePointer()); std::for_each(mColumns.begin(), mColumns.end(), DeletePointer());
} }
void LLScrollListItem::addColumn(const std::string& text, const LLFontGL* font, S32 width, U8 font_style, LLFontGL::HAlign font_alignment, bool visible) void LLScrollListItem::addColumn(const LLScrollListCell::Params& p)
{ {
mColumns.push_back(new LLScrollListText(text, font, width, font_style, font_alignment, LLColor4::black, false, visible)); mColumns.push_back(LLScrollListCell::create(p));
} }
void LLScrollListItem::setNumColumns(S32 columns) void LLScrollListItem::setNumColumns(S32 columns)

View File

@@ -41,6 +41,30 @@ class LLScrollListItem
{ {
friend class LLScrollListCtrl; friend class LLScrollListCtrl;
public: public:
struct Params : public LLInitParam::Block<Params>
{
Optional<bool> enabled;
Optional<void*> userdata;
Optional<LLSD> value;
Ignored name; // use for localization tools
Ignored type;
Ignored length;
Multiple<LLScrollListCell::Params> columns;
Params()
: enabled("enabled", true),
value("value"),
name("name"),
type("type"),
length("length"),
columns("columns")
{
addSynonym(columns, "column");
addSynonym(value, "id");
}
};
virtual ~LLScrollListItem(); virtual ~LLScrollListItem();
@@ -59,7 +83,7 @@ public:
void setRect(LLRect rect) { mRectangle = rect; } void setRect(LLRect rect) { mRectangle = rect; }
LLRect getRect() const { return mRectangle; } LLRect getRect() const { return mRectangle; }
void addColumn( const std::string& text, const LLFontGL* font, S32 width = 0, U8 font_style = LLFontGL::NORMAL, LLFontGL::HAlign font_alignment = LLFontGL::LEFT, bool visible = true ); void addColumn( const LLScrollListCell::Params& p );
void setNumColumns(S32 columns); void setNumColumns(S32 columns);
@@ -74,7 +98,7 @@ public:
virtual void draw(const LLRect& rect, const LLColor4& fg_color, const LLColor4& bg_color, const LLColor4& highlight_color, S32 column_padding); virtual void draw(const LLRect& rect, const LLColor4& fg_color, const LLColor4& bg_color, const LLColor4& highlight_color, S32 column_padding);
protected: protected:
LLScrollListItem( bool enabled = true, const LLSD& value = LLSD(), void* userdata = NULL ); LLScrollListItem( const Params& );
private: private:
BOOL mSelected; BOOL mSelected;

View File

@@ -778,7 +778,7 @@ void LLFloaterAvatarList::refreshAvatarList()
BOOST_FOREACH(av_list_t::value_type& entry, mAvatars) BOOST_FOREACH(av_list_t::value_type& entry, mAvatars)
{ {
LLSD element; LLScrollListItem::Params element;
LLUUID av_id; LLUUID av_id;
std::string av_name; std::string av_name;
@@ -825,33 +825,30 @@ void LLFloaterAvatarList::refreshAvatarList()
continue; continue;
} }
element.value = av_id;
element["id"] = av_id; LLScrollListCell::Params mark;
mark.column = "marked";
element["columns"][LIST_MARK]["column"] = "marked"; mark.type = "text";
element["columns"][LIST_MARK]["type"] = "text";
if (entry->isMarked()) if (entry->isMarked())
{ {
element["columns"][LIST_MARK]["value"] = "X"; mark.value = "X";
element["columns"][LIST_MARK]["color"] = LLColor4::blue.getValue(); mark.color = LLColor4::blue;
element["columns"][LIST_MARK]["font-style"] = "BOLD"; mark.font_style = "BOLD";
}
else
{
element["columns"][LIST_MARK]["value"] = "";
} }
element["columns"][LIST_AVATAR_NAME]["column"] = "avatar_name"; LLScrollListCell::Params name;
element["columns"][LIST_AVATAR_NAME]["type"] = "text"; name.column = "avatar_name";
element["columns"][LIST_AVATAR_NAME]["value"] = av_name; name.type = "text";
name.value = av_name;
if (entry->isFocused()) if (entry->isFocused())
{ {
element["columns"][LIST_AVATAR_NAME]["font-style"] = "BOLD"; name.font_style = "BOLD";
} }
//<edit> custom colors for certain types of avatars! //<edit> custom colors for certain types of avatars!
//Changed a bit so people can modify them in settings. And since they're colors, again it's possibly account-based. Starting to think I need a function just to determine that. - HgB //Changed a bit so people can modify them in settings. And since they're colors, again it's possibly account-based. Starting to think I need a function just to determine that. - HgB
//element["columns"][LIST_AVATAR_NAME]["color"] = gColors.getColor( "MapAvatar" ).getValue(); //name.color = gColors.getColor( "MapAvatar" );
LLViewerRegion* parent_estate = LLWorld::getInstance()->getRegionFromPosGlobal(entry->getPosition()); LLViewerRegion* parent_estate = LLWorld::getInstance()->getRegionFromPosGlobal(entry->getPosition());
LLUUID estate_owner = LLUUID::null; LLUUID estate_owner = LLUUID::null;
if(parent_estate && parent_estate->isAlive()) if(parent_estate && parent_estate->isAlive())
@@ -895,12 +892,13 @@ void LLFloaterAvatarList::refreshAvatarList()
name_color = name_color*0.5f + unselected_color*0.5f; name_color = name_color*0.5f + unselected_color*0.5f;
element["columns"][LIST_AVATAR_NAME]["color"] = name_color.getValue(); name.color = name_color;
char temp[32]; char temp[32];
LLColor4 color = sDefaultListText; LLColor4 color = sDefaultListText;
element["columns"][LIST_DISTANCE]["column"] = "distance"; LLScrollListCell::Params dist;
element["columns"][LIST_DISTANCE]["type"] = "text"; dist.column = "distance";
dist.type = "text";
if (UnknownAltitude) if (UnknownAltitude)
{ {
strcpy(temp, "?"); strcpy(temp, "?");
@@ -932,9 +930,10 @@ void LLFloaterAvatarList::refreshAvatarList()
snprintf(temp, sizeof(temp), "%d", (S32)distance); snprintf(temp, sizeof(temp), "%d", (S32)distance);
} }
} }
element["columns"][LIST_DISTANCE]["value"] = temp; dist.value = temp;
element["columns"][LIST_DISTANCE]["color"] = color.getValue(); dist.color = color;
LLScrollListCell::Params pos;
position = position - simpos; position = position - simpos;
S32 x = (S32)position.mdV[VX]; S32 x = (S32)position.mdV[VX];
@@ -963,12 +962,13 @@ void LLFloaterAvatarList::refreshAvatarList()
strcat(temp, "E"); strcat(temp, "E");
} }
} }
element["columns"][LIST_POSITION]["column"] = "position"; pos.column = "position";
element["columns"][LIST_POSITION]["type"] = "text"; pos.type = "text";
element["columns"][LIST_POSITION]["value"] = temp; pos.value = temp;
element["columns"][LIST_ALTITUDE]["column"] = "altitude"; LLScrollListCell::Params alt;
element["columns"][LIST_ALTITUDE]["type"] = "text"; alt.column = "altitude";
alt.type = "text";
if (UnknownAltitude) if (UnknownAltitude)
{ {
strcpy(temp, "?"); strcpy(temp, "?");
@@ -977,10 +977,11 @@ void LLFloaterAvatarList::refreshAvatarList()
{ {
snprintf(temp, sizeof(temp), "%d", (S32)position.mdV[VZ]); snprintf(temp, sizeof(temp), "%d", (S32)position.mdV[VZ]);
} }
element["columns"][LIST_ALTITUDE]["value"] = temp; alt.value = temp;
element["columns"][LIST_ACTIVITY]["column"] = "activity"; LLScrollListCell::Params act;
element["columns"][LIST_ACTIVITY]["type"] = "icon"; act.column = "activity";
act.type = "icon";
std::string activity_icon = ""; std::string activity_icon = "";
std::string activity_tip = ""; std::string activity_tip = "";
@@ -1032,12 +1033,13 @@ void LLFloaterAvatarList::refreshAvatarList()
break; break;
} }
element["columns"][LIST_ACTIVITY]["value"] = activity_icon;//icon_image_id; //"icn_active-speakers-dot-lvl0.tga"; act.value = activity_icon;//icon_image_id; //"icn_active-speakers-dot-lvl0.tga";
//element["columns"][LIST_AVATAR_ACTIVITY]["color"] = icon_color.getValue(); //act.color = icon_color;
element["columns"][LIST_ACTIVITY]["tool_tip"] = activity_tip; act.tool_tip = activity_tip;
element["columns"][LIST_AGE]["column"] = "age"; LLScrollListCell::Params agep;
element["columns"][LIST_AGE]["type"] = "text"; agep.column = "age";
agep.type = "text";
color = sDefaultListText; color = sDefaultListText;
std::string age = boost::lexical_cast<std::string>(entry->mAge); std::string age = boost::lexical_cast<std::string>(entry->mAge);
if (entry->mAge > -1) if (entry->mAge > -1)
@@ -1057,21 +1059,22 @@ void LLFloaterAvatarList::refreshAvatarList()
{ {
age = "?"; age = "?";
} }
element["columns"][LIST_AGE]["value"] = age; agep.value = age;
element["columns"][LIST_AGE]["color"] = color.getValue(); agep.color = color;
int dur = difftime(time(NULL), entry->getTime()); int dur = difftime(time(NULL), entry->getTime());
int hours = dur / 3600; int hours = dur / 3600;
int mins = (dur % 3600) / 60; int mins = (dur % 3600) / 60;
int secs = (dur % 3600) % 60; int secs = (dur % 3600) % 60;
element["columns"][LIST_TIME]["column"] = "time"; LLScrollListCell::Params time;
element["columns"][LIST_TIME]["type"] = "text"; time.column = "time";
element["columns"][LIST_TIME]["value"] = llformat("%d:%02d:%02d", hours, mins, secs); time.type = "text";
time.value = llformat("%d:%02d:%02d", hours, mins, secs);
element["columns"][LIST_CLIENT]["column"] = "client";
element["columns"][LIST_CLIENT]["type"] = "text";
LLScrollListCell::Params viewer;
viewer.column = "client";
viewer.type = "text";
static const LLCachedControl<LLColor4> avatar_name_color(gColors, "AvatarNameColor",LLColor4(0.98f, 0.69f, 0.36f, 1.f)); static const LLCachedControl<LLColor4> avatar_name_color(gColors, "AvatarNameColor",LLColor4(0.98f, 0.69f, 0.36f, 1.f));
LLColor4 client_color(avatar_name_color); LLColor4 client_color(avatar_name_color);
@@ -1085,18 +1088,30 @@ void LLFloaterAvatarList::refreshAvatarList()
client_color = unselected_color; client_color = unselected_color;
client = "?"; client = "?";
} }
viewer.value = client.c_str();
} }
else else
{ {
element["columns"][LIST_CLIENT]["value"] = getString("Out Of Range"); viewer.value = getString("Out Of Range");
} }
//Blend to make the color show up better //Blend to make the color show up better
client_color = client_color *.5f + unselected_color * .5f; client_color = client_color *.5f + unselected_color * .5f;
element["columns"][LIST_CLIENT]["color"] = client_color.getValue(); viewer.color = client_color;
// Add individual column cell params to the item param
element.columns.add(mark);
element.columns.add(name);
element.columns.add(dist);
element.columns.add(pos);
element.columns.add(alt);
element.columns.add(act);
element.columns.add(agep);
element.columns.add(time);
element.columns.add(viewer);
// Add to list // Add to list
mAvatarList->addElement(element, ADD_BOTTOM); mAvatarList->addRow(element);
} }
// finish // finish

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB