Commits

Bryan O'Sullivan  committed ab9809c Merge

Merge with SVN viewer-2.0.0-3 branch

  • Participants
  • Parent commits 7015875, 633a71b

Comments (0)

Files changed (148)

File indra/llcommon/linden_common.h

 #include "lldefs.h"
 #include "llerror.h"
 #include "llextendedstatus.h"
-#include "llfasttimer.h"
+// Don't do this, adds 15K lines of header code to every library file.
+//#include "llfasttimer.h"
 #include "llfile.h"
 #include "llformat.h"
 

File indra/llcommon/lldate.cpp

 #include "apr_time.h"
 
 #include <time.h>
-#include <locale>
+#include <locale.h>
 #include <string>
 #include <iomanip>
 #include <sstream>
 {
 	LLFastTimer ft1(FT_DATE_FORMAT);
 	
-	std::ostringstream stream;
 	time_t locSeconds = (time_t) mSecondsSinceEpoch;
 	struct tm * gmt = gmtime (&locSeconds);
-
-	stream.imbue (std::locale(LLStringUtil::getLocale().c_str()));
-	toHTTPDateStream (stream, gmt, fmt);
-	return stream.str();
+	return toHTTPDateString(gmt, fmt);
 }
 
 std::string LLDate::toHTTPDateString (tm * gmt, std::string fmt)
 {
 	LLFastTimer ft1(FT_DATE_FORMAT);
-	
-	std::ostringstream stream;
-	stream.imbue (std::locale(LLStringUtil::getLocale().c_str()));
-	toHTTPDateStream (stream, gmt, fmt);
-	return stream.str();
-}
 
-void LLDate::toHTTPDateStream(std::ostream& s, tm * gmt, std::string fmt)
-{
-	LLFastTimer ft1(FT_DATE_FORMAT);
+	// avoid calling setlocale() unnecessarily - it's expensive.
+	static std::string prev_locale = "";
+	std::string this_locale = LLStringUtil::getLocale();
+	if (this_locale != prev_locale)
+	{
+		setlocale(LC_TIME, this_locale.c_str());
+		prev_locale = this_locale;
+	}
 
-	const char * pBeg = fmt.c_str();
-	const char * pEnd = pBeg + fmt.length();
-	const std::time_put<char>& tp = std::use_facet<std::time_put<char> >(s.getloc());
-	tp.put (s, s, s.fill(), gmt, pBeg, pEnd);
+	// use strftime() as it appears to be faster than std::time_put
+	char buffer[128];
+	strftime(buffer, 128, fmt.c_str(), gmt);
+	return std::string(buffer);
 }
 
 void LLDate::toStream(std::ostream& s) const

File indra/llcommon/lldate.h

 	void toStream(std::ostream&) const;
 	std::string toHTTPDateString (std::string fmt) const;
 	static std::string toHTTPDateString (tm * gmt, std::string fmt);
-	static void toHTTPDateStream(std::ostream&, tm *, std::string);
 	/** 
 	 * @brief Set the date from an ISO-8601 string.
 	 *

File indra/llcommon/llstring.h

 #include <string>
 #include <locale>
 #include <iomanip>
-#include <boost/regex.hpp>
 #include "llsd.h"
 #include "llfasttimer.h"
 
 	
 	typedef std::map<LLFormatMapString, LLFormatMapString> format_map_t;
 	static void getTokens(const std::basic_string<T>& instr, std::vector<std::basic_string<T> >& tokens, const std::basic_string<T>& delims);
-	static size_type getSubstitution(const std::basic_string<T>& instr, size_type& start, std::vector<std::basic_string<T> >& tokens);
 	static void formatNumber(std::basic_string<T>& numStr, std::basic_string<T> decimals);
 	static bool formatDatetime(std::basic_string<T>& replacement, std::basic_string<T> token, std::basic_string<T> param, S32 secFromEpoch);
 	static S32 format(std::basic_string<T>& s, const format_map_t& substitutions);
 	static void		testHarness();
 #endif
 
+private:
+	static size_type getSubstitution(const std::basic_string<T>& instr, size_type& start, std::vector<std::basic_string<T> >& tokens);
 };
 
 template<class T> std::basic_string<T> LLStringUtilBase<T>::null;

File indra/llmath/llcoord.h

 	{}
 	LLCoordGL(S32 x, S32 y) : LLCoord(x, y)
 	{}
+	bool operator==(const LLCoordGL& other) const { return mX == other.mX && mY == other.mY; }
+	bool operator!=(const LLCoordGL& other) const { return !(*this == other); }
 };
 
+//bool operator ==(const LLCoordGL& a, const LLCoordGL& b);
 
 // Window coords include things like window borders,
 // menu regions, etc.
 	{}
 	LLCoordWindow(S32 x, S32 y) : LLCoord(x, y)
 	{}
+	bool operator==(const LLCoordWindow& other) const { return mX == other.mX && mY == other.mY; }
+	bool operator!=(const LLCoordWindow& other) const { return !(*this == other); }
 };
 
 
 	{}
 	LLCoordScreen(S32 x, S32 y) : LLCoord(x, y)
 	{}
+	bool operator==(const LLCoordScreen& other) const { return mX == other.mX && mY == other.mY; }
+	bool operator!=(const LLCoordScreen& other) const { return !(*this == other); }
 };
 
 class LLCoordFont : public LLCoord
 	
 	void set(S32 x, S32 y) { LLCoord::set(x,y); mZ = 0.f; }
 	void set(S32 x, S32 y, F32 z) { mX = x; mY = y; mZ = z; }
+	bool operator==(const LLCoordFont& other) const { return mX == other.mX && mY == other.mY; }
+	bool operator!=(const LLCoordFont& other) const { return !(*this == other); }
 };
 	
 

File indra/llplugin/llpluginclassmedia.h

 #ifndef LL_LLPLUGINCLASSMEDIA_H
 #define LL_LLPLUGINCLASSMEDIA_H
 
-#include "llgl.h"
+#include "llgltypes.h"
 #include "llpluginprocessparent.h"
 #include "llrect.h"
 #include "llpluginclassmediaowner.h"

File indra/llplugin/llpluginclassmediaowner.h

 #ifndef LL_LLPLUGINCLASSMEDIAOWNER_H
 #define LL_LLPLUGINCLASSMEDIAOWNER_H
 
-#include "llgl.h"
 #include "llpluginprocessparent.h"
 #include "llrect.h"
 #include <queue>

File indra/llui/CMakeLists.txt

     lllayoutstack.cpp
     lllineeditor.cpp
     lllistctrl.cpp
+    lllocalcliprect.cpp
     llmenugl.cpp
     llmodaldialog.cpp
     llmultifloater.cpp 
     lltexteditor.cpp
     lltextparser.cpp
     lltransutil.cpp
+    lltooltip.cpp
     llui.cpp
     lluicolortable.cpp
     lluictrl.cpp
     lllazyvalue.h
     lllineeditor.h
     lllistctrl.h
+    lllocalcliprect.h
     llmenugl.h
     llmodaldialog.h
     llmultifloater.h 
     lltextbox.h
     lltexteditor.h
     lltextparser.h
+    lltooltip.h
     lltransutil.h
     lluicolortable.h
     lluiconstants.h

File indra/llui/llbutton.cpp

 // virtual
 void LLButton::draw()
 {
+	F32 alpha = getDrawContext().mAlpha;
 	bool flash = FALSE;
 	static LLUICachedControl<F32> button_flash_rate("ButtonFlashRate", 0);
 	static LLUICachedControl<S32> button_flash_count("ButtonFlashCount", 0);
 	// Unselected image assignments
 	S32 local_mouse_x;
 	S32 local_mouse_y;
-	LLUI::getCursorPositionLocal(this, &local_mouse_x, &local_mouse_y);
+	LLUI::getMousePositionLocal(this, &local_mouse_x, &local_mouse_y);
 
 	bool enabled = isInEnabledChain();
 
 	if (hasFocus())
 	{
 		F32 lerp_amt = gFocusMgr.getFocusFlashAmt();
-		drawBorder(imagep, gFocusMgr.getFocusColor(), llround(lerp(1.f, 3.f, lerp_amt)));
+		drawBorder(imagep, gFocusMgr.getFocusColor() % alpha, llround(lerp(1.f, 3.f, lerp_amt)));
 	}
 	
 	if (use_glow_effect)
 		LLColor4 disabled_color = mFadeWhenDisabled ? mDisabledImageColor.get() % 0.5f : mDisabledImageColor.get();
 		if ( mScaleImage)
 		{
-			imagep->draw(getLocalRect(), enabled ? mImageColor.get() : disabled_color  );
+			imagep->draw(getLocalRect(), (enabled ? mImageColor.get() : disabled_color) % alpha  );
 			if (mCurGlowStrength > 0.01f)
 			{
 				gGL.setSceneBlendType(glow_type);
-				imagep->drawSolid(0, 0, getRect().getWidth(), getRect().getHeight(), glow_color % mCurGlowStrength);
+				imagep->drawSolid(0, 0, getRect().getWidth(), getRect().getHeight(), glow_color % (mCurGlowStrength * alpha));
 				gGL.setSceneBlendType(LLRender::BT_ALPHA);
 			}
 		}
 		else
 		{
-			imagep->draw(0, 0, enabled ? mImageColor.get() : disabled_color );
+			imagep->draw(0, 0, (enabled ? mImageColor.get() : disabled_color) % alpha );
 			if (mCurGlowStrength > 0.01f)
 			{
 				gGL.setSceneBlendType(glow_type);
-				imagep->drawSolid(0, 0, glow_color % mCurGlowStrength);
+				imagep->drawSolid(0, 0, glow_color % (mCurGlowStrength * alpha));
 				gGL.setSceneBlendType(LLRender::BT_ALPHA);
 			}
 		}
 		// no image
 		lldebugs << "No image for button " << getName() << llendl;
 		// draw it in pink so we can find it
-		gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4::pink1, FALSE);
+		gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4::pink1 % alpha, FALSE);
 	}
 
 	// let overlay image and text play well together
 		{
 			overlay_color.mV[VALPHA] = 0.5f;
 		}
+		overlay_color.mV[VALPHA] *= alpha;
 
 		switch(mImageOverlayAlignment)
 		{
 		// Due to U32_MAX is equal to S32 -1 value I have rest this value for non-ellipses mode.
 		// Not sure if it is really needed. Probably S32_MAX should be always passed as max_chars.
 		mGLFont->render(label, 0, (F32)x, (F32)(LLBUTTON_V_PAD + y_offset), 
-			label_color,
+			label_color % alpha,
 			mHAlign, LLFontGL::BOTTOM,
 			LLFontGL::NORMAL,
 			mDropShadowedText ? LLFontGL::DROP_SHADOW_SOFT : LLFontGL::NO_SHADOW,
 	setImageColor(color);
 }
 
-void LLButton::setAlpha(F32 alpha)
-{
-	LLColor4 temp = mImageColor.get();
-	temp.setAlpha(alpha);
-	mImageColor.set(temp);
-	
-	temp = mDisabledImageColor.get();
-	temp.setAlpha(alpha * 0.5f);
-	mDisabledImageColor.set(temp);
-}
-
 void LLButton::setImageDisabled(LLPointer<LLUIImage> image)
 {
 	mImageDisabled = image;

File indra/llui/llbutton.h

 	void			setImageColor(const std::string& color_control);
 	void			setImageColor(const LLColor4& c);
 	/*virtual*/ void	setColor(const LLColor4& c);
