Skip to content
Snippets Groups Projects
lltabcontainer.cpp 43.1 KiB
Newer Older
James Cook's avatar
James Cook committed
		btn->setToolTip( tooltip );
		btn->setScaleImage(TRUE);
Jon Wolk's avatar
Jon Wolk committed
		btn->setImages(tab_img, tab_selected_img);
James Cook's avatar
James Cook committed

		// Try to squeeze in a bit more text
		btn->setLeftHPad( 4 );
		btn->setRightHPad( 2 );
		btn->setHAlign(LLFontGL::LEFT);
		btn->setTabStop(FALSE);
		if (indent)
		{
			btn->setLeftHPad(indent);
		}

		if( mTabPosition == TOP )
		{
			btn->setFollowsTop();
		}
		else
		{
			btn->setFollowsBottom();
		}

		LLTabTuple* tuple = new LLTabTuple( this, child, btn, on_tab_clicked, userdata );
		btn->setCallbackUserData( tuple );
		addChild( btn, 0 );
		addChild( child, 1 );
		insertTuple(tuple, insertion_point);
	}

	updateMaxScrollPos();

	if( select )
	{
		selectLastTab();
	}
}

void LLTabContainer::removeTabPanel(LLPanel* child)
{
	// Adjust the total tab width.
	for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
	{
		LLTabTuple* tuple = *iter;
		if( tuple->mTabPanel == child )
		{
			mTotalTabWidth -= tuple->mButton->getRect().getWidth();
			break;
		}
	}

	LLTabContainerCommon::removeTabPanel(child);
}

void LLTabContainer::setPanelTitle(S32 index, const LLString& title)
{
	if (index >= 0 && index < (S32)mTabList.size())
	{
		LLTabTuple* tuple = mTabList[index];
		LLButton* tab_button = tuple->mButton;
James Cook's avatar
James Cook committed
		const LLFontGL* fontp = gResMgr->getRes( LLFONT_SANSSERIF_SMALL );
		mTotalTabWidth -= tab_button->getRect().getWidth();
		tab_button->reshape(llclamp(fontp->getWidth(title) + TAB_PADDING + tuple->mPadding, mMinTabWidth, mMaxTabWidth), tab_button->getRect().getHeight());
James Cook's avatar
James Cook committed
		mTotalTabWidth += tab_button->getRect().getWidth();
		tab_button->setLabelSelected(title);
		tab_button->setLabelUnselected(title);
	}
	updateMaxScrollPos();
}


void LLTabContainer::updateMaxScrollPos()
{
	S32 tab_space = 0;
	S32 available_space = 0;
	tab_space = mTotalTabWidth;
	available_space = mRect.getWidth() - mRightTabBtnOffset - 2 * (LLPANEL_BORDER_WIDTH + TABCNTR_TAB_H_PAD);

	if( tab_space > available_space )
	{
		S32 available_width_with_arrows = mRect.getWidth() - mRightTabBtnOffset - 2 * (LLPANEL_BORDER_WIDTH + TABCNTR_ARROW_BTN_SIZE  + TABCNTR_ARROW_BTN_SIZE + 1);
James Cook's avatar
James Cook committed
		// subtract off reserved portion on left
		available_width_with_arrows -= TABCNTR_TAB_PARTIAL_WIDTH;

		S32 running_tab_width = 0;
		mMaxScrollPos = mTabList.size();
		for(tuple_list_t::reverse_iterator tab_it = mTabList.rbegin(); tab_it != mTabList.rend(); ++tab_it)
		{
			running_tab_width += (*tab_it)->mButton->getRect().getWidth();
			if (running_tab_width > available_width_with_arrows)
			{
				break;
			}
			mMaxScrollPos--;
		}
		// in case last tab doesn't actually fit on screen, make it the last scrolling position
		mMaxScrollPos = llmin(mMaxScrollPos, (S32)mTabList.size() - 1);
	}
	else
	{
		mMaxScrollPos = 0;
		mScrollPos = 0;
	}
	if (mScrollPos > mMaxScrollPos)
	{
		mScrollPos = mMaxScrollPos;
	}
}

void LLTabContainer::commitHoveredButton(S32 x, S32 y)
{
James Cook's avatar
James Cook committed
	{
		for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
		{
			LLTabTuple* tuple = *iter;
			tuple->mButton->setVisible( TRUE );
			S32 local_x = x - tuple->mButton->getRect().mLeft;
			S32 local_y = y - tuple->mButton->getRect().mBottom;
			if (tuple->mButton->pointInView(local_x, local_y) && tuple->mButton->getEnabled() && !tuple->mTabPanel->getVisible())
			{
				tuple->mButton->onCommit();
			}
		}
	}
}

