示例#1
0
void LLToolTip::initFromParams(const LLToolTip::Params& p)
{
	LLPanel::initFromParams(p);

	// do this *after* we've had our size set in LLPanel::initFromParams();
	const S32 REALLY_LARGE_HEIGHT = 10000;
	mTextBox->reshape(p.max_width, REALLY_LARGE_HEIGHT);

	if (p.styled_message.isProvided())
	{
		for (LLInitParam::ParamIterator<LLToolTip::StyledText>::const_iterator text_it = p.styled_message.begin();
			text_it != p.styled_message.end();
			++text_it)
		{
			mTextBox->appendText(text_it->text(), false, text_it->style);
		}
	}
	else
	{
		mTextBox->setText(p.message());
	}

	S32 text_width = llmin(p.max_width(), mTextBox->getTextPixelWidth());
	S32 text_height = mTextBox->getTextPixelHeight();
	mTextBox->reshape(text_width, text_height);

	// reshape tooltip panel to fit text box
	LLRect tooltip_rect = calcBoundingRect();
	tooltip_rect.mTop += mPadding;
	tooltip_rect.mRight += mPadding;
	tooltip_rect.mBottom = 0;
	tooltip_rect.mLeft = 0;

	setShape(tooltip_rect);
}
示例#2
0
//virtual
BOOL LLNameListCtrl::handleToolTip(S32 x, S32 y, MASK mask)
{
	BOOL handled = FALSE;
	S32 column_index = getColumnIndexFromOffset(x);
	LLNameListItem* hit_item = dynamic_cast<LLNameListItem*>(hitItem(x, y));
	if (hit_item
		&& column_index == mNameColumnIndex)
	{
		// ...this is the column with the avatar name
		LLUUID avatar_id = hit_item->getUUID();
		if (avatar_id.notNull())
		{
			// ...valid avatar id

			LLScrollListCell* hit_cell = hit_item->getColumn(column_index);
			if (hit_cell)
			{
				S32 row_index = getItemIndex(hit_item);
				LLRect cell_rect = getCellRect(row_index, column_index);
				// Convert rect local to screen coordinates
				LLRect sticky_rect;
				localRectToScreen(cell_rect, &sticky_rect);

				// Spawn at right side of cell
				LLPointer<LLUIImage> icon = LLUI::getUIImage("Info_Small");
				LLCoordGL pos( sticky_rect.mRight - info_icon_size, sticky_rect.mTop - (sticky_rect.getHeight() - icon->getHeight())/2 );

				// Should we show a group or an avatar inspector?
				bool is_group = hit_item->isGroup();
				bool is_experience = hit_item->isExperience();

				LLToolTip::Params params;
				params.background_visible( false );
				params.click_callback( boost::bind(&LLNameListCtrl::showInspector, this, avatar_id, is_group, is_experience) );
				params.delay_time(0.0f);		// spawn instantly on hover
				params.image( icon );
				params.message("");
				params.padding(0);
				params.pos(pos);
				params.sticky_rect(sticky_rect);

				LLToolTipMgr::getInstance()->show(params);
				handled = TRUE;
			}
		}
	}
	if (!handled)
	{
		handled = LLScrollListCtrl::handleToolTip(x, y, mask);
	}
	return handled;
}
示例#3
0
LLToolTip::LLToolTip(const LLToolTip::Params& p)
:	LLPanel(p),
	mHasClickCallback(p.click_callback.isProvided()),
	mPadding(p.padding),
	mTextBox(NULL),
	mInfoButton(NULL),
	mPlayMediaButton(NULL),
	mHomePageButton(NULL)
{
	LLTextBox::Params params;
	params.name = params.initial_value().asString();
	// bake textbox padding into initial rect
	params.rect = LLRect (mPadding, mPadding + 1, mPadding + 1, mPadding);
	params.h_pad = 0;
	params.v_pad = 0;
	params.mouse_opaque = false;
	params.text_color = p.text_color;
	params.bg_visible = false;
	params.font = p.font;
	params.use_ellipses = true;
	params.wrap = p.wrap;
	params.parse_urls = false; // disallow hyperlinks in tooltips, as they want to spawn their own explanatory tooltips
	mTextBox = LLUICtrlFactory::create<LLTextBox> (params);
	addChild(mTextBox);
	
	S32 TOOLTIP_ICON_SIZE = 0;
	S32 TOOLTIP_PLAYBUTTON_SIZE = 0;
	if (p.image.isProvided())
	{
		LLButton::Params icon_params;
		icon_params.name = "tooltip_info";
		icon_params.label(""); // provid label but set to empty so name does not overwrite it -angela
		LLRect icon_rect;
		LLUIImage* imagep = p.image;
		TOOLTIP_ICON_SIZE = (imagep ? imagep->getWidth() : 16);
		icon_rect.setOriginAndSize(mPadding, mPadding, TOOLTIP_ICON_SIZE, TOOLTIP_ICON_SIZE);
		icon_params.rect = icon_rect;
		icon_params.image_unselected(imagep);
		icon_params.image_selected(imagep);

		icon_params.scale_image(true);
		icon_params.flash_color(icon_params.highlight_color());
		mInfoButton  = LLUICtrlFactory::create<LLButton>(icon_params);
		if (p.click_callback.isProvided())
		{
			mInfoButton->setCommitCallback(boost::bind(p.click_callback()));
		}
		addChild(mInfoButton);
		
		// move text over to fit image in
		mTextBox->translate(TOOLTIP_ICON_SIZE + mPadding, 0);
	}
	
	if (p.time_based_media)
	{
		LLButton::Params p_button;
		p_button.name(std::string("play_media"));
		p_button.label(""); // provide label but set to empty so name does not overwrite it -angela
		TOOLTIP_PLAYBUTTON_SIZE = 16;
		LLRect button_rect;
		button_rect.setOriginAndSize((mPadding +TOOLTIP_ICON_SIZE+ mPadding ), mPadding, TOOLTIP_ICON_SIZE, TOOLTIP_ICON_SIZE);
		p_button.rect = button_rect;
		p_button.image_selected.name("button_anim_pause.tga");
		p_button.image_unselected.name("button_anim_play.tga");
		p_button.scale_image(true);
		
		mPlayMediaButton = LLUICtrlFactory::create<LLButton>(p_button); 
		if(p.click_playmedia_callback.isProvided())
		{
			mPlayMediaButton->setCommitCallback(boost::bind(p.click_playmedia_callback()));
		}
		mPlayMediaButton->setToggleState(p.media_playing);
		addChild(mPlayMediaButton);
		
		// move text over to fit image in
		mTextBox->translate(TOOLTIP_PLAYBUTTON_SIZE + mPadding, 0);
	}
	
	if (p.web_based_media)
	{
		LLButton::Params p_w_button;
		p_w_button.name(std::string("home_page"));
		p_w_button.label(""); // provid label but set to empty so name does not overwrite it -angela
		TOOLTIP_PLAYBUTTON_SIZE = 16;
		LLRect button_rect;
		button_rect.setOriginAndSize((mPadding +TOOLTIP_ICON_SIZE+ mPadding ), mPadding, TOOLTIP_ICON_SIZE, TOOLTIP_ICON_SIZE);
		p_w_button.rect = button_rect;
		p_w_button.image_unselected.name("map_home.tga");
		p_w_button.scale_image(true);
		
		mHomePageButton = LLUICtrlFactory::create<LLButton>(p_w_button); 
		if(p.click_homepage_callback.isProvided())
		{
			mHomePageButton->setCommitCallback(boost::bind(p.click_homepage_callback()));
		}
		addChild(mHomePageButton);
		
		// move text over to fit image in
		mTextBox->translate(TOOLTIP_PLAYBUTTON_SIZE + mPadding, 0);
	}
	
	if (p.click_callback.isProvided())
	{
		setMouseUpCallback(boost::bind(p.click_callback()));
	}
}