-	/*virtual*/ void	setAlpha(F32 alpha);
 
 	void			setImages(const std::string &image_name, const std::string &selected_name);
 	

File indra/llui/llcombobox.cpp

 #include "lllineeditor.h"
 #include "v2math.h"
 #include "lluictrlfactory.h"
+#include "lltooltip.h"
 
 // Globals
 S32 LLCOMBOBOX_HEIGHT = 0;
 
 LLComboBox::Params::Params()
 :	allow_text_entry("allow_text_entry", false),
+	allow_new_values("allow_new_values", false),
 	show_text_as_tentative("show_text_as_tentative", true),
 	max_chars("max_chars", 20),
 	list_position("list_position", BELOW),
 	mTextEntryTentative(p.show_text_as_tentative),
 	mHasAutocompletedText(false),
 	mAllowTextEntry(p.allow_text_entry),
+	mAllowNewValues(p.allow_new_values),
 	mMaxChars(p.max_chars),
 	mPrearrangeCallback(p.prearrange_callback()),
 	mTextEntryCallback(p.text_entry_callback()),
 	if (mList->getVisible())
 	{
 		// assert selection in list
-		mList->selectNthItem(mLastSelectedIndex);
+		if(mAllowNewValues)
+		{
+			// mLastSelectedIndex = -1 means that we entered a new value, don't select
+			// any of existing items in this case.
+			if(mLastSelectedIndex >= 0)
+				mList->selectNthItem(mLastSelectedIndex);
+		}
+		else
+			mList->selectNthItem(mLastSelectedIndex);
 
 		mButton->setToggleState(FALSE);
 		mList->setVisible(FALSE);
 	}
 }
 
-BOOL LLComboBox::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen)
+BOOL LLComboBox::handleToolTip(S32 x, S32 y, std::string& msg, LLRect& sticky_rect_screen)
 {
     std::string tool_tip;
 
 		return TRUE;
 	}
 	
-	if (LLUI::sShowXUINames)
+	tool_tip = getToolTip();
+	if (tool_tip.empty())
 	{
-		tool_tip = getShowNamesToolTip();
-	}
-	else
-	{
-		tool_tip = getToolTip();
-		if (tool_tip.empty())
-		{
-			tool_tip = getSelectedItemLabel();
-		}
+		tool_tip = getSelectedItemLabel();
 	}
 	
 	if( !tool_tip.empty() )
 	{
-		msg = tool_tip;
-
-		// Convert rect local to screen coordinates
-		*sticky_rect_screen = calcScreenRect();
+		LLToolTipMgr::instance().show(LLToolTipParams()
+			.message(tool_tip)
+			.sticky_rect(calcScreenRect()));
 	}
 	return TRUE;
 }

File indra/llui/llcombobox.h

 	:	public LLInitParam::Block<Params, LLUICtrl::Params>
 	{
 		Optional<bool>						allow_text_entry,
-											show_text_as_tentative;
+											show_text_as_tentative,
+											allow_new_values;
 		Optional<S32>						max_chars;
 		Optional<commit_callback_t> 		prearrange_callback,
 											text_entry_callback,
 	// LLView interface
 	virtual void	onFocusLost();
 
-	virtual BOOL	handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect);
+	virtual BOOL	handleToolTip(S32 x, S32 y, std::string& msg, LLRect& sticky_rect);
 	virtual BOOL	handleKeyHere(KEY key, MASK mask);
 	virtual BOOL	handleUnicodeCharHere(llwchar uni_char);
 
 
 private:
 	BOOL				mAllowTextEntry;
+	BOOL				mAllowNewValues;
 	S32					mMaxChars;
 	BOOL				mTextEntryTentative;
 	commit_callback_t	mPrearrangeCallback;

File indra/llui/lldockablefloater.cpp

 
 #include "lldockablefloater.h"
 
+//static
+LLDockableFloater* LLDockableFloater::instance = NULL;
+
 LLDockableFloater::LLDockableFloater(LLDockControl* dockControl,
 		const LLSD& key, const Params& params) :
 	LLFloater(key, params), mDockControl(dockControl)
 {
+	resetInstance();
 }
 
 LLDockableFloater::~LLDockableFloater()
 	return LLView::postBuild();
 }
 
