From 05a72687d848c13754039f6e720a137827533fdb Mon Sep 17 00:00:00 2001
From: Gilbert Gonzales <gilbert@lindenlab.com>
Date: Wed, 17 Oct 2012 14:55:36 -0700
Subject: [PATCH] CHUI-410: Now when a converation floater is focused the
 default text 'To <Some User>' displays only when the text input field is
 empty.

---
 indra/llui/llchatentry.cpp                    | 28 +++++++++++++++++++
 indra/llui/llchatentry.h                      |  5 ++++
 indra/llui/lltextbase.cpp                     | 20 +++++++++++--
 indra/llui/lltextbase.h                       |  4 ++-
 .../default/xui/en/floater_im_session.xml     |  3 +-
 5 files changed, 56 insertions(+), 4 deletions(-)

diff --git a/indra/llui/llchatentry.cpp b/indra/llui/llchatentry.cpp
index 2a6ccc3dc90..38e2a8106a2 100644
--- a/indra/llui/llchatentry.cpp
+++ b/indra/llui/llchatentry.cpp
@@ -136,6 +136,34 @@ void LLChatEntry::updateHistory()
 	}
 }
 
+void LLChatEntry::beforeValueChange()
+{
+    if(this->getLength() == 0 && !mLabel.empty())
+    {
+        this->clearSegments();
+    }
+}
+
+void LLChatEntry::onValueChange(S32 start, S32 end)
+{
+    resetLabel();
+}
+
+BOOL LLChatEntry::useLabel()
+{
+    return !getLength() && !mLabel.empty();
+}
+
+void LLChatEntry::onFocusReceived()
+{
+
+}
+
+void LLChatEntry::onFocusLost()
+{
+
+}
+
 BOOL LLChatEntry::handleSpecialKey(const KEY key, const MASK mask)
 {
 	BOOL handled = FALSE;
diff --git a/indra/llui/llchatentry.h b/indra/llui/llchatentry.h
index 10a4594e83f..1f3fcf89455 100644
--- a/indra/llui/llchatentry.h
+++ b/indra/llui/llchatentry.h
@@ -54,11 +54,16 @@ class LLChatEntry : public LLTextEditor
 
 	friend class LLUICtrlFactory;
 	LLChatEntry(const Params& p);
+    /*virtual*/ void    beforeValueChange();
+    /*virtual*/ void    onValueChange(S32 start, S32 end);
+    /*virtual*/ BOOL    useLabel();
 
 public:
 
 	virtual void	draw();
 	virtual	void	onCommit();
+    /*virtual*/ void	onFocusReceived();
+    /*virtual*/ void	onFocusLost();
 
 	boost::signals2::connection setTextExpandedCallback(const commit_signal_t::slot_type& cb);
 
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index 98624f42b94..15856ae4efb 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -338,6 +338,11 @@ const LLStyle::Params& LLTextBase::getStyleParams()
 	return mStyle;
 }
 
+void LLTextBase::beforeValueChange()
+{
+
+}
+
 void LLTextBase::onValueChange(S32 start, S32 end)
 {
 }
@@ -530,7 +535,7 @@ void LLTextBase::drawText()
 	{
 		return;
 	}
-	else if (text_len <= 0 && !mLabel.empty() && !hasFocus())
+	else if (useLabel() == TRUE)
 	{
 		text_len = mLabel.getWString().length();
 	}
@@ -747,6 +752,8 @@ void LLTextBase::drawText()
 
 S32 LLTextBase::insertStringNoUndo(S32 pos, const LLWString &wstr, LLTextBase::segment_vec_t* segments )
 {
+    beforeValueChange();
+
 	S32 old_len = getLength();		// length() returns character length
 	S32 insert_len = wstr.length();
 
@@ -822,6 +829,8 @@ S32 LLTextBase::insertStringNoUndo(S32 pos, const LLWString &wstr, LLTextBase::s
 
 S32 LLTextBase::removeStringNoUndo(S32 pos, S32 length)
 {
+
+    beforeValueChange();
 	segment_set_t::iterator seg_iter = getSegIterContaining(pos);
 	while(seg_iter != mSegments.end())
 	{
@@ -880,6 +889,8 @@ S32 LLTextBase::removeStringNoUndo(S32 pos, S32 length)
 
 S32 LLTextBase::overwriteCharNoUndo(S32 pos, llwchar wc)
 {
+    beforeValueChange();
+
 	if (pos > (S32)getLength())
 	{
 		return 0;
@@ -2048,7 +2059,7 @@ BOOL LLTextBase::setLabelArg(const std::string& key, const LLStringExplicit& tex
 
 void LLTextBase::resetLabel()
 {
-	if (!getLength() && !mLabel.empty() && !hasFocus())
+	if (useLabel() == TRUE)
 	{
 		clearSegments();
 
@@ -2061,6 +2072,11 @@ void LLTextBase::resetLabel()
 	}
 }
 
+BOOL LLTextBase::useLabel()
+{
+    return !getLength() && !mLabel.empty() && !hasFocus();
+}
+
 void LLTextBase::setFont(const LLFontGL* font)
 {
 	mFont = font;
diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h
index 79662ebd33e..44b149d2640 100644
--- a/indra/llui/lltextbase.h
+++ b/indra/llui/lltextbase.h
@@ -382,7 +382,7 @@ class LLTextBase
 
 	/**
 	 * If label is set, draws text label (which is LLLabelTextSegment)
-	 * that is visible when no user text provided and has no focus
+	 * that is visible when no user text provided
 	 */
 	void					resetLabel();
 
@@ -501,7 +501,9 @@ class LLTextBase
 	LLTextBase(const Params &p);
 	virtual ~LLTextBase();
 	void							initFromParams(const Params& p);
+    virtual void					beforeValueChange();
 	virtual void					onValueChange(S32 start, S32 end);
+    virtual BOOL                    useLabel();
 
 	// draw methods
 	void							drawSelectionBackground(); // draws the black box behind the selected text
diff --git a/indra/newview/skins/default/xui/en/floater_im_session.xml b/indra/newview/skins/default/xui/en/floater_im_session.xml
index 8cd0463de89..2b542595c5e 100644
--- a/indra/newview/skins/default/xui/en/floater_im_session.xml
+++ b/indra/newview/skins/default/xui/en/floater_im_session.xml
@@ -255,11 +255,12 @@
              bottom="0"
              expand_lines_count="5"
              follows="left|right|bottom"
-	         font="SansSerifSmall"
+	           font="SansSerifSmall"
              visible="true"
              height="20"
              is_expandable="true"
              label="To"
+             text_tentative_color="TextFgTentativeColor"
              layout="bottomleft"
              name="chat_editor"
              max_length="1023"
-- 
GitLab