diff options
author | Seth ProductEngine <slitovchuk@productengine.com> | 2012-05-17 02:51:18 +0300 |
---|---|---|
committer | Seth ProductEngine <slitovchuk@productengine.com> | 2012-05-17 02:51:18 +0300 |
commit | f59aa880395d4b744c89b0a375b21ee2bf429625 (patch) | |
tree | fbce0a02b92dd79ba5f03ae896875d4042d1da2f /indra/newview | |
parent | e2824864590ded669eac3c53efbfc60d04107ee4 (diff) |
CHUI-105 WIP Implemented collapsed/expanded state transitions for messages and conversation panes.
The states and dimensions of Conversations floater panes are saved in per account settings.
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/app_settings/settings_per_account.xml | 55 | ||||
-rw-r--r-- | indra/newview/llimfloater.cpp | 4 | ||||
-rw-r--r-- | indra/newview/llimfloatercontainer.cpp | 133 | ||||
-rw-r--r-- | indra/newview/llimfloatercontainer.h | 18 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_im_container.xml | 158 |
5 files changed, 293 insertions, 75 deletions
diff --git a/indra/newview/app_settings/settings_per_account.xml b/indra/newview/app_settings/settings_per_account.xml index 8cdd8ed838..fdc52b7394 100644 --- a/indra/newview/app_settings/settings_per_account.xml +++ b/indra/newview/app_settings/settings_per_account.xml @@ -22,6 +22,61 @@ <key>Value</key> <string>The Resident you messaged is in 'busy mode' which means they have requested not to be disturbed. Your message will still be shown in their IM panel for later viewing.</string> </map> + <key>ConversationsExpandMessagePaneFirst</key> + <map> + <key>Comment</key> + <string>Expand either messages or conversations list pane from Conversations compact mode.</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>1</integer> + </map> + <key>ConversationsListPaneCollapsed</key> + <map> + <key>Comment</key> + <string>Stores the expanded/collapsed state of the conversations list pane in Conversations floater.</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> + <key>ConversationsListPaneWidth</key> + <map> + <key>Comment</key> + <string>Conversations floater list pane width.</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>S32</string> + <key>Value</key> + <integer>268</integer> + </map> + <key>ConversationsMessagePaneCollapsed</key> + <map> + <key>Comment</key> + <string>Stores the expanded/collapsed state of Conversations floater message pane.</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> + <key>ConversationsMessagePaneWidth</key> + <map> + <key>Comment</key> + <string>Conversations floater message pane width.</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>S32</string> + <key>Value</key> + <integer>412</integer> + </map> <key>InstantMessageLogPath</key> <map> <key>Comment</key> diff --git a/indra/newview/llimfloater.cpp b/indra/newview/llimfloater.cpp index 1ca3545aae..051bb39540 100644 --- a/indra/newview/llimfloater.cpp +++ b/indra/newview/llimfloater.cpp @@ -188,7 +188,7 @@ void LLIMFloater::onOpen(const LLSD& key) if (host_floater) { // Show the messages pane when opening a floater hosted in the Conversations - host_floater->toggleMessagesPane(true); + host_floater->collapseMessagesPane(false); } } @@ -536,7 +536,7 @@ void LLIMFloater::onSlide() if (host_floater) { // Hide the messages pane if a floater is hosted in the Conversations - host_floater->toggleMessagesPane(false); + host_floater->collapseMessagesPane(true); } else ///< floater is torn off { diff --git a/indra/newview/llimfloatercontainer.cpp b/indra/newview/llimfloatercontainer.cpp index c8b8cb208d..b051440589 100644 --- a/indra/newview/llimfloatercontainer.cpp +++ b/indra/newview/llimfloatercontainer.cpp @@ -28,19 +28,23 @@ #include "llviewerprecompiledheaders.h" #include "llimfloatercontainer.h" + #include "llfloaterreg.h" -#include "llimview.h" +#include "lllayoutstack.h" + +#include "llagent.h" #include "llavatariconctrl.h" #include "llgroupiconctrl.h" -#include "llagent.h" +#include "llimview.h" #include "lltransientfloatermgr.h" +#include "llviewercontrol.h" // // LLIMFloaterContainer // LLIMFloaterContainer::LLIMFloaterContainer(const LLSD& seed) : LLMultiFloater(seed) - ,mMessagesPaneWidth(0) + ,mExpandCollapseBtn(NULL) { mAutoResize = FALSE; LLTransientFloaterMgr::getInstance()->addControlView(LLTransientFloaterMgr::IM, this); @@ -50,6 +54,9 @@ LLIMFloaterContainer::~LLIMFloaterContainer() { mNewMessageConnection.disconnect(); LLTransientFloaterMgr::getInstance()->removeControlView(LLTransientFloaterMgr::IM, this); + + gSavedPerAccountSettings.setBOOL("ConversationsListPaneCollapsed", mConversationsPane->isCollapsed()); + gSavedPerAccountSettings.setBOOL("ConversationsMessagePaneCollapsed", mMessagesPane->isCollapsed()); } BOOL LLIMFloaterContainer::postBuild() @@ -60,6 +67,16 @@ BOOL LLIMFloaterContainer::postBuild() setTabContainer(getChild<LLTabContainer>("im_box_tab_container")); + mConversationsStack = getChild<LLLayoutStack>("conversations_stack"); + mConversationsPane = getChild<LLLayoutPanel>("conversations_layout_panel"); + mMessagesPane = getChild<LLLayoutPanel>("messages_layout_panel"); + + mExpandCollapseBtn = getChild<LLButton>("expand_collapse_btn"); + mExpandCollapseBtn->setClickedCallback(boost::bind(&LLIMFloaterContainer::onExpandCollapseButtonClicked, this)); + + collapseMessagesPane(gSavedPerAccountSettings.getBOOL("ConversationsMessagePaneCollapsed")); + collapseConversationsPane(gSavedPerAccountSettings.getBOOL("ConversationsListPaneCollapsed")); + return TRUE; } @@ -146,6 +163,37 @@ void LLIMFloaterContainer::onCloseFloater(LLUUID& id) mSessions.erase(id); } +// virtual +void LLIMFloaterContainer::computeResizeLimits(S32& new_min_width, S32& new_min_height) +{ + bool is_left_pane_expanded = !mConversationsPane->isCollapsed(); + bool is_right_pane_expanded = !mMessagesPane->isCollapsed(); + + S32 conversations_pane_min_dim = mConversationsPane->getMinDim(); + + if (is_right_pane_expanded) + { + S32 conversations_pane_width = + (is_left_pane_expanded ? gSavedPerAccountSettings.getS32("ConversationsListPaneWidth") : conversations_pane_min_dim); + + // possibly increase minimum size constraint due to children's minimums. + for (S32 tab_idx = 0; tab_idx < mTabContainer->getTabCount(); ++tab_idx) + { + LLFloater* floaterp = dynamic_cast<LLFloater*>(mTabContainer->getPanelByIndex(tab_idx)); + if (floaterp) + { + new_min_width = llmax(new_min_width, + floaterp->getMinWidth() + conversations_pane_width + LLPANEL_BORDER_WIDTH * 2); + new_min_height = llmax(new_min_height, floaterp->getMinHeight()); + } + } + } + else + { + new_min_width = conversations_pane_min_dim; + } +} + void LLIMFloaterContainer::onNewMessageReceived(const LLSD& data) { LLUUID session_id = data["session_id"].asUUID(); @@ -160,6 +208,21 @@ void LLIMFloaterContainer::onNewMessageReceived(const LLSD& data) } } +void LLIMFloaterContainer::onExpandCollapseButtonClicked() +{ + if (mConversationsPane->isCollapsed() && mMessagesPane->isCollapsed() + && gSavedPerAccountSettings.getBOOL("ConversationsExpandMessagePaneFirst")) + { + // Expand the messages pane from ultra minimized state + // if it was collapsed last in order. + collapseMessagesPane(false); + } + else + { + collapseConversationsPane(!mConversationsPane->isCollapsed()); + } +} + LLIMFloaterContainer* LLIMFloaterContainer::findInstance() { return LLFloaterReg::findTypedInstance<LLIMFloaterContainer>("im_container"); @@ -186,29 +249,67 @@ void LLIMFloaterContainer::setMinimized(BOOL b) } } -void LLIMFloaterContainer::toggleMessagesPane(bool expand) +void LLIMFloaterContainer::collapseMessagesPane(bool collapse) { - LLView* messages_pane = getChild<LLView>("im_box_tab_container"); - bool is_expanded = messages_pane->getVisible(); - if (is_expanded == expand) + if (mMessagesPane->isCollapsed() == collapse) { return; } - // Store the messages pane width before collapsing it. - if (!expand) + if (collapse) { - LLView* conversations_pane = getChild<LLView>("conversations_pane"); - S32 horizontal_pad = messages_pane->getRect().mLeft - conversations_pane->getRect().mRight; - mMessagesPaneWidth = messages_pane->getRect().getWidth() + horizontal_pad; + // Save the messages pane width before collapsing it. + gSavedPerAccountSettings.setS32("ConversationsMessagePaneWidth", mMessagesPane->getRect().getWidth()); + + // Save the order in which the panels are closed to reverse user's last action. + gSavedPerAccountSettings.setBOOL("ConversationsExpandMessagePaneFirst", mConversationsPane->isCollapsed()); } // Show/hide the messages pane. - messages_pane->setVisible(expand); + mConversationsStack->collapsePanel(mMessagesPane, collapse); + + updateState(collapse, gSavedPerAccountSettings.getS32("ConversationsMessagePaneWidth")); +} + +void LLIMFloaterContainer::collapseConversationsPane(bool collapse) +{ + if (mConversationsPane->isCollapsed() == collapse) + { + return; + } + + LLView* button_panel = getChild<LLView>("conversations_pane_buttons_expanded"); + button_panel->setVisible(!collapse); + mExpandCollapseBtn->setImageOverlay(getString(collapse ? "expand_icon" : "collapse_icon")); + + if (collapse) + { + // Save the conversations pane width before collapsing it. + gSavedPerAccountSettings.setS32("ConversationsListPaneWidth", mConversationsPane->getRect().getWidth()); + + // Save the order in which the panels are closed to reverse user's last action. + gSavedPerAccountSettings.setBOOL("ConversationsExpandMessagePaneFirst", !mMessagesPane->isCollapsed()); + } + + mConversationsStack->collapsePanel(mConversationsPane, collapse); + + S32 collapsed_width = mConversationsPane->getMinDim(); + updateState(collapse, gSavedPerAccountSettings.getS32("ConversationsListPaneWidth") - collapsed_width); +} + +void LLIMFloaterContainer::updateState(bool collapse, S32 delta_width) +{ + LLRect floater_rect = getRect(); + floater_rect.mRight += ((collapse ? -1 : 1) * delta_width); + setShape(floater_rect); + + updateResizeLimits(); + + bool is_left_pane_expanded = !mConversationsPane->isCollapsed(); + bool is_right_pane_expanded = !mMessagesPane->isCollapsed(); - S32 floater_width = getRect().getWidth(); - floater_width += (expand ? mMessagesPaneWidth : -mMessagesPaneWidth); - reshape(floater_width, getRect().getHeight()); + setCanResize(is_left_pane_expanded || is_right_pane_expanded); + setCanMinimize(is_left_pane_expanded || is_right_pane_expanded); } // EOF diff --git a/indra/newview/llimfloatercontainer.h b/indra/newview/llimfloatercontainer.h index 045f053b1c..92938ff405 100644 --- a/indra/newview/llimfloatercontainer.h +++ b/indra/newview/llimfloatercontainer.h @@ -35,6 +35,9 @@ #include "llavatarpropertiesprocessor.h" #include "llgroupmgr.h" +class LLButton; +class LLLayoutPanel; +class LLLayoutStack; class LLTabContainer; class LLIMFloaterContainer : public LLMultiFloater @@ -60,16 +63,27 @@ public: virtual void setMinimized(BOOL b); - void toggleMessagesPane(bool expand); + void collapseMessagesPane(bool collapse); private: typedef std::map<LLUUID,LLFloater*> avatarID_panel_map_t; avatarID_panel_map_t mSessions; boost::signals2::connection mNewMessageConnection; + /*virtual*/ void computeResizeLimits(S32& new_min_width, S32& new_min_height); + void onNewMessageReceived(const LLSD& data); - S32 mMessagesPaneWidth; + void onExpandCollapseButtonClicked(); + + void collapseConversationsPane(bool collapse); + + void updateState(bool collapse, S32 delta_width); + + LLButton* mExpandCollapseBtn; + LLLayoutPanel* mMessagesPane; + LLLayoutPanel* mConversationsPane; + LLLayoutStack* mConversationsStack; }; #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 8a0181bae4..ce40f44a64 100644 --- a/indra/newview/skins/default/xui/en/floater_im_container.xml +++ b/indra/newview/skins/default/xui/en/floater_im_container.xml @@ -5,7 +5,7 @@ can_resize="true" height="430" layout="topleft" - min_width="510" + min_height="50" name="floater_im_box" help_topic="floater_im_box" save_rect="true" @@ -13,62 +13,110 @@ single_instance="true" title="CONVERSATIONS" width="680"> - <panel - border="true" - follows="top|bottom|left" - layout="topleft" - name="conversations_pane" - opaque="true" - top="0" - left="5" - height="425" - width="263"> - <menu_button - follows="top|left" - height="25" - image_hover_unselected="Toolbar_Middle_Over" - image_overlay="OptionsMenu_Off" - image_selected="Toolbar_Middle_Selected" - image_unselected="Toolbar_Middle_Off" - layout="topleft" - left="5" - name="sort_btn" - top="5" - width="31" /> - <button - follows="top|left" - height="25" - image_hover_unselected="Toolbar_Middle_Over" - image_overlay="AddItem_Off" - image_selected="Toolbar_Middle_Selected" - image_unselected="Toolbar_Middle_Off" - layout="topleft" - top="5" - left_pad="4" - name="add_btn" - tool_tip="Add button on the left panel" - width="31"> - </button> - <button - follows="right|top" - height="25" - image_hover_unselected="Toolbar_Middle_Over" - image_overlay="TabIcon_Open_Off" - image_selected="Toolbar_Middle_Selected" - image_unselected="Toolbar_Middle_Off" - layout="topleft" - top="5" - left="228" - name="expand_collapse_btn" - width="31" /> - </panel> - <panel_container + <string + name="collapse_icon" + value="TabIcon_Open_Off"/> + <string + name="expand_icon" + value="TabIcon_Close_Off"/> + <layout_stack + animate="true" follows="all" height="430" layout="topleft" - left_pad="15" - min_width="290" - name="im_box_tab_container" + left="0" + name="conversations_stack" + orientation="horizontal" top="0" - width="389"/> + width="680"> + <layout_panel + auto_resize="true" + height="430" + name="conversations_layout_panel" + min_dim="41" + width="268"> + <layout_stack + animate="false" + follows="left|top|right" + height="35" + layout="topleft" + left="0" + name="conversations_pane_buttons_stack" + orientation="horizontal" + top="0" + width="268"> + <layout_panel + auto_resize="true" + height="35" + name="conversations_pane_buttons_expanded"> + <menu_button + follows="top|left" + height="25" + image_hover_unselected="Toolbar_Middle_Over" + image_overlay="OptionsMenu_Off" + image_selected="Toolbar_Middle_Selected" + image_unselected="Toolbar_Middle_Off" + layout="topleft" + left="10" + name="sort_btn" + top="5" + width="31" /> + <button + follows="top|left" + height="25" + image_hover_unselected="Toolbar_Middle_Over" + image_overlay="AddItem_Off" + image_selected="Toolbar_Middle_Selected" + image_unselected="Toolbar_Middle_Off" + layout="topleft" + top="5" + left_pad="4" + name="add_btn" + tool_tip="Add button on the left panel" + width="31"/> + </layout_panel> + <layout_panel + auto_resize="false" + height="35" + name="conversations_pane_buttons_collapsed" + width="41"> + <button + follows="right|top" + height="25" + image_hover_unselected="Toolbar_Middle_Over" + image_overlay="TabIcon_Open_Off" + image_selected="Toolbar_Middle_Selected" + image_unselected="Toolbar_Middle_Off" + layout="topleft" + top="5" + left="5" + name="expand_collapse_btn" + width="31" /> + </layout_panel> + </layout_stack> + <panel + follows="all" + layout="topleft" + name="conversations_list_panel" + opaque="true" + top_pad="0" + left="5" + height="390" + width="263"/> + </layout_panel> + <layout_panel + auto_resize="true" + height="430" + name="messages_layout_panel" + width="412"> + <panel_container + follows="all" + height="430" + layout="topleft" + left="10" + name="im_box_tab_container" + top="0" + width="402"/> + </layout_panel> + </layout_stack> </multi_floater> |