+void LLDockableFloater::resetInstance()
+{
+	if (instance != this)
+	{
+		if (instance != NULL && instance->isDocked())
+		{
+			//closeFloater() is not virtual
+			if (instance->canClose())
+			{
+				instance->closeFloater();
+			}
+			else
+			{
+				instance->setVisible(FALSE);
+			}
+		}
+		instance = this;
+	}
+}
+
+void LLDockableFloater::setVisible(BOOL visible)
+{
+	if(visible && isDocked())
+	{
+		resetInstance();
+	}
+	LLFloater::setVisible(visible);
+}
+
 void LLDockableFloater::setDocked(bool docked, bool pop_on_undock)
 {
-	if (docked)
+	if (mDockControl.get() != NULL)
 	{
-		mDockControl.get()->on();
+		if (docked)
+		{
+			resetInstance();
+			mDockControl.get()->on();
+		}
+		else
+		{
+			mDockControl.get()->off();
+		}
 	}
-	else
+
+	if (!docked && pop_on_undock)
 	{
-		mDockControl.get()->off();
+		// visually pop up a little bit to emphasize the undocking
+		translate(0, UNDOCK_LEAP_HEIGHT);
 	}
+
 	LLFloater::setDocked(docked, pop_on_undock);
 }
 
 void LLDockableFloater::draw()
 {
-	mDockControl.get()->repositionDockable();
-	mDockControl.get()->drawToungue();
+	if (mDockControl.get() != NULL)
+	{
+		mDockControl.get()->repositionDockable();
+		mDockControl.get()->drawToungue();
+	}
 	LLFloater::draw();
 }
 

File indra/llui/lldockablefloater.h

  */
 class LLDockableFloater : public LLFloater
 {
+	static const U32 UNDOCK_LEAP_HEIGHT = 12;
 public:
 	LOG_CLASS(LLDockableFloater);
 	LLDockableFloater(LLDockControl* dockControl, const LLSD& key, const Params& params = getDefaultParams());
 	/* virtula */BOOL postBuild();
 	/* virtual */void setDocked(bool docked, bool pop_on_undock = true);
 	/* virtual */void draw();
+	/*virtual*/ void setVisible(BOOL visible);
+
+private:
+	/**
+	 * Provides unique of dockable floater.
+	 * If dockable floater already exists it should  be closed.
+	 */
+	void resetInstance();
 
 protected:
 	void setDockControl(LLDockControl* dockControl);
 private:
 	std::auto_ptr<LLDockControl> mDockControl;
 	LLUIImagePtr mDockTongue;
+	static LLDockableFloater* instance;
 };
 
 #endif /* LL_DOCKABLEFLOATER_H */

File indra/llui/llfiltereditor.cpp

 	line_editor_p.rect(getLocalRect());
 	line_editor_p.follows.flags(FOLLOWS_ALL);
 	line_editor_p.text_pad_right(getRect().getHeight());
+	line_editor_p.revert_on_esc(false);
 	line_editor_p.keystroke_callback(boost::bind(&LLUICtrl::onCommit, this));
 
 	mFilterEditor = LLUICtrlFactory::create<LLLineEditor>(line_editor_p);

File indra/llui/llfloater.cpp

 	close_callback("close_callback"),
 	can_dock("can_dock", false)
 {
-	name = "floater";
-	// defaults that differ from LLPanel:
-	background_visible = true;
 	visible = false;
 }
 
 	}
 }
 
+// defaults for floater param block pulled from widgets/floater.xml
+static LLWidgetNameRegistry::StaticRegistrar sRegisterFloaterParams(&typeid(LLFloater::Params), "floater");
+
 LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p)
-	:	LLPanel(),
-		mDragHandle(NULL),
-		mTitle(p.title),
-		mShortTitle(p.short_title),
-		mSingleInstance(p.single_instance),
-		mKey(key),
-		mAutoTile(p.auto_tile),
-		mCanTearOff(p.can_tear_off),
-		mCanMinimize(p.can_minimize),
-		mCanClose(p.can_close),
-		mDragOnLeft(p.can_drag_on_left),
-		mResizable(p.can_resize),
-		mMinWidth(p.min_width),
-		mMinHeight(p.min_height),
-		mMinimized(FALSE),
-		mForeground(FALSE),
-		mFirstLook(TRUE),
-		mEditing(FALSE),
-		mButtonScale(1.0f),
-		mAutoFocus(TRUE), // automatically take focus when opened
-		mCanDock(false),
-		mDocked(false),
-		mHasBeenDraggedWhileMinimized(FALSE),
-		mPreviousMinimizedBottom(0),
-		mPreviousMinimizedLeft(0),
-		mNotificationContext(NULL)
+:	LLPanel(),
+	mDragHandle(NULL),
+	mTitle(p.title),
+	mShortTitle(p.short_title),
+	mSingleInstance(p.single_instance),
+	mKey(key),
+	mAutoTile(p.auto_tile),
+	mCanTearOff(p.can_tear_off),
+	mCanMinimize(p.can_minimize),
+	mCanClose(p.can_close),
+	mDragOnLeft(p.can_drag_on_left),
+	mResizable(p.can_resize),
+	mMinWidth(p.min_width),
+	mMinHeight(p.min_height),
+	mMinimized(FALSE),
+	mForeground(FALSE),
+	mFirstLook(TRUE),
+	mEditing(FALSE),
+	mButtonScale(1.0f),
+	mAutoFocus(TRUE), // automatically take focus when opened
+	mCanDock(false),
+	mDocked(false),
+	mHasBeenDraggedWhileMinimized(FALSE),
+	mPreviousMinimizedBottom(0),
+	mPreviousMinimizedLeft(0),
+	mNotificationContext(NULL)
 {
-	static LLUIColor default_background_color = LLUIColorTable::instance().getColor("FloaterDefaultBackgroundColor");
-	static LLUIColor focus_background_color = LLUIColorTable::instance().getColor("FloaterFocusBackgroundColor");
-	
 	mHandle.bind(this);
 	mNotificationContext = new LLFloaterNotificationContext(getHandle());
-	mBgColorAlpha        = default_background_color;
-	mBgColorOpaque       = focus_background_color;
 
 	// Clicks stop here.
 	setMouseOpaque(TRUE);
 
 void LLFloater::applyTitle()
 {
-	if (gNoRender)
-	{
-		return;
-	}
-
 	if (!mDragHandle)
 	{
 		return;
 // virtual
 void LLFloater::draw()
 {
+	F32 alpha = getDrawContext().mAlpha;
 	// draw background
 	if( isBackgroundVisible() )
 	{
 			shadow_color.mV[VALPHA] *= 0.5f;
 		}
 		gl_drop_shadow(left, top, right, bottom, 
-			shadow_color, 
+			shadow_color % alpha, 
 			llround(shadow_offset));
 
 		// No transparent windows in simple UI
 		if (isBackgroundOpaque())
 		{
-			gl_rect_2d( left, top, right, bottom, mBgColorOpaque );
+			gl_rect_2d( left, top, right, bottom, getBackgroundColor() % alpha );
 		}
 		else
 		{
-			gl_rect_2d( left, top, right, bottom, mBgColorAlpha );
+			gl_rect_2d( left, top, right, bottom, getTransparentColor() % alpha );
 		}
 
-		if(gFocusMgr.childHasKeyboardFocus(this) && !getIsChrome() && !getCurrentTitle().empty())
+		if(hasFocus() 
+			&& !getIsChrome() 
+			&& !getCurrentTitle().empty())
 		{
 			static LLUIColor titlebar_focus_color = LLUIColorTable::instance().getColor("TitleBarFocusColor");
 			// draw highlight on title bar to indicate focus.  RDW
 			const LLFontGL* font = LLFontGL::getFontSansSerif();
 			LLRect r = getRect();
 			gl_rect_2d_offset_local(0, r.getHeight(), r.getWidth(), r.getHeight() - (S32)font->getLineHeight() - 1, 
-				titlebar_focus_color, 0, TRUE);
+				titlebar_focus_color % alpha, 0, TRUE);
 		}
 	}
 
 		static LLUIColor unfocus_border_color = LLUIColorTable::instance().getColor("FloaterUnfocusBorderColor");
 		LLUI::setLineWidth(1.5f);
 		LLColor4 outlineColor = gFocusMgr.childHasKeyboardFocus(this) ? focus_border_color : unfocus_border_color;
-		gl_rect_2d_offset_local(0, getRect().getHeight() + 1, getRect().getWidth() + 1, 0, outlineColor, -LLPANEL_BORDER_WIDTH, FALSE);
+		gl_rect_2d_offset_local(0, getRect().getHeight() + 1, getRect().getWidth() + 1, 0, outlineColor % alpha, -LLPANEL_BORDER_WIDTH, FALSE);
 		LLUI::setLineWidth(1.f);
 	}
 

File indra/llui/llfloater.h

 	S32				mPreviousMinimizedBottom;
 	S32				mPreviousMinimizedLeft;
 
-	LLColor4		mBgColorAlpha;
-	LLColor4		mBgColorOpaque;
-
 	LLFloaterNotificationContext* mNotificationContext;
 	LLRootHandle<LLFloater>		mHandle;	
 };

