summaryrefslogtreecommitdiff
path: root/indra/newview/llimfloater.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llimfloater.cpp')
-rw-r--r--indra/newview/llimfloater.cpp180
1 files changed, 111 insertions, 69 deletions
diff --git a/indra/newview/llimfloater.cpp b/indra/newview/llimfloater.cpp
index 5e9ffdf410..9de0b1f827 100644
--- a/indra/newview/llimfloater.cpp
+++ b/indra/newview/llimfloater.cpp
@@ -44,6 +44,7 @@
#include "llchiclet.h"
#include "llfloaterchat.h"
#include "llfloaterreg.h"
+#include "llimfloatercontainer.h" // to replace separate IM Floaters with multifloater container
#include "lllineeditor.h"
#include "lllogchat.h"
#include "llpanelimcontrolpanel.h"
@@ -55,10 +56,6 @@
#include "lltransientfloatermgr.h"
#include "llinventorymodel.h"
-#ifdef USE_IM_CONTAINER
- #include "llimfloatercontainer.h" // to replace separate IM Floaters with multifloater container
-#endif
-
LLIMFloater::LLIMFloater(const LLUUID& session_id)
@@ -263,11 +260,14 @@ BOOL LLIMFloater::postBuild()
//*TODO if session is not initialized yet, add some sort of a warning message like "starting session...blablabla"
//see LLFloaterIMPanel for how it is done (IB)
-#ifdef USE_IM_CONTAINER
- return LLFloater::postBuild();
-#else
- return LLDockableFloater::postBuild();
-#endif
+ if(isChatMultiTab())
+ {
+ return LLFloater::postBuild();
+ }
+ else
+ {
+ return LLDockableFloater::postBuild();
+ }
}
// virtual
@@ -328,59 +328,69 @@ void LLIMFloater::onSlide()
//static
LLIMFloater* LLIMFloater::show(const LLUUID& session_id)
{
-#ifdef USE_IM_CONTAINER
- LLIMFloater* target_floater = findInstance(session_id);
- bool not_existed = NULL == target_floater;
+ bool not_existed = true;
-#else
- //hide all
- LLFloaterReg::const_instance_list_t& inst_list = LLFloaterReg::getFloaterList("impanel");
- for (LLFloaterReg::const_instance_list_t::const_iterator iter = inst_list.begin();
- iter != inst_list.end(); ++iter)
+ if(isChatMultiTab())
{
- LLIMFloater* floater = dynamic_cast<LLIMFloater*>(*iter);
- if (floater && floater->isDocked())
+ LLIMFloater* target_floater = findInstance(session_id);
+ not_existed = NULL == target_floater;
+ }
+ else
+ {
+ //hide all
+ LLFloaterReg::const_instance_list_t& inst_list = LLFloaterReg::getFloaterList("impanel");
+ for (LLFloaterReg::const_instance_list_t::const_iterator iter = inst_list.begin();
+ iter != inst_list.end(); ++iter)
{
- floater->setVisible(false);
+ LLIMFloater* floater = dynamic_cast<LLIMFloater*>(*iter);
+ if (floater && floater->isDocked())
+ {
+ floater->setVisible(false);
+ }
}
}
-#endif
LLIMFloater* floater = LLFloaterReg::showTypedInstance<LLIMFloater>("impanel", session_id);
- floater->updateMessages();
- floater->mInputEditor->setFocus(TRUE);
-
-#ifdef USE_IM_CONTAINER
- // do not add existed floaters to avoid adding torn off instances
- if (not_existed)
+ if(isChatMultiTab())
{
- // LLTabContainer::eInsertionPoint i_pt = user_initiated ? LLTabContainer::RIGHT_OF_CURRENT : LLTabContainer::END;
- // TODO: mantipov: use LLTabContainer::RIGHT_OF_CURRENT if it exists
- LLTabContainer::eInsertionPoint i_pt = LLTabContainer::END;
+ // do not add existed floaters to avoid adding torn off instances
+ if (not_existed)
+ {
+ // LLTabContainer::eInsertionPoint i_pt = user_initiated ? LLTabContainer::RIGHT_OF_CURRENT : LLTabContainer::END;
+ // TODO: mantipov: use LLTabContainer::RIGHT_OF_CURRENT if it exists
+ LLTabContainer::eInsertionPoint i_pt = LLTabContainer::END;
- LLIMFloaterContainer* floater_container = LLFloaterReg::showTypedInstance<LLIMFloaterContainer>("im_container");
- floater_container->addFloater(floater, TRUE, i_pt);
+ LLIMFloaterContainer* floater_container = LLFloaterReg::showTypedInstance<LLIMFloaterContainer>("im_container");
+ floater_container->addFloater(floater, TRUE, i_pt);
+ }
}
-#else
- if (floater->getDockControl() == NULL)
+ else
{
- LLChiclet* chiclet =
- LLBottomTray::getInstance()->getChicletPanel()->findChiclet<LLChiclet>(
- session_id);
- if (chiclet == NULL)
- {
- llerror("Dock chiclet for LLIMFloater doesn't exists", 0);
- }
- else
+ // Docking may move chat window, hide it before moving, or user will see how window "jumps"
+ floater->setVisible(false);
+
+ if (floater->getDockControl() == NULL)
{
- LLBottomTray::getInstance()->getChicletPanel()->scrollToChiclet(chiclet);
+ LLChiclet* chiclet =
+ LLBottomTray::getInstance()->getChicletPanel()->findChiclet<LLChiclet>(
+ session_id);
+ if (chiclet == NULL)
+ {
+ llerror("Dock chiclet for LLIMFloater doesn't exists", 0);
+ }
+ else
+ {
+ LLBottomTray::getInstance()->getChicletPanel()->scrollToChiclet(chiclet);
+ }
+
+ floater->setDockControl(new LLDockControl(chiclet, floater, floater->getDockTongue(),
+ LLDockControl::TOP, boost::bind(&LLIMFloater::getAllowedRect, floater, _1)));
}
- floater->setDockControl(new LLDockControl(chiclet, floater, floater->getDockTongue(),
- LLDockControl::TOP, boost::bind(&LLIMFloater::getAllowedRect, floater, _1)));
+ // window is positioned, now we can show it.
+ floater->setVisible(true);
}
-#endif
return floater;
}
@@ -397,9 +407,10 @@ void LLIMFloater::setDocked(bool docked, bool pop_on_undock)
(LLNotificationsUI::LLChannelManager::getInstance()->
findChannelByID(LLUUID(gSavedSettings.getString("NotificationChannelUUID"))));
-#ifndef USE_IM_CONTAINER
- LLTransientDockableFloater::setDocked(docked, pop_on_undock);
-#endif
+ if(!isChatMultiTab())
+ {
+ LLTransientDockableFloater::setDocked(docked, pop_on_undock);
+ }
// update notification channel state
if(channel)
@@ -408,6 +419,16 @@ void LLIMFloater::setDocked(bool docked, bool pop_on_undock)
}
}
+void LLIMFloater::setTornOff(bool torn_off)
+{
+ // When IM Floater isn't torn off, "close" button should be hidden.
+ // This call will just disables it, since there is a hack in LLFloater::updateButton,
+ // which prevents hiding of close button in that case.
+ setCanClose(torn_off);
+
+ LLTransientDockableFloater::setTornOff(torn_off);
+}
+
void LLIMFloater::setVisible(BOOL visible)
{
LLNotificationsUI::LLScreenChannel* channel = dynamic_cast<LLNotificationsUI::LLScreenChannel*>
@@ -420,33 +441,39 @@ void LLIMFloater::setVisible(BOOL visible)
{
channel->updateShowToastsState();
}
+
+ if (visible && mChatHistory && mInputEditor)
+ {
+ //only if floater was construced and initialized from xml
+ updateMessages();
+ mInputEditor->setFocus(TRUE);
+ }
}
//static
bool LLIMFloater::toggle(const LLUUID& session_id)
{
-#ifndef USE_IM_CONTAINER
- LLIMFloater* floater = LLFloaterReg::findTypedInstance<LLIMFloater>("impanel", session_id);
- if (floater && floater->getVisible() && floater->isDocked())
- {
- // clicking on chiclet to close floater just hides it to maintain existing
- // scroll/text entry state
- floater->setVisible(false);
- return false;
- }
- else if(floater && !floater->isDocked())
- {
- floater->setVisible(TRUE);
- floater->setFocus(TRUE);
- return true;
- }
- else
-#endif
+ if(!isChatMultiTab())
{
- // ensure the list of messages is updated when floater is made visible
- show(session_id);
- return true;
+ LLIMFloater* floater = LLFloaterReg::findTypedInstance<LLIMFloater>("impanel", session_id);
+ if (floater && floater->getVisible() && floater->isDocked())
+ {
+ // clicking on chiclet to close floater just hides it to maintain existing
+ // scroll/text entry state
+ floater->setVisible(false);
+ return false;
+ }
+ else if(floater && !floater->isDocked())
+ {
+ floater->setVisible(TRUE);
+ floater->setFocus(TRUE);
+ return true;
+ }
}
+
+ // ensure the list of messages is updated when floater is made visible
+ show(session_id);
+ return true;
}
//static
@@ -892,3 +919,18 @@ void LLIMFloater::removeTypingIndicator(const LLIMInfo* im_info)
}
}
+// static
+bool LLIMFloater::isChatMultiTab()
+{
+ // Restart is required in order to change chat window type.
+ static bool is_single_window = gSavedSettings.getS32("ChatWindow") == 1;
+ return is_single_window;
+}
+
+// static
+void LLIMFloater::initIMFloater()
+{
+ // This is called on viewer start up
+ // init chat window type before user changed it in preferences
+ isChatMultiTab();
+}