From ee4fbb8e37ca20ebfbf85845dbb67941b7abfd29 Mon Sep 17 00:00:00 2001
From: Mnikolenko ProductEngine <mnikolenko@productengine.com>
Date: Fri, 15 Mar 2013 12:33:46 +0200
Subject: [PATCH] CHUI-830 FIXED Button for collapsing torn-off floater(to a
 single input line) is added. Show toasts for new messages for that
 conversation, regardless of other prefs.

---
 indra/newview/app_settings/settings.xml       |  11 ++
 indra/newview/llfloaterimnearbychat.cpp       |   1 +
 .../newview/llfloaterimnearbychathandler.cpp  |  10 +-
 indra/newview/llfloaterimsession.cpp          |   2 +-
 indra/newview/llfloaterimsessiontab.cpp       |  82 +++++++++++-
 indra/newview/llfloaterimsessiontab.h         |  15 +++
 indra/newview/llimview.cpp                    |   7 +-
 .../skins/default/textures/textures.xml       |   2 +
 .../default/xui/en/floater_im_session.xml     | 123 +++++++++++++++---
 9 files changed, 227 insertions(+), 26 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index e216c7865df..ca6b9843fde 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -4281,6 +4281,17 @@
       <string>Boolean</string>
       <key>Value</key>
       <integer>1</integer>
+    </map>
+     <key>IMShowContentPanel</key>
+    <map>
+      <key>Comment</key>
+      <string>Show Toolbar and Body Panels</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>Boolean</string>
+      <key>Value</key>
+      <integer>1</integer>
     </map>
     <key>IgnoreAllNotifications</key>
     <map>
diff --git a/indra/newview/llfloaterimnearbychat.cpp b/indra/newview/llfloaterimnearbychat.cpp
index eb1a1f54ed4..148f6a0609f 100644
--- a/indra/newview/llfloaterimnearbychat.cpp
+++ b/indra/newview/llfloaterimnearbychat.cpp
@@ -290,6 +290,7 @@ void LLFloaterIMNearbyChat::onOpen(const LLSD& key)
 void LLFloaterIMNearbyChat::onClose(bool app_quitting)
 {
 	// Override LLFloaterIMSessionTab::onClose() so that Nearby Chat is not removed from the conversation floater
+	LLFloaterIMSessionTab::restoreFloater();
 	onClickCloseBtn();
 }
 
diff --git a/indra/newview/llfloaterimnearbychathandler.cpp b/indra/newview/llfloaterimnearbychathandler.cpp
index 8870d54cd2b..7afcf288ce5 100644
--- a/indra/newview/llfloaterimnearbychathandler.cpp
+++ b/indra/newview/llfloaterimnearbychathandler.cpp
@@ -559,12 +559,14 @@ void LLFloaterIMNearbyChatHandler::processChat(const LLChat& chat_msg,
 
     LLFloaterIMContainer* im_box = LLFloaterReg::getTypedInstance<LLFloaterIMContainer>("im_container");
 
-	if( nearby_chat->hasFocus() 
+	if(( nearby_chat->hasFocus()
         || im_box->hasFocus()
 		|| ( chat_msg.mSourceType == CHAT_SOURCE_AGENT
 			&& gSavedSettings.getBOOL("UseChatBubbles") )
 		|| mChannel.isDead()
-		|| !mChannel.get()->getShowToasts() ) // to prevent toasts in Do Not Disturb mode
+		|| !mChannel.get()->getShowToasts() )
+		&& nearby_chat->isMessagePaneExpanded())
+		// to prevent toasts in Do Not Disturb mode
 		return;//no need in toast if chat is visible or if bubble chat is enabled
 
 	// arrange a channel on a screen
@@ -606,7 +608,7 @@ void LLFloaterIMNearbyChatHandler::processChat(const LLChat& chat_msg,
 
 		//Don't show nearby toast, if conversation is visible but not focused
 		LLFloaterIMSessionTab* session_floater = LLFloaterIMSessionTab::getConversation(LLUUID());
-		if (session_floater
+		if (session_floater && session_floater->isMessagePaneExpanded()
 		    && session_floater->isInVisibleChain() && !session_floater->isMinimized()
 		    && !(session_floater->getHost() && session_floater->getHost()->isMinimized()))
 		{
@@ -614,7 +616,7 @@ void LLFloaterIMNearbyChatHandler::processChat(const LLChat& chat_msg,
 		}
 
         //Will show toast when chat preference is set        
-        if(gSavedSettings.getString("NotificationNearbyChatOptions") == "toast")
+        if((gSavedSettings.getString("NotificationNearbyChatOptions") == "toast") || !session_floater->isMessagePaneExpanded())
         {
             // Add a nearby chat toast.
             LLUUID id;
diff --git a/indra/newview/llfloaterimsession.cpp b/indra/newview/llfloaterimsession.cpp
index 50b2ed8c51b..733678364e7 100644
--- a/indra/newview/llfloaterimsession.cpp
+++ b/indra/newview/llfloaterimsession.cpp
@@ -618,7 +618,7 @@ void LLFloaterIMSession::onClose(bool app_quitting)
 	// Last change:
 	// EXT-3516 X Button should end IM session, _ button should hide
 	gIMMgr->leaveSession(mSessionID);
-
+	LLFloaterIMSessionTab::restoreFloater();
 	// Clean up the conversation *after* the session has been ended
 	LLFloaterIMSessionTab::onClose(app_quitting);
 }
diff --git a/indra/newview/llfloaterimsessiontab.cpp b/indra/newview/llfloaterimsessiontab.cpp
index 9fd22b15372..c744350dc6d 100644
--- a/indra/newview/llfloaterimsessiontab.cpp
+++ b/indra/newview/llfloaterimsessiontab.cpp
@@ -194,19 +194,28 @@ BOOL LLFloaterIMSessionTab::postBuild()
 {
 	BOOL result;
 
+	mBodyStack = getChild<LLLayoutStack>("main_stack");
+
+
 	mCloseBtn = getChild<LLButton>("close_btn");
 	mCloseBtn->setCommitCallback(boost::bind(&LLFloater::onClickClose, this));
 
 	mExpandCollapseBtn = getChild<LLButton>("expand_collapse_btn");
 	mExpandCollapseBtn->setClickedCallback(boost::bind(&LLFloaterIMSessionTab::onSlide, this));
 
+	mExpandCollapseLineBtn = getChild<LLButton>("minz_btn");
+	mExpandCollapseLineBtn->setClickedCallback(boost::bind(&LLFloaterIMSessionTab::onCollapseToLine, this));
+
 	mTearOffBtn = getChild<LLButton>("tear_off_btn");
 	mTearOffBtn->setCommitCallback(boost::bind(&LLFloaterIMSessionTab::onTearOffClicked, this));
 
 	mGearBtn = getChild<LLButton>("gear_btn");
 
 	mParticipantListPanel = getChild<LLLayoutPanel>("speakers_list_panel");
-	
+	mToolbarPanel = getChild<LLLayoutPanel>("toolbar_panel");
+	mContentPanel = getChild<LLLayoutPanel>("body_panel");
+	mInputButtonPanel = getChild<LLLayoutPanel>("input_button_layout_panel");
+	mInputButtonPanel->setVisible(false);
 	// Add a scroller for the folder (participant) view
 	LLRect scroller_view_rect = mParticipantListPanel->getRect();
 	scroller_view_rect.translate(-scroller_view_rect.mLeft, -scroller_view_rect.mBottom);
@@ -264,6 +273,8 @@ BOOL LLFloaterIMSessionTab::postBuild()
 	mConversationsRoot->setFollowsAll();
 	mConversationsRoot->addChild(mConversationsRoot->mStatusTextBox);
 
+	setMessagePaneExpanded(true);
+
 	buildConversationViewParticipant();
 	refreshConversation();
 
@@ -651,6 +662,7 @@ void LLFloaterIMSessionTab::updateHeaderAndToolbar()
 
 	mParticipantListPanel->setVisible(is_participant_list_visible);
 
+
 	// Display collapse image (<<) if the floater is hosted
 	// or if it is torn off but has an open control panel.
 	bool is_expanded = is_not_torn_off || is_participant_list_visible;
@@ -674,6 +686,7 @@ void LLFloaterIMSessionTab::updateHeaderAndToolbar()
 	mTearOffBtn->setImageOverlay(getString(is_not_torn_off? "tear_off_icon" : "return_icon"));
 	mTearOffBtn->setToolTip(getString(is_not_torn_off? "tooltip_to_separate_window" : "tooltip_to_main_window"));
 
+
 	mCloseBtn->setVisible(is_not_torn_off && !mIsNearbyChat);
 
 	enableDisableCallBtn();
@@ -784,6 +797,65 @@ void LLFloaterIMSessionTab::onSlide(LLFloaterIMSessionTab* self)
 	}
 }
 
+void LLFloaterIMSessionTab::onCollapseToLine(LLFloaterIMSessionTab* self)
+{
+	LLFloaterIMContainer* host_floater = dynamic_cast<LLFloaterIMContainer*>(self->getHost());
+	if (!host_floater)
+	{
+		if(self->mParticipantListPanel->getVisible())
+		{
+			onSlide(self);
+		}
+
+		bool expand = self->isMessagePaneExpanded();
+		self->mExpandCollapseLineBtn->setImageOverlay(self->getString(expand ? "collapseline_icon" : "expandline_icon"));
+		self->mContentPanel->setVisible(!expand);
+		self->mToolbarPanel->setVisible(!expand);
+		self->reshapeFloater(expand);
+		self->setMessagePaneExpanded(!expand);
+
+	}
+}
+
+void LLFloaterIMSessionTab::reshapeFloater(bool collapse)
+{
+	LLRect floater_rect = getRect();
+
+	if(collapse)
+	{
+		mFloaterHeight = floater_rect.getHeight();
+		S32 height = mContentPanel->getRect().getHeight() + mToolbarPanel->getRect().getHeight();
+		floater_rect.mTop -= height;
+		enableResizeCtrls(true, true, false);
+	}
+	else
+	{
+		floater_rect.mTop = floater_rect.mBottom + mFloaterHeight;
+		enableResizeCtrls(true, true, true);
+
+	}
+
+	setShape(floater_rect, true);
+	mBodyStack->updateLayout();
+
+}
+
+void LLFloaterIMSessionTab::restoreFloater()
+{
+	if(!isMessagePaneExpanded())
+	{
+		mContentPanel->setVisible(true);
+		mToolbarPanel->setVisible(true);
+		LLRect floater_rect = getRect();
+		floater_rect.mTop = floater_rect.mBottom + mFloaterHeight;
+		setShape(floater_rect, true);
+		mBodyStack->updateLayout();
+		mExpandCollapseLineBtn->setImageOverlay(getString("expandline_icon"));
+		setMessagePaneExpanded(true);
+		enableResizeCtrls(true, true, true);
+	}
+}
+
 /*virtual*/
 void LLFloaterIMSessionTab::onOpen(const LLSD& key)
 {
@@ -793,12 +865,15 @@ void LLFloaterIMSessionTab::onOpen(const LLSD& key)
 		// Show the messages pane when opening a floater hosted in the Conversations
 		host_floater->collapseMessagesPane(false);
 	}
+
+	mInputButtonPanel->setVisible(isTornOff());
 }
 
 
 void LLFloaterIMSessionTab::onTearOffClicked()
 {
-    setFollows(isTornOff()? FOLLOWS_ALL : FOLLOWS_NONE);
+	restoreFloater();
+	setFollows(isTornOff()? FOLLOWS_ALL : FOLLOWS_NONE);
     mSaveRect = isTornOff();
     initRectControl();
 	LLFloater::onClickTearOff(this);
@@ -813,7 +888,10 @@ void LLFloaterIMSessionTab::onTearOffClicked()
 	else
 	{
 		container->selectConversation(mSessionID);
+
 	}
+	mInputButtonPanel->setVisible(isTornOff());
+
 	refreshConversation();
 	updateGearBtn();
 }
diff --git a/indra/newview/llfloaterimsessiontab.h b/indra/newview/llfloaterimsessiontab.h
index e8ae5574127..e41f6390373 100644
--- a/indra/newview/llfloaterimsessiontab.h
+++ b/indra/newview/llfloaterimsessiontab.h
@@ -98,6 +98,8 @@ class LLFloaterIMSessionTab
 	LLConversationItem* getCurSelectedViewModelItem();
 	void forceReshape();
 	virtual BOOL handleKeyHere( KEY key, MASK mask );
+	bool isMessagePaneExpanded(){return mMessagePaneExpanded;}
+	void setMessagePaneExpanded(bool expanded){mMessagePaneExpanded = expanded;}
 
 protected:
 
@@ -111,6 +113,9 @@ class LLFloaterIMSessionTab
 	bool onIMShowModesMenuItemCheck(const LLSD& userdata);
 	bool onIMShowModesMenuItemEnable(const LLSD& userdata);
 	static void onSlide(LLFloaterIMSessionTab *self);
+	static void onCollapseToLine(LLFloaterIMSessionTab *self);
+	void reshapeFloater(bool collapse);
+	void restoreFloater();
 
 	// refresh a visual state of the Call button
 	void updateCallBtnState(bool callIsActive);
@@ -138,15 +143,22 @@ class LLFloaterIMSessionTab
 
 	bool mIsNearbyChat;
 	bool mIsP2PChat;
+
+	bool mMessagePaneExpanded;
 	bool mIsParticipantListExpanded;
 
+
 	LLIMModel::LLIMSession* mSession;
 
 	// Participants list: model and view
 	LLConversationViewParticipant* createConversationViewParticipant(LLConversationItem* item);
 	
 	LLUUID mSessionID; 
+	LLLayoutStack* mBodyStack;
 	LLLayoutPanel* mParticipantListPanel;	// add the widgets to that see mConversationsListPanel
+	LLLayoutPanel* mContentPanel;
+	LLLayoutPanel* mToolbarPanel;
+	LLLayoutPanel* mInputButtonPanel;
 	LLParticipantList* getParticipantList();
 	conversations_widgets_map mConversationsWidgets;
 	LLConversationViewModel mConversationViewModel;
@@ -158,11 +170,14 @@ class LLFloaterIMSessionTab
 	LLChatEntry* mInputEditor;
 	int mInputEditorTopPad; // padding between input field and chat history
 
+	LLButton* mExpandCollapseLineBtn;
 	LLButton* mExpandCollapseBtn;
 	LLButton* mTearOffBtn;
 	LLButton* mCloseBtn;
 	LLButton* mGearBtn;
 
+	S32 mFloaterHeight;
+
 
 private:
 	// Handling selection and contextual menu
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index 1d62a32fc20..d04e76c0b3a 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -226,17 +226,18 @@ void on_new_message(const LLSD& msg)
             && !session_floater->isMinimized()
             && !(session_floater->getHost() && session_floater->getHost()->isMinimized());
 
-    if ("toast" == action && !session_floater_is_open)
+    bool conversation_floater_collapsed = !session_floater->isMessagePaneExpanded();
+    if (("toast" == action && !session_floater_is_open) || conversation_floater_collapsed)
     {
         //User is not focused on conversation containing the message
-        if(session_floater_not_focused)
+        if(session_floater_not_focused || conversation_floater_collapsed)
         {
         	if(!LLMuteList::getInstance()->isMuted(participant_id))
         	{
         		im_box->flashConversationItemWidget(session_id, true);
         	}
             //The conversation floater isn't focused/open
-            if(conversation_floater_not_focused)
+            if(conversation_floater_not_focused || conversation_floater_collapsed)
             {
             	if(!LLMuteList::getInstance()->isMuted(participant_id) 
                     && !gAgent.isDoNotDisturb())
diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml
index a07d7e48553..93c9cb02cb0 100644
--- a/indra/newview/skins/default/textures/textures.xml
+++ b/indra/newview/skins/default/textures/textures.xml
@@ -171,6 +171,8 @@ with the same filename but different name
   <texture name="Conv_toolbar_call_log" file_name="icons/Conv_toolbar_call_log.png" preload="false" />
   <texture name="Conv_toolbar_close" file_name="icons/Conv_toolbar_close.png" preload="false" />
   <texture name="Conv_toolbar_collapse" file_name="icons/Conv_toolbar_collapse.png" preload="false" />
+  <texture name="Conv_collapse_to_one_line" file_name="icons/collapse_to_one_line.png" preload="false" />
+  <texture name="Conv_expand_one_line" file_name="icons/expand_one_liner.png" preload="false" />
   <texture name="Conv_toolbar_expand" file_name="icons/Conv_toolbar_expand.png" preload="false" />
   <texture name="Conv_toolbar_hang_up" file_name="icons/Conv_toolbar_hang_up.png" preload="false" />
   <texture name="Conv_toolbar_open_call" file_name="icons/Conv_toolbar_open_call.png" preload="false" />
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 8f0574177f3..1a9199f9e71 100644
--- a/indra/newview/skins/default/xui/en/floater_im_session.xml
+++ b/indra/newview/skins/default/xui/en/floater_im_session.xml
@@ -19,6 +19,12 @@
  positioning="relative">
     <floater.string name="call_btn_start">Conv_toolbar_open_call</floater.string>
     <floater.string name="call_btn_stop">Conv_toolbar_hang_up</floater.string>
+    <floater.string
+     name="collapseline_icon"
+     value="Conv_collapse_to_one_line"/>
+    <floater.string
+     name="expandline_icon"
+     value="Conv_expand_one_line"/>
     <floater.string
      name="collapse_icon"
      value="Conv_toolbar_collapse"/>
@@ -65,14 +71,28 @@
         top="0"
         left="0"
         height="355"
-        width="394"> 
-     <panel
+        width="394">
+   <layout_stack
+   animate="true" 
+   default_tab_group="2"
+   follows="all"
+  height="355"
+  width="394"
+  layout="topleft"
+  orientation="vertical"
+   name="main_stack"
+  tab_group="1"
+  top="0"
+  left="0">
+  
+     <layout_panel
          follows="left|top|right"
          layout="topleft"
          name="toolbar_panel"
          top="0"
          left="0"
          height="35"
+         min_height="35"
          width="394">         
              <menu_button
                  menu_filename="menu_im_session_showmodes.xml"
@@ -180,12 +200,19 @@
                  left_pad="5"
                  name="tear_off_btn"
                  width="31" />
-     </panel>
+     </layout_panel>
+     <layout_panel
+      name="body_panel"
+      follows="all"
+      width="394" 
+      height="235" 
+      user_resize="false"
+      auto_resize="true">
   <layout_stack
    animate="true" 
    default_tab_group="2"
   follows="all"
-  height="310"
+  height="275"
   width="394"
   layout="topleft"
   orientation="horizontal"
@@ -198,7 +225,7 @@
       follows="all"
       min_width="115"
       width="150" 
-      height="310" 
+      height="275" 
       user_resize="true"
       auto_resize="true">
       </layout_panel>
@@ -208,7 +235,7 @@
        tab_group="2"
        follows="all"
        top="0"
-       height="310"
+       height="275"
 	   width="244"
        layout="topleft"
        user_resize="true"
@@ -221,13 +248,13 @@
          follows="all"
          layout="topleft"
          visible="true"
-         height="275"
+         height="240"
          width="244">
          <layout_stack
           animate="true" 
           default_tab_group="2"
           follows="all"
-          height="275"
+          height="240"
           width="244"
           layout="topleft"
           visible="true"
@@ -258,7 +285,7 @@
                  width="230" />
             </layout_panel>
             <layout_panel
-             height="248"
+             height="233"
              width="210"
              layout="topleft"
              follows="all"
@@ -273,7 +300,7 @@
                 font="SansSerifSmall"
                 follows="all"
                 visible="true"
-                height="240"
+                height="225"
                 name="chat_history"
                 parse_highlights="true"
                 parse_urls="true"
@@ -283,26 +310,90 @@
             </layout_panel>
            </layout_stack>
            </panel>
-            <chat_editor
+    </layout_panel>
+  </layout_stack>
+  </layout_panel>
+  <layout_panel
+             height="35"
+             layout="topleft"
+             follows="left|right|bottom"
+             left_delta="0"
+             right="0"
+             top_delta="0"
              bottom="0"
+             visible="true"
+             user_resize="false"
+             auto_resize="false"
+             name="chat_layout_panel">
+   <layout_stack
+   animate="true" 
+   default_tab_group="2"
+   follows="all"
+   height="35"
+   right="0"
+   layout="topleft"
+   orientation="horizontal"
+   name="input_panels"
+   top_pad="0"
+   left="0">
+     <layout_panel
+             height="35"
+             layout="topleft"
+             follows="left|right|bottom"
+             left_delta="0"
+             top_delta="0"
+             bottom="0"
+             visible="true"
+             user_resize="false"
+             auto_resize="true"
+             name="input_editor_layout_panel">
+              <chat_editor
+             top="6"
              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"
+             layout="topleft"
              name="chat_editor"
              max_length="1023"
              spellcheck="true"
              tab_group="3"
-             width="220"
-             left="10"
+             width="160"
+             left="5"
+             right="-5"
              wrap="true">
             </chat_editor>
-    </layout_panel>
+            </layout_panel>
+            <layout_panel             
+             height="35"
+             layout="topleft"
+             follows="left|right|bottom"
+             left_delta="0"
+             top_delta="0"
+             bottom="0"
+             width="35"
+             visible="true"
+             user_resize="false"
+             auto_resize="false"
+             name="input_button_layout_panel">
+            <button
+                 follows="left|right|bottom"
+                 height="25"
+                 image_hover_unselected="Toolbar_Middle_Over"
+                 image_overlay="Conv_expand_one_line"
+                 image_selected="Toolbar_Middle_Selected"
+                 image_unselected="Toolbar_Middle_Off"
+                 layout="topleft"
+                 name="minz_btn"
+                 tool_tip="Shows/hides message panel"
+                 width="28"/>
+           </layout_panel>
+  </layout_stack>
+  </layout_panel>
   </layout_stack>
     </view>
 </floater>
-- 
GitLab