fixed EXT-6848 Avoid creation of dummy objects in LLOnlineStatusToast and LLPanelGenericTip classes.

* decoupled tip toast panel related logic from class LLTast;
* moved documentation comment of  LLPanelGenericTip constructor from .cpp to .h file;
* corrected name attribute in panel_generic_tip.xml;

reviewed by Mike Antipov and Vadim Savchuk at https://codereview.productengine.com/secondlife/r/230/

--HG--
branch : product-engine
master
Alexei Arabadji 2010-04-19 17:21:16 +03:00
parent eddb964e70
commit d57e8ecc7e
9 changed files with 159 additions and 37 deletions

View File

@ -303,6 +303,7 @@ set(viewer_SOURCE_FILES
llpanelcontents.cpp
llpaneleditwearable.cpp
llpanelface.cpp
llpanelgenerictip.cpp
llpanelgroup.cpp
llpanelgroupgeneral.cpp
llpanelgroupinvite.cpp
@ -342,6 +343,7 @@ set(viewer_SOURCE_FILES
llpanelprofile.cpp
llpanelprofileview.cpp
llpanelteleporthistory.cpp
llpaneltiptoast.cpp
llpanelvolume.cpp
llpanelvolumepulldown.cpp
llparcelselection.cpp
@ -437,7 +439,6 @@ set(viewer_SOURCE_FILES
lltracker.cpp
lltransientdockablefloater.cpp
lltransientfloatermgr.cpp
llpanelgenerictip.cpp
lluilistener.cpp
lluploaddialog.cpp
llurl.cpp
@ -802,6 +803,7 @@ set(viewer_HEADER_FILES
llpanelcontents.h
llpaneleditwearable.h
llpanelface.h
llpanelgenerictip.h
llpanelgroup.h
llpanelgroupgeneral.h
llpanelgroupinvite.h
@ -841,6 +843,7 @@ set(viewer_HEADER_FILES
llpanelprofile.h
llpanelprofileview.h
llpanelteleporthistory.h
llpaneltiptoast.h
llpanelvolume.h
llpanelvolumepulldown.h
llparcelselection.h
@ -939,7 +942,6 @@ set(viewer_HEADER_FILES
lltracker.h
lltransientdockablefloater.h
lltransientfloatermgr.h
llpanelgenerictip.h
lluiconstants.h
lluilistener.h
lluploaddialog.h

View File

@ -41,10 +41,11 @@
#include "llviewercontrol.h"
#include "llviewerwindow.h"
#include "llnotificationmanager.h"
#include "llpaneltiptoast.h"
using namespace LLNotificationsUI;
class LLOnlineStatusToast : public LLToastPanel
class LLOnlineStatusToast : public LLPanelTipToast
{
public:
@ -57,7 +58,7 @@ public:
Params() {}
};
LLOnlineStatusToast(Params& p) : LLToastPanel(p.notification)
LLOnlineStatusToast(Params& p) : LLPanelTipToast(p.notification)
{
LLUICtrlFactory::getInstance()->buildPanel(this, "panel_online_status_toast.xml");

View File

@ -36,15 +36,10 @@
#include "llpanelgenerictip.h"
#include "llnotifications.h"
/**
* Generic toast tip panel.
* This is particular case of toast panel that decoupled from LLToastNotifyPanel.
* From now LLToastNotifyPanel is deprecated and will be removed after all panel
* types are represented in separate classes.
*/
LLPanelGenericTip::LLPanelGenericTip(
const LLNotificationPtr& notification) :
LLToastPanel(notification)
LLPanelTipToast(notification)
{
LLUICtrlFactory::getInstance()->buildPanel(this, "panel_generic_tip.xml");

View File

@ -34,14 +34,24 @@
#ifndef LL_PANELGENERICTIP_H
#define LL_PANELGENERICTIP_H
#include "lltoastpanel.h"
#include "llpaneltiptoast.h"
class LLPanelGenericTip: public LLToastPanel
/**
* Represents tip toast panel that contains only one child element - message text.
* This panel can be used for different cases of tip notifications.
*/
class LLPanelGenericTip: public LLPanelTipToast
{
// disallow instantiation of this class
private:
// grant privileges to instantiate this class to LLToastPanel
friend class LLToastPanel;
/**
* Generic toast tip panel.
* This is particular case of toast panel that decoupled from LLToastNotifyPanel.
* From now LLToastNotifyPanel is deprecated and will be removed after all panel
* types are represented in separate classes.
*/
LLPanelGenericTip(const LLNotificationPtr& notification);
};
#endif /* LL_PANELGENERICTIP_H */

View File

@ -0,0 +1,69 @@
/**
* @file llpaneltiptoast.cpp
* @brief Represents a base class of tip toast panels.
*
* $LicenseInfo:firstyear=2010&license=viewergpl$
*
* Copyright (c) 2010, 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"
#include "llpaneltiptoast.h"
BOOL LLPanelTipToast::postBuild()
{
mMessageText= findChild<LLUICtrl>("message");
if (mMessageText != NULL)
{
mMessageText->setMouseUpCallback(boost::bind(&LLPanelTipToast::onMessageTextClick,this));
setMouseUpCallback(boost::bind(&LLPanelTipToast::onPanelClick, this, _2, _3, _4));
}
else
{
llassert(!"Can't find child 'message' text box.");
return FALSE;
}
return TRUE;
}
void LLPanelTipToast::onMessageTextClick()
{
// notify parent toast about need hide
LLSD info;
info["action"] = "hide_toast";
notifyParent(info);
}
void LLPanelTipToast::onPanelClick(S32 x, S32 y, MASK mask)
{
if (!mMessageText->getRect().pointInRect(x, y))
{
onMessageTextClick();
}
}

View File

@ -0,0 +1,57 @@
/**
* @file llpaneltiptoast.h
* @brief Represents a base class of tip toast panels.
*
* $LicenseInfo:firstyear=2010&license=viewergpl$
*
* Copyright (c) 2010, 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 "lltoastpanel.h"
#ifndef LL_PANELTOASTTIP_H
#define LL_PANELTOASTTIP_H
/**
* Base class for tip toast panels.
*
* Tip toast panels are required to have text message box named as 'message'.
*/
class LLPanelTipToast : public LLToastPanel
{
LOG_CLASS(LLPanelTipToast);
public:
LLPanelTipToast(const LLNotificationPtr& notification): LLToastPanel(notification) {}
virtual BOOL postBuild();
private:
void onMessageTextClick();
void onPanelClick(S32 x, S32 y, MASK mask);
LLUICtrl* mMessageText;
};
#endif /* LL_PANELTOASTTIP_H */

View File

@ -119,29 +119,9 @@ BOOL LLToast::postBuild()
mTimer->stop();
}
if (mIsTip)
{
mTextEditor = mPanel->getChild<LLTextEditor>("text_editor_box");
if (mTextEditor)
{
mTextEditor->setMouseUpCallback(boost::bind(&LLToast::hide,this));
mPanel->setMouseUpCallback(boost::bind(&LLToast::handleTipToastClick, this, _2, _3, _4));
}
}
return TRUE;
}
//--------------------------------------------------------------------------
void LLToast::handleTipToastClick(S32 x, S32 y, MASK mask)
{
if (!mTextEditor->getRect().pointInRect(x, y))
{
hide();
}
}
//--------------------------------------------------------------------------
void LLToast::setHideButtonEnabled(bool enabled)
{
@ -421,4 +401,13 @@ bool LLToast::isNotificationValid()
//--------------------------------------------------------------------------
S32 LLToast::notifyParent(const LLSD& info)
{
if (info.has("action") && "hide_toast" == info["action"].asString())
{
hide();
return 1;
}
return LLModalDialog::notifyParent(info);
}

View File

@ -190,14 +190,14 @@ public:
boost::signals2::connection setMouseEnterCallback( const commit_signal_t::slot_type& cb ) { return mToastMouseEnterSignal.connect(cb); };
boost::signals2::connection setMouseLeaveCallback( const commit_signal_t::slot_type& cb ) { return mToastMouseLeaveSignal.connect(cb); };
virtual S32 notifyParent(const LLSD& info);
private:
void onToastMouseEnter();
void onToastMouseLeave();
void handleTipToastClick(S32 x, S32 y, MASK mask);
void expire();
LLUUID mNotificationID;
@ -213,7 +213,6 @@ private:
LLPanel* mPanel;
LLButton* mHideBtn;
LLTextEditor* mTextEditor;
LLColor4 mBgColor;
bool mCanFade;

View File

@ -3,7 +3,7 @@
height="40"
layout="topleft"
left="0"
name="panel_system_tip"
name="panel_generic_tip"
top="0"
width="305">
<text