Blame toonz/sources/toonzlib/observer.cpp
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/observer.h"
|
|
Toshihiro Shimizu |
890ddd |
// OBSOLETO??
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TNotifier *TNotifier::instance()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
static TNotifier theNotifier;
|
|
Toshihiro Shimizu |
890ddd |
return &theNotifier;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
void TNotifier::attach(TChangeObserver*observer)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::vector<tobserverlist*>::iterator it;</tobserverlist*>
|
|
Toshihiro Shimizu |
890ddd |
for(it = m_obsList.begin(); it != m_obsList.end(); ++it)
|
|
Toshihiro Shimizu |
890ddd |
(*it)->attach(observer);
|
|
Toshihiro Shimizu |
890ddd |
if(TGlobalObserver *go = dynamic_cast<tglobalobserver *="">(observer))</tglobalobserver>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if(m_newSceneNotifiedObs.find(go) == m_newSceneNotifiedObs.end())
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
go->update(TGlobalChange(true));
|
|
Toshihiro Shimizu |
890ddd |
m_newSceneNotifiedObs.insert(go);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TNotifier::detach(TChangeObserver*observer)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::vector<tobserverlist*>::iterator it;</tobserverlist*>
|
|
Toshihiro Shimizu |
890ddd |
for(it = m_obsList.begin(); it != m_obsList.end(); ++it)
|
|
Toshihiro Shimizu |
890ddd |
(*it)->detach(observer);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void TNotifier::notify(const TGlobalChange &c)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_globalObs.notify(c);
|
|
Toshihiro Shimizu |
890ddd |
if (c.isSceneChanged()) {
|
|
Toshihiro Shimizu |
890ddd |
m_newSceneNotifiedObs.clear();
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < (int)m_globalObs.m_observers.size(); i++)
|
|
Toshihiro Shimizu |
890ddd |
m_newSceneNotifiedObs.insert(m_globalObs.m_observers[i]);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|