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 |
|
|
Shinya Kitaoka |
120a6e |
TNotifier *TNotifier::instance() {
|
|
Shinya Kitaoka |
120a6e |
static TNotifier theNotifier;
|
|
Shinya Kitaoka |
120a6e |
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 |
|
|
Shinya Kitaoka |
120a6e |
void TNotifier::notify(const TGlobalChange &c) {
|
|
Shinya Kitaoka |
120a6e |
m_globalObs.notify(c);
|
|
Shinya Kitaoka |
120a6e |
if (c.isSceneChanged()) {
|
|
Shinya Kitaoka |
120a6e |
m_newSceneNotifiedObs.clear();
|
|
Shinya Kitaoka |
120a6e |
for (int i = 0; i < (int)m_globalObs.m_observers.size(); i++)
|
|
Shinya Kitaoka |
120a6e |
m_newSceneNotifiedObs.insert(m_globalObs.m_observers[i]);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|