void LLTabContainer::setMinTabWidth(S32 width)
{
	mMinTabWidth = width;
}

void LLTabContainer::setMaxTabWidth(S32 width)
{
	mMaxTabWidth = width;
}

S32 LLTabContainer::getMinTabWidth() const
{
	return mMinTabWidth;
}

S32 LLTabContainer::getMaxTabWidth() const
{
	return mMaxTabWidth;
}

BOOL LLTabContainer::selectTab(S32 which)
{
	if (which >= (S32)mTabList.size()) return FALSE;
	if (which < 0) return FALSE;

	//if( gFocusMgr.childHasKeyboardFocus( this ) )
	//{
Jon Wolk's avatar
Jon Wolk committed
	//	gFocusMgr.setKeyboardFocus( NULL );
James Cook's avatar
James Cook committed
	//}

	LLTabTuple* selected_tuple = mTabList[which];
	if (!selected_tuple)
	{
		return FALSE;
	}
	
	if (mTabList[which]->mButton->getEnabled())
	{
		mCurrentTabIdx = which;

		S32 i = 0;
		for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
		{
			LLTabTuple* tuple = *iter;
			BOOL is_selected = ( tuple == selected_tuple );
			tuple->mTabPanel->setVisible( is_selected );
// 			tuple->mTabPanel->setFocus(is_selected); // not clear that we want to do this here.
			tuple->mButton->setToggleState( is_selected );
			// RN: this limits tab-stops to active button only, which would require arrow keys to switch tabs
			tuple->mButton->setTabStop( is_selected );
James Cook's avatar
James Cook committed
			
			if( is_selected && mMaxScrollPos > 0)
			{
				// Make sure selected tab is within scroll region
				if( i < mScrollPos )
				{
					mScrollPos = i;
				}
				else
				{
					S32 available_width_with_arrows = mRect.getWidth() - mRightTabBtnOffset - 2 * (LLPANEL_BORDER_WIDTH + TABCNTR_ARROW_BTN_SIZE  + TABCNTR_ARROW_BTN_SIZE + 1);
James Cook's avatar
James Cook committed
					S32 running_tab_width = tuple->mButton->getRect().getWidth();
					S32 j = i - 1;
					S32 min_scroll_pos = i;
					if (running_tab_width < available_width_with_arrows)
					{
						while (j >= 0)
						{
							LLTabTuple* other_tuple = mTabList[j];
							running_tab_width += other_tuple->mButton->getRect().getWidth();
							if (running_tab_width > available_width_with_arrows)
							{
								break;
							}
							j--;
						}
						min_scroll_pos = j + 1;
					}
					mScrollPos = llclamp(mScrollPos, min_scroll_pos, i);
					mScrollPos = llmin(mScrollPos, mMaxScrollPos);
				}
			}
			i++;
		}
		if( selected_tuple->mOnChangeCallback )
		{
			selected_tuple->mOnChangeCallback( selected_tuple->mUserData, false );
		}
		return TRUE;
	}
	else
	{
		return FALSE;
	}
}

