diff options
author | Dmitry Zaporozhan <dzaporozhan@productengine.com> | 2009-12-02 14:18:40 +0200 |
---|---|---|
committer | Dmitry Zaporozhan <dzaporozhan@productengine.com> | 2009-12-02 14:18:40 +0200 |
commit | 9d8b189886ae14800d58f9729d8c8ea9b338ed52 (patch) | |
tree | 70bbfd2ed96710569bae959f6d1ac480f08919da /indra/newview/llimfloater.cpp | |
parent | 52ce4b922947579337226d7932bcd6ffb931da82 (diff) |
Implemented normal sub-task EXT-2975 - Make the IM multifloater optional.
--HG--
branch : product-engine
Diffstat (limited to 'indra/newview/llimfloater.cpp')
-rw-r--r-- | indra/newview/llimfloater.cpp | 160 |
1 files changed, 94 insertions, 66 deletions
diff --git a/indra/newview/llimfloater.cpp b/indra/newview/llimfloater.cpp index 5e9ffdf410..3315d5b18d 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,72 @@ 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 +410,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) @@ -425,28 +439,27 @@ void LLIMFloater::setVisible(BOOL visible) //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()) + if(!isChatMultiTab()) { - // 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 - { - // 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 +905,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(); +} |