From c285f59ce2a05703e3a1232fcaf3ee3aea714b3f Mon Sep 17 00:00:00 2001 From: Ansariel Date: Sun, 18 Feb 2024 12:52:19 +0100 Subject: Replace BOOL with bool in llwindow and dependent classes --- indra/newview/llsyswellwindow.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/llsyswellwindow.cpp') diff --git a/indra/newview/llsyswellwindow.cpp b/indra/newview/llsyswellwindow.cpp index 8f64cff47c..0bfc034330 100644 --- a/indra/newview/llsyswellwindow.cpp +++ b/indra/newview/llsyswellwindow.cpp @@ -277,20 +277,20 @@ void LLIMWellWindow::ObjectRowPanel::onMouseLeave(S32 x, S32 y, MASK mask) //--------------------------------------------------------------------------------- // virtual -BOOL LLIMWellWindow::ObjectRowPanel::handleMouseDown(S32 x, S32 y, MASK mask) +bool LLIMWellWindow::ObjectRowPanel::handleMouseDown(S32 x, S32 y, MASK mask) { // Pass the mouse down event to the chiclet (EXT-596). if (!mChiclet->pointInView(x, y) && !mCloseBtn->getRect().pointInRect(x, y)) // prevent double call of LLIMChiclet::onMouseDown() { mChiclet->onMouseDown(); - return TRUE; + return true; } return LLPanel::handleMouseDown(x, y, mask); } // virtual -BOOL LLIMWellWindow::ObjectRowPanel::handleRightMouseDown(S32 x, S32 y, MASK mask) +bool LLIMWellWindow::ObjectRowPanel::handleRightMouseDown(S32 x, S32 y, MASK mask) { return mChiclet->handleRightMouseDown(x, y, mask); } -- cgit v1.2.3 From a5261a5fa8fad810ecb5c260d92c3e771822bf58 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Tue, 20 Feb 2024 23:46:23 +0100 Subject: Convert BOOL to bool in llui --- indra/newview/llsyswellwindow.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/newview/llsyswellwindow.cpp') diff --git a/indra/newview/llsyswellwindow.cpp b/indra/newview/llsyswellwindow.cpp index 0bfc034330..6e8a8e4849 100644 --- a/indra/newview/llsyswellwindow.cpp +++ b/indra/newview/llsyswellwindow.cpp @@ -50,7 +50,7 @@ LLSysWellWindow::LLSysWellWindow(const LLSD& key) : LLTransientDockableFloater(N } //--------------------------------------------------------------------------------- -BOOL LLSysWellWindow::postBuild() +bool LLSysWellWindow::postBuild() { mMessageList = getChild("notification_list"); @@ -61,7 +61,7 @@ BOOL LLSysWellWindow::postBuild() } //--------------------------------------------------------------------------------- -void LLSysWellWindow::setMinimized(BOOL minimize) +void LLSysWellWindow::setMinimized(bool minimize) { LLTransientDockableFloater::setMinimized(minimize); } @@ -137,7 +137,7 @@ void LLSysWellWindow::initChannel() } //--------------------------------------------------------------------------------- -void LLSysWellWindow::setVisible(BOOL visible) +void LLSysWellWindow::setVisible(bool visible) { if (visible) { @@ -150,7 +150,7 @@ void LLSysWellWindow::setVisible(BOOL visible) } // do not show empty window - if (NULL == mMessageList || isWindowEmpty()) visible = FALSE; + if (NULL == mMessageList || isWindowEmpty()) visible = false; LLTransientDockableFloater::setVisible(visible); @@ -323,9 +323,9 @@ LLIMWellWindow* LLIMWellWindow::findInstance(const LLSD& key /*= LLSD()*/) return LLFloaterReg::findTypedInstance("im_well_window", key); } -BOOL LLIMWellWindow::postBuild() +bool LLIMWellWindow::postBuild() { - BOOL rv = LLSysWellWindow::postBuild(); + bool rv = LLSysWellWindow::postBuild(); setTitle(getString("title_im_well_window")); LLIMChiclet::sFindChicletsSignal.connect(boost::bind(&LLIMWellWindow::findObjectChiclet, this, _1)); -- cgit v1.2.3 From 60d3dd98a44230c21803c1606552ee098ed9fa7c Mon Sep 17 00:00:00 2001 From: Ansariel Date: Wed, 21 Feb 2024 21:05:14 +0100 Subject: Convert remaining BOOL to bool --- indra/newview/llsyswellwindow.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview/llsyswellwindow.cpp') diff --git a/indra/newview/llsyswellwindow.cpp b/indra/newview/llsyswellwindow.cpp index 6e8a8e4849..faf28e68db 100644 --- a/indra/newview/llsyswellwindow.cpp +++ b/indra/newview/llsyswellwindow.cpp @@ -77,7 +77,7 @@ void LLSysWellWindow::handleReshape(const LLRect& rect, bool by_user) void LLSysWellWindow::onStartUpToastClick(S32 x, S32 y, MASK mask) { // just set floater visible. Screen channels will be cleared. - setVisible(TRUE); + setVisible(true); } void LLSysWellWindow::setSysWellChiclet(LLSysWellChiclet* chiclet) @@ -114,7 +114,7 @@ void LLSysWellWindow::removeItemByID(const LLUUID& id) // hide chiclet window if there are no items left if(isWindowEmpty()) { - setVisible(FALSE); + setVisible(false); } } @@ -198,7 +198,7 @@ void LLSysWellWindow::reshapeWindow() S32 newWidth = curRect.getWidth() < MIN_WINDOW_WIDTH ? MIN_WINDOW_WIDTH : curRect.getWidth(); curRect.setLeftTopAndSize(curRect.mLeft, curRect.mTop, newWidth, new_window_height); - reshape(curRect.getWidth(), curRect.getHeight(), TRUE); + reshape(curRect.getWidth(), curRect.getHeight(), true); setRect(curRect); } @@ -375,7 +375,7 @@ void LLIMWellWindow::removeObjectRow(const LLUUID& notification_id) // hide chiclet window if there are no items left if(isWindowEmpty()) { - setVisible(FALSE); + setVisible(false); } } -- cgit v1.2.3 From e2e37cced861b98de8c1a7c9c0d3a50d2d90e433 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Wed, 22 May 2024 21:25:21 +0200 Subject: Fix line endlings --- indra/newview/llsyswellwindow.cpp | 900 +++++++++++++++++++------------------- 1 file changed, 450 insertions(+), 450 deletions(-) (limited to 'indra/newview/llsyswellwindow.cpp') diff --git a/indra/newview/llsyswellwindow.cpp b/indra/newview/llsyswellwindow.cpp index 2d629c2983..30142ad601 100644 --- a/indra/newview/llsyswellwindow.cpp +++ b/indra/newview/llsyswellwindow.cpp @@ -1,450 +1,450 @@ -/** - * @file llsyswellwindow.cpp - * @brief // TODO - * $LicenseInfo:firstyear=2000&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "llviewerprecompiledheaders.h" // must be first include -#include "llsyswellwindow.h" - -#include "llchiclet.h" -#include "llchicletbar.h" -#include "llflatlistview.h" -#include "llfloaterreg.h" -#include "llnotificationmanager.h" -#include "llnotificationsutil.h" -#include "llscriptfloater.h" -#include "llspeakers.h" -#include "lltoastpanel.h" - -//--------------------------------------------------------------------------------- -LLSysWellWindow::LLSysWellWindow(const LLSD& key) : LLTransientDockableFloater(NULL, true, key), - mChannel(NULL), - mMessageList(NULL), - mSysWellChiclet(NULL), - NOTIFICATION_WELL_ANCHOR_NAME("notification_well_panel"), - IM_WELL_ANCHOR_NAME("im_well_panel"), - mIsReshapedByUser(false) - -{ - setOverlapsScreenChannel(true); -} - -//--------------------------------------------------------------------------------- -bool LLSysWellWindow::postBuild() -{ - mMessageList = getChild("notification_list"); - - // get a corresponding channel - initChannel(); - - return LLTransientDockableFloater::postBuild(); -} - -//--------------------------------------------------------------------------------- -void LLSysWellWindow::setMinimized(bool minimize) -{ - LLTransientDockableFloater::setMinimized(minimize); -} - -//--------------------------------------------------------------------------------- -void LLSysWellWindow::handleReshape(const LLRect& rect, bool by_user) -{ - mIsReshapedByUser |= by_user; // mark floater that it is reshaped by user - LLTransientDockableFloater::handleReshape(rect, by_user); -} - -//--------------------------------------------------------------------------------- -void LLSysWellWindow::onStartUpToastClick(S32 x, S32 y, MASK mask) -{ - // just set floater visible. Screen channels will be cleared. - setVisible(true); -} - -void LLSysWellWindow::setSysWellChiclet(LLSysWellChiclet* chiclet) -{ - mSysWellChiclet = chiclet; - if(NULL != mSysWellChiclet) - { - mSysWellChiclet->updateWidget(isWindowEmpty()); - } -} - -//--------------------------------------------------------------------------------- -LLSysWellWindow::~LLSysWellWindow() -{ -} - -//--------------------------------------------------------------------------------- -void LLSysWellWindow::removeItemByID(const LLUUID& id) -{ - if(mMessageList->removeItemByValue(id)) - { - if (NULL != mSysWellChiclet) - { - mSysWellChiclet->updateWidget(isWindowEmpty()); - } - reshapeWindow(); - } - else - { - LL_WARNS() << "Unable to remove notification from the list, ID: " << id - << LL_ENDL; - } - - // hide chiclet window if there are no items left - if(isWindowEmpty()) - { - setVisible(false); - } -} - - LLPanel * LLSysWellWindow::findItemByID(const LLUUID& id) -{ - return mMessageList->getItemByValue(id); -} - -//--------------------------------------------------------------------------------- -//--------------------------------------------------------------------------------- -void LLSysWellWindow::initChannel() -{ - LLNotificationsUI::LLScreenChannelBase* channel = LLNotificationsUI::LLChannelManager::getInstance()->findChannelByID( - LLNotificationsUI::NOTIFICATION_CHANNEL_UUID); - mChannel = dynamic_cast(channel); - if(NULL == mChannel) - { - LL_WARNS() << "LLSysWellWindow::initChannel() - could not get a requested screen channel" << LL_ENDL; - } -} - -//--------------------------------------------------------------------------------- -void LLSysWellWindow::setVisible(bool visible) -{ - if (visible) - { - if (NULL == getDockControl() && getDockTongue().notNull()) - { - setDockControl(new LLDockControl( - LLChicletBar::getInstance()->getChild(getAnchorViewName()), this, - getDockTongue(), LLDockControl::BOTTOM)); - } - } - - // do not show empty window - if (NULL == mMessageList || isWindowEmpty()) visible = false; - - LLTransientDockableFloater::setVisible(visible); - - // update notification channel state - initChannel(); // make sure the channel still exists - if(mChannel) - { - mChannel->updateShowToastsState(); - mChannel->redrawToasts(); - } -} - -//--------------------------------------------------------------------------------- -void LLSysWellWindow::setDocked(bool docked, bool pop_on_undock) -{ - LLTransientDockableFloater::setDocked(docked, pop_on_undock); - - // update notification channel state - if(mChannel) - { - mChannel->updateShowToastsState(); - mChannel->redrawToasts(); - } -} - -//--------------------------------------------------------------------------------- -void LLSysWellWindow::reshapeWindow() -{ - // save difference between floater height and the list height to take it into account while calculating new window height - // it includes height from floater top to list top and from floater bottom and list bottom - static S32 parent_list_delta_height = getRect().getHeight() - mMessageList->getRect().getHeight(); - - if (!mIsReshapedByUser) // Don't reshape Well window, if it ever was reshaped by user. See EXT-5715. - { - S32 notif_list_height = mMessageList->getItemsRect().getHeight() + 2 * mMessageList->getBorderWidth(); - - LLRect curRect = getRect(); - - S32 new_window_height = notif_list_height + parent_list_delta_height; - - if (new_window_height > MAX_WINDOW_HEIGHT) - { - new_window_height = MAX_WINDOW_HEIGHT; - } - S32 newWidth = curRect.getWidth() < MIN_WINDOW_WIDTH ? MIN_WINDOW_WIDTH : curRect.getWidth(); - - curRect.setLeftTopAndSize(curRect.mLeft, curRect.mTop, newWidth, new_window_height); - reshape(curRect.getWidth(), curRect.getHeight(), true); - setRect(curRect); - } - - // update notification channel state - // update on a window reshape is important only when a window is visible and docked - if(mChannel && getVisible() && isDocked()) - { - mChannel->updateShowToastsState(); - } -} - -//--------------------------------------------------------------------------------- -bool LLSysWellWindow::isWindowEmpty() -{ - return mMessageList->size() == 0; -} - -/************************************************************************/ -/* ObjectRowPanel implementation */ -/************************************************************************/ - -LLIMWellWindow::ObjectRowPanel::ObjectRowPanel(const LLUUID& notification_id, bool new_message/* = false*/) - : LLPanel() - , mChiclet(NULL) -{ - buildFromFile( "panel_active_object_row.xml"); - - initChiclet(notification_id); - - LLTextBox* obj_name = getChild("object_name"); - obj_name->setValue(LLScriptFloaterManager::getObjectName(notification_id)); - - mCloseBtn = getChild("hide_btn"); - mCloseBtn->setCommitCallback(boost::bind(&LLIMWellWindow::ObjectRowPanel::onClosePanel, this)); -} - -//--------------------------------------------------------------------------------- -LLIMWellWindow::ObjectRowPanel::~ObjectRowPanel() -{ -} - -//--------------------------------------------------------------------------------- -void LLIMWellWindow::ObjectRowPanel::onClosePanel() -{ - LLScriptFloaterManager::getInstance()->removeNotification(mChiclet->getSessionId()); -} - -void LLIMWellWindow::ObjectRowPanel::initChiclet(const LLUUID& notification_id, bool new_message/* = false*/) -{ - // Choose which of the pre-created chiclets to use. - switch(LLScriptFloaterManager::getObjectType(notification_id)) - { - case LLScriptFloaterManager::OBJ_GIVE_INVENTORY: - mChiclet = getChild("inv_offer_chiclet"); - break; - default: - mChiclet = getChild("object_chiclet"); - break; - } - - mChiclet->setVisible(true); - mChiclet->setSessionId(notification_id); -} - -//--------------------------------------------------------------------------------- -void LLIMWellWindow::ObjectRowPanel::onMouseEnter(S32 x, S32 y, MASK mask) -{ - setTransparentColor(LLUIColorTable::instance().getColor("SysWellItemSelected")); -} - -//--------------------------------------------------------------------------------- -void LLIMWellWindow::ObjectRowPanel::onMouseLeave(S32 x, S32 y, MASK mask) -{ - setTransparentColor(LLUIColorTable::instance().getColor("SysWellItemUnselected")); -} - -//--------------------------------------------------------------------------------- -// virtual -bool LLIMWellWindow::ObjectRowPanel::handleMouseDown(S32 x, S32 y, MASK mask) -{ - // Pass the mouse down event to the chiclet (EXT-596). - if (!mChiclet->pointInView(x, y) && !mCloseBtn->getRect().pointInRect(x, y)) // prevent double call of LLIMChiclet::onMouseDown() - { - mChiclet->onMouseDown(); - return true; - } - - return LLPanel::handleMouseDown(x, y, mask); -} - -// virtual -bool LLIMWellWindow::ObjectRowPanel::handleRightMouseDown(S32 x, S32 y, MASK mask) -{ - return mChiclet->handleRightMouseDown(x, y, mask); -} - -/************************************************************************/ -/* LLIMWellWindow implementation */ -/************************************************************************/ - -////////////////////////////////////////////////////////////////////////// -// PUBLIC METHODS -LLIMWellWindow::LLIMWellWindow(const LLSD& key) -: LLSysWellWindow(key) -{ -} - -LLIMWellWindow::~LLIMWellWindow() -{ -} - -// static -LLIMWellWindow* LLIMWellWindow::getInstance(const LLSD& key /*= LLSD()*/) -{ - return LLFloaterReg::getTypedInstance("im_well_window", key); -} - - -// static -LLIMWellWindow* LLIMWellWindow::findInstance(const LLSD& key /*= LLSD()*/) -{ - return LLFloaterReg::findTypedInstance("im_well_window", key); -} - -bool LLIMWellWindow::postBuild() -{ - bool rv = LLSysWellWindow::postBuild(); - setTitle(getString("title_im_well_window")); - - LLIMChiclet::sFindChicletsSignal.connect(boost::bind(&LLIMWellWindow::findObjectChiclet, this, _1)); - - return rv; -} - -LLChiclet* LLIMWellWindow::findObjectChiclet(const LLUUID& notification_id) -{ - if (!mMessageList) return NULL; - - LLChiclet* res = NULL; - ObjectRowPanel* panel = mMessageList->getTypedItemByValue(notification_id); - if (panel != NULL) - { - res = panel->mChiclet; - } - - return res; -} - -////////////////////////////////////////////////////////////////////////// -// PRIVATE METHODS - -void LLIMWellWindow::addObjectRow(const LLUUID& notification_id, bool new_message/* = false*/) -{ - if (mMessageList->getItemByValue(notification_id) == NULL) - { - ObjectRowPanel* item = new ObjectRowPanel(notification_id, new_message); - if (!mMessageList->addItem(item, notification_id)) - { - LL_WARNS() << "Unable to add Object Row into the list, notificationID: " << notification_id << LL_ENDL; - item->die(); - } - reshapeWindow(); - } -} - -void LLIMWellWindow::removeObjectRow(const LLUUID& notification_id) -{ - if (!mMessageList->removeItemByValue(notification_id)) - { - LL_WARNS() << "Unable to remove Object Row from the list, notificationID: " << notification_id << LL_ENDL; - } - - reshapeWindow(); - // hide chiclet window if there are no items left - if(isWindowEmpty()) - { - setVisible(false); - } -} - -void LLIMWellWindow::closeAll() -{ - // Generate an ignorable alert dialog if there is an active voice IM sesion - bool need_confirmation = false; - const LLIMModel& im_model = LLIMModel::instance(); - std::vector values; - mMessageList->getValues(values); - for (std::vector::iterator - iter = values.begin(), - iter_end = values.end(); - iter != iter_end; ++iter) - { - LLIMSpeakerMgr* speaker_mgr = im_model.getSpeakerManager(*iter); - if (speaker_mgr && speaker_mgr->isVoiceActive()) - { - need_confirmation = true; - break; - } - } - if ( need_confirmation ) - { - //Bring up a confirmation dialog - LLNotificationsUtil::add - ("ConfirmCloseAll", LLSD(), LLSD(), - boost::bind(&LLIMWellWindow::confirmCloseAll, this, _1, _2)); - } - else - { - closeAllImpl(); - } -} - -void LLIMWellWindow::closeAllImpl() -{ - std::vector values; - mMessageList->getValues(values); - - for (std::vector::iterator - iter = values.begin(), - iter_end = values.end(); - iter != iter_end; ++iter) - { - LLPanel* panel = mMessageList->getItemByValue(*iter); - - ObjectRowPanel* obj_panel = dynamic_cast (panel); - if (obj_panel) - { - LLScriptFloaterManager::instance().removeNotification(*iter); - } - } -} - -bool LLIMWellWindow::confirmCloseAll(const LLSD& notification, const LLSD& response) -{ - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - switch(option) - { - case 0: - { - closeAllImpl(); - return true; - } - default: - break; - } - return false; -} - - +/** + * @file llsyswellwindow.cpp + * @brief // TODO + * $LicenseInfo:firstyear=2000&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" // must be first include +#include "llsyswellwindow.h" + +#include "llchiclet.h" +#include "llchicletbar.h" +#include "llflatlistview.h" +#include "llfloaterreg.h" +#include "llnotificationmanager.h" +#include "llnotificationsutil.h" +#include "llscriptfloater.h" +#include "llspeakers.h" +#include "lltoastpanel.h" + +//--------------------------------------------------------------------------------- +LLSysWellWindow::LLSysWellWindow(const LLSD& key) : LLTransientDockableFloater(NULL, true, key), + mChannel(NULL), + mMessageList(NULL), + mSysWellChiclet(NULL), + NOTIFICATION_WELL_ANCHOR_NAME("notification_well_panel"), + IM_WELL_ANCHOR_NAME("im_well_panel"), + mIsReshapedByUser(false) + +{ + setOverlapsScreenChannel(true); +} + +//--------------------------------------------------------------------------------- +bool LLSysWellWindow::postBuild() +{ + mMessageList = getChild("notification_list"); + + // get a corresponding channel + initChannel(); + + return LLTransientDockableFloater::postBuild(); +} + +//--------------------------------------------------------------------------------- +void LLSysWellWindow::setMinimized(bool minimize) +{ + LLTransientDockableFloater::setMinimized(minimize); +} + +//--------------------------------------------------------------------------------- +void LLSysWellWindow::handleReshape(const LLRect& rect, bool by_user) +{ + mIsReshapedByUser |= by_user; // mark floater that it is reshaped by user + LLTransientDockableFloater::handleReshape(rect, by_user); +} + +//--------------------------------------------------------------------------------- +void LLSysWellWindow::onStartUpToastClick(S32 x, S32 y, MASK mask) +{ + // just set floater visible. Screen channels will be cleared. + setVisible(true); +} + +void LLSysWellWindow::setSysWellChiclet(LLSysWellChiclet* chiclet) +{ + mSysWellChiclet = chiclet; + if(NULL != mSysWellChiclet) + { + mSysWellChiclet->updateWidget(isWindowEmpty()); + } +} + +//--------------------------------------------------------------------------------- +LLSysWellWindow::~LLSysWellWindow() +{ +} + +//--------------------------------------------------------------------------------- +void LLSysWellWindow::removeItemByID(const LLUUID& id) +{ + if(mMessageList->removeItemByValue(id)) + { + if (NULL != mSysWellChiclet) + { + mSysWellChiclet->updateWidget(isWindowEmpty()); + } + reshapeWindow(); + } + else + { + LL_WARNS() << "Unable to remove notification from the list, ID: " << id + << LL_ENDL; + } + + // hide chiclet window if there are no items left + if(isWindowEmpty()) + { + setVisible(false); + } +} + + LLPanel * LLSysWellWindow::findItemByID(const LLUUID& id) +{ + return mMessageList->getItemByValue(id); +} + +//--------------------------------------------------------------------------------- +//--------------------------------------------------------------------------------- +void LLSysWellWindow::initChannel() +{ + LLNotificationsUI::LLScreenChannelBase* channel = LLNotificationsUI::LLChannelManager::getInstance()->findChannelByID( + LLNotificationsUI::NOTIFICATION_CHANNEL_UUID); + mChannel = dynamic_cast(channel); + if(NULL == mChannel) + { + LL_WARNS() << "LLSysWellWindow::initChannel() - could not get a requested screen channel" << LL_ENDL; + } +} + +//--------------------------------------------------------------------------------- +void LLSysWellWindow::setVisible(bool visible) +{ + if (visible) + { + if (NULL == getDockControl() && getDockTongue().notNull()) + { + setDockControl(new LLDockControl( + LLChicletBar::getInstance()->getChild(getAnchorViewName()), this, + getDockTongue(), LLDockControl::BOTTOM)); + } + } + + // do not show empty window + if (NULL == mMessageList || isWindowEmpty()) visible = false; + + LLTransientDockableFloater::setVisible(visible); + + // update notification channel state + initChannel(); // make sure the channel still exists + if(mChannel) + { + mChannel->updateShowToastsState(); + mChannel->redrawToasts(); + } +} + +//--------------------------------------------------------------------------------- +void LLSysWellWindow::setDocked(bool docked, bool pop_on_undock) +{ + LLTransientDockableFloater::setDocked(docked, pop_on_undock); + + // update notification channel state + if(mChannel) + { + mChannel->updateShowToastsState(); + mChannel->redrawToasts(); + } +} + +//--------------------------------------------------------------------------------- +void LLSysWellWindow::reshapeWindow() +{ + // save difference between floater height and the list height to take it into account while calculating new window height + // it includes height from floater top to list top and from floater bottom and list bottom + static S32 parent_list_delta_height = getRect().getHeight() - mMessageList->getRect().getHeight(); + + if (!mIsReshapedByUser) // Don't reshape Well window, if it ever was reshaped by user. See EXT-5715. + { + S32 notif_list_height = mMessageList->getItemsRect().getHeight() + 2 * mMessageList->getBorderWidth(); + + LLRect curRect = getRect(); + + S32 new_window_height = notif_list_height + parent_list_delta_height; + + if (new_window_height > MAX_WINDOW_HEIGHT) + { + new_window_height = MAX_WINDOW_HEIGHT; + } + S32 newWidth = curRect.getWidth() < MIN_WINDOW_WIDTH ? MIN_WINDOW_WIDTH : curRect.getWidth(); + + curRect.setLeftTopAndSize(curRect.mLeft, curRect.mTop, newWidth, new_window_height); + reshape(curRect.getWidth(), curRect.getHeight(), true); + setRect(curRect); + } + + // update notification channel state + // update on a window reshape is important only when a window is visible and docked + if(mChannel && getVisible() && isDocked()) + { + mChannel->updateShowToastsState(); + } +} + +//--------------------------------------------------------------------------------- +bool LLSysWellWindow::isWindowEmpty() +{ + return mMessageList->size() == 0; +} + +/************************************************************************/ +/* ObjectRowPanel implementation */ +/************************************************************************/ + +LLIMWellWindow::ObjectRowPanel::ObjectRowPanel(const LLUUID& notification_id, bool new_message/* = false*/) + : LLPanel() + , mChiclet(NULL) +{ + buildFromFile( "panel_active_object_row.xml"); + + initChiclet(notification_id); + + LLTextBox* obj_name = getChild("object_name"); + obj_name->setValue(LLScriptFloaterManager::getObjectName(notification_id)); + + mCloseBtn = getChild("hide_btn"); + mCloseBtn->setCommitCallback(boost::bind(&LLIMWellWindow::ObjectRowPanel::onClosePanel, this)); +} + +//--------------------------------------------------------------------------------- +LLIMWellWindow::ObjectRowPanel::~ObjectRowPanel() +{ +} + +//--------------------------------------------------------------------------------- +void LLIMWellWindow::ObjectRowPanel::onClosePanel() +{ + LLScriptFloaterManager::getInstance()->removeNotification(mChiclet->getSessionId()); +} + +void LLIMWellWindow::ObjectRowPanel::initChiclet(const LLUUID& notification_id, bool new_message/* = false*/) +{ + // Choose which of the pre-created chiclets to use. + switch(LLScriptFloaterManager::getObjectType(notification_id)) + { + case LLScriptFloaterManager::OBJ_GIVE_INVENTORY: + mChiclet = getChild("inv_offer_chiclet"); + break; + default: + mChiclet = getChild("object_chiclet"); + break; + } + + mChiclet->setVisible(true); + mChiclet->setSessionId(notification_id); +} + +//--------------------------------------------------------------------------------- +void LLIMWellWindow::ObjectRowPanel::onMouseEnter(S32 x, S32 y, MASK mask) +{ + setTransparentColor(LLUIColorTable::instance().getColor("SysWellItemSelected")); +} + +//--------------------------------------------------------------------------------- +void LLIMWellWindow::ObjectRowPanel::onMouseLeave(S32 x, S32 y, MASK mask) +{ + setTransparentColor(LLUIColorTable::instance().getColor("SysWellItemUnselected")); +} + +//--------------------------------------------------------------------------------- +// virtual +bool LLIMWellWindow::ObjectRowPanel::handleMouseDown(S32 x, S32 y, MASK mask) +{ + // Pass the mouse down event to the chiclet (EXT-596). + if (!mChiclet->pointInView(x, y) && !mCloseBtn->getRect().pointInRect(x, y)) // prevent double call of LLIMChiclet::onMouseDown() + { + mChiclet->onMouseDown(); + return true; + } + + return LLPanel::handleMouseDown(x, y, mask); +} + +// virtual +bool LLIMWellWindow::ObjectRowPanel::handleRightMouseDown(S32 x, S32 y, MASK mask) +{ + return mChiclet->handleRightMouseDown(x, y, mask); +} + +/************************************************************************/ +/* LLIMWellWindow implementation */ +/************************************************************************/ + +////////////////////////////////////////////////////////////////////////// +// PUBLIC METHODS +LLIMWellWindow::LLIMWellWindow(const LLSD& key) +: LLSysWellWindow(key) +{ +} + +LLIMWellWindow::~LLIMWellWindow() +{ +} + +// static +LLIMWellWindow* LLIMWellWindow::getInstance(const LLSD& key /*= LLSD()*/) +{ + return LLFloaterReg::getTypedInstance("im_well_window", key); +} + + +// static +LLIMWellWindow* LLIMWellWindow::findInstance(const LLSD& key /*= LLSD()*/) +{ + return LLFloaterReg::findTypedInstance("im_well_window", key); +} + +bool LLIMWellWindow::postBuild() +{ + bool rv = LLSysWellWindow::postBuild(); + setTitle(getString("title_im_well_window")); + + LLIMChiclet::sFindChicletsSignal.connect(boost::bind(&LLIMWellWindow::findObjectChiclet, this, _1)); + + return rv; +} + +LLChiclet* LLIMWellWindow::findObjectChiclet(const LLUUID& notification_id) +{ + if (!mMessageList) return NULL; + + LLChiclet* res = NULL; + ObjectRowPanel* panel = mMessageList->getTypedItemByValue(notification_id); + if (panel != NULL) + { + res = panel->mChiclet; + } + + return res; +} + +////////////////////////////////////////////////////////////////////////// +// PRIVATE METHODS + +void LLIMWellWindow::addObjectRow(const LLUUID& notification_id, bool new_message/* = false*/) +{ + if (mMessageList->getItemByValue(notification_id) == NULL) + { + ObjectRowPanel* item = new ObjectRowPanel(notification_id, new_message); + if (!mMessageList->addItem(item, notification_id)) + { + LL_WARNS() << "Unable to add Object Row into the list, notificationID: " << notification_id << LL_ENDL; + item->die(); + } + reshapeWindow(); + } +} + +void LLIMWellWindow::removeObjectRow(const LLUUID& notification_id) +{ + if (!mMessageList->removeItemByValue(notification_id)) + { + LL_WARNS() << "Unable to remove Object Row from the list, notificationID: " << notification_id << LL_ENDL; + } + + reshapeWindow(); + // hide chiclet window if there are no items left + if(isWindowEmpty()) + { + setVisible(false); + } +} + +void LLIMWellWindow::closeAll() +{ + // Generate an ignorable alert dialog if there is an active voice IM sesion + bool need_confirmation = false; + const LLIMModel& im_model = LLIMModel::instance(); + std::vector values; + mMessageList->getValues(values); + for (std::vector::iterator + iter = values.begin(), + iter_end = values.end(); + iter != iter_end; ++iter) + { + LLIMSpeakerMgr* speaker_mgr = im_model.getSpeakerManager(*iter); + if (speaker_mgr && speaker_mgr->isVoiceActive()) + { + need_confirmation = true; + break; + } + } + if ( need_confirmation ) + { + //Bring up a confirmation dialog + LLNotificationsUtil::add + ("ConfirmCloseAll", LLSD(), LLSD(), + boost::bind(&LLIMWellWindow::confirmCloseAll, this, _1, _2)); + } + else + { + closeAllImpl(); + } +} + +void LLIMWellWindow::closeAllImpl() +{ + std::vector values; + mMessageList->getValues(values); + + for (std::vector::iterator + iter = values.begin(), + iter_end = values.end(); + iter != iter_end; ++iter) + { + LLPanel* panel = mMessageList->getItemByValue(*iter); + + ObjectRowPanel* obj_panel = dynamic_cast (panel); + if (obj_panel) + { + LLScriptFloaterManager::instance().removeNotification(*iter); + } + } +} + +bool LLIMWellWindow::confirmCloseAll(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + switch(option) + { + case 0: + { + closeAllImpl(); + return true; + } + default: + break; + } + return false; +} + + -- cgit v1.2.3