summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
authorJames Cook <james@lindenlab.com>2009-11-25 01:15:50 -0800
committerJames Cook <james@lindenlab.com>2009-11-25 01:15:50 -0800
commitcbc0783cd19f096b454cabe47174c97d3d42842b (patch)
tree96a4596d101c1d205fc4f56b0b54951dd408df80 /indra/llui
parent0e351bedb6ec15ecb4da6073c8db4edc34ccc0ba (diff)
Created lightweight LLNotificationsUtil::add(), switched most alerts to use it
Cuts number of includes of llnotifications.h from 300+ to 40.
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/CMakeLists.txt2
-rw-r--r--indra/llui/llbutton.cpp4
-rw-r--r--indra/llui/llfloater.h2
-rw-r--r--indra/llui/llnotifications.cpp14
-rw-r--r--indra/llui/llnotifications.h7
-rw-r--r--indra/llui/llnotificationsutil.cpp91
-rw-r--r--indra/llui/llnotificationsutil.h68
7 files changed, 175 insertions, 13 deletions
diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt
index b97092da9a..74b49b846e 100644
--- a/indra/llui/CMakeLists.txt
+++ b/indra/llui/CMakeLists.txt
@@ -60,6 +60,7 @@ set(llui_SOURCE_FILES
llmultisliderctrl.cpp
llnotifications.cpp
llnotificationslistener.cpp
+ llnotificationsutil.cpp
llpanel.cpp
llprogressbar.cpp
llradiogroup.cpp
@@ -150,6 +151,7 @@ set(llui_HEADER_FILES
llnotificationptr.h
llnotifications.h
llnotificationslistener.h
+ llnotificationsutil.h
llpanel.h
llprogressbar.h
llradiogroup.h
diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp
index 8930e32055..b91c614424 100644
--- a/indra/llui/llbutton.cpp
+++ b/indra/llui/llbutton.cpp
@@ -48,7 +48,7 @@
#include "llfloaterreg.h"
#include "llfocusmgr.h"
#include "llwindow.h"
-#include "llnotifications.h"
+#include "llnotificationsutil.h"
#include "llrender.h"
#include "lluictrlfactory.h"
#include "llhelp.h"
@@ -1106,7 +1106,7 @@ void LLButton::showHelp(LLUICtrl* ctrl, const LLSD& sdname)
// display an error if we can't find a help_topic string.
// fix this by adding a help_topic attribute to the xui file
- LLNotifications::instance().add("UnableToFindHelpTopic");
+ LLNotificationsUtil::add("UnableToFindHelpTopic");
}
void LLButton::resetMouseDownTimer()
diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h
index 233f3462b5..42d3240c0a 100644
--- a/indra/llui/llfloater.h
+++ b/indra/llui/llfloater.h
@@ -39,7 +39,7 @@
#include "llpanel.h"
#include "lluuid.h"
-//#include "llnotifications.h"
+//#include "llnotificationsutil.h"
#include <set>
class LLDragHandle;
diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp
index eb8cc3e2c5..05f2d3a9cf 100644
--- a/indra/llui/llnotifications.cpp
+++ b/indra/llui/llnotifications.cpp
@@ -1395,10 +1395,9 @@ void LLNotifications::addFromCallback(const LLSD& name)
add(LLNotification::Params().name(name.asString()));
}
-// we provide a couple of simple add notification functions so that it's reasonable to create notifications in one line
LLNotificationPtr LLNotifications::add(const std::string& name,
- const LLSD& substitutions,
- const LLSD& payload)
+ const LLSD& substitutions,
+ const LLSD& payload)
{
LLNotification::Params::Functor functor_p;
functor_p.name = name;
@@ -1406,15 +1405,16 @@ LLNotificationPtr LLNotifications::add(const std::string& name,
}
LLNotificationPtr LLNotifications::add(const std::string& name,
- const LLSD& substitutions,
- const LLSD& payload,
- const std::string& functor_name)
+ const LLSD& substitutions,
+ const LLSD& payload,
+ const std::string& functor_name)
{
LLNotification::Params::Functor functor_p;
functor_p.name = functor_name;
return add(LLNotification::Params().name(name).substitutions(substitutions).payload(payload).functor(functor_p));
}
-
+
+//virtual
LLNotificationPtr LLNotifications::add(const std::string& name,
const LLSD& substitutions,
const LLSD& payload,
diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h
index d959baf541..aeb4cebf1b 100644
--- a/indra/llui/llnotifications.h
+++ b/indra/llui/llnotifications.h
@@ -839,10 +839,11 @@ public:
// Add a simple notification (from XUI)
void addFromCallback(const LLSD& name);
- // we provide a collection of simple add notification functions so that it's reasonable to create notifications in one line
+ // *NOTE: To add simple notifications, #include "llnotificationsutil.h"
+ // and use LLNotificationsUtil::add("MyNote") or add("MyNote", args)
LLNotificationPtr add(const std::string& name,
- const LLSD& substitutions = LLSD(),
- const LLSD& payload = LLSD());
+ const LLSD& substitutions,
+ const LLSD& payload);
LLNotificationPtr add(const std::string& name,
const LLSD& substitutions,
const LLSD& payload,
diff --git a/indra/llui/llnotificationsutil.cpp b/indra/llui/llnotificationsutil.cpp
new file mode 100644
index 0000000000..2cd165f1b3
--- /dev/null
+++ b/indra/llui/llnotificationsutil.cpp
@@ -0,0 +1,91 @@
+/**
+ * @file llnotificationsutil.cpp
+ *
+ * $LicenseInfo:firstyear=2008&license=viewergpl$
+ *
+ * Copyright (c) 2008-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 "linden_common.h"
+
+#include "llnotificationsutil.h"
+
+#include "llnotifications.h"
+#include "llsd.h"
+#include "llxmlnode.h" // apparently needed to call LLNotifications::instance()
+
+LLNotificationPtr LLNotificationsUtil::add(const std::string& name)
+{
+ LLNotification::Params::Functor functor_p;
+ functor_p.name = name;
+ return LLNotifications::instance().add(
+ LLNotification::Params().name(name).substitutions(LLSD()).payload(LLSD()).functor(functor_p));
+}
+
+LLNotificationPtr LLNotificationsUtil::add(const std::string& name,
+ const LLSD& substitutions)
+{
+ LLNotification::Params::Functor functor_p;
+ functor_p.name = name;
+ return LLNotifications::instance().add(
+ LLNotification::Params().name(name).substitutions(substitutions).payload(LLSD()).functor(functor_p));
+}
+
+LLNotificationPtr LLNotificationsUtil::add(const std::string& name,
+ const LLSD& substitutions,
+ const LLSD& payload)
+{
+ LLNotification::Params::Functor functor_p;
+ functor_p.name = name;
+ return LLNotifications::instance().add(
+ LLNotification::Params().name(name).substitutions(substitutions).payload(payload).functor(functor_p));
+}
+
+LLNotificationPtr LLNotificationsUtil::add(const std::string& name,
+ const LLSD& substitutions,
+ const LLSD& payload,
+ const std::string& functor_name)
+{
+ LLNotification::Params::Functor functor_p;
+ functor_p.name = functor_name;
+ return LLNotifications::instance().add(
+ LLNotification::Params().name(name).substitutions(substitutions).payload(payload).functor(functor_p));
+}
+
+LLNotificationPtr LLNotificationsUtil::add(const std::string& name,
+ const LLSD& substitutions,
+ const LLSD& payload,
+ boost::function<void (const LLSD&, const LLSD&)> functor)
+{
+ LLNotification::Params::Functor functor_p;
+ functor_p.function = functor;
+ return LLNotifications::instance().add(
+ LLNotification::Params().name(name).substitutions(substitutions).payload(payload).functor(functor_p));
+}
+
+S32 LLNotificationsUtil::getSelectedOption(const LLSD& notification, const LLSD& response)
+{
+ return LLNotification::getSelectedOption(notification, response);
+}
diff --git a/indra/llui/llnotificationsutil.h b/indra/llui/llnotificationsutil.h
new file mode 100644
index 0000000000..a0801b338f
--- /dev/null
+++ b/indra/llui/llnotificationsutil.h
@@ -0,0 +1,68 @@
+/**
+ * @file llnotificationsutil.h
+ *
+ * $LicenseInfo:firstyear=2008&license=viewergpl$
+ *
+ * Copyright (c) 2008-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$
+ */
+#ifndef LLNOTIFICATIONSUTIL_H
+#define LLNOTIFICATIONSUTIL_H
+
+// The vast majority of clients of the notifications system just want to add
+// a notification to the screen, so define this lightweight public interface
+// to avoid including the heavyweight llnotifications.h
+
+#include "llnotificationptr.h"
+
+#include <boost/function.hpp>
+
+class LLSD;
+
+namespace LLNotificationsUtil
+{
+ LLNotificationPtr add(const std::string& name);
+
+ LLNotificationPtr add(const std::string& name,
+ const LLSD& substitutions);
+
+ LLNotificationPtr add(const std::string& name,
+ const LLSD& substitutions,
+ const LLSD& payload);
+
+ LLNotificationPtr add(const std::string& name,
+ const LLSD& substitutions,
+ const LLSD& payload,
+ const std::string& functor_name);
+
+ LLNotificationPtr add(const std::string& name,
+ const LLSD& substitutions,
+ const LLSD& payload,
+ boost::function<void (const LLSD&, const LLSD&)> functor);
+
+ S32 getSelectedOption(const LLSD& notification, const LLSD& response);
+}
+
+#endif