void LLTabContainer::draw()
{
	S32 target_pixel_scroll = 0;
	S32 cur_scroll_pos = mScrollPos;
	if (cur_scroll_pos > 0)
	{
		S32 available_width_with_arrows = mRect.getWidth() - mRightTabBtnOffset - 2 * (LLPANEL_BORDER_WIDTH + TABCNTR_ARROW_BTN_SIZE  + TABCNTR_ARROW_BTN_SIZE + 1);
James Cook's avatar
James Cook committed
		for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
		{
			if (cur_scroll_pos == 0)
			{
				break;
			}
			target_pixel_scroll += (*iter)->mButton->getRect().getWidth();
			cur_scroll_pos--;
		}

		// Show part of the tab to the left of what is fully visible
		target_pixel_scroll -= TABCNTR_TAB_PARTIAL_WIDTH;
		// clamp so that rightmost tab never leaves right side of screen
		target_pixel_scroll = llmin(mTotalTabWidth - available_width_with_arrows, target_pixel_scroll);
	}

	mScrollPosPixels = (S32)lerp((F32)mScrollPosPixels, (F32)target_pixel_scroll, LLCriticalDamp::getInterpolant(0.08f));
	if( getVisible() )
	{
		BOOL has_scroll_arrows = (mMaxScrollPos > 0) || (mScrollPosPixels > 0);
		mJumpLeftArrowBtn->setVisible( has_scroll_arrows );
		mJumpRightArrowBtn->setVisible( has_scroll_arrows );
James Cook's avatar
James Cook committed
		mLeftArrowBtn->setVisible( has_scroll_arrows );
		mRightArrowBtn->setVisible( has_scroll_arrows );

		// Set the leftmost position of the tab buttons.
		S32 left = LLPANEL_BORDER_WIDTH + (has_scroll_arrows ? (TABCNTR_ARROW_BTN_SIZE * 2) : TABCNTR_TAB_H_PAD);
James Cook's avatar
James Cook committed
		left -= mScrollPosPixels;

		// Hide all the buttons
		for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
		{
			LLTabTuple* tuple = *iter;
			tuple->mButton->setVisible( FALSE );
		}

		LLPanel::draw();

		// if tabs are hidden, don't draw them and leave them in the invisible state
		if (!mTabsHidden)
James Cook's avatar
James Cook committed
		{
			// Show all the buttons
			for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
			{
				LLTabTuple* tuple = *iter;
				tuple->mButton->setVisible( TRUE );
			}
James Cook's avatar
James Cook committed

			// Draw some of the buttons...
			LLRect clip_rect = getLocalRect();
			if (has_scroll_arrows)
James Cook's avatar
James Cook committed
			{
				// ...but clip them.
				clip_rect.mLeft = mLeftArrowBtn->getRect().mRight;
				clip_rect.mRight = mRightArrowBtn->getRect().mLeft;
James Cook's avatar
James Cook committed
			}
			LLLocalClipRect clip(clip_rect);
James Cook's avatar
James Cook committed

			S32 max_scroll_visible = mTabList.size() - mMaxScrollPos + mScrollPos;
			S32 idx = 0;
			for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
			{
				LLTabTuple* tuple = *iter;
				tuple->mButton->translate( left - tuple->mButton->getRect().mLeft, 0 );
				left += tuple->mButton->getRect().getWidth();
James Cook's avatar
James Cook committed

				if( idx < mScrollPos )
James Cook's avatar
James Cook committed
				{
					if( tuple->mButton->getFlashing() )
					{
						mLeftArrowBtn->setFlashing( TRUE );
					}
James Cook's avatar
James Cook committed
				}
				else
				if( max_scroll_visible < idx )
James Cook's avatar
James Cook committed
				{
					if( tuple->mButton->getFlashing() )
					{
						mRightArrowBtn->setFlashing( TRUE );
					}
				LLUI::pushMatrix();
				{
					LLUI::translate((F32)tuple->mButton->getRect().mLeft, (F32)tuple->mButton->getRect().mBottom, 0.f);
					tuple->mButton->draw();
				}
				LLUI::popMatrix();
			
				idx++;
James Cook's avatar
James Cook committed
			}
		}

		mLeftArrowBtn->setFlashing(FALSE);
		mRightArrowBtn->setFlashing(FALSE);
	}
}


void LLTabContainer::setRightTabBtnOffset(S32 offset)
{
	mRightArrowBtn->translate( -offset - mRightTabBtnOffset, 0 );
	mRightTabBtnOffset = offset;
	updateMaxScrollPos();
}

BOOL LLTabContainer::handleMouseDown( S32 x, S32 y, MASK mask )
{
	BOOL handled = FALSE;
	BOOL has_scroll_arrows = (mMaxScrollPos > 0);

	if (has_scroll_arrows)
	{		
		if (mJumpLeftArrowBtn->getRect().pointInRect(x, y))
		{
			S32 local_x = x - mJumpLeftArrowBtn->getRect().mLeft;
			S32 local_y = y - mJumpLeftArrowBtn->getRect().mBottom;
			handled = mJumpLeftArrowBtn->handleMouseDown(local_x, local_y, mask);
		}
		if (mJumpRightArrowBtn->getRect().pointInRect(x, y))
		{
			S32 local_x = x - mJumpRightArrowBtn->getRect().mLeft;
			S32 local_y = y - mJumpRightArrowBtn->getRect().mBottom;
			handled = mJumpRightArrowBtn->handleMouseDown(local_x, local_y, mask);
		}
James Cook's avatar
James Cook committed
		if (mLeftArrowBtn->getRect().pointInRect(x, y))
		{
			S32 local_x = x - mLeftArrowBtn->getRect().mLeft;
			S32 local_y = y - mLeftArrowBtn->getRect().mBottom;
			handled = mLeftArrowBtn->handleMouseDown(local_x, local_y, mask);
		}
		else if (mRightArrowBtn->getRect().pointInRect(x, y))
		{
			S32 local_x = x - mRightArrowBtn->getRect().mLeft;
			S32 local_y = y - mRightArrowBtn->getRect().mBottom;
			handled = mRightArrowBtn->handleMouseDown(local_x, local_y, mask);
		}
	}
	if (!handled)
	{
		handled = LLPanel::handleMouseDown( x, y, mask );
	}

	if (mTabList.size() > 0)
	{
		LLTabTuple* firsttuple = mTabList[0];
		LLRect tab_rect(has_scroll_arrows ? mLeftArrowBtn->getRect().mRight : mJumpLeftArrowBtn->getRect().mLeft,
James Cook's avatar
James Cook committed
						firsttuple->mButton->getRect().mTop,
						has_scroll_arrows ? mRightArrowBtn->getRect().mLeft : mJumpRightArrowBtn->getRect().mRight,
James Cook's avatar
James Cook committed
						firsttuple->mButton->getRect().mBottom );
		if( tab_rect.pointInRect( x, y ) )
		{
			LLButton* tab_button = mTabList[getCurrentPanelIndex()]->mButton;
Jon Wolk's avatar
Jon Wolk committed
			gFocusMgr.setKeyboardFocus(tab_button);
James Cook's avatar
James Cook committed
		}
	}
	return handled;
}

BOOL LLTabContainer::handleHover( S32 x, S32 y, MASK mask )
{
	BOOL handled = FALSE;
	BOOL has_scroll_arrows = (mMaxScrollPos > 0);

	if (has_scroll_arrows)
	{		
		if (mJumpLeftArrowBtn->getRect().pointInRect(x, y))
		{
			S32 local_x = x - mJumpLeftArrowBtn->getRect().mLeft;
			S32 local_y = y - mJumpLeftArrowBtn->getRect().mBottom;
			handled = mJumpLeftArrowBtn->handleHover(local_x, local_y, mask);
		}
		if (mJumpRightArrowBtn->getRect().pointInRect(x, y))
		{
			S32 local_x = x - mJumpRightArrowBtn->getRect().mLeft;
			S32 local_y = y - mJumpRightArrowBtn->getRect().mBottom;
			handled = mJumpRightArrowBtn->handleHover(local_x, local_y, mask);
		}
James Cook's avatar
James Cook committed
		if (mLeftArrowBtn->getRect().pointInRect(x, y))
		{
			S32 local_x = x - mLeftArrowBtn->getRect().mLeft;
			S32 local_y = y - mLeftArrowBtn->getRect().mBottom;
			handled = mLeftArrowBtn->handleHover(local_x, local_y, mask);
		}
		else if (mRightArrowBtn->getRect().pointInRect(x, y))
		{
			S32 local_x = x - mRightArrowBtn->getRect().mLeft;
			S32 local_y = y - mRightArrowBtn->getRect().mBottom;
			handled = mRightArrowBtn->handleHover(local_x, local_y, mask);
		}
	}
	if (!handled)
	{
		handled = LLPanel::handleHover(x, y, mask);
	}

	commitHoveredButton(x, y);
	return handled;
}

BOOL LLTabContainer::handleMouseUp( S32 x, S32 y, MASK mask )
{
	BOOL handled = FALSE;
	BOOL has_scroll_arrows = (mMaxScrollPos > 0);

	if (has_scroll_arrows)
	{
		if (mJumpLeftArrowBtn->getRect().pointInRect(x, y))
		{
			S32 local_x = x - mJumpLeftArrowBtn->getRect().mLeft;
			S32 local_y = y - mJumpLeftArrowBtn->getRect().mBottom;
			handled = mJumpLeftArrowBtn->handleMouseUp(local_x, local_y, mask);
		}		
		if (mJumpRightArrowBtn->getRect().pointInRect(x,	y))
		{
			S32	local_x	= x	- mJumpRightArrowBtn->getRect().mLeft;
			S32	local_y	= y	- mJumpRightArrowBtn->getRect().mBottom;
			handled = mJumpRightArrowBtn->handleMouseUp(local_x,	local_y, mask);
		}
James Cook's avatar
James Cook committed
		if (mLeftArrowBtn->getRect().pointInRect(x, y))
		{
			S32 local_x = x - mLeftArrowBtn->getRect().mLeft;
			S32 local_y = y - mLeftArrowBtn->getRect().mBottom;
			handled = mLeftArrowBtn->handleMouseUp(local_x, local_y, mask);
		}
		else if (mRightArrowBtn->getRect().pointInRect(x, y))
		{
			S32 local_x = x - mRightArrowBtn->getRect().mLeft;
			S32 local_y = y - mRightArrowBtn->getRect().mBottom;
			handled = mRightArrowBtn->handleMouseUp(local_x, local_y, mask);
		}
	}
	if (!handled)
	{
		handled = LLPanel::handleMouseUp( x, y, mask );
	}

	commitHoveredButton(x, y);
	LLPanel* cur_panel = getCurrentPanel();
James Cook's avatar
James Cook committed
	{
		if (cur_panel)
		{
			if (!cur_panel->focusFirstItem(FALSE))
			{
				// if nothing in the panel gets focus, make sure the new tab does
				// otherwise the last tab might keep focus
				mTabList[getCurrentPanelIndex()]->mButton->setFocus(TRUE);
			}
		}
James Cook's avatar
James Cook committed
	}
	return handled;
}

BOOL LLTabContainer::handleToolTip( S32 x, S32 y, LLString& msg, LLRect* sticky_rect )
{
	BOOL handled = LLPanel::handleToolTip( x, y, msg, sticky_rect );
Jon Wolk's avatar
Jon Wolk committed
	if (!handled && mTabList.size() > 0) 
James Cook's avatar
James Cook committed
	{
		LLTabTuple* firsttuple = mTabList[0];

		BOOL has_scroll_arrows = (mMaxScrollPos > 0);
		LLRect clip(
			has_scroll_arrows ? mJumpLeftArrowBtn->getRect().mRight : mJumpLeftArrowBtn->getRect().mLeft,
James Cook's avatar
James Cook committed
			firsttuple->mButton->getRect().mTop,
			has_scroll_arrows ? mRightArrowBtn->getRect().mLeft : mRightArrowBtn->getRect().mRight,
			0 );
		if( clip.pointInRect( x, y ) )
		{
			for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
			{
				LLTabTuple* tuple = *iter;
				tuple->mButton->setVisible( TRUE );
				S32 local_x = x - tuple->mButton->getRect().mLeft;
				S32 local_y = y - tuple->mButton->getRect().mBottom;
				handled = tuple->mButton->handleToolTip( local_x, local_y, msg, sticky_rect );
				if( handled )
				{
					break;
				}
			}
		}

		for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
		{
			LLTabTuple* tuple = *iter;
			tuple->mButton->setVisible( FALSE );
		}
	}
	return handled;
}

BOOL LLTabContainer::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent)
{
	if (!getEnabled()) return FALSE;

	if (!gFocusMgr.childHasKeyboardFocus(this)) return FALSE;

	BOOL handled = FALSE;
	if (key == KEY_LEFT && mask == MASK_ALT)
James Cook's avatar
James Cook committed
	{
		selectPrevTab();
		handled = TRUE;
	}
	else if (key == KEY_RIGHT && mask == MASK_ALT)
James Cook's avatar
James Cook committed
	{
		selectNextTab();
		handled = TRUE;
	}

	if (handled)
	{
		if (getCurrentPanel())
		{
			getCurrentPanel()->setFocus(TRUE);
		}
	}

	if (!gFocusMgr.childHasKeyboardFocus(getCurrentPanel()))
	{
		// if child has focus, but not the current panel, focus
		// is on a button
		switch(key)
		{
		case KEY_UP:
			if (getTabPosition() == BOTTOM && getCurrentPanel())
			{
				getCurrentPanel()->setFocus(TRUE);
			}
			handled = TRUE;
			break;
		case KEY_DOWN:
			if (getTabPosition() == TOP && getCurrentPanel())
			{
				getCurrentPanel()->setFocus(TRUE);
			}
			handled = TRUE;
			break;
		case KEY_LEFT:
		  	selectPrevTab();
			handled = TRUE;
			break;
		case KEY_RIGHT:
		  	selectNextTab();
			handled = TRUE;
			break;
		default:
			break;
		}
	}
	return handled;
}

