Esempio n. 1
0
void LLScrollListItem::draw(const LLRect& rect, const LLColor4& fg_color, const LLColor4& bg_color, const LLColor4& highlight_color, S32 column_padding)
{
	// draw background rect
	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
	LLRect bg_rect = rect;
	gl_rect_2d( bg_rect, bg_color );

	S32 cur_x = rect.mLeft;
	S32 num_cols = getNumColumns();
	S32 cur_col = 0;

	for (LLScrollListCell* cell = getColumn(0); cur_col < num_cols; cell = getColumn(++cur_col))
	{
		// Two ways a cell could be hidden
		if (cell->getWidth() < 0
			|| !cell->getVisible()) continue;

		LLUI::pushMatrix();
		{
			LLUI::translate((F32) cur_x, (F32) rect.mBottom);

			cell->draw( fg_color, highlight_color );
		}
		LLUI::popMatrix();
		
		cur_x += cell->getWidth() + column_padding;
	}
}
Esempio n. 2
0
// virtual
LLXMLNodePtr LLComboBox::getXML(bool save_children) const
{
	LLXMLNodePtr node = LLUICtrl::getXML();

	node->setName(LL_COMBO_BOX_TAG);

	// Attributes

	node->createChild("allow_text_entry", TRUE)->setBoolValue(mAllowTextEntry);

	node->createChild("max_chars", TRUE)->setIntValue(mMaxChars);

	// Contents

	std::vector<LLScrollListItem*> data_list = mList->getAllData();
	std::vector<LLScrollListItem*>::iterator data_itor;
	for (data_itor = data_list.begin(); data_itor != data_list.end(); ++data_itor)
	{
		LLScrollListItem* item = *data_itor;
		LLScrollListCell* cell = item->getColumn(0);
		if (cell)
		{
			LLXMLNodePtr item_node = node->createChild("combo_item", FALSE);
			LLSD value = item->getValue();
			item_node->createChild("value", TRUE)->setStringValue(value.asString());
			item_node->createChild("enabled", TRUE)->setBoolValue(item->getEnabled());
			item_node->setStringValue(cell->getValue().asString());
		}
	}

	return node;
}
///////////////////////////////////////////////////////////////////////////////
// wrapper for testing a URL against the whitelist. We grab entries from
// white list list box widget and build a list to test against. 
bool LLPanelMediaSettingsSecurity::urlPassesWhiteList( const std::string& test_url )
{
	// If the whitlelist list is tentative, it means we have multiple settings.
	// In that case, we have no choice but to return true
	if ( mWhiteListList->getTentative() ) return true;
	
	// the checkUrlAgainstWhitelist(..) function works on a vector
	// of strings for the white list entries - in this panel, the white list
	// is stored in the widgets themselves so we need to build something compatible.
	std::vector< std::string > whitelist_strings;
	whitelist_strings.clear();	// may not be required - I forget what the spec says.

	// step through whitelist widget entries and grab them as strings
    std::vector< LLScrollListItem* > whitelist_items = mWhiteListList->getAllData();
    std::vector< LLScrollListItem* >::iterator iter = whitelist_items.begin(); 
	while( iter != whitelist_items.end()  )
    {
		LLScrollListCell* cell = (*iter)->getColumn( ENTRY_COLUMN );
		std::string whitelist_url = cell->getValue().asString();

		whitelist_strings.push_back( whitelist_url );

		++iter;
    };

	// possible the URL is just a fragment so we validize it
	const std::string valid_url = makeValidUrl( test_url );

	// indicate if the URL passes whitelist
	return LLMediaEntry::checkUrlAgainstWhitelist( valid_url, whitelist_strings );
}
//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;
}
Esempio n. 5
0
// public
void LLNameListCtrl::refresh(const LLUUID& id, const std::string& first, 
							 const std::string& last, BOOL is_group)
{
	//llinfos << "LLNameListCtrl::refresh " << id << " '" << first << " "
	//	<< last << "'" << llendl;

	std::string fullname;
	if (!is_group)
	{
		fullname = first + " " + last;
	}
	else
	{
		fullname = first;
	}

	// TODO: scan items for that ID, fix if necessary
	item_list::iterator iter;
	for (iter = getItemList().begin(); iter != getItemList().end(); iter++)
	{
		LLScrollListItem* item = *iter;
		if (item->getUUID() == id)
		{
			LLScrollListCell* cell = item->getColumn(mNameColumnIndex);
			if (cell)
			{
				cell->setValue(fullname);
			}
		}
	}

	dirtyColumns();
}
Esempio n. 6
0
void LLNameListCtrl::onAvatarNameCache(const LLUUID& agent_id,
									   const LLAvatarName& av_name,
									   std::string suffix,
									   LLHandle<LLNameListItem> item)
{
	avatar_name_cache_connection_map_t::iterator it = mAvatarNameCacheConnections.find(agent_id);
	if (it != mAvatarNameCacheConnections.end())
	{
		if (it->second.connected())
		{
			it->second.disconnect();
		}
		mAvatarNameCacheConnections.erase(it);
	}

	std::string name;
	if (mShortNames)
		name = av_name.getDisplayName();
	else
		name = av_name.getCompleteName();

	// Append optional suffix.
	if (!suffix.empty())
	{
		name.append(suffix);
	}

	LLNameListItem* list_item = item.get();
	if (list_item && list_item->getUUID() == agent_id)
	{
		LLScrollListCell* cell = list_item->getColumn(mNameColumnIndex);
		if (cell)
		{
			cell->setValue(name);
			setNeedsSort();
		}
	}
	
	//////////////////////////////////////////////////////////////////////////
	// BAKER - FIX NameListCtrl
 	//if (mPendingLookupsRemaining <= 0)
 	{
 		// We might get into a state where mPendingLookupsRemaining might
 		//	go negative.  So just reset it right now and figure out if it's
 		//	possible later :)
 		//mPendingLookupsRemaining = 0;
		
 		mNameListCompleteSignal(true);
 	}
 	//else
 	{
 	//	mPendingLookupsRemaining--;
 	}
	//////////////////////////////////////////////////////////////////////////

	dirtyColumns();
}
void LLFloaterPathfindingObjects::handleObjectNameResponse(const LLPathfindingObject *pObject)
{
	llassert(pObject != NULL);
	const std::string uuid = pObject->getUUID().asString();
	scroll_list_item_map::iterator scrollListItemIter = mMissingNameObjectsScrollListItems.find(uuid);
	if (scrollListItemIter != mMissingNameObjectsScrollListItems.end())
	{
		LLScrollListItem *scrollListItem = scrollListItemIter->second;
		llassert(scrollListItem != NULL);

		LLScrollListCell *scrollListCell = scrollListItem->getColumn(getOwnerNameColumnIndex());
		LLSD ownerName = getOwnerName(pObject);

		scrollListCell->setValue(ownerName);

		mMissingNameObjectsScrollListItems.erase(scrollListItemIter);
	}
}
void LLNameListCtrl::onAvatarNameCache(const LLUUID& agent_id,
									   const LLAvatarName& av_name,
									   LLHandle<LLScrollListItem> item)
{
	std::string name;
	if (mShortNames)
		name = av_name.mDisplayName;
	else
		name = av_name.getCompleteName();

	LLScrollListItem* list_item = item.get();
	if (list_item && list_item->getUUID() == agent_id)
	{
		LLScrollListCell* cell = list_item->getColumn(mNameColumnIndex);
		if (cell)
		{
			cell->setValue(name);
			setNeedsSort();
		}
	}

	dirtyColumns();
}
void LLPanelMediaSettingsSecurity::getValues( LLSD &fill_me_in, bool include_tentative )
{
    if (include_tentative || !mEnableWhiteList->getTentative()) 
		fill_me_in[LLMediaEntry::WHITELIST_ENABLE_KEY] = (LLSD::Boolean)mEnableWhiteList->getValue();
	
	if (include_tentative || !mWhiteListList->getTentative())
	{
		// iterate over white list and extract items
		std::vector< LLScrollListItem* > whitelist_items = mWhiteListList->getAllData();
		std::vector< LLScrollListItem* >::iterator iter = whitelist_items.begin();
		
		// *NOTE: need actually set the key to be an emptyArray(), or the merge
		// we do with this LLSD will think there's nothing to change.
		fill_me_in[LLMediaEntry::WHITELIST_KEY] = LLSD::emptyArray();
		while( iter != whitelist_items.end() )
		{
			LLScrollListCell* cell = (*iter)->getColumn( ENTRY_COLUMN );
			std::string whitelist_url = cell->getValue().asString();
			
			fill_me_in[ LLMediaEntry::WHITELIST_KEY ].append( whitelist_url );
			++iter;
		};
	}
}
void LLPanelNearByMedia::updateListItem(LLScrollListItem* item,
										  const std::string &item_name,
										  const std::string &item_tooltip,
										  S32 proximity,
										  bool is_disabled,
										  bool has_media,
										  bool is_time_based_and_playing,
										  LLPanelNearByMedia::MediaClass media_class,
										  const std::string &debug_str)
{
	LLScrollListCell* cell = item->getColumn(PROXIMITY_COLUMN);
	if(cell)
	{
		// since we are forced to sort by text, encode sort order as string
		std::string proximity_string = STRINGIZE(proximity);
		std::string old_proximity_string = cell->getValue().asString();
		if(proximity_string != old_proximity_string)
		{
			cell->setValue(proximity_string);
			mMediaList->setNeedsSort(true);
		}
	}
	
	cell = item->getColumn(CHECKBOX_COLUMN);
	if(cell)
	{
		cell->setValue(!is_disabled);
	}
	
	cell = item->getColumn(VISIBILITY_COLUMN);
	if(cell)
	{
		S32 old_visibility = cell->getValue();
		// *HACK ALERT: force ordering of Media before Audio before the rest of the list
		S32 new_visibility = 
			item->getUUID() == PARCEL_MEDIA_LIST_ITEM_UUID ? 3
			: item->getUUID() == PARCEL_AUDIO_LIST_ITEM_UUID ? 2
			: (has_media) ? 1 
			: ((is_disabled) ? 0
			: -1);
		cell->setValue(STRINGIZE(new_visibility));
		if (new_visibility != old_visibility)
		{			
			mMediaList->setNeedsSort(true);
		}
	}
	
	cell = item->getColumn(NAME_COLUMN);
	if(cell)
	{
		std::string name = item_name;
		std::string old_name = cell->getValue().asString();
		if (has_media) 
		{
			name += " " + mPlayingString;
		}
		if (name != old_name)
		{
			cell->setValue(name);
		}
		cell->setToolTip(item_tooltip);
		
		// *TODO: Make these font styles/colors configurable via XUI
		U8 font_style = LLFontGL::NORMAL;
		LLColor4 cell_color = LLUI::sColorsGroup->getColor("DefaultListText");
		
		// Only colorize by class in debug
		if (mDebugInfoVisible)
		{
			switch (media_class) {
				case MEDIA_CLASS_FOCUSED:
					cell_color = LLColor4::yellow;
					break;
				case MEDIA_CLASS_ON_OTHERS:
					cell_color = LLColor4::red;
					break;
				case MEDIA_CLASS_OUTSIDE_PARCEL:
					cell_color = LLColor4::orange;
					break;
				case MEDIA_CLASS_WITHIN_PARCEL:
				default:
					break;
			}
		}
		if (is_disabled)
		{
			if (mDebugInfoVisible)
			{
				font_style |= LLFontGL::ITALIC;
				cell_color = LLUI::sColorsGroup->getColor("DefaultListText");
			}
			else {
				// Dim it if it is disabled
				cell_color.setAlpha(0.25);
			}
		}
		// Dim it if it isn't "showing"
		else if (!has_media)
		{
			cell_color.setAlpha(0.25);
		}
		// Bold it if it is time-based media and it is playing
		else if (is_time_based_and_playing)
		{
			if (mDebugInfoVisible) font_style |= LLFontGL::BOLD;
		}
		cell->setColor(cell_color);
		LLScrollListText *text_cell = dynamic_cast<LLScrollListText*> (cell);
		if (text_cell)
		{
			text_cell->setFontStyle(font_style);
		}
	}
	
	cell = item->getColumn(CLASS_COLUMN);
	if(cell)
	{
		// TODO: clean this up!
		cell->setValue(STRINGIZE(media_class));
	}
	
	if(mDebugInfoVisible)
	{
		cell = item->getColumn(DEBUG_COLUMN);
		if(cell)
		{
			cell->setValue(debug_str);
		}
	}
}
Esempio n. 11
0
LLScrollListItem* LLNameListCtrl::addNameItemRow(
	const LLNameListCtrl::NameItem& name_item,
	EAddPosition pos,
	const std::string& suffix)
{
	LLUUID id = name_item.value().asUUID();
	LLNameListItem* item = NULL;

	// Store item type so that we can invoke the proper inspector.
	// *TODO Vadim: Is there a more proper way of storing additional item data?
	{
		LLNameListCtrl::NameItem item_p(name_item);
		item_p.value = LLSD().with("uuid", id).with("is_group", name_item.target() == GROUP);
		item = new LLNameListItem(item_p);
		LLScrollListCtrl::addRow(item, item_p, pos);
	}

	if (!item) return NULL;

	// use supplied name by default
	std::string fullname = name_item.name;
	switch(name_item.target)
	{
	case GROUP:
		gCacheName->getGroupName(id, fullname);
		// fullname will be "nobody" if group not found
		break;
	case SPECIAL:
		// just use supplied name
		break;
	case INDIVIDUAL:
		{
			LLAvatarName av_name;
			if (id.isNull())
			{
				fullname = LLTrans::getString("AvatarNameNobody");
			}
			else if (LLAvatarNameCache::get(id, &av_name))
			{
				if (mShortNames)
					fullname = av_name.mDisplayName;
				else
					fullname = av_name.getCompleteName();
			}
			else
			{
				// ...schedule a callback
//				LLAvatarNameCache::get(id,
//					boost::bind(&LLNameListCtrl::onAvatarNameCache,
//						this, _1, _2));
// [SL:KB] - Patch: UI-GroupPanel | Checked: 2011-05-30 (Catznip-2.6.0a) | Added: Catznip-2.6.0a
				LLAvatarNameCache::get(id, boost::bind(&LLNameListItem::onAvatarNameCache, item, mNameColumnIndex, mShortNames, _1, _2));
// [/SL:KB]
			}
			break;
		}
	default:
		break;
	}
	
	// Append optional suffix.
	if (!suffix.empty())
	{
		fullname.append(suffix);
	}

	LLScrollListCell* cell = item->getColumn(mNameColumnIndex);
	if (cell)
	{
		cell->setValue(fullname);
	}

	dirtyColumns();

	// this column is resizable
	LLScrollListColumn* columnp = getColumn(mNameColumnIndex);
	if (columnp && columnp->mHeader)
	{
		columnp->mHeader->setHasResizableElement(TRUE);
	}

	return item;
}
Esempio n. 12
0
LLScrollListItem* LLNameListCtrl::addNameItemRow(
	const LLNameListCtrl::NameItem& name_item,
	EAddPosition pos,
	std::string& suffix)
{
	LLUUID id = name_item.value().asUUID();
	LLNameListItem* item = NULL;

	// Store item type so that we can invoke the proper inspector.
	// *TODO Vadim: Is there a more proper way of storing additional item data?
	{
		LLNameListCtrl::NameItem item_p(name_item);
		item_p.value = LLSD().with("uuid", id).with("is_group", name_item.target() == GROUP);
		item = new LLNameListItem(item_p);
		LLScrollListCtrl::addRow(item, item_p, pos);
	}

	if (!item) return NULL;

	// use supplied name by default
	std::string fullname = name_item.name;
	switch(name_item.target)
	{
	case GROUP:
		gCacheName->getGroupName(id, fullname);
		// fullname will be "nobody" if group not found
		break;
	case SPECIAL:
		// just use supplied name
		break;
	case INDIVIDUAL:
		{
			std::string name;
			if (gCacheName->getFullName(id, name))
			{
				fullname = name;
			}
			break;
		}
	default:
		break;
	}
	
	// Append optional suffix.
	if (!suffix.empty())
	{
		fullname.append(suffix);
	}

	LLScrollListCell* cell = item->getColumn(mNameColumnIndex);
	if (cell)
	{
		cell->setValue(fullname);
	}

	dirtyColumns();

	// this column is resizable
	LLScrollListColumn* columnp = getColumn(mNameColumnIndex);
	if (columnp && columnp->mHeader)
	{
		columnp->mHeader->setHasResizableElement(TRUE);
	}

	return item;
}
LLScrollListItem* LLNameListCtrl::addNameItemRow(const LLSD& value, EAddPosition pos, void* userdata)
{

	LLScrollListItem* item = LLScrollListCtrl::addElement(value, pos, userdata);
	if (!item) return NULL;

	LLUUID id = item->getUUID();

	// use supplied name by default
	std::string fullname = value["name"].asString();
	switch(value["target"].asInteger())
	{
	case GROUP:
		gCacheName->getGroupName(id, fullname);
		// fullname will be "nobody" if group not found
		break;
	case SPECIAL:
		// just use supplied name
		break;
	case INDIVIDUAL:
	{
		LLAvatarName av_name;
		if (id.isNull())
		{
			fullname = LLTrans::getString("AvatarNameNobody");
		}
		else if (LLAvatarNameCache::get(id, &av_name))
		{
			if (mShortNames)
				fullname = av_name.mDisplayName;
			else
				fullname = av_name.getCompleteName();
		}
		else
		{
			fullname = " ( " + LLTrans::getString("LoadingData") + " ) ";
			// ...schedule a callback
			LLAvatarNameCache::get(id,
				boost::bind(&LLNameListCtrl::onAvatarNameCache,
					this, _1, _2, item->getHandle()));
		}
			break;
		}
	default:
		break;
	}
	
	// Append optional suffix.
	std::string suffix = value["suffix"];
	if(!suffix.empty())
	{
		fullname.append(suffix);
	}

	LLScrollListCell* cell = item->getColumn(mNameColumnIndex);
	if (cell && !fullname.empty() && cell->getValue().asString().empty())
	{
		cell->setValue(fullname);
	}

	dirtyColumns();

	// this column is resizable
	LLScrollListColumn* columnp = getColumn(mNameColumnIndex);
	if (columnp && columnp->mHeader)
	{
		columnp->mHeader->setHasResizableElement(TRUE);
	}

	return item;
}
Esempio n. 14
0
LLScrollListItem* LLNameListCtrl::addNameItemRow(
	const LLNameListCtrl::NameItem& name_item,
	EAddPosition pos,
	const std::string& suffix,
	const std::string& prefix)
{
	LLUUID id = name_item.value().asUUID();
	LLNameListItem* item = new LLNameListItem(name_item,name_item.target() == GROUP, name_item.target() == EXPERIENCE);

	if (!item) return NULL;

	LLScrollListCtrl::addRow(item, name_item, pos);

	// use supplied name by default
	std::string fullname = name_item.name;
	switch(name_item.target)
	{
	case GROUP:
		gCacheName->getGroupName(id, fullname);
		// fullname will be "nobody" if group not found
		break;
	case SPECIAL:
		// just use supplied name
		break;
	case INDIVIDUAL:
		{
			LLAvatarName av_name;
			if (id.isNull())
			{
				fullname = LLTrans::getString("AvatarNameNobody");
			}
			else if (LLAvatarNameCache::get(id, &av_name))
			{
				if (mShortNames)
					fullname = av_name.getDisplayName();
				else
					fullname = av_name.getCompleteName();
			}
			else
			{
				// ...schedule a callback
				avatar_name_cache_connection_map_t::iterator it = mAvatarNameCacheConnections.find(id);
				if (it != mAvatarNameCacheConnections.end())
				{
					if (it->second.connected())
					{
						it->second.disconnect();
					}
					mAvatarNameCacheConnections.erase(it);
				}
				mAvatarNameCacheConnections[id] = LLAvatarNameCache::get(id,boost::bind(&LLNameListCtrl::onAvatarNameCache,this, _1, _2, suffix, item->getHandle()));

				if(mPendingLookupsRemaining <= 0)
				{
					// BAKER TODO:
					// We might get into a state where mPendingLookupsRemaining might
					//	go negative.  So just reset it right now and figure out if it's
					//	possible later :)
					mPendingLookupsRemaining = 0;
					mNameListCompleteSignal(false);
				}
				mPendingLookupsRemaining++;
			}
			break;
		}
	case EXPERIENCE:
		// just use supplied name
	default:
		break;
	}
	
	// Append optional suffix.
	if (!suffix.empty())
	{
		fullname.append(suffix);
	}

	LLScrollListCell* cell = item->getColumn(mNameColumnIndex);
	if (cell)
	{
		cell->setValue(prefix + fullname);
	}

	dirtyColumns();

	// this column is resizable
	LLScrollListColumn* columnp = getColumn(mNameColumnIndex);
	if (columnp && columnp->mHeader)
	{
		columnp->mHeader->setHasResizableElement(TRUE);
	}

	return item;
}