diff options
author | Loren Shih <seraph@lindenlab.com> | 2009-11-24 12:10:10 -0500 |
---|---|---|
committer | Loren Shih <seraph@lindenlab.com> | 2009-11-24 12:10:10 -0500 |
commit | a22bb00530bb779d8e5bb40b68e55767604d88dc (patch) | |
tree | 520019b0c1e8c9cf475d19a60a0322a3c1caea6e /indra/newview/llchiclet.cpp | |
parent | 0904cbe4846192c9897267c9a60175f84881f9ed (diff) | |
parent | 76be5ddc7022508e7d3fcb04165b4a6f64f1d58d (diff) |
merge
--HG--
branch : avatar-pipeline
Diffstat (limited to 'indra/newview/llchiclet.cpp')
-rw-r--r-- | indra/newview/llchiclet.cpp | 155 |
1 files changed, 108 insertions, 47 deletions
diff --git a/indra/newview/llchiclet.cpp b/indra/newview/llchiclet.cpp index 9845664c74..433f70700c 100644 --- a/indra/newview/llchiclet.cpp +++ b/indra/newview/llchiclet.cpp @@ -1,34 +1,34 @@ /** -* @file llchiclet.cpp -* @brief LLChiclet class implementation -* -* $LicenseInfo:firstyear=2002&license=viewergpl$ -* -* Copyright (c) 2002-2009, Linden Research, Inc. -* -* 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 -* -* 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 -* -* 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. -* -* 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$ -*/ + * @file llchiclet.cpp + * @brief LLChiclet class implementation + * + * $LicenseInfo:firstyear=2002&license=viewergpl$ + * + * Copyright (c) 2002-2009, Linden Research, Inc. + * + * 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 + * + * 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 + * + * 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. + * + * 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$ + */ #include "llviewerprecompiledheaders.h" // must be first include #include "llchiclet.h" @@ -43,6 +43,7 @@ #include "lllocalcliprect.h" #include "llmenugl.h" #include "lloutputmonitorctrl.h" +#include "llscriptfloater.h" #include "lltextbox.h" #include "llvoiceclient.h" #include "llvoicecontrolpanel.h" @@ -55,6 +56,7 @@ static LLDefaultChildRegistry::Register<LLNotificationChiclet> t2("chiclet_notif static LLDefaultChildRegistry::Register<LLIMP2PChiclet> t3("chiclet_im_p2p"); static LLDefaultChildRegistry::Register<LLIMGroupChiclet> t4("chiclet_im_group"); static LLDefaultChildRegistry::Register<LLAdHocChiclet> t5("chiclet_im_adhoc"); +static LLDefaultChildRegistry::Register<LLScriptChiclet> t6("chiclet_script"); static const LLRect CHICLET_RECT(0, 25, 25, 0); static const LLRect CHICLET_ICON_RECT(0, 22, 22, 0); @@ -922,34 +924,45 @@ void LLChicletPanel::onCurrentVoiceChannelChanged(const LLUUID& session_id) s_previous_active_voice_session_id = session_id; } -S32 LLChicletPanel::calcChickletPanleWidth() -{ - S32 res = 0; - - for (chiclet_list_t::iterator it = mChicletList.begin(); it - != mChicletList.end(); it++) - { - res = (*it)->getRect().getWidth() + getChicletPadding(); - } - return res; -} - bool LLChicletPanel::addChiclet(LLChiclet* chiclet, S32 index) { if(mScrollArea->addChild(chiclet)) { - // chicklets should be aligned to right edge of scroll panel - S32 offset = 0; + // chiclets should be aligned to right edge of scroll panel + S32 left_shift = 0; if (!canScrollLeft()) { - offset = mScrollArea->getRect().getWidth() - - chiclet->getRect().getWidth() - calcChickletPanleWidth(); + // init left shift for the first chiclet in the list... + if (mChicletList.empty()) + { + // ...start from the right border of the scroll area for the first added chiclet + left_shift = mScrollArea->getRect().getWidth(); + } + else + { + // ... start from the left border of the first chiclet minus padding + left_shift = getChiclet(0)->getRect().mLeft - getChicletPadding(); + } + + // take into account width of the being added chiclet + left_shift -= chiclet->getRequiredRect().getWidth(); + + // if we overflow the scroll area we do not need to shift chiclets + if (left_shift < 0) + { + left_shift = 0; + } } mChicletList.insert(mChicletList.begin() + index, chiclet); - getChiclet(0)->translate(offset, 0); + // shift first chiclet to place it in correct position. + // rest ones will be placed in arrange() + if (!canScrollLeft()) + { + getChiclet(0)->translate(left_shift - getChiclet(0)->getRect().mLeft, 0); + } chiclet->setLeftButtonClickCallback(boost::bind(&LLChicletPanel::onChicletClick, this, _1, _2)); chiclet->setChicletSizeChangedCallback(boost::bind(&LLChicletPanel::onChicletSizeChanged, this, _1, index)); @@ -1400,3 +1413,51 @@ LLChicletSpeakerCtrl::LLChicletSpeakerCtrl(const Params&p) : LLOutputMonitorCtrl(p) { } + +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// + +LLScriptChiclet::Params::Params() + : icon("icon") +{ + // *TODO Vadim: Get rid of hardcoded values. + rect(CHICLET_RECT); + icon.rect(CHICLET_ICON_RECT); +} + +LLScriptChiclet::LLScriptChiclet(const Params&p) + : LLIMChiclet(p) + , mChicletIconCtrl(NULL) +{ + LLIconCtrl::Params icon_params = p.icon; + mChicletIconCtrl = LLUICtrlFactory::create<LLIconCtrl>(icon_params); + // Let "new message" icon be on top, else it will be hidden behind chiclet icon. + addChildInBack(mChicletIconCtrl); +} + +void LLScriptChiclet::setSessionId(const LLUUID& session_id) +{ + setShowNewMessagesIcon( getSessionId() != session_id ); + + LLIMChiclet::setSessionId(session_id); + LLUUID notification_id = LLScriptFloaterManager::getInstance()->findNotificationId(session_id); + LLNotificationPtr notification = LLNotifications::getInstance()->find(notification_id); + if(notification) + { + setToolTip(notification->getSubstitutions()["TITLE"].asString()); + } +} + +void LLScriptChiclet::onMouseDown() +{ + LLScriptFloaterManager::getInstance()->toggleScriptFloater(getSessionId()); +} + +BOOL LLScriptChiclet::handleMouseDown(S32 x, S32 y, MASK mask) +{ + onMouseDown(); + return LLChiclet::handleMouseDown(x, y, mask); +} + +// EOF |