// virtual
LLXMLNodePtr LLTabContainer::getXML(bool save_children) const
{
	LLXMLNodePtr node = LLTabContainerCommon::getXML();

	node->createChild("tab_position", TRUE)->setStringValue((mTabPosition == TOP ? "top" : "bottom"));

	return node;
}

BOOL LLTabContainer::handleDragAndDrop(S32 x, S32 y, MASK mask,	BOOL drop,	EDragAndDropType type, void* cargo_data, EAcceptance *accept, LLString	&tooltip)
{
	BOOL has_scroll_arrows = (mMaxScrollPos	> 0);

	if( mDragAndDropDelayTimer.getElapsedTimeF32() > SCROLL_DELAY_TIME )
James Cook's avatar
James Cook committed
	{
James Cook's avatar
James Cook committed
		{
			if (mJumpLeftArrowBtn->getRect().pointInRect(x,	y))
			{
				S32	local_x	= x	- mJumpLeftArrowBtn->getRect().mLeft;
				S32	local_y	= y	- mJumpLeftArrowBtn->getRect().mBottom;
				mJumpLeftArrowBtn->handleHover(local_x,	local_y, mask);
			}
			if (mJumpRightArrowBtn->getRect().pointInRect(x,	y))
			{
				S32	local_x	= x	- mJumpRightArrowBtn->getRect().mLeft;
				S32	local_y	= y	- mJumpRightArrowBtn->getRect().mBottom;
				mJumpRightArrowBtn->handleHover(local_x,	local_y, mask);
			}
			if (mLeftArrowBtn->getRect().pointInRect(x,	y))
			{
				S32	local_x	= x	- mLeftArrowBtn->getRect().mLeft;
				S32	local_y	= y	- mLeftArrowBtn->getRect().mBottom;
				mLeftArrowBtn->handleHover(local_x,	local_y, mask);
			}
			else if	(mRightArrowBtn->getRect().pointInRect(x, y))
			{
				S32	local_x	= x	- mRightArrowBtn->getRect().mLeft;
				S32	local_y	= y	- mRightArrowBtn->getRect().mBottom;
				mRightArrowBtn->handleHover(local_x, local_y, mask);
			}
		for(tuple_list_t::iterator iter	= mTabList.begin();	iter !=	 mTabList.end(); ++iter)
James Cook's avatar
James Cook committed
		{
			LLTabTuple*	tuple =	*iter;
			tuple->mButton->setVisible(	TRUE );
			S32	local_x	= x	- tuple->mButton->getRect().mLeft;
			S32	local_y	= y	- tuple->mButton->getRect().mBottom;
			if (tuple->mButton->pointInView(local_x, local_y) &&  tuple->mButton->getEnabled() && !tuple->mTabPanel->getVisible())
			{
				tuple->mButton->onCommit();
				mDragAndDropDelayTimer.stop();
			}
James Cook's avatar
James Cook committed
		}
	}

	return LLView::handleDragAndDrop(x,	y, mask, drop, type, cargo_data,  accept, tooltip);
}
void LLTabContainer::setTabImage(LLPanel* child, std::string image_name, const LLColor4& color)
{
	LLTabTuple* tuple = getTabByPanel(child);
	if( tuple )
	{
		tuple->mButton->setImageOverlay(image_name, LLFontGL::RIGHT, color);

		const LLFontGL* fontp = gResMgr->getRes( LLFONT_SANSSERIF_SMALL );
		// remove current width from total tab strip width
		mTotalTabWidth -= tuple->mButton->getRect().getWidth();

		S32 image_overlay_width = tuple->mButton->getImageOverlay().notNull() ? 
Jon Wolk's avatar
Jon Wolk committed
			tuple->mButton->getImageOverlay()->getImage()->getWidth(0) :

		tuple->mPadding = image_overlay_width;

Jon Wolk's avatar
Jon Wolk committed
		tuple->mButton->setRightHPad(6);
		tuple->mButton->reshape(llclamp(fontp->getWidth(tuple->mButton->getLabelSelected()) + TAB_PADDING + tuple->mPadding, mMinTabWidth, mMaxTabWidth), 
								tuple->mButton->getRect().getHeight());
		// add back in button width to total tab strip width
		mTotalTabWidth += tuple->mButton->getRect().getWidth();

		// tabs have changed size, might need to scroll to see current tab
		updateMaxScrollPos();
	}