Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "toonz/txshlevelhandle.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "toonz/txshlevel.h"
Toshihiro Shimizu 890ddd
#include "toonz/txshsimplelevel.h"
Toshihiro Shimizu 890ddd
#include "toonz/txsheet.h"
Toshihiro Shimizu 890ddd
#include "toonz/txshcell.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// TXshLevelHandle
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TXshLevelHandle::TXshLevelHandle() : m_level(0) {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TXshLevelHandle::~TXshLevelHandle() {
Shinya Kitaoka 120a6e
  if (m_level) m_level->release();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TXshLevel *TXshLevelHandle::getLevel() const { return m_level; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TXshSimpleLevel *TXshLevelHandle::getSimpleLevel() const {
Shinya Kitaoka 120a6e
  if (!m_level)
Shinya Kitaoka 120a6e
    return 0;
Shinya Kitaoka 120a6e
  else
Shinya Kitaoka 120a6e
    return m_level->getSimpleLevel();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TXshLevelHandle::setLevel(TXshLevel *level) {
Shinya Kitaoka 120a6e
  if (m_level == level) return;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TXshLevel *oldLevel = m_level;
Shinya Kitaoka 120a6e
  m_level             = level;
Shinya Kitaoka 120a6e
  if (level) level->addRef();
Shinya Kitaoka 120a6e
  bool levelExists = oldLevel ? oldLevel->getRefCount() > 1 : false;
Shinya Kitaoka 120a6e
  if (oldLevel) oldLevel->release();
Shinya Kitaoka 120a6e
  emit xshLevelSwitched(levelExists ? oldLevel : 0);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------