File indra/llui/lliconctrl.cpp

 {
 	if( mImagep.notNull() )
 	{
-		mImagep->draw(getLocalRect(), mColor.get() );
+		mImagep->draw(getLocalRect(), mColor.get() % getDrawContext().mAlpha );
 	}
 
 	LLUICtrl::draw();
 }
 
-// virtual 
-void LLIconCtrl::setAlpha(F32 alpha)
-{
-	LLColor4 temp = mColor.get();
-	temp.setAlpha(alpha);
-	mColor.set(temp);
-}
-
 // virtual
 // value might be a string or a UUID
 void LLIconCtrl::setValue(const LLSD& value )

File indra/llui/lliconctrl.h

 
 	std::string	getImageName() const;
 
-	/*virtual*/ void	setAlpha(F32 alpha);
-
 	void			setColor(const LLColor4& color) { mColor = color; }
 
 private:

File indra/llui/lllayoutstack.cpp

 #include "linden_common.h"
 
 #include "lllayoutstack.h"
+#include "lllocalcliprect.h"
 #include "llresizebar.h"
 #include "llcriticaldamp.h"
 
 				FALSE, output_child);
 
 			LLPanel::Params p;
+			p.mouse_opaque(false);
 			LLPanel* panelp = LLUICtrlFactory::create<LLPanel>(p);
 			LLView* new_child = LLUICtrlFactory::getInstance()->createFromXML(child_node, panelp, LLStringUtil::null, LLPanel::child_registry_t::instance(), output_child);
 			if (new_child)

File indra/llui/lllineeditor.cpp

 	background_image_focused("background_image_focused"),
 	select_on_focus("select_on_focus", false),
 	handle_edit_keys_directly("handle_edit_keys_directly", false),
+	revert_on_esc("revert_on_esc", true),
 	commit_on_focus_lost("commit_on_focus_lost", true),
 	ignore_tab("ignore_tab", true),
 	cursor_color("cursor_color"),
 	mMinHPixels(0),		// computed in updateTextPadding() below
 	mMaxHPixels(0),		// computed in updateTextPadding() below
 	mCommitOnFocusLost( p.commit_on_focus_lost ),
-	mRevertOnEsc( TRUE ),
+	mRevertOnEsc( p.revert_on_esc ),
 	mKeystrokeCallback( p.keystroke_callback() ),
 	mIsSelecting( FALSE ),
 	mSelectionStart( 0 ),

File indra/llui/lllineeditor.h

 
 		Optional<bool>					select_on_focus,
 										handle_edit_keys_directly,
+										revert_on_esc,
 										commit_on_focus_lost,
 										ignore_tab;
 

File indra/llui/lllocalcliprect.cpp

+/** 
+* @file lllocalcliprect.cpp
+*
+* $LicenseInfo:firstyear=2009&license=viewergpl$
+* 
+* Copyright (c) 2009, Linden Research, Inc.
+* 
+* Second Life Viewer Source Code
+* The source code in this file ("Source Code") is provided by Linden Lab
+* to you under the terms of the GNU General Public License, version 2.0
+* ("GPL"), unless you have obtained a separate licensing agreement
+* ("Other License"), formally executed by you and Linden Lab.  Terms of
+* the GPL can be found in doc/GPL-license.txt in this distribution, or
+* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+* 
+* There are special exceptions to the terms and conditions of the GPL as
+* it is applied to this Source Code. View the full text of the exception
+* in the file doc/FLOSS-exception.txt in this software distribution, or
+* online at
+* http://secondlifegrid.net/programs/open_source/licensing/flossexception
+* 
+* By copying, modifying or distributing this software, you acknowledge
+* that you have read and understood your obligations described above,
+* and agree to abide by those obligations.
+* 
+* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+* COMPLETENESS OR PERFORMANCE.
+* $/LicenseInfo$
+*/
+#include "linden_common.h"
+
+#include "lllocalcliprect.h"
+
+#include "llfontgl.h"
+#include "llgl.h"
+#include "llui.h"
+
+#include <stack>
+
+//---------------------------------------------------------------------------
+// LLScreenClipRect
+// implementation class in screen space
+//---------------------------------------------------------------------------
+class LLScreenClipRect
+{
+public:
+	LLScreenClipRect(const LLRect& rect, BOOL enabled = TRUE);
+	virtual ~LLScreenClipRect();
+
+private:
+	static void pushClipRect(const LLRect& rect);
+	static void popClipRect();
+	static void updateScissorRegion();
+
+private:
+	LLGLState		mScissorState;
+	BOOL			mEnabled;
+
+	static std::stack<LLRect> sClipRectStack;
+};
+
+/*static*/ std::stack<LLRect> LLScreenClipRect::sClipRectStack;
+
+
+LLScreenClipRect::LLScreenClipRect(const LLRect& rect, BOOL enabled)
+:	mScissorState(GL_SCISSOR_TEST),
+	mEnabled(enabled)
+{
+	if (mEnabled)
+	{
+		pushClipRect(rect);
+	}
+	mScissorState.setEnabled(!sClipRectStack.empty());
+	updateScissorRegion();
+}
+
+LLScreenClipRect::~LLScreenClipRect()
+{
+	if (mEnabled)
+	{
+		popClipRect();
+	}
+	updateScissorRegion();
+}
+
+//static 
+void LLScreenClipRect::pushClipRect(const LLRect& rect)
+{
+	LLRect combined_clip_rect = rect;
+	if (!sClipRectStack.empty())
+	{
+		LLRect top = sClipRectStack.top();
+		combined_clip_rect.intersectWith(top);
+
+		if(combined_clip_rect.isEmpty())
+		{
+			// avoid artifacts where zero area rects show up as lines
+			combined_clip_rect = LLRect::null;
+		}
+	}
+	sClipRectStack.push(combined_clip_rect);
+}
+
+//static 
+void LLScreenClipRect::popClipRect()
+{
+	sClipRectStack.pop();
+}
+
+//static
+void LLScreenClipRect::updateScissorRegion()
+{
+	if (sClipRectStack.empty()) return;
+
+	LLRect rect = sClipRectStack.top();
+	stop_glerror();
+	S32 x,y,w,h;
+	x = llfloor(rect.mLeft * LLUI::sGLScaleFactor.mV[VX]);
+	y = llfloor(rect.mBottom * LLUI::sGLScaleFactor.mV[VY]);
+	w = llmax(0, llceil(rect.getWidth() * LLUI::sGLScaleFactor.mV[VX])) + 1;
+	h = llmax(0, llceil(rect.getHeight() * LLUI::sGLScaleFactor.mV[VY])) + 1;
+	glScissor( x,y,w,h );
+	stop_glerror();
+}
+
+//---------------------------------------------------------------------------
+// LLLocalClipRect
+//---------------------------------------------------------------------------
+LLLocalClipRect::LLLocalClipRect(const LLRect& rect, BOOL enabled /* = TRUE */)
+{
+	LLRect screen(rect.mLeft + LLFontGL::sCurOrigin.mX, 
+		rect.mTop + LLFontGL::sCurOrigin.mY, 
+		rect.mRight + LLFontGL::sCurOrigin.mX, 
+		rect.mBottom + LLFontGL::sCurOrigin.mY);
+	mScreenClipRect = new LLScreenClipRect(screen, enabled);
+}
+
+LLLocalClipRect::~LLLocalClipRect()
+{
+	delete mScreenClipRect;
+	mScreenClipRect = NULL;
+}

