diff options
Diffstat (limited to 'indra/newview/llsyswellwindow.cpp')
-rw-r--r-- | indra/newview/llsyswellwindow.cpp | 153 |
1 files changed, 119 insertions, 34 deletions
diff --git a/indra/newview/llsyswellwindow.cpp b/indra/newview/llsyswellwindow.cpp index 750fbe54a7..cbb030836e 100644 --- a/indra/newview/llsyswellwindow.cpp +++ b/indra/newview/llsyswellwindow.cpp @@ -1,25 +1,31 @@ /** * @file llsyswellwindow.cpp * @brief // TODO - * $LicenseInfo:firstyear=2000&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * $LicenseInfo:firstyear=2000&license=viewergpl$ + * + * Copyright (c) 2000-2009, 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. + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 * - * 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. + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * - * 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 + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. * $/LicenseInfo$ */ @@ -50,11 +56,14 @@ LLSysWellWindow::LLSysWellWindow(const LLSD& key) : LLTransientDockableFloater(N mChannel(NULL), mMessageList(NULL), mSysWellChiclet(NULL), + mSeparator(NULL), NOTIFICATION_WELL_ANCHOR_NAME("notification_well_panel"), IM_WELL_ANCHOR_NAME("im_well_panel"), mIsReshapedByUser(false) { + mTypedItemsCount[IT_NOTIFICATION] = 0; + mTypedItemsCount[IT_INSTANT_MESSAGE] = 0; setOverlapsScreenChannel(true); } @@ -66,6 +75,18 @@ BOOL LLSysWellWindow::postBuild() // get a corresponding channel initChannel(); + LLPanel::Params params; + mSeparator = LLUICtrlFactory::create<LLPanel>(params); + LLUICtrlFactory::instance().buildPanel(mSeparator, "panel_separator.xml"); + + LLRect rc = mSeparator->getRect(); + rc.setOriginAndSize(0, 0, mMessageList->getItemsRect().getWidth(), rc.getHeight()); + mSeparator->setRect(rc); + mSeparator->setFollows(FOLLOWS_LEFT | FOLLOWS_RIGHT | FOLLOWS_TOP); + mSeparator->setVisible(FALSE); + + mMessageList->addItem(mSeparator); + // click on SysWell Window should clear "new message" state (and 'Lit' status). EXT-3147. // mouse up callback is not called in this case. setMouseDownCallback(boost::bind(&LLSysWellWindow::releaseNewMessagesState, this)); @@ -109,7 +130,7 @@ void LLSysWellWindow::removeItemByID(const LLUUID& id) { if(mMessageList->removeItemByValue(id)) { - mSysWellChiclet->updateWidget(isWindowEmpty()); + handleItemRemoved(IT_NOTIFICATION); reshapeWindow(); } else @@ -237,7 +258,76 @@ void LLSysWellWindow::releaseNewMessagesState() //--------------------------------------------------------------------------------- bool LLSysWellWindow::isWindowEmpty() { - return mMessageList->size() == 0; + // keep in mind, mSeparator is always in the list + return mMessageList->size() == 1; +} + +// *TODO: mantipov: probably is deprecated +void LLSysWellWindow::handleItemAdded(EItemType added_item_type) +{ + bool should_be_shown = ++mTypedItemsCount[added_item_type] == 1 && anotherTypeExists(added_item_type); + + if (should_be_shown && !mSeparator->getVisible()) + { + mSeparator->setVisible(TRUE); + + // refresh list to recalculate mSeparator position + mMessageList->reshape(mMessageList->getRect().getWidth(), mMessageList->getRect().getHeight()); + } + + //fix for EXT-3254 + //set limits for min_height. + S32 parent_list_delta_height = getRect().getHeight() - mMessageList->getRect().getHeight(); + + std::vector<LLPanel*> items; + mMessageList->getItems(items); + + if(items.size()>1)//first item is separator + { + S32 min_height; + S32 min_width; + getResizeLimits(&min_width,&min_height); + + min_height = items[1]->getRect().getHeight() + 2 * mMessageList->getBorderWidth() + parent_list_delta_height; + + setResizeLimits(min_width,min_height); + } + mSysWellChiclet->updateWidget(isWindowEmpty()); +} + +void LLSysWellWindow::handleItemRemoved(EItemType removed_item_type) +{ + bool should_be_hidden = --mTypedItemsCount[removed_item_type] == 0; + + if (should_be_hidden && mSeparator->getVisible()) + { + mSeparator->setVisible(FALSE); + + // refresh list to recalculate mSeparator position + mMessageList->reshape(mMessageList->getRect().getWidth(), mMessageList->getRect().getHeight()); + } + mSysWellChiclet->updateWidget(isWindowEmpty()); +} + +bool LLSysWellWindow::anotherTypeExists(EItemType item_type) +{ + bool exists = false; + switch(item_type) + { + case IT_INSTANT_MESSAGE: + if (mTypedItemsCount[IT_NOTIFICATION] > 0) + { + exists = true; + } + break; + case IT_NOTIFICATION: + if (mTypedItemsCount[IT_INSTANT_MESSAGE] > 0) + { + exists = true; + } + break; + } + return exists; } /************************************************************************/ @@ -365,7 +455,7 @@ LLIMWellWindow::ObjectRowPanel::~ObjectRowPanel() //--------------------------------------------------------------------------------- void LLIMWellWindow::ObjectRowPanel::onClosePanel() { - LLScriptFloaterManager::getInstance()->removeNotification(mChiclet->getSessionId()); + LLScriptFloaterManager::getInstance()->onRemoveNotification(mChiclet->getSessionId()); } void LLIMWellWindow::ObjectRowPanel::initChiclet(const LLUUID& notification_id, bool new_message/* = false*/) @@ -469,7 +559,8 @@ void LLNotificationWellWindow::addItem(LLSysWellItem::Params p) LLSysWellItem* new_item = new LLSysWellItem(p); if (mMessageList->addItem(new_item, value, ADD_TOP)) { - mSysWellChiclet->updateWidget(isWindowEmpty()); + handleItemAdded(IT_NOTIFICATION); + reshapeWindow(); new_item->setOnItemCloseCallback(boost::bind(&LLNotificationWellWindow::onItemClose, this, _1)); @@ -576,6 +667,8 @@ LLIMWellWindow::LLIMWellWindow(const LLSD& key) : LLSysWellWindow(key) { LLIMMgr::getInstance()->addSessionObserver(this); + LLIMChiclet::sFindChicletsSignal.connect(boost::bind(&LLIMWellWindow::findIMChiclet, this, _1)); + LLIMChiclet::sFindChicletsSignal.connect(boost::bind(&LLIMWellWindow::findObjectChiclet, this, _1)); } LLIMWellWindow::~LLIMWellWindow() @@ -593,10 +686,6 @@ BOOL LLIMWellWindow::postBuild() { BOOL rv = LLSysWellWindow::postBuild(); setTitle(getString("title_im_well_window")); - - LLIMChiclet::sFindChicletsSignal.connect(boost::bind(&LLIMWellWindow::findIMChiclet, this, _1)); - LLIMChiclet::sFindChicletsSignal.connect(boost::bind(&LLIMWellWindow::findObjectChiclet, this, _1)); - return rv; } @@ -637,8 +726,6 @@ void LLIMWellWindow::sessionIDUpdated(const LLUUID& old_session_id, const LLUUID LLChiclet* LLIMWellWindow::findObjectChiclet(const LLUUID& notification_id) { - if (!mMessageList) return NULL; - LLChiclet* res = NULL; ObjectRowPanel* panel = mMessageList->getTypedItemByValue<ObjectRowPanel>(notification_id); if (panel != NULL) @@ -653,8 +740,6 @@ LLChiclet* LLIMWellWindow::findObjectChiclet(const LLUUID& notification_id) // PRIVATE METHODS LLChiclet* LLIMWellWindow::findIMChiclet(const LLUUID& sessionId) { - if (!mMessageList) return NULL; - LLChiclet* res = NULL; RowPanel* panel = mMessageList->getTypedItemByValue<RowPanel>(sessionId); if (panel != NULL) @@ -670,9 +755,9 @@ void LLIMWellWindow::addIMRow(const LLUUID& sessionId, S32 chicletCounter, const std::string& name, const LLUUID& otherParticipantId) { RowPanel* item = new RowPanel(this, sessionId, chicletCounter, name, otherParticipantId); - if (mMessageList->addItem(item, sessionId)) + if (mMessageList->insertItemAfter(mSeparator, item, sessionId)) { - mSysWellChiclet->updateWidget(isWindowEmpty()); + handleItemAdded(IT_INSTANT_MESSAGE); } else { @@ -697,7 +782,7 @@ void LLIMWellWindow::delIMRow(const LLUUID& sessionId) if (mMessageList->removeItemByValue(sessionId)) { - mSysWellChiclet->updateWidget(isWindowEmpty()); + handleItemRemoved(IT_INSTANT_MESSAGE); } else { @@ -725,9 +810,9 @@ void LLIMWellWindow::addObjectRow(const LLUUID& notification_id, bool new_messag if (mMessageList->getItemByValue(notification_id) == NULL) { ObjectRowPanel* item = new ObjectRowPanel(notification_id, new_message); - if (mMessageList->addItem(item, notification_id)) + if (mMessageList->insertItemAfter(mSeparator, item, notification_id)) { - mSysWellChiclet->updateWidget(isWindowEmpty()); + handleItemAdded(IT_INSTANT_MESSAGE); } else { @@ -742,7 +827,7 @@ void LLIMWellWindow::removeObjectRow(const LLUUID& notification_id) { if (mMessageList->removeItemByValue(notification_id)) { - mSysWellChiclet->updateWidget(isWindowEmpty()); + handleItemRemoved(IT_INSTANT_MESSAGE); } else { @@ -826,7 +911,7 @@ void LLIMWellWindow::closeAllImpl() ObjectRowPanel* obj_panel = dynamic_cast <ObjectRowPanel*> (panel); if (obj_panel) { - LLScriptFloaterManager::instance().removeNotification(*iter); + LLScriptFloaterManager::instance().onRemoveNotification(*iter); } } } |