summaryrefslogtreecommitdiff
path: root/indra/newview/llchannelmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llchannelmanager.cpp')
-rw-r--r--indra/newview/llchannelmanager.cpp126
1 files changed, 54 insertions, 72 deletions
diff --git a/indra/newview/llchannelmanager.cpp b/indra/newview/llchannelmanager.cpp
index a8373491cf..7ae9976338 100644
--- a/indra/newview/llchannelmanager.cpp
+++ b/indra/newview/llchannelmanager.cpp
@@ -37,6 +37,8 @@
#include "llappviewer.h"
#include "llviewercontrol.h"
#include "llimview.h"
+#include "llbottomtray.h"
+#include "llviewerwindow.h"
#include <algorithm>
@@ -48,12 +50,34 @@ LLChannelManager::LLChannelManager()
LLAppViewer::instance()->setOnLoginCompletedCallback(boost::bind(&LLChannelManager::onLoginCompleted, this));
mChannelList.clear();
mStartUpChannel = NULL;
+
+ if(!gViewerWindow)
+ {
+ llerrs << "LLChannelManager::LLChannelManager() - viwer window is not initialized yet" << llendl;
+ }
}
//--------------------------------------------------------------------------
LLChannelManager::~LLChannelManager()
{
- //All channels are being deleted by Parent View
+ for(std::vector<ChannelElem>::iterator it = mChannelList.begin(); it != mChannelList.end(); ++it)
+ {
+ delete (*it).channel;
+ }
+
+ mChannelList.clear();
+}
+
+//--------------------------------------------------------------------------
+LLScreenChannel* LLChannelManager::createNotificationChannel()
+{
+ // creating params for a channel
+ LLChannelManager::Params p;
+ p.id = LLUUID(gSavedSettings.getString("NotificationChannelUUID"));
+ p.channel_align = CA_RIGHT;
+
+ // Getting a Channel for our notifications
+ return LLChannelManager::getInstance()->getChannel(p);
}
//--------------------------------------------------------------------------
@@ -61,20 +85,22 @@ void LLChannelManager::onLoginCompleted()
{
S32 away_notifications = 0;
+ // calc a number of all offline notifications
for(std::vector<ChannelElem>::iterator it = mChannelList.begin(); it != mChannelList.end(); ++it)
{
+ // don't calc notifications for Nearby Chat
if((*it).channel->getChannelID() == LLUUID(gSavedSettings.getString("NearByChatChannelUUID")))
{
continue;
}
+ // don't calc notifications for channels that always show their notifications
if(!(*it).channel->getDisplayToastsAlways())
{
away_notifications +=(*it).channel->getNumberOfHiddenToasts();
}
}
- // *TODO: calculate IM notifications
away_notifications += gIMMgr->getNumberOfUnreadIM();
if(!away_notifications)
@@ -83,11 +109,11 @@ void LLChannelManager::onLoginCompleted()
return;
}
+ // create a channel for the StartUp Toast
LLChannelManager::Params p;
p.id = LLUUID(gSavedSettings.getString("StartUpChannelUUID"));
- p.channel_right_bound = getRootView()->getRect().mRight - gSavedSettings.getS32("NotificationChannelRightMargin");
- p.channel_width = gSavedSettings.getS32("NotifyBoxWidth");
- mStartUpChannel = createChannel(p);
+ p.channel_align = CA_RIGHT;
+ mStartUpChannel = getChannel(p);
if(!mStartUpChannel)
{
@@ -95,8 +121,13 @@ void LLChannelManager::onLoginCompleted()
return;
}
+ // init channel's position and size
+ S32 channel_right_bound = gViewerWindow->getWorldViewRect().mRight - gSavedSettings.getS32("NotificationChannelRightMargin");
+ S32 channel_width = gSavedSettings.getS32("NotifyBoxWidth");
+ mStartUpChannel->init(channel_right_bound - channel_width, channel_right_bound);
mStartUpChannel->setShowToasts(true);
- static_cast<LLUICtrl*>(mStartUpChannel)->setCommitCallback(boost::bind(&LLChannelManager::onStartUpToastClose, this));
+
+ mStartUpChannel->setCommitCallback(boost::bind(&LLChannelManager::onStartUpToastClose, this));
mStartUpChannel->createStartUpToast(away_notifications, gSavedSettings.getS32("ChannelBottomPanelMargin"), gSavedSettings.getS32("StartUpToastTime"));
}
@@ -107,76 +138,56 @@ void LLChannelManager::onStartUpToastClose()
{
mStartUpChannel->setVisible(FALSE);
mStartUpChannel->closeStartUpToast();
- getRootView()->removeChild(mStartUpChannel);
removeChannelByID(LLUUID(gSavedSettings.getString("StartUpChannelUUID")));
delete mStartUpChannel;
mStartUpChannel = NULL;
}
- // set StartUp Toast Flag
+ // set StartUp Toast Flag to allow all other channels to show incoming toasts
LLScreenChannel::setStartUpToastShown();
- // allow all other channels to show incoming toasts
- for(std::vector<ChannelElem>::iterator it = mChannelList.begin(); it != mChannelList.end(); ++it)
- {
- (*it).channel->setShowToasts(true);
- }
-
// force NEARBY CHAT CHANNEL to repost all toasts if present
- LLScreenChannel* nearby_channel = getChannelByID(LLUUID(gSavedSettings.getString("NearByChatChannelUUID")));
+ LLScreenChannel* nearby_channel = findChannelByID(LLUUID(gSavedSettings.getString("NearByChatChannelUUID")));
nearby_channel->loadStoredToastsToChannel();
nearby_channel->setCanStoreToasts(false);
}
//--------------------------------------------------------------------------
-LLScreenChannel* LLChannelManager::createChannel(LLChannelManager::Params& p)
+LLScreenChannel* LLChannelManager::getChannel(LLChannelManager::Params& p)
{
LLScreenChannel* new_channel = NULL;
- if(!p.chiclet)
- {
- new_channel = getChannelByID(p.id);
- }
- else
- {
- new_channel = getChannelByChiclet(p.chiclet);
- }
+ new_channel = findChannelByID(p.id);
if(new_channel)
return new_channel;
new_channel = new LLScreenChannel(p.id);
- getRootView()->addChild(new_channel);
- new_channel->init(p.channel_right_bound - p.channel_width, p.channel_right_bound);
- new_channel->setToastAlignment(p.align);
+
+ if(!new_channel)
+ {
+ llerrs << "LLChannelManager::getChannel(LLChannelManager::Params& p) - can't create a channel!" << llendl;
+ }
+ else
+ {
+ new_channel->setToastAlignment(p.toast_align);
+ new_channel->setChannelAlignment(p.channel_align);
new_channel->setDisplayToastsAlways(p.display_toasts_always);
ChannelElem new_elem;
new_elem.id = p.id;
- new_elem.chiclet = p.chiclet;
new_elem.channel = new_channel;
-
- mChannelList.push_back(new_elem); //TODO: remove chiclet from ScreenChannel?
-
- return new_channel;
-}
-//--------------------------------------------------------------------------
-LLScreenChannel* LLChannelManager::getChannelByID(const LLUUID id)
-{
- std::vector<ChannelElem>::iterator it = find(mChannelList.begin(), mChannelList.end(), id);
- if(it != mChannelList.end())
- {
- return (*it).channel;
+ mChannelList.push_back(new_elem);
}
- return NULL;
+ return new_channel;
}
//--------------------------------------------------------------------------
-LLScreenChannel* LLChannelManager::getChannelByChiclet(const LLChiclet* chiclet)
+LLScreenChannel* LLChannelManager::findChannelByID(const LLUUID id)
{
- std::vector<ChannelElem>::iterator it = find(mChannelList.begin(), mChannelList.end(), chiclet);
+ std::vector<ChannelElem>::iterator it = find(mChannelList.begin(), mChannelList.end(), id);
if(it != mChannelList.end())
{
return (*it).channel;
@@ -186,22 +197,6 @@ LLScreenChannel* LLChannelManager::getChannelByChiclet(const LLChiclet* chiclet)
}
//--------------------------------------------------------------------------
-void LLChannelManager::reshape(S32 width, S32 height, BOOL called_from_parent)
-{
- for(std::vector<ChannelElem>::iterator it = mChannelList.begin(); it != mChannelList.end(); ++it)
- {
- if((*it).channel->getToastAlignment() == NA_CENTRE)
- {
- LLRect channel_rect = (*it).channel->getRect();
- S32 screen_width = getRootView()->getRect().getWidth();
- channel_rect.setLeftTopAndSize(screen_width/2, channel_rect.mTop, channel_rect.getWidth(), channel_rect.getHeight());
- (*it).channel->setRect(channel_rect);
- (*it).channel->showToasts();
- }
- }
-}
-
-//--------------------------------------------------------------------------
void LLChannelManager::removeChannelByID(const LLUUID id)
{
std::vector<ChannelElem>::iterator it = find(mChannelList.begin(), mChannelList.end(), id);
@@ -212,18 +207,5 @@ void LLChannelManager::removeChannelByID(const LLUUID id)
}
//--------------------------------------------------------------------------
-void LLChannelManager::removeChannelByChiclet(const LLChiclet* chiclet)
-{
- std::vector<ChannelElem>::iterator it = find(mChannelList.begin(), mChannelList.end(), chiclet);
- if(it != mChannelList.end())
- {
- mChannelList.erase(it);
- }
-}
-
-//--------------------------------------------------------------------------
-
-
-