summaryrefslogtreecommitdiff
path: root/indra/newview/llimfloater.cpp
diff options
context:
space:
mode:
authorSeth ProductEngine <slitovchuk@productengine.com>2012-05-18 02:04:22 +0300
committerSeth ProductEngine <slitovchuk@productengine.com>2012-05-18 02:04:22 +0300
commitacbce3248987d7e71be0fa0a251879c4066d9042 (patch)
treea0faa99fb3177cfc0e8a01ce486ccb0e1556408f /indra/newview/llimfloater.cpp
parent4fc8000d6692290516eae1f865b6b41f1d56cc0b (diff)
CHUI-105 WIP Minor code clean up and optimization.
Removed overloaded updateTitleButtons() and moved its functionality to a new method that should be called less frequently.
Diffstat (limited to 'indra/newview/llimfloater.cpp')
-rw-r--r--indra/newview/llimfloater.cpp120
1 files changed, 55 insertions, 65 deletions
diff --git a/indra/newview/llimfloater.cpp b/indra/newview/llimfloater.cpp
index c6608337c8..981250d223 100644
--- a/indra/newview/llimfloater.cpp
+++ b/indra/newview/llimfloater.cpp
@@ -65,6 +65,7 @@ LLIMFloater::LLIMFloater(const LLUUID& session_id)
mLastMessageIndex(-1),
mDialog(IM_NOTHING_SPECIAL),
mInputEditor(NULL),
+ mCloseBtn(NULL),
mExpandCollapseBtn(NULL),
mTearOffBtn(NULL),
mSavedTitle(),
@@ -192,6 +193,8 @@ void LLIMFloater::onOpen(const LLSD& key)
// Show the messages pane when opening a floater hosted in the Conversations
host_floater->collapseMessagesPane(false);
}
+
+ updateHeaderAndToolbar();
}
// virtual
@@ -308,7 +311,8 @@ BOOL LLIMFloater::postBuild()
boundVoiceChannel();
- getChild<LLButton>("close_btn")->setCommitCallback(boost::bind(&LLFloater::onClickClose, this));
+ mCloseBtn = getChild<LLButton>("close_btn");
+ mCloseBtn->setCommitCallback(boost::bind(&LLFloater::onClickClose, this));
mExpandCollapseBtn = getChild<LLButton>("expand_collapse_btn");
mExpandCollapseBtn->setClickedCallback(boost::bind(&LLIMFloater::onSlide, this));
@@ -328,7 +332,7 @@ BOOL LLIMFloater::postBuild()
}
mTearOffBtn = getChild<LLButton>("tear_off_btn");
- mTearOffBtn->setCommitCallback(boost::bind(&LLFloater::onClickTearOff, this));
+ mTearOffBtn->setCommitCallback(boost::bind(&LLIMFloater::onTearOffClicked, this));
mInputEditor = getChild<LLLineEditor>("chat_editor");
mInputEditor->setMaxTextLength(1023);
@@ -391,10 +395,11 @@ BOOL LLIMFloater::postBuild()
}
}
-void LLIMFloater::onTearOffClicked(LLIMFloater* self)
+void LLIMFloater::onTearOffClicked()
{
- onClickTearOff(self);
- updateTitleButtons();
+ onClickTearOff(this);
+
+ updateHeaderAndToolbar();
}
void LLIMFloater::boundVoiceChannel()
@@ -1256,6 +1261,51 @@ void LLIMFloater::removeTypingIndicator(const LLIMInfo* im_info)
}
}
+void LLIMFloater::updateHeaderAndToolbar()
+{
+ bool is_hosted = getHost() != NULL;
+
+ if (is_hosted)
+ {
+ for (S32 i = 0; i < BUTTON_COUNT; i++)
+ {
+ if (!mButtons[i])
+ {
+ continue;
+ }
+
+ // Hide the standard header buttons in a docked IM floater.
+ mButtons[i]->setVisible(false);
+ }
+ }
+
+ // Display collapse image (<<) if the floater is hosted
+ // or if it is torn off but has an open control panel.
+ bool is_expanded = is_hosted || (mControlPanel && mControlPanel->getParent()->getVisible());
+ mExpandCollapseBtn->setImageOverlay(getString(is_expanded ? "collapse_icon" : "expand_icon"));
+
+ LLIMModel::LLIMSession* session = LLIMModel::instance().findIMSession(mSessionID);
+ if (session)
+ {
+ // The button (>>) should be disabled for torn off P2P conversations.
+ mExpandCollapseBtn->setEnabled(is_hosted || !session->isP2PSessionType());
+ }
+ else
+ {
+ llwarns << "IM session not found." << llendl;
+ }
+
+ if (mDragHandle)
+ {
+ // toggle floater's drag handle and title visibility
+ mDragHandle->setVisible(!is_hosted);
+ }
+
+ mTearOffBtn->setImageOverlay(getString(is_hosted ? "tear_off_icon" : "return_icon"));
+
+ mCloseBtn->setVisible(is_hosted);
+}
+
// static
void LLIMFloater::closeHiddenIMToasts()
{
@@ -1376,63 +1426,3 @@ void LLIMFloater::onClickCloseBtn()
LLFloater::onClickCloseBtn();
}
-
-// virtual
-void LLIMFloater::updateTitleButtons()
-{
- // This gets called before LLIMFloater::postBuild() while some LLIMFloater members are NULL
- if ( !mDragHandle
- //|| !mControlPanel
- || !mExpandCollapseBtn
- || !mTearOffBtn)
- {
- return;
- }
-
- bool is_hosted = getHost() != NULL;
-
- if (is_hosted) ///< floater is hosted
- {
- for (S32 i = 0; i < BUTTON_COUNT; i++)
- {
- if (!mButtons[i])
- {
- continue;
- }
-
- // 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();
-
- if (mControlPanel)
- {
- bool is_expanded = mControlPanel->getParent()->getVisible();
- mExpandCollapseBtn->setImageOverlay(getString(is_expanded ? "collapse_icon" : "expand_icon"));
- }
- }
-
- getChild<LLButton>("close_btn")->setVisible(is_hosted);
-
- LLIMModel::LLIMSession* session = LLIMModel::instance().findIMSession(mSessionID);
- if (session)
- {
- mExpandCollapseBtn->setEnabled(is_hosted || !session->isP2PSessionType());
- }
- else
- {
- llwarns << "Empty session." << llendl;
- return;
- }
-
- // toggle floater's drag handle and title visibility
- mDragHandle->setVisible(!is_hosted);
-
- mTearOffBtn->setImageOverlay(getString(is_hosted ? "tear_off_icon" : "return_icon"));
-}