File indra/llui/lllocalcliprect.h

+/** 
+* @file lllocalcliprect.h
+*
+* $LicenseInfo:firstyear=2009&license=viewergpl$
+* 
+* Copyright (c) 2009, Linden Research, Inc.
+* 
+* Second Life Viewer Source Code
+* The source code in this file ("Source Code") is provided by Linden Lab
+* to you under the terms of the GNU General Public License, version 2.0
+* ("GPL"), unless you have obtained a separate licensing agreement
+* ("Other License"), formally executed by you and Linden Lab.  Terms of
+* the GPL can be found in doc/GPL-license.txt in this distribution, or
+* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+* 
+* There are special exceptions to the terms and conditions of the GPL as
+* it is applied to this Source Code. View the full text of the exception
+* in the file doc/FLOSS-exception.txt in this software distribution, or
+* online at
+* http://secondlifegrid.net/programs/open_source/licensing/flossexception
+* 
+* By copying, modifying or distributing this software, you acknowledge
+* that you have read and understood your obligations described above,
+* and agree to abide by those obligations.
+* 
+* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+* COMPLETENESS OR PERFORMANCE.
+* $/LicenseInfo$
+*/
+#ifndef LLLOCALCLIPRECT_H
+#define LLLOCALCLIPRECT_H
+
+#include "llrect.h"		// can't forward declare, it's templated
+
+// Clip rendering to a specific rectangle using GL scissor
+// Just create one of these on the stack:
+// {
+//     LLLocalClipRect(rect);
+//     draw();
+// }
+class LLLocalClipRect
+{
+public:
+	LLLocalClipRect(const LLRect& rect, BOOL enabled = TRUE);
+	~LLLocalClipRect();
+
+private:
+	// implementation class
+	class LLScreenClipRect* mScreenClipRect;
+};
+
+#endif

File indra/llui/llmenugl.cpp

 	// If the mouse doesn't move, the menu will stay open ala the Mac.
 	// See also LLContextMenu::show()
 	S32 mouse_x, mouse_y;
-	LLUI::getCursorPositionLocal(menu->getParent(), &mouse_x, &mouse_y);
+	LLUI::getMousePositionLocal(menu->getParent(), &mouse_x, &mouse_y);
 	LLMenuHolderGL::sContextMenuSpawnPos.set(mouse_x,mouse_y);
 
 	const LLRect menu_region_rect = LLMenuGL::sMenuContainer->getMenuRect();
 	return handled;
 }
 
+BOOL LLMenuHolderGL::handleKey(KEY key, MASK mask, BOOL called_from_parent)
+{
+	BOOL handled =  false;
+	LLMenuGL* const  pMenu  = dynamic_cast<LLMenuGL*>(getVisibleMenu());
+			
+	if (pMenu)
+	{
+		//handle ESCAPE and RETURN key
+		handled = LLPanel::handleKey(key, mask, called_from_parent);
+		if (!handled)
+		{
+			if (pMenu->getHighlightedItem())
+			{
+				handled = pMenu->handleKey(key, mask, TRUE);
+			}
+			else
+			{
+				//highlight first enabled one
+				pMenu->highlightNextItem(NULL);
+				handled = true;
+			}
+		}
+	}
+	
+	return handled;
+	
+}
+
 void LLMenuHolderGL::reshape(S32 width, S32 height, BOOL called_from_parent)
 {
 	if (width != getRect().getWidth() || height != getRect().getHeight())
 	LLView::reshape(width, height, called_from_parent);
 }
 
-BOOL LLMenuHolderGL::hasVisibleMenu() const
+LLView* const LLMenuHolderGL::getVisibleMenu() const
 {
 	for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
 	{
 		LLView* viewp = *child_it;
 		if (viewp->getVisible() && dynamic_cast<LLMenuBarGL*>(viewp) == NULL)
 		{
-			return TRUE;
+			return viewp;
 		}
 	}
-	return FALSE;
+	return NULL;
 }
 
 

File indra/llui/llmenugl.h

 	// Close context menus on right mouse up not handled by menus.
 	/*virtual*/ BOOL handleRightMouseUp( S32 x, S32 y, MASK mask );
 
+	virtual BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent);
 	virtual const LLRect getMenuRect() const { return getLocalRect(); }
-	virtual BOOL hasVisibleMenu() const;
+	LLView*const getVisibleMenu() const;
+	virtual BOOL hasVisibleMenu() const {return getVisibleMenu() != NULL;}
 
 	static void setActivatedItem(LLMenuItemGL* item);
 

File indra/llui/llpanel.cpp

 
 LLPanel::LLPanel(const LLPanel::Params& p)
 :	LLUICtrl(p),
-	mBgColorAlpha(p.bg_alpha_color().get()),
-	mBgColorOpaque(p.bg_opaque_color().get()),
+	mBgColorAlpha(p.bg_alpha_color()),
+	mBgColorOpaque(p.bg_opaque_color()),
 	mBgVisible(p.background_visible),
 	mBgOpaque(p.background_opaque),
 	mDefaultBtn(NULL),
 	mLabel(p.label),
 	mCommitCallbackRegistrar(false),
 	mEnableCallbackRegistrar(false),
-	mXMLFilename("")
+	mXMLFilename(p.filename)
 {
 	setIsChrome(FALSE);
 
 
 void LLPanel::draw()
 {
+	F32 alpha = getDrawContext().mAlpha;
+
 	// draw background
 	if( mBgVisible )
 	{
 
 		if (mBgOpaque )
 		{
-			gl_rect_2d( left, top, right, bottom, mBgColorOpaque );
+			gl_rect_2d( left, top, right, bottom, mBgColorOpaque.get() % alpha);
 		}
 		else
 		{
-			gl_rect_2d( left, top, right, bottom, mBgColorAlpha );
+			gl_rect_2d( left, top, right, bottom, mBgColorAlpha.get() % alpha);
 		}
 	}
 
 	LLView::draw();
 }
 
-/*virtual*/
-void LLPanel::setAlpha(F32 alpha)
-{
-	mBgColorOpaque.setAlpha(alpha);
-}
-
 void LLPanel::updateDefaultBtn()
 {
 	if( mDefaultBtn)
 	setVisible(p.visible);
 	setEnabled(p.enabled);
 
+	setSoundFlags(p.sound_flags);
+
 	 // control_name, tab_stop, focus_lost_callback, initial_value, rect, enabled, visible
 	LLUICtrl::initFromParams(p);
 	
 		child->setColor(color);
 	}
 }
