summaryrefslogtreecommitdiff
path: root/indra/newview/llavatarlist.cpp
diff options
context:
space:
mode:
authorSteven Bennetts <steve@lindenlab.com>2009-07-30 23:22:41 +0000
committerSteven Bennetts <steve@lindenlab.com>2009-07-30 23:22:41 +0000
commite97f7728a90dd66014f6b3f0cd5e8d4c71f48691 (patch)
tree4be178df6b50a3395105cdd3ac0044d6467a9fa3 /indra/newview/llavatarlist.cpp
parentd5aa10143a0e6457b3326ba839c81b7c956a015e (diff)
merge https://svn.aws.productengine.com/secondlife/export-from-ll/viewer-2-0/indra@1170 https://svn.aws.productengine.com/secondlife/pe/stable-1/indra@1187 -> viewer-2.0.0-3
Diffstat (limited to 'indra/newview/llavatarlist.cpp')
-rw-r--r--indra/newview/llavatarlist.cpp134
1 files changed, 127 insertions, 7 deletions
diff --git a/indra/newview/llavatarlist.cpp b/indra/newview/llavatarlist.cpp
index 7b5ce765d3..a85f8710c7 100644
--- a/indra/newview/llavatarlist.cpp
+++ b/indra/newview/llavatarlist.cpp
@@ -37,24 +37,40 @@
// newview
#include "llcallingcard.h" // for LLAvatarTracker
#include "llcachename.h"
+#include "lloutputmonitorctrl.h"
+#include "llvoiceclient.h"
static LLDefaultChildRegistry::Register<LLAvatarList> r("avatar_list");
LLAvatarList::Params::Params()
+:
+ volume_column_width("volume_column_width", 0)
+ , online_go_first("online_go_first", true)
{
draw_heading = true;
draw_stripes = false;
multi_select = false;
column_padding = 0;
- search_column = LIST_NAME;
- sort_column = LIST_NAME;
+ search_column = COL_NAME;
+ sort_column = COL_NAME;
}
LLAvatarList::LLAvatarList(const Params& p)
: LLScrollListCtrl(p)
+ , mHaveVolumeColumn(p.volume_column_width > 0)
+ , mOnlineGoFirst(p.online_go_first)
{
setCommitOnSelectionChange(TRUE); // there's no such param in LLScrollListCtrl::Params
+ // "volume" column
+ {
+ LLScrollListColumn::Params col_params;
+ col_params.name = "volume";
+ col_params.header.label = "Volume"; // *TODO: localize or remove the header
+ col_params.width.pixel_width = p.volume_column_width;
+ addColumn(col_params);
+ }
+
// "name" column
{
LLScrollListColumn::Params col_params;
@@ -63,18 +79,42 @@ LLAvatarList::LLAvatarList(const Params& p)
col_params.width.dynamic_width = true;
addColumn(col_params);
}
+
+ // "online status" column
+ {
+ LLScrollListColumn::Params col_params;
+ col_params.name = "online";
+ col_params.header.label = "Online"; // *TODO: localize or remove the header
+ col_params.width.pixel_width = 0; // invisible column
+ addColumn(col_params);
+ }
+
// invisible "id" column
{
LLScrollListColumn::Params col_params;
col_params.name = "id";
+ col_params.header.label = "ID"; // *TODO: localize or remove the header
col_params.width.pixel_width = 0;
addColumn(col_params);
}
- // The corresponding parameters don't work because we create columns dynamically.
- sortByColumnIndex(LIST_NAME, TRUE);
- setSearchColumn(LIST_NAME);
+ // Primary sort = online status, secondary sort = name
+ // The corresponding parameters don't work because we create columns dynamically.
+ sortByColumnIndex(COL_NAME, TRUE);
+ if (mOnlineGoFirst)
+ sortByColumnIndex(COL_ONLINE, FALSE);
+ setSearchColumn(COL_NAME);
+}
+
+// virtual
+void LLAvatarList::draw()
+{
+ LLScrollListCtrl::draw();
+ if (mHaveVolumeColumn)
+ {
+ updateVolume();
+ }
}
std::vector<LLUUID> LLAvatarList::getSelectedIDs()
@@ -97,17 +137,30 @@ void LLAvatarList::addItem(const LLUUID& id, const std::string& name, BOOL is_bo
LLSD element;
element["id"] = id;
- LLSD& friend_column = element["columns"][LIST_NAME];
+ // Update volume column (if we have one)
+ {
+ std::string icon = mHaveVolumeColumn ? getVolumeIcon(id) : "";
+ LLSD& volume_column = element["columns"][COL_VOLUME];
+ volume_column["column"] = "volume";
+ volume_column["type"] = "icon";
+ volume_column["value"] = icon;
+ }
+
+ LLSD& friend_column = element["columns"][COL_NAME];
friend_column["column"] = "name";
friend_column["value"] = name;
+ LLSD& online_column = element["columns"][COL_ONLINE];
+ online_column["column"] = "online";
+ online_column["value"] = is_bold ? "1" : "0";
+
LLScrollListItem* new_itemp = addElement(element, pos);
// Indicate buddy online status.
// (looks like parsing font parameters from LLSD is broken)
if (is_bold)
{
- LLScrollListText* name_textp = dynamic_cast<LLScrollListText*>(new_itemp->getColumn(LIST_NAME));
+ LLScrollListText* name_textp = dynamic_cast<LLScrollListText*>(new_itemp->getColumn(COL_NAME));
if (name_textp)
name_textp->setFontStyle(LLFontGL::BOLD);
else
@@ -169,3 +222,70 @@ BOOL LLAvatarList::update(const std::vector<LLUUID>& all_buddies, const std::str
return have_names;
}
+
+// static
+std::string LLAvatarList::getVolumeIcon(const LLUUID& id)
+{
+ //
+ // Determine icon appropriate for the current avatar volume.
+ //
+ // *TODO: remove this in favor of LLOutputMonitorCtrl
+ // when ListView widget is implemented
+ // which is capable of containing arbitrary widgets.
+ //
+ static LLOutputMonitorCtrl::Params default_monitor_params(LLUICtrlFactory::getDefaultParams<LLOutputMonitorCtrl>());
+ bool muted = gVoiceClient->getIsModeratorMuted(id) || gVoiceClient->getOnMuteList(id);
+ F32 power = gVoiceClient->getCurrentPower(id);
+ std::string icon;
+
+ if (muted)
+ {
+ icon = default_monitor_params.image_mute.name;
+ }
+ else if (power == 0.f)
+ {
+ icon = default_monitor_params.image_off.name;
+ }
+ else if (power < LLVoiceClient::OVERDRIVEN_POWER_LEVEL)
+ {
+ S32 icon_image_idx = llmin(2, llfloor((power / LLVoiceClient::OVERDRIVEN_POWER_LEVEL) * 3.f));
+ switch(icon_image_idx)
+ {
+ default:
+ case 0:
+ icon = default_monitor_params.image_on.name;
+ break;
+ case 1:
+ icon = default_monitor_params.image_level_1.name;
+ break;
+ case 2:
+ icon = default_monitor_params.image_level_2.name;
+ break;
+ }
+ }
+ else
+ {
+ // overdriven
+ icon = default_monitor_params.image_level_3.name;
+ }
+
+ return icon;
+}
+
+// Update volume column for all list rows.
+void LLAvatarList::updateVolume()
+{
+ item_list& items = getItemList();
+
+ for (item_list::iterator item_it = items.begin();
+ item_it != items.end();
+ ++item_it)
+ {
+ LLScrollListItem* itemp = (*item_it);
+ LLUUID speaker_id = itemp->getUUID();
+
+ LLScrollListCell* icon_cell = itemp->getColumn(COL_VOLUME);
+ if (icon_cell)
+ icon_cell->setValue(getVolumeIcon(speaker_id));
+ }
+}