diff options
Diffstat (limited to 'indra/newview/llnearbychathandler.cpp')
-rw-r--r-- | indra/newview/llnearbychathandler.cpp | 123 |
1 files changed, 59 insertions, 64 deletions
diff --git a/indra/newview/llnearbychathandler.cpp b/indra/newview/llnearbychathandler.cpp index 957b6d5f94..240a7c7a35 100644 --- a/indra/newview/llnearbychathandler.cpp +++ b/indra/newview/llnearbychathandler.cpp @@ -29,7 +29,6 @@ #include "llagentdata.h" // for gAgentID #include "llnearbychathandler.h" -#include "llbottomtray.h" #include "llchatitemscontainerctrl.h" #include "llfirstuse.h" #include "llfloaterscriptdebug.h" @@ -41,6 +40,9 @@ #include "llfloaterreg.h"//for LLFloaterReg::getTypedInstance #include "llviewerwindow.h"//for screen channel position +#include "llnearbychatbar.h" +#include "llrootview.h" +#include "lllayoutstack.h" //add LLNearbyChatHandler to LLNotificationsUI namespace using namespace LLNotificationsUI; @@ -61,7 +63,8 @@ public: typedef std::vector<LLHandle<LLToast> > toast_vec_t; typedef std::list<LLHandle<LLToast> > toast_list_t; - LLNearbyChatScreenChannel(const LLUUID& id):LLScreenChannelBase(id) + LLNearbyChatScreenChannel(const Params& p) + : LLScreenChannelBase(p) { mStopProcessing = false; @@ -80,7 +83,6 @@ public: void addNotification (LLSD& notification); void arrangeToasts (); - void showToastsBottom (); typedef boost::function<LLToastPanelBase* (void )> create_toast_panel_callback_t; void setCreatePanelCallback(create_toast_panel_callback_t value) { m_create_toast_panel_callback_t = value;} @@ -88,8 +90,6 @@ public: void onToastDestroyed (LLToast* toast, bool app_quitting); void onToastFade (LLToast* toast); - void reshape (S32 width, S32 height, BOOL called_from_parent); - void redrawToasts() { arrangeToasts(); @@ -149,6 +149,7 @@ protected: toast_list_t m_toast_pool; bool mStopProcessing; + bool mChannelRect; }; //----------------------------------------------------------------------------------------------- @@ -351,27 +352,6 @@ void LLNearbyChatScreenChannel::addNotification(LLSD& notification) arrangeToasts(); } -void LLNearbyChatScreenChannel::arrangeToasts() -{ - if(!isHovering()) - { - showToastsBottom(); - } - - if (m_active_toasts.empty()) - { - LLHints::registerHintTarget("incoming_chat", LLHandle<LLView>()); - } - else - { - LLToast* toast = m_active_toasts.front().get(); - if (toast) - { - LLHints::registerHintTarget("incoming_chat", m_active_toasts.front().get()->LLView::getHandle()); - } - } -} - static bool sort_toasts_predicate(LLHandle<LLToast> first, LLHandle<LLToast> second) { if (!first.get() || !second.get()) return false; // STORM-1352 @@ -381,16 +361,34 @@ static bool sort_toasts_predicate(LLHandle<LLToast> first, LLHandle<LLToast> sec return v1 > v2; } -void LLNearbyChatScreenChannel::showToastsBottom() +void LLNearbyChatScreenChannel::arrangeToasts() { - if(mStopProcessing) + if(mStopProcessing || isHovering()) return; + if (mFloaterSnapRegion == NULL) + { + mFloaterSnapRegion = gViewerWindow->getRootView()->getChildView("floater_snap_region"); + } + + if (!getParent()) + { + // connect to floater snap region just to get resize events, we don't care about being a proper widget + mFloaterSnapRegion->addChild(this); + setFollows(FOLLOWS_ALL); + } + LLRect toast_rect; - updateBottom(); - S32 channel_bottom = getRect().mBottom; + updateRect(); + + LLRect channel_rect; + mFloaterSnapRegion->localRectToOtherView(mFloaterSnapRegion->getLocalRect(), &channel_rect, gFloaterView); + channel_rect.mLeft += 10; + channel_rect.mRight = channel_rect.mLeft + 300; - S32 bottom = channel_bottom; + S32 channel_bottom = channel_rect.mBottom; + + S32 bottom = channel_bottom + 80; S32 margin = gSavedSettings.getS32("ToastGap"); //sort active toasts @@ -409,7 +407,7 @@ void LLNearbyChatScreenChannel::showToastsBottom() S32 toast_top = bottom + toast->getRect().getHeight() + margin; - if(toast_top > gFloaterView->getRect().getHeight()) + if(toast_top > channel_rect.getHeight()) { while(it!=m_active_toasts.end()) { @@ -420,7 +418,7 @@ void LLNearbyChatScreenChannel::showToastsBottom() } toast_rect = toast->getRect(); - toast_rect.setLeftTopAndSize(getRect().mLeft , bottom + toast_rect.getHeight(), toast_rect.getWidth() ,toast_rect.getHeight()); + toast_rect.setLeftTopAndSize(channel_rect.mLeft , bottom + toast_rect.getHeight(), toast_rect.getWidth() ,toast_rect.getHeight()); toast->setRect(toast_rect); bottom += toast_rect.getHeight() - toast->getTopPad() + margin; @@ -438,15 +436,10 @@ void LLNearbyChatScreenChannel::showToastsBottom() } } - } - -void LLNearbyChatScreenChannel::reshape (S32 width, S32 height, BOOL called_from_parent) -{ - LLScreenChannelBase::reshape(width, height, called_from_parent); - arrangeToasts(); } + //----------------------------------------------------------------------------------------------- //LLNearbyChatHandler //----------------------------------------------------------------------------------------------- @@ -457,7 +450,9 @@ LLNearbyChatHandler::LLNearbyChatHandler(e_notification_type type, const LLSD& i mType = type; // Getting a Channel for our notifications - LLNearbyChatScreenChannel* channel = new LLNearbyChatScreenChannel(LLUUID(gSavedSettings.getString("NearByChatChannelUUID"))); + LLNearbyChatScreenChannel::Params p; + p.id = LLUUID(gSavedSettings.getString("NearByChatChannelUUID")); + LLNearbyChatScreenChannel* channel = new LLNearbyChatScreenChannel(p); LLNearbyChatScreenChannel::create_toast_panel_callback_t callback = createToastPanel; @@ -473,15 +468,13 @@ LLNearbyChatHandler::~LLNearbyChatHandler() void LLNearbyChatHandler::initChannel() { - LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat", LLSD()); - LLView* chat_box = LLBottomTray::getInstance()->getChildView("chat_box"); - S32 channel_right_bound = nearby_chat->getRect().mRight; - mChannel->init(chat_box->getRect().mLeft, channel_right_bound); + //LLRect snap_rect = gFloaterView->getSnapRect(); + //mChannel->init(snap_rect.mLeft, snap_rect.mLeft + 200); } -void LLNearbyChatHandler::processChat(const LLChat& chat_msg, // WARNING - not really const, see hack below changing chat_msg.mText +void LLNearbyChatHandler::processChat(const LLChat& chat_msg, const LLSD &args) { if(chat_msg.mMuted == TRUE) @@ -490,24 +483,9 @@ void LLNearbyChatHandler::processChat(const LLChat& chat_msg, // WARNING - not if(chat_msg.mText.empty()) return;//don't process empty messages - // Handle irc styled messages for toast panel - // HACK ALERT - changes mText, stripping out IRC style "/me" prefixes - LLChat& tmp_chat = const_cast<LLChat&>(chat_msg); - std::string original_message = tmp_chat.mText; // Save un-modified version of chat text - if (tmp_chat.mChatStyle == CHAT_STYLE_IRC) - { - if(!tmp_chat.mFromName.empty()) - tmp_chat.mText = tmp_chat.mFromName + tmp_chat.mText.substr(3); - else - tmp_chat.mText = tmp_chat.mText.substr(3); - } + LLFloater* chat_bar = LLFloaterReg::getInstance("chat_bar"); - LLNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLNearbyChat>("nearby_chat", LLSD()); - { - //sometimes its usefull to have no name at all... - //if(tmp_chat.mFromName.empty() && tmp_chat.mFromID!= LLUUID::null) - // tmp_chat.mFromName = tmp_chat.mFromID.asString(); - } + LLNearbyChat* nearby_chat = chat_bar->findChild<LLNearbyChat>("nearby_chat"); // Build notification data LLSD notification; @@ -551,7 +529,7 @@ void LLNearbyChatHandler::processChat(const LLChat& chat_msg, // WARNING - not LLViewerChat::getChatColor(chat_msg,txt_color); - LLFloaterScriptDebug::addScriptLine(original_message, // Send full message with "/me" style prefix + LLFloaterScriptDebug::addScriptLine(chat_msg.mText, chat_msg.mFromName, txt_color, chat_msg.mFromID); @@ -576,7 +554,8 @@ void LLNearbyChatHandler::processChat(const LLChat& chat_msg, // WARNING - not sChatWatcher->post(notification); - if( nearby_chat->getVisible() + if( !chat_bar->isMinimized() + && nearby_chat->isInVisibleChain() || ( chat_msg.mSourceType == CHAT_SOURCE_AGENT && gSavedSettings.getBOOL("UseChatBubbles") ) || !mChannel->getShowToasts() ) // to prevent toasts in Busy mode @@ -604,6 +583,21 @@ void LLNearbyChatHandler::processChat(const LLChat& chat_msg, // WARNING - not if(channel) { + // Handle IRC styled messages. + std::string toast_msg; + if (chat_msg.mChatStyle == CHAT_STYLE_IRC) + { + if (!chat_msg.mFromName.empty()) + { + toast_msg += chat_msg.mFromName; + } + toast_msg += chat_msg.mText.substr(3); + } + else + { + toast_msg = chat_msg.mText; + } + // Add a nearby chat toast. LLUUID id; id.generate(); @@ -615,6 +609,7 @@ void LLNearbyChatHandler::processChat(const LLChat& chat_msg, // WARNING - not notification["text_color"] = r_color_name; notification["color_alpha"] = r_color_alpha; notification["font_size"] = (S32)LLViewerChat::getChatFontSize() ; + notification["message"] = toast_msg; channel->addNotification(notification); } } |