-void LLPanel::childSetAlpha(const std::string& id, F32 alpha)
-{
-	LLUICtrl* child = getChild<LLUICtrl>(id, true);
-	if (child)
-	{
-		child->setAlpha(alpha);
-	}
-}
 
 LLCtrlSelectionInterface* LLPanel::childGetSelectionInterface(const std::string& id) const
 {

File indra/llui/llpanel.h

 
 	// From LLFocusableElement
 	/*virtual*/ void	setFocus( BOOL b );
-	virtual void setAlpha(F32 alpha);
-
 	
 	// New virtuals
 	virtual 	void	refresh();	// called in setFocus()
 	void childSetValidate(const std::string& id, boost::function<bool (const LLSD& data)> cb );
 
 	void childSetColor(const std::string& id, const LLColor4& color);
-	void childSetAlpha(const std::string& id, F32 alpha);
 
 	LLCtrlSelectionInterface* childGetSelectionInterface(const std::string& id) const;
 	LLCtrlListInterface* childGetListInterface(const std::string& id) const;
 	virtual void	onOpen(const LLSD& key) {}
 
 	void setXMLFilename(std::string filename) { mXMLFilename = filename; };
+	std::string getXMLFilename() { return mXMLFilename; };
 	
 protected:
 	// Override to set not found list
 	commit_signal_t mVisibleSignal;		// Called when visibility changes, passes new visibility as LLSD()
 	
 private:
-	// Unified error reporting for the child* functions
-	typedef std::set<std::string> expected_members_list_t;
-	mutable expected_members_list_t mExpectedMembers;
-	mutable expected_members_list_t mNewExpectedMembers;
-
-	LLColor4		mBgColorAlpha;
-	LLColor4		mBgColorOpaque;
+	LLUIColor		mBgColorAlpha;
+	LLUIColor		mBgColorOpaque;
 	BOOL			mBgVisible;
 	BOOL			mBgOpaque;
 	LLViewBorder*	mBorder;

File indra/llui/llscrollbar.cpp

 
 	S32 local_mouse_x;
 	S32 local_mouse_y;
-	LLUI::getCursorPositionLocal(this, &local_mouse_x, &local_mouse_y);
+	LLUI::getMousePositionLocal(this, &local_mouse_x, &local_mouse_y);
 	BOOL other_captor = gFocusMgr.getMouseCapture() && gFocusMgr.getMouseCapture() != this;
 	BOOL hovered = getEnabled() && !other_captor && (hasMouseCapture() || mThumbRect.pointInRect(local_mouse_x, local_mouse_y));
 	if (hovered)

File indra/llui/llscrollcontainer.cpp

 
 #include "llrender.h"
 #include "llcontainerview.h"
+#include "lllocalcliprect.h"
 // #include "llfolderview.h"
 #include "llscrollingpanellist.h"
 #include "llscrollbar.h"

File indra/llui/llscrolllistctrl.cpp

 #include "llcheckboxctrl.h"
 #include "llclipboard.h"
 #include "llfocusmgr.h"
+#include "llgl.h"				// LLGLSUIDefault()
+#include "lllocalcliprect.h"
 //#include "llrender.h"
 #include "llresmgr.h"
 #include "llscrollbar.h"
 #include "llcachename.h"
 #include "llmenugl.h"
 #include "llurlaction.h"
+#include "lltooltip.h"
 
 #include <boost/bind.hpp>
 
 	return handled;
 }
 
-BOOL LLScrollListCtrl::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen)
+BOOL LLScrollListCtrl::handleToolTip(S32 x, S32 y, std::string& msg, LLRect& sticky_rect_screen)
 {
 	S32 column_index = getColumnIndexFromOffset(x);
 	LLScrollListColumn* columnp = getColumn(column_index);
 			LLRect cell_rect;
 			cell_rect.setOriginAndSize(rect_left, rect_bottom, rect_left + columnp->getWidth(), mLineHeight);
 			// Convert rect local to screen coordinates
-			localRectToScreen(cell_rect, sticky_rect_screen);
-			msg = hit_cell->getValue().asString();
+			LLRect sticky_rect;
+			localRectToScreen(cell_rect, &sticky_rect);
+			LLToolTipMgr::instance().show(LLToolTipParams()
+				.message(hit_cell->getValue().asString())
+				.sticky_rect(sticky_rect));		
 		}
 		handled = TRUE;
 	}
 	LLScrollColumnHeader* headerp = columnp->mHeader;
 	if (headerp && !handled)
 	{
-		headerp->handleToolTip(x, y, msg, sticky_rect_screen);
-		handled = !msg.empty();
+		handled = headerp->handleToolTip(x, y, msg, sticky_rect_screen);
 	}
 
 	return handled;

File indra/llui/llscrolllistctrl.h

 	/*virtual*/ BOOL	handleKeyHere(KEY key, MASK mask);
 	/*virtual*/ BOOL	handleUnicodeCharHere(llwchar uni_char);
 	/*virtual*/ BOOL	handleScrollWheel(S32 x, S32 y, S32 clicks);
-	/*virtual*/ BOOL	handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect);
+	/*virtual*/ BOOL	handleToolTip(S32 x, S32 y, std::string& msg, LLRect& sticky_rect);
 	/*virtual*/ void	setEnabled(BOOL enabled);
 	/*virtual*/ void	setFocus( BOOL b );
 	/*virtual*/ void	onFocusReceived();
 	void			sortOnce(S32 column, BOOL ascending);
 
 	// manually call this whenever editing list items in place to flag need for resorting
-	void			setNeedsSort() { mSorted = false; }
+	void			setNeedsSort(bool val = true) { mSorted = !val; }
 	void			dirtyColumns(); // some operation has potentially affected column layout or ordering
 
 protected:

File indra/llui/llsdparam.cpp

 	mNameStack.clear();
 	setParseSilently(silent);
 
-	// must have named elements at top level to submit for parsing
-	if (sd.isMap())
-	{
-		readSDValues(sd, block);
-	}
-	else
-	{
-		parserWarning("Top level map required for LLSD->Block conversion");
-	}
+	readSDValues(sd, block);
 }
 
 void LLParamSDParser::writeSD(LLSD& sd, const LLInitParam::BaseBlock& block)

File indra/llui/llslider.cpp

 
 void LLSlider::draw()
 {
+	F32 alpha = getDrawContext().mAlpha;
+
 	// since thumb image might still be decoding, need thumb to accomodate image size
 	updateThumbRect();
 
 						getRect().getWidth() - mThumbImage->getWidth() / 2, 
 						getLocalRect().getCenterY() - (mTrackImage->getHeight() / 2) );
 	LLRect highlight_rect(track_rect.mLeft, track_rect.mTop, mThumbRect.getCenterX(), track_rect.mBottom);
-	mTrackImage->draw(track_rect);
-	mTrackHighlightImage->draw(highlight_rect);
+	mTrackImage->draw(track_rect, LLColor4::white % alpha);
+	mTrackHighlightImage->draw(highlight_rect, LLColor4::white % alpha);
 
 	// Thumb
 	if (hasFocus())
 	{
 		// Draw focus highlighting.
-		mThumbImage->drawBorder(mThumbRect, gFocusMgr.getFocusColor(), gFocusMgr.getFocusFlashWidth());
+		mThumbImage->drawBorder(mThumbRect, gFocusMgr.getFocusColor() % alpha, gFocusMgr.getFocusFlashWidth());
 	}
 
 	if( hasMouseCapture() ) // currently clicking on slider
 		// Show ghost where thumb was before dragging began.
 		if (mThumbImage.notNull())
 		{
-			mThumbImage->draw(mDragStartThumbRect, mThumbCenterColor.get() % 0.3f);
+			mThumbImage->draw(mDragStartThumbRect, mThumbCenterColor.get() % (0.3f * alpha));
 		}
 		if (mThumbImagePressed.notNull())
 		{
-			mThumbImagePressed->draw(mThumbRect, mThumbOutlineColor);
+			mThumbImagePressed->draw(mThumbRect, mThumbOutlineColor % alpha);
 		}
 	}
 	else if (!isInEnabledChain())
 	{
 		if (mThumbImageDisabled.notNull())
 		{
-			mThumbImageDisabled->draw(mThumbRect, mThumbCenterColor);
+			mThumbImageDisabled->draw(mThumbRect, mThumbCenterColor % alpha);
 		}
 	}
 	else
 	{
 		if (mThumbImage.notNull())
 		{
-			mThumbImage->draw(mThumbRect, mThumbCenterColor);
+			mThumbImage->draw(mThumbRect, mThumbCenterColor % alpha);
 		}
 	}
 	

