From 7eaeb88bc37a747ff82fd37df84592f54c88cdbf Mon Sep 17 00:00:00 2001 From: Seth ProductEngine Date: Thu, 10 May 2012 20:40:15 +0300 Subject: CHUI-105 WIP Added expand/collapse behavior for Conversations floater messages pane. --- indra/newview/llimfloater.cpp | 70 ++++++++++++++-------- indra/newview/llimfloater.h | 5 ++ indra/newview/llimfloatercontainer.cpp | 26 ++++++++ indra/newview/llimfloatercontainer.h | 4 ++ .../skins/default/xui/en/floater_im_container.xml | 44 +++++--------- .../skins/default/xui/en/floater_im_session.xml | 41 +++++-------- 6 files changed, 111 insertions(+), 79 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llimfloater.cpp b/indra/newview/llimfloater.cpp index d02db458b4..b2a5c4a64d 100644 --- a/indra/newview/llimfloater.cpp +++ b/indra/newview/llimfloater.cpp @@ -67,6 +67,8 @@ LLIMFloater::LLIMFloater(const LLUUID& session_id) mDialog(IM_NOTHING_SPECIAL), mChatHistory(NULL), mInputEditor(NULL), + mExpandCollapseBtn(NULL), + mTearOffBtn(NULL), mSavedTitle(), mTypingStart(), mShouldSendTypingState(false), @@ -180,6 +182,17 @@ void LLIMFloater::onFocusReceived() } } +/*virtual*/ +void LLIMFloater::onOpen(const LLSD& key) +{ + LLIMFloaterContainer* host_floater = dynamic_cast(getHost()); + if (host_floater) + { + // Show the messages pane when opening a floater hosted in the Conversations + host_floater->toggleMessagesPane(true); + } +} + // virtual void LLIMFloater::onClose(bool app_quitting) { @@ -291,19 +304,14 @@ BOOL LLIMFloater::postBuild() mControlPanel->setSessionId(mSessionID); mControlPanel->getParent()->setVisible(gSavedSettings.getBOOL("IMShowControlPanel")); - LLButton* slide_left = getChild("slide_left_btn"); - slide_left->setVisible(mControlPanel->getParent()->getVisible()); - slide_left->setClickedCallback(boost::bind(&LLIMFloater::onSlide, this)); - - LLButton* slide_right = getChild("slide_right_btn"); - slide_right->setVisible(!mControlPanel->getParent()->getVisible()); - slide_right->setClickedCallback(boost::bind(&LLIMFloater::onSlide, this)); + getChild("close_btn")->setCommitCallback(boost::bind(&LLFloater::onClickClose, this)); - LLButton* return_btn = getChild("return_btn"); - return_btn->setCommitCallback(boost::bind(&LLFloater::onClickTearOff, this)); + mExpandCollapseBtn = getChild("expand_collapse_btn"); + mExpandCollapseBtn->setImageOverlay(getString(mControlPanel->getParent()->getVisible() ? "collapse_icon" : "expand_icon")); + mExpandCollapseBtn->setClickedCallback(boost::bind(&LLIMFloater::onSlide, this)); - LLButton* tear_off_btn = getChild("tear_off_btn"); - tear_off_btn->setCommitCallback(boost::bind(&LLFloater::onClickTearOff, this)); + mTearOffBtn = getChild("tear_off_btn"); + mTearOffBtn->setCommitCallback(boost::bind(&LLFloater::onClickTearOff, this)); mInputEditor = getChild("chat_editor"); mInputEditor->setMaxTextLength(1023); @@ -427,12 +435,23 @@ void* LLIMFloater::createPanelAdHocControl(void* userdata) void LLIMFloater::onSlide() { - mControlPanel->getParent()->setVisible(!mControlPanel->getParent()->getVisible()); + LLIMFloaterContainer* host_floater = dynamic_cast(getHost()); + if (host_floater) + { + // Hide the messages pane if a floater is hosted in the Conversations + host_floater->toggleMessagesPane(false); + } + else ///< floater is torn off + { + bool expand = !mControlPanel->getParent()->getVisible(); - gSavedSettings.setBOOL("IMShowControlPanel", mControlPanel->getParent()->getVisible()); + // Expand/collapse the IM control panel + mControlPanel->getParent()->setVisible(expand); - getChild("slide_left_btn")->setVisible(mControlPanel->getParent()->getVisible()); - getChild("slide_right_btn")->setVisible(!mControlPanel->getParent()->getVisible()); + gSavedSettings.setBOOL("IMShowControlPanel", expand); + + mExpandCollapseBtn->setImageOverlay(getString(expand ? "collapse_icon" : "expand_icon")); + } } //static @@ -1253,14 +1272,16 @@ void LLIMFloater::onClickCloseBtn() // virtual void LLIMFloater::updateTitleButtons() { - if (!mDragHandle) + // This gets called before LLIMFloater::postBuild() while some LLIMFloater members are NULL + if ( !mDragHandle + || !mControlPanel + || !mExpandCollapseBtn + || !mTearOffBtn) { return; } - LLMultiFloater* host_floater = getHost(); - - bool is_hosted = host_floater != NULL; + bool is_hosted = getHost() != NULL; if (is_hosted) ///< floater is hosted { for (S32 i = 0; i < BUTTON_COUNT; i++) @@ -1273,18 +1294,19 @@ void LLIMFloater::updateTitleButtons() // Hide the standard header buttons in a docked IM floater. mButtons[i]->setVisible(false); } + + mExpandCollapseBtn->setImageOverlay(getString("collapse_icon")); } else ///< floater is torn off { LLFloater::updateTitleButtons(); + + bool is_expanded = mControlPanel->getParent()->getVisible(); + mExpandCollapseBtn->setImageOverlay(getString(is_expanded ? "collapse_icon" : "expand_icon")); } // toggle floater's drag handle and title visibility mDragHandle->setVisible(!is_hosted); - - LLButton* return_btn = getChild("return_btn"); - return_btn->setVisible(!is_hosted); - LLButton* tear_off_btn = getChild("tear_off_btn"); - tear_off_btn->setVisible(is_hosted); + mTearOffBtn->setImageOverlay(getString(is_hosted ? "tear_off_icon" : "return_icon")); } diff --git a/indra/newview/llimfloater.h b/indra/newview/llimfloater.h index ff4eaed0b9..4f161449f7 100644 --- a/indra/newview/llimfloater.h +++ b/indra/newview/llimfloater.h @@ -33,6 +33,7 @@ #include "lltransientdockablefloater.h" class LLAvatarName; +class LLButton; class LLLineEditor; class LLPanelChatControlPanel; class LLChatHistory; @@ -59,6 +60,7 @@ public: /*virtual*/ void draw(); // LLFloater overrides + /*virtual*/ void onOpen(const LLSD& key); /*virtual*/ void onClose(bool app_quitting); /*virtual*/ void setDocked(bool docked, bool pop_on_undock = true); @@ -182,6 +184,9 @@ private: bool mSessionInitialized; LLSD mQueuedMsgsForInit; + + LLButton* mExpandCollapseBtn; + LLButton* mTearOffBtn; }; diff --git a/indra/newview/llimfloatercontainer.cpp b/indra/newview/llimfloatercontainer.cpp index 9b5055fb98..c8b8cb208d 100644 --- a/indra/newview/llimfloatercontainer.cpp +++ b/indra/newview/llimfloatercontainer.cpp @@ -40,6 +40,7 @@ // LLIMFloaterContainer::LLIMFloaterContainer(const LLSD& seed) : LLMultiFloater(seed) + ,mMessagesPaneWidth(0) { mAutoResize = FALSE; LLTransientFloaterMgr::getInstance()->addControlView(LLTransientFloaterMgr::IM, this); @@ -185,4 +186,29 @@ void LLIMFloaterContainer::setMinimized(BOOL b) } } +void LLIMFloaterContainer::toggleMessagesPane(bool expand) +{ + LLView* messages_pane = getChild("im_box_tab_container"); + bool is_expanded = messages_pane->getVisible(); + if (is_expanded == expand) + { + return; + } + + // Store the messages pane width before collapsing it. + if (!expand) + { + LLView* conversations_pane = getChild("conversations_pane"); + S32 horizontal_pad = messages_pane->getRect().mLeft - conversations_pane->getRect().mRight; + mMessagesPaneWidth = messages_pane->getRect().getWidth() + horizontal_pad; + } + + // Show/hide the messages pane. + messages_pane->setVisible(expand); + + S32 floater_width = getRect().getWidth(); + floater_width += (expand ? mMessagesPaneWidth : -mMessagesPaneWidth); + reshape(floater_width, getRect().getHeight()); +} + // EOF diff --git a/indra/newview/llimfloatercontainer.h b/indra/newview/llimfloatercontainer.h index 93b91fe3cf..045f053b1c 100644 --- a/indra/newview/llimfloatercontainer.h +++ b/indra/newview/llimfloatercontainer.h @@ -60,12 +60,16 @@ public: virtual void setMinimized(BOOL b); + void toggleMessagesPane(bool expand); + private: typedef std::map avatarID_panel_map_t; avatarID_panel_map_t mSessions; boost::signals2::connection mNewMessageConnection; void onNewMessageReceived(const LLSD& data); + + S32 mMessagesPaneWidth; }; #endif // LL_LLIMFLOATERCONTAINER_H diff --git a/indra/newview/skins/default/xui/en/floater_im_container.xml b/indra/newview/skins/default/xui/en/floater_im_container.xml index d19b36971f..8a0181bae4 100644 --- a/indra/newview/skins/default/xui/en/floater_im_container.xml +++ b/indra/newview/skins/default/xui/en/floater_im_container.xml @@ -1,6 +1,6 @@ -