Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

moved nuiNotificationManager from nuiTopLevel to nglKernel.

Kept some shortcuts in nuiTopLevel.
Added new shortcuts to nglKernel.
  • Loading branch information...
commit 6c7ef02a755800ac97a985bca60625a744e38630 1 parent a035ec7
@meeloo meeloo authored
View
11 include/nglKernel.h
@@ -20,6 +20,8 @@
class nglKernel;
class nglPath;
+class nuiNotificationManager;
+class nuiNotificationObserver;
extern NGL_API nglKernel* App;
/*!<
@@ -307,6 +309,12 @@ class NGL_API nglKernel : public nglError, public nglEvent, public nuiMessageQue
static void SetCrashReportEmail(const nglString& rEmail);
+ // Notification manager proxy:
+ void PostNotification(nuiNotification* pNotification); ///< Put this notification in a queue in order to broadcast when the system feels like it.
+ void BroadcastNotification(const nuiNotification& rNotification); ///< Send this notification now to all registered observers.
+ void RegisterObserver(const nglString& rNotificationName, nuiNotificationObserver* pObserver); ///< Register an observer for the given notification type. If the type is nglString::Empty, all the notifications will be sent to the observer.
+ void UnregisterObserver(nuiNotificationObserver* pObserver, const nglString& rNotificationName = nglString::Null); ///< Unregister pObserver so that it doesn't receive the given notification. By default it is removed from all notification types (nglString::Null).
+
protected:
// Life cycle
nglKernel();
@@ -337,6 +345,9 @@ class NGL_API nglKernel : public nglError, public nglEvent, public nuiMessageQue
// From nglError
virtual const nglChar* OnError (uint& rError) const;
+
+ nuiNotificationManager* mpNotificationManager;
+ void OnMessageQueueTick(const nuiEvent& rEvent);
private:
typedef std::list<ExitFunc> ExitFuncList;
View
2  include/nuiNotification.h
@@ -38,7 +38,7 @@ class NUI_API nuiNotificationObserver
};
-class NUI_API nuiNotificationManager
+class NUI_API nuiNotificationManager : public nuiRefCount
{
public:
nuiNotificationManager();
View
4 include/nuiTopLevel.h
@@ -151,10 +151,8 @@ class NUI_API nuiTopLevel : public nuiSimpleContainer
// Notification manager proxy:
void PostNotification(nuiNotification* pNotification); ///< Put this notification in a queue in order to broadcast when the system feels like it.
void BroadcastNotification(const nuiNotification& rNotification); ///< Send this notification now to all registered observers.
- void BroadcastQueuedNotifications(); ///< Broadcast all the notifications that have been queued up to now.
void RegisterObserver(const nglString& rNotificationName, nuiNotificationObserver* pObserver); ///< Register an observer for the given notification type. If the type is nglString::Empty, all the notifications will be sent to the observer.
void UnregisterObserver(nuiNotificationObserver* pObserver, const nglString& rNotificationName = nglString::Null); ///< Unregister pObserver so that it doesn't receive the given notification. By default it is removed from all notification types (nglString::Null).
- void ClearNotifications();
protected:
@@ -228,8 +226,6 @@ class NUI_API nuiTopLevel : public nuiSimpleContainer
std::map<nuiWidgetPtr, nuiWidgetPtr> mTabBackward;
std::map<nuiWidgetPtr, std::set<nuiWidgetPtr> > mTabForwardRev;
std::map<nuiWidgetPtr, std::set<nuiWidgetPtr> > mTabBackwardRev;
-
- nuiNotificationManager mNotificationManager;
};
typedef nuiTopLevel* nuiTopLevelPtr;
View
28 src/Application/nglKernel.cpp
@@ -14,6 +14,7 @@
#include "nglDataObjects.h"
#include "nuiNativeResourceVolume.h"
+#include "nuiNotification.h"
#include "ucdata.h"
@@ -317,6 +318,7 @@ void nglKernel::CallOnInit()
nglVolume::Mount(pResources);
nuiTimer* pTimer = nuiAnimation::AcquireTimer();
mKernelEventSink.Connect(pTimer->Tick, &nglKernel::ProcessMessages);
+ mpNotificationManager = new nuiNotificationManager();
OnInit();
}
@@ -393,4 +395,30 @@ void nglKernel::ProcessMessages(const nuiEvent& rEvent)
pCommand->Do();
delete pNotif;
}
+
+ mpNotificationManager->BroadcastQueuedNotifications();
}
+
+void nglKernel::PostNotification(nuiNotification* pNotification)
+{
+ mpNotificationManager->PostNotification(pNotification);
+}
+
+void nglKernel::BroadcastNotification(const nuiNotification& rNotification)
+{
+ mpNotificationManager->BroadcastNotification(rNotification);
+}
+
+void nglKernel::RegisterObserver(const nglString& rNotificationName, nuiNotificationObserver* pObserver)
+{
+ mpNotificationManager->RegisterObserver(rNotificationName, pObserver);
+}
+
+void nglKernel::UnregisterObserver(nuiNotificationObserver* pObserver, const nglString& rNotificationName)
+{
+ mpNotificationManager->UnregisterObserver(pObserver, rNotificationName);
+}
+
+
+
+
View
25 src/WidgetTree/nuiTopLevel.cpp
@@ -174,7 +174,6 @@ nuiTopLevel::nuiTopLevel(const nglPath& rResPath)
mTopLevelSink.Connect(mToolTipTimerOn.Tick, &nuiTopLevel::ToolTipOn);
mTopLevelSink.Connect(mToolTipTimerOff.Tick, &nuiTopLevel::ToolTipOff);
- mTopLevelSink.Connect(nuiAnimation::AcquireTimer()->Tick, &nuiTopLevel::OnMessageQueueTick);
mpGrab.clear();
mMouseInfo.TouchId = -1;
@@ -2015,12 +2014,6 @@ void nuiTopLevel::SetWatchedWidget(nuiWidget* pWatchedWidget)
Invalidate();
}
-void nuiTopLevel::OnMessageQueueTick(const nuiEvent& rEvent)
-{
- CheckValid();
- BroadcastQueuedNotifications();
-}
-
//// CSS Stuff:
void nuiTopLevel::PrepareWidgetCSS(nuiWidget* pWidget, bool Recursive, uint32 MatchersTag)
{
@@ -2258,32 +2251,22 @@ bool nuiTopLevel::IsEnteringText() const
void nuiTopLevel::PostNotification(nuiNotification* pNotification)
{
- mNotificationManager.PostNotification(pNotification);
+ App->PostNotification(pNotification);
}
void nuiTopLevel::BroadcastNotification(const nuiNotification& rNotification)
{
- mNotificationManager.BroadcastNotification(rNotification);
-}
-
-void nuiTopLevel::BroadcastQueuedNotifications()
-{
- mNotificationManager.BroadcastQueuedNotifications();
+ App->BroadcastNotification(rNotification);
}
void nuiTopLevel::RegisterObserver(const nglString& rNotificationName, nuiNotificationObserver* pObserver)
{
- mNotificationManager.RegisterObserver(rNotificationName, pObserver);
+ App->RegisterObserver(rNotificationName, pObserver);
}
void nuiTopLevel::UnregisterObserver(nuiNotificationObserver* pObserver, const nglString& rNotificationName)
{
- mNotificationManager.UnregisterObserver(pObserver, rNotificationName);
-}
-
-void nuiTopLevel::ClearNotifications()
-{
- mNotificationManager.Clear();
+ App->UnregisterObserver(pObserver, rNotificationName);
}
Please sign in to comment.
Something went wrong with that request. Please try again.