File indra/llui/lltabcontainer.cpp

  */
 
 #include "linden_common.h"
+
 #include "lltabcontainer.h"
+
 #include "llfocusmgr.h"
 #include "llbutton.h"
+#include "lllocalcliprect.h"
 #include "llrect.h"
 #include "llresizehandle.h"
 #include "lltextbox.h"
 }
 
 // virtual
-BOOL LLTabContainer::handleToolTip( S32 x, S32 y, std::string& msg, LLRect* sticky_rect )
+BOOL LLTabContainer::handleToolTip( S32 x, S32 y, std::string& msg, LLRect& sticky_rect )
 {
 	static LLUICachedControl<S32> tabcntrv_pad ("UITabCntrvPad", 0);
 	BOOL handled = LLPanel::handleToolTip( x, y, msg, sticky_rect );
 {
 	BOOL has_scroll_arrows = (getMaxScrollPos() > 0);
 
-	if( mDragAndDropDelayTimer.getElapsedTimeF32() > SCROLL_DELAY_TIME )
+	if( mDragAndDropDelayTimer.getStarted() && mDragAndDropDelayTimer.getElapsedTimeF32() > SCROLL_DELAY_TIME )
 	{
 		if (has_scroll_arrows)
 		{

File indra/llui/lltabcontainer.h

 	/*virtual*/ BOOL handleMouseDown( S32 x, S32 y, MASK mask );
 	/*virtual*/ BOOL handleHover( S32 x, S32 y, MASK mask );
 	/*virtual*/ BOOL handleMouseUp( S32 x, S32 y, MASK mask );
-	/*virtual*/ BOOL handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect );
+	/*virtual*/ BOOL handleToolTip(S32 x, S32 y, std::string& msg, LLRect& sticky_rect );
 	/*virtual*/ BOOL handleKeyHere(KEY key, MASK mask);
 	/*virtual*/ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask,	BOOL drop,
 									   EDragAndDropType type, void* cargo_data,

File indra/llui/lltextbase.cpp

 #include "llview.h"
 #include "llwindow.h"
 #include "llmenugl.h"
+#include "lltooltip.h"
 #include "lluictrl.h"
 #include "llurlaction.h"
 #include "llurlregistry.h"
 	return FALSE;
 }
 
-BOOL LLTextBase::handleToolTipForUrl(LLView *view, S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen)
+BOOL LLTextBase::handleToolTipForUrl(LLView *view, S32 x, S32 y, std::string& msg, LLRect& sticky_rect_screen)
 {
+	std::string tooltip_msg;
 	const LLTextSegment* cur_segment = getSegmentAtLocalPos( x, y );
-	if (cur_segment && cur_segment->getToolTip( msg ) && view)
+	if (cur_segment && cur_segment->getToolTip( tooltip_msg ) && view)
 	{
 		// Use a slop area around the cursor
 		const S32 SLOP = 8;
 		// Convert rect local to screen coordinates
-		view->localPointToScreen(x - SLOP, y - SLOP, &(sticky_rect_screen->mLeft),
-								 &(sticky_rect_screen->mBottom));
-		sticky_rect_screen->mRight = sticky_rect_screen->mLeft + 2 * SLOP;
-		sticky_rect_screen->mTop = sticky_rect_screen->mBottom + 2 * SLOP;
+		view->localPointToScreen(x - SLOP, y - SLOP, &(sticky_rect_screen.mLeft),
+								 &(sticky_rect_screen.mBottom));
+		sticky_rect_screen.mRight = sticky_rect_screen.mLeft + 2 * SLOP;
+		sticky_rect_screen.mTop = sticky_rect_screen.mBottom + 2 * SLOP;
+
+		LLToolTipMgr::instance().show(LLToolTipParams()
+			.message(tooltip_msg)
+			.sticky_rect(sticky_rect_screen));
 	}
 	return TRUE;
 }

File indra/llui/lltextbase.h

 	BOOL                handleHoverOverUrl(S32 x, S32 y);
 	BOOL                handleMouseUpOverUrl(S32 x, S32 y);
 	BOOL                handleRightMouseDownOverUrl(LLView *view, S32 x, S32 y);
-	BOOL                handleToolTipForUrl(LLView *view, S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen);
+	BOOL                handleToolTipForUrl(LLView *view, S32 x, S32 y, std::string& msg, LLRect& sticky_rect_screen);
 
 	// pure virtuals that have to be implemented by any subclasses
 	virtual S32         getLineCount() const = 0;

File indra/llui/lltextbox.cpp

 	drop_shadow_visible("drop_shadow_visible"),
 	disabled_color("disabled_color"),
 	background_color("background_color"),
-	border_color("border_color"),
 	v_pad("v_pad", 0),
 	h_pad("h_pad", 0),
 	line_spacing("line_spacing", 0),
 	mTextColor(p.text_color()),
 	mDisabledColor(p.disabled_color()),
 	mBackgroundColor(p.background_color()),
-	mBorderColor(p.border_color()),
 	mHAlign(p.font_halign),
 	mLineSpacing(p.line_spacing),
 	mDidWordWrap(FALSE)
 	return LLView::handleHover(x,y,mask);
 }
 
-BOOL LLTextBox::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen)
+BOOL LLTextBox::handleToolTip(S32 x, S32 y, std::string& msg, LLRect& sticky_rect_screen)
 {
 	return handleToolTipForUrl(this, x, y, msg, sticky_rect_screen);
 }
 
 void LLTextBox::draw()
 {
+	F32 alpha = getDrawContext().mAlpha;
+
 	if (mBorderVisible)
 	{
 		gl_rect_2d_offset_local(getLocalRect(), 2, FALSE);
 		static LLUIColor color_drop_shadow = LLUIColorTable::instance().getColor("ColorDropShadow");
 		static LLUICachedControl<S32> drop_shadow_tooltip ("DropShadowTooltip", 0);
 		gl_drop_shadow(0, getRect().getHeight(), getRect().getWidth(), 0,
-			color_drop_shadow, drop_shadow_tooltip);
+			color_drop_shadow % alpha, drop_shadow_tooltip);
 	}
 
 	if (mBackgroundVisible)
 	{
 		LLRect r( 0, getRect().getHeight(), getRect().getWidth(), 0 );
-		gl_rect_2d( r, mBackgroundColor.get() );
+		gl_rect_2d( r, mBackgroundColor.get() % alpha );
 	}
 
 	S32 text_x = 0;
 
 void LLTextBox::drawText( S32 x, S32 y, const LLWString &text, const LLColor4& color )
 {
+	F32 alpha = getDrawContext().mAlpha;
 	if (mSegments.size() > 1)
 	{
 		// we have Urls (or other multi-styled segments)
 	else if( mLineLengthList.empty() )
 	{
 		// simple case of 1 line of text in one style
-		mDefaultFont->render(text, 0, (F32)x, (F32)y, color,
+		mDefaultFont->render(text, 0, (F32)x, (F32)y, color % alpha,
 							 mHAlign, mVAlign, 
 							 0,
 							 mShadowType,
 			iter != mLineLengthList.end(); ++iter)
 		{
 			S32 line_length = *iter;
-			mDefaultFont->render(text, cur_pos, (F32)x, (F32)y, color,
+			mDefaultFont->render(text, cur_pos, (F32)x, (F32)y, color % alpha,
 								 mHAlign, mVAlign,
 								 0,
 								 mShadowType,
 
 void LLTextBox::reshapeToFitText()
 {
+	// wrap remaining lines that did not fit on call to setWrappedText()
+	setLineLengths();
+
 	S32 width = getTextPixelWidth();
 	S32 height = getTextPixelHeight();
 	reshape( width + 2 * mHPad, height + 2 * mVPad );
 
 void LLTextBox::drawTextSegments(S32 init_x, S32 init_y, const LLWString &text)
 {
+	F32 alpha = getDrawContext().mAlpha;
+
 	const S32 text_len = text.length();
 	if (text_len <= 0)
 	{
 					{
 						color = mDisabledColor.get();
 					}
+					color = color % alpha;
 
 					// render a single line worth for this segment
 					mDefaultFont->render(text, seg_start, text_x, text_y, color,

File indra/llui/lltextbox.h

 
 		Optional<LLUIColor>	text_color,
 							disabled_color,
-							background_color,
-							border_color;
+							background_color;
 
 		Optional<S32>		v_pad,
 							h_pad,
 	virtual BOOL	handleMouseUp(S32 x, S32 y, MASK mask);
 	virtual BOOL	handleHover(S32 x, S32 y, MASK mask);
 	virtual BOOL	handleRightMouseDown(S32 x, S32 y, MASK mask);
-	virtual BOOL	handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen);
+	virtual BOOL	handleToolTip(S32 x, S32 y, std::string& msg, LLRect& sticky_rect_screen);
 
 	void			setColor( const LLColor4& c )			{ mTextColor = c; }
 	void			setDisabledColor( const LLColor4& c)	{ mDisabledColor = c; }
 	void			setBackgroundColor( const LLColor4& c)	{ mBackgroundColor = c; }	
-	void			setBorderColor( const LLColor4& c)		{ mBorderColor = c; }	
 
 	void			setText( const LLStringExplicit& text );
 	void			setWrappedText(const LLStringExplicit& text, F32 max_width = -1.f); // -1 means use existing control width

File indra/llui/lltexteditor.cpp

 
 #include "llfontfreetype.h" // for LLFontFreetype::FIRST_CHAR
 #include "llfontgl.h"
+#include "llgl.h"			// LLGLSUIDefault()
+#include "lllocalcliprect.h"
 #include "llrender.h"
 #include "llui.h"
 #include "lluictrlfactory.h"
 #include "llscrollcontainer.h"
 #include "llpanel.h"
 #include "llurlregistry.h"
+#include "lltooltip.h"
 
 #include <queue>
 #include "llcombobox.h"
 }
 
 
-BOOL LLTextEditor::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect_screen)
+BOOL LLTextEditor::handleToolTip(S32 x, S32 y, std::string& msg, LLRect& sticky_rect_screen)
 {
-	for ( child_list_const_iter_t child_it = getChildList()->begin();
-		  child_it != getChildList()->end(); ++child_it)
-	{
-		LLView* viewp = *child_it;
-		S32 local_x = x - viewp->getRect().mLeft;
-		S32 local_y = y - viewp->getRect().mBottom;
-		if( viewp->handleToolTip(local_x, local_y, msg, sticky_rect_screen ) )
-		{
-			return TRUE;
-		}
+	if (childrenHandleToolTip(x, y, msg, sticky_rect_screen))
+	{
+		return TRUE;
 	}
 
 	return handleToolTipForUrl(this, x, y, msg, sticky_rect_screen);
 
 	mDocumentPanel->setBackgroundColor(bg_color);
 
-	drawChildren();
+	LLView::draw();
 	drawBackground(); //overlays scrolling panel bg
 	drawLineNumbers();
 

File indra/llui/lltexteditor.h

 	virtual BOOL	handleKeyHere(KEY key, MASK mask );
 	virtual BOOL	handleUnicodeCharHere(llwchar uni_char);
 
-	virtual BOOL	handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect);
+	virtual BOOL	handleToolTip(S32 x, S32 y, std::string& msg, LLRect& sticky_rect);
 	virtual BOOL	handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
 									  EDragAndDropType cargo_type, void *cargo_data,
 									  EAcceptance *accept, std::string& tooltip_msg);

File indra/llui/lltooltip.cpp

+/** 
+ * @file lltooltip.cpp
+ * @brief LLToolTipMgr class implementation and related classes
+ *
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ * 
+ * Copyright (c) 2001-2009, Linden Research, Inc.
+ * 
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab.  Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * 
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * 
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ * 
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#include "linden_common.h"
+
+// self include
+#include "lltooltip.h"
+
+// Library includes
+#include "llpanel.h"
+#include "lltextbox.h"
+#include "lliconctrl.h"
+#include "llui.h"			// positionViewNearMouse()
+#include "llwindow.h"
+
+//
+// Constants
+//
+const F32 DELAY_BEFORE_SHOW_TIP = 0.35f;
+
+//
+// Local globals
+//
+
+LLToolTipView *gToolTipView = NULL;
+
+//
+// Member functions
+//
+
+LLToolTipView::LLToolTipView(const LLToolTipView::Params& p)
+:	LLView(p)
+{
+}
+
+void LLToolTipView::draw()
+{
+	if (LLUI::getWindow()->isCursorHidden() )
+	{
+		LLToolTipMgr::instance().hideToolTips();
+	}
+
+	// do the usual thing
+	LLView::draw();
+}
+
+BOOL LLToolTipView::handleHover(S32 x, S32 y, MASK mask)
+{
+	static S32 last_x = x;
+	static S32 last_y = y;
+
+	LLToolTipMgr& tooltip_mgr = LLToolTipMgr::instance();
+
+	// hide existing tooltips when mouse moves out of sticky rect
+	if (tooltip_mgr.toolTipVisible() 
+		&& !tooltip_mgr.getStickyRect().pointInRect(x, y))
+	{
+		tooltip_mgr.hideToolTips();
+	}
+
+	// allow new tooltips whenever mouse moves
+	if (x != last_x && y != last_y)
+	{
+		tooltip_mgr.enableToolTips();
+	}
+
+	last_x = x;
+	last_y = y;
+	return LLView::handleHover(x, y, mask);
+}
+
+BOOL LLToolTipView::handleMouseDown(S32 x, S32 y, MASK mask)
+{
+	LLToolTipMgr::instance().hideToolTips();
+	return LLView::handleMouseDown(x, y, mask);
+}
+
+BOOL LLToolTipView::handleMiddleMouseDown(S32 x, S32 y, MASK mask)
+{
+	LLToolTipMgr::instance().hideToolTips();
+	return LLView::handleMiddleMouseDown(x, y, mask);
+}
+
+BOOL LLToolTipView::handleRightMouseDown(S32 x, S32 y, MASK mask)
+{
+	LLToolTipMgr::instance().hideToolTips();
+	return LLView::handleRightMouseDown(x, y, mask);
+}
+
+
+BOOL LLToolTipView::handleScrollWheel( S32 x, S32 y, S32 clicks )
+{
+	LLToolTipMgr::instance().hideToolTips();
+	return FALSE;
+}
+
+void LLToolTipView::onMouseLeave(S32 x, S32 y, MASK mask)
+{
+	LLToolTipMgr::instance().hideToolTips();
+}
+
+
+void LLToolTipView::drawStickyRect()
+{
+	gl_rect_2d(LLToolTipMgr::instance().getStickyRect(), LLColor4::white, false);
+}
+//
+// LLToolTip
+//
+class LLToolTip : public LLPanel
+{
+public:
+	struct Params : public LLInitParam::Block<Params, LLPanel::Params> 
+	{
+		Mandatory<F32>				visible_time;
+	
+		Optional<LLToolTipParams::click_callback_t>	click_callback;
+		Optional<LLUIImage*>						image;
+
+		Params()
+		{
+			//use_bounding_rect = true;
+		}
+	};
+	/*virtual*/ void draw();
+	/*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask);
+
+	/*virtual*/ void setValue(const LLSD& value);
+	/*virtual*/ void setVisible(BOOL visible);
+
+	bool isFading() { return mFadeTimer.getStarted(); }
+
+	LLToolTip(const Params& p);
+
+private: