diff options
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/llmenugl.cpp | 2 | ||||
-rw-r--r-- | indra/llui/llmenugl.h | 2 | ||||
-rw-r--r-- | indra/llui/llnotifications.cpp | 23 | ||||
-rw-r--r-- | indra/llui/llnotifications.h | 87 | ||||
-rw-r--r-- | indra/llui/llpanel.h | 3 | ||||
-rw-r--r-- | indra/llui/llui.h | 4 | ||||
-rw-r--r-- | indra/llui/llview.cpp | 2 | ||||
-rw-r--r-- | indra/llui/llview.h | 12 |
8 files changed, 62 insertions, 73 deletions
diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index 0762d7c12d..a8d06643ff 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -67,6 +67,8 @@ #include <set> #include <boost/tokenizer.hpp> +using namespace LLOldEvents; + // static LLMenuHolderGL *LLMenuGL::sMenuContainer = NULL; diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h index 030b81b58c..e62402d617 100644 --- a/indra/llui/llmenugl.h +++ b/indra/llui/llmenugl.h @@ -224,7 +224,7 @@ private: // calls a user defined callback. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -class LLMenuItemCallGL : public LLMenuItemGL, public LLObservable +class LLMenuItemCallGL : public LLMenuItemGL, public LLOldEvents::LLObservable { public: // normal constructor diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index 6b7dd0a3de..fe1ea95070 100644 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -714,7 +714,7 @@ std::string LLNotification::getLabel() const // ========================================================= // LLNotificationChannel implementation // --- -void LLNotificationChannelBase::connectChanged(const LLStandardSignal::slot_type& slot) +LLBoundListener LLNotificationChannelBase::connectChangedImpl(const LLEventListener& slot) { // when someone wants to connect to a channel, we first throw them // all of the notifications that are already in the channel @@ -722,23 +722,23 @@ void LLNotificationChannelBase::connectChanged(const LLStandardSignal::slot_type // only about new notifications for (LLNotificationSet::iterator it = mItems.begin(); it != mItems.end(); ++it) { - slot.get_slot_function()(LLSD().insert("sigtype", "load").insert("id", (*it)->id())); + slot(LLSD().insert("sigtype", "load").insert("id", (*it)->id())); } // and then connect the signal so that all future notifications will also be // forwarded. - mChanged.connect(slot); + return mChanged.connect(slot); } -void LLNotificationChannelBase::connectPassedFilter(const LLStandardSignal::slot_type& slot) +LLBoundListener LLNotificationChannelBase::connectPassedFilterImpl(const LLEventListener& slot) { // these two filters only fire for notifications added after the current one, because // they don't participate in the hierarchy. - mPassedFilter.connect(slot); + return mPassedFilter.connect(slot); } -void LLNotificationChannelBase::connectFailedFilter(const LLStandardSignal::slot_type& slot) +LLBoundListener LLNotificationChannelBase::connectFailedFilterImpl(const LLEventListener& slot) { - mFailedFilter.connect(slot); + return mFailedFilter.connect(slot); } // external call, conforms to our standard signature @@ -896,8 +896,7 @@ mParent(parent) else { LLNotificationChannelPtr p = LLNotifications::instance().getChannel(parent); - LLStandardSignal::slot_type f = boost::bind(&LLNotificationChannelBase::updateItem, this, _1); - p->connectChanged(f); + p->connectChanged(boost::bind(&LLNotificationChannelBase::updateItem, this, _1)); } } @@ -1093,11 +1092,11 @@ void LLNotifications::createDefaultChannels() // connect action methods to these channels LLNotifications::instance().getChannel("Expiration")-> - connectChanged(boost::bind(&LLNotifications::expirationHandler, this, _1)); + connectChanged(boost::bind(&LLNotifications::expirationHandler, this, _1)); LLNotifications::instance().getChannel("Unique")-> - connectChanged(boost::bind(&LLNotifications::uniqueHandler, this, _1)); + connectChanged(boost::bind(&LLNotifications::uniqueHandler, this, _1)); LLNotifications::instance().getChannel("Unique")-> - connectFailedFilter(boost::bind(&LLNotifications::failedUniquenessTest, this, _1)); + connectFailedFilter(boost::bind(&LLNotifications::failedUniquenessTest, this, _1)); LLNotifications::instance().getChannel("Ignore")-> connectFailedFilter(&handleIgnoredNotification); } diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index bb379121cc..d01296c89e 100644 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -91,49 +91,20 @@ #include <boost/utility.hpp> #include <boost/shared_ptr.hpp> -#include <boost/signal.hpp> +#include <boost/enable_shared_from_this.hpp> #include <boost/type_traits.hpp> // we want to minimize external dependencies, but this one is important #include "llsd.h" // and we need this to manage the notification callbacks +#include "llevents.h" #include "llfunctorregistry.h" #include "llui.h" class LLNotification; typedef boost::shared_ptr<LLNotification> LLNotificationPtr; -/***************************************************************************** -* Signal and handler declarations -* Using a single handler signature means that we can have a common handler -* type, rather than needing a distinct one for each different handler. -*****************************************************************************/ - -/** - * A boost::signals Combiner that stops the first time a handler returns true - * We need this because we want to have our handlers return bool, so that - * we have the option to cause a handler to stop further processing. The - * default handler fails when the signal returns a value but has no slots. - */ -struct LLStopWhenHandled -{ - typedef bool result_type; - - template<typename InputIterator> - result_type operator()(InputIterator first, InputIterator last) const - { - for (InputIterator si = first; si != last; ++si) - { - if (*si) - { - return true; - } - } - return false; - } -}; - typedef enum e_notification_priority { @@ -144,27 +115,11 @@ typedef enum e_notification_priority NOTIFICATION_PRIORITY_CRITICAL } ENotificationPriority; -/** - * We want to have a standard signature for all signals; this way, - * we can easily document a protocol for communicating across - * dlls and into scripting languages someday. - * we want to return a bool to indicate whether the signal has been - * handled and should NOT be passed on to other listeners. - * Return true to stop further handling of the signal, and false - * to continue. - * We take an LLSD because this way the contents of the signal - * are independent of the API used to communicate it. - * It is const ref because then there's low cost to pass it; - * if you only need to inspect it, it's very cheap. - */ - typedef boost::function<void (const LLSD&, const LLSD&)> LLNotificationResponder; typedef LLFunctorRegistry<LLNotificationResponder> LLNotificationFunctorRegistry; typedef LLFunctorRegistration<LLNotificationResponder> LLNotificationFunctorRegistration; -typedef boost::signal<bool(const LLSD&), LLStopWhenHandled> LLStandardSignal; - // context data that can be looked up via a notification's payload by the display logic // derive from this class to implement specific contexts class LLNotificationContext : public LLInstanceTracker<LLNotificationContext, LLUUID> @@ -699,7 +654,7 @@ typedef std::multimap<std::string, LLNotificationPtr> LLNotificationMap; // all of the built-in tests should attach to the "Visible" channel // class LLNotificationChannelBase : - public boost::signals::trackable + public LLEventTrackable { LOG_CLASS(LLNotificationChannelBase); public: @@ -709,15 +664,45 @@ public: virtual ~LLNotificationChannelBase() {} // you can also connect to a Channel, so you can be notified of // changes to this channel - virtual void connectChanged(const LLStandardSignal::slot_type& slot); - virtual void connectPassedFilter(const LLStandardSignal::slot_type& slot); - virtual void connectFailedFilter(const LLStandardSignal::slot_type& slot); + template <typename LISTENER> + LLBoundListener connectChanged(const LISTENER& slot) + { + // Examine slot to see if it binds an LLEventTrackable subclass, or a + // boost::shared_ptr to something, or a boost::weak_ptr to something. + // Call this->connectChangedImpl() to actually connect it. + return LLEventDetail::visit_and_connect(slot, + boost::bind(&LLNotificationChannelBase::connectChangedImpl, + this, + _1)); + } + template <typename LISTENER> + LLBoundListener connectPassedFilter(const LISTENER& slot) + { + // see comments in connectChanged() + return LLEventDetail::visit_and_connect(slot, + boost::bind(&LLNotificationChannelBase::connectPassedFilterImpl, + this, + _1)); + } + template <typename LISTENER> + LLBoundListener connectFailedFilter(const LISTENER& slot) + { + // see comments in connectChanged() + return LLEventDetail::visit_and_connect(slot, + boost::bind(&LLNotificationChannelBase::connectFailedFilterImpl, + this, + _1)); + } // use this when items change or to add a new one bool updateItem(const LLSD& payload); const LLNotificationFilter& getFilter() { return mFilter; } protected: + LLBoundListener connectChangedImpl(const LLEventListener& slot); + LLBoundListener connectPassedFilterImpl(const LLEventListener& slot); + LLBoundListener connectFailedFilterImpl(const LLEventListener& slot); + LLNotificationSet mItems; LLStandardSignal mChanged; LLStandardSignal mPassedFilter; diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h index 756d02ef7d..a7c9579030 100644 --- a/indra/llui/llpanel.h +++ b/indra/llui/llpanel.h @@ -42,6 +42,7 @@ #include "llviewborder.h" #include "lluistring.h" #include "v4color.h" +#include "llevents.h" #include <list> #include <queue> @@ -56,7 +57,7 @@ const BOOL BORDER_NO = FALSE; * With or without border, * Can contain LLUICtrls. */ -class LLPanel : public LLUICtrl, public boost::signals::trackable +class LLPanel : public LLUICtrl, public LLEventTrackable { public: diff --git a/indra/llui/llui.h b/indra/llui/llui.h index ebcc7304b1..6d6ce7a97c 100644 --- a/indra/llui/llui.h +++ b/indra/llui/llui.h @@ -43,7 +43,7 @@ #include "llgl.h" // *TODO: break this dependency #include <stack> //#include "llimagegl.h" -#include <boost/signal.hpp> +#include <boost/signals2.hpp> // LLUIFactory #include "llsd.h" @@ -661,7 +661,7 @@ template <typename T> std::set<T*> LLInstanceTracker<T, T*>::sInstances; class LLCallbackRegistry { public: - typedef boost::signal<void()> callback_signal_t; + typedef boost::signals2::signal<void()> callback_signal_t; void registerCallback(const callback_signal_t::slot_type& slot) { diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index 2350ea6050..8ec681fcaf 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -56,6 +56,8 @@ #include "lltexteditor.h" #include "lltextbox.h" +using namespace LLOldEvents; + //HACK: this allows you to instantiate LLView from xml with "<view/>" which we don't want static LLRegisterWidget<LLView> r("view"); diff --git a/indra/llui/llview.h b/indra/llui/llview.h index e0e0f6ba47..721fe99f4a 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -441,11 +441,11 @@ public: void localRectToScreen( const LLRect& local, LLRect* screen ) const; // Listener dispatching functions (Dispatcher deletes pointers to listeners on deregistration or destruction) - LLSimpleListener* getListenerByName(const std::string& callback_name); - void registerEventListener(std::string name, LLSimpleListener* function); + LLOldEvents::LLSimpleListener* getListenerByName(const std::string& callback_name); + void registerEventListener(std::string name, LLOldEvents::LLSimpleListener* function); void deregisterEventListener(std::string name); - std::string findEventListener(LLSimpleListener *listener) const; - void addListenerToControl(LLEventDispatcher *observer, const std::string& name, LLSD filter, LLSD userdata); + std::string findEventListener(LLOldEvents::LLSimpleListener *listener) const; + void addListenerToControl(LLOldEvents::LLEventDispatcher *observer, const std::string& name, LLSD filter, LLSD userdata); void addBoolControl(const std::string& name, bool initial_value); LLControlVariable *getControl(const std::string& name); @@ -651,7 +651,7 @@ private: static LLWindow* sWindow; // All root views must know about their window. - typedef std::map<std::string, LLPointer<LLSimpleListener> > dispatch_list_t; + typedef std::map<std::string, LLPointer<LLOldEvents::LLSimpleListener> > dispatch_list_t; dispatch_list_t mDispatchList; std::string mControlName; @@ -659,7 +659,7 @@ private: typedef std::map<std::string, LLView*> dummy_widget_map_t; mutable dummy_widget_map_t mDummyWidgets; - boost::signals::connection mControlConnection; + boost::signals2::connection mControlConnection; ECursorType mHoverCursor; |