tahoma2d/toonz/sources/toonzqt/selection.cpp

61 lines
1.7 KiB
C++
Raw Normal View History

2016-03-19 06:57:51 +13:00
#include "toonzqt/selection.h"
#include "toonzqt/tselectionhandle.h"
#include "assert.h"
//#include "menubar.h"
#include <QMenu>
#include <QWidget>
//=============================================================================
// TSelection
//-----------------------------------------------------------------------------
2016-06-15 18:43:10 +12:00
TSelection::TSelection() : m_view(0) {}
2016-03-19 06:57:51 +13:00
//-----------------------------------------------------------------------------
2016-06-15 18:43:10 +12:00
TSelection::~TSelection() {}
2016-03-19 06:57:51 +13:00
//-----------------------------------------------------------------------------
2016-06-15 18:43:10 +12:00
void TSelection::makeCurrent() {
TSelectionHandle::getCurrent()->setSelection(this);
2016-03-19 06:57:51 +13:00
}
//-----------------------------------------------------------------------------
2016-06-15 18:43:10 +12:00
void TSelection::makeNotCurrent() {
TSelectionHandle *sh = TSelectionHandle::getCurrent();
if (sh->getSelection() == this) sh->setSelection(0);
2016-03-19 06:57:51 +13:00
}
//-----------------------------------------------------------------------------
2016-06-15 18:43:10 +12:00
TSelection *TSelection::getCurrent() {
return TSelectionHandle::getCurrent()->getSelection();
2016-03-19 06:57:51 +13:00
}
//-----------------------------------------------------------------------------
2016-06-15 18:43:10 +12:00
void TSelection::setCurrent(TSelection *selection) {
// assert(0);
TSelectionHandle::getCurrent()->setSelection(selection);
2016-03-19 06:57:51 +13:00
}
//-----------------------------------------------------------------------------
2016-06-15 18:43:10 +12:00
void TSelection::enableCommand(CommandId cmdId,
CommandHandlerInterface *handler) {
TSelectionHandle::getCurrent()->enableCommand(cmdId, handler);
2016-03-19 06:57:51 +13:00
}
2016-06-15 18:43:10 +12:00
void TSelection::addMenuAction(QMenu *menu, CommandId cmdId) {
menu->addAction(CommandManager::instance()->getAction(cmdId));
2016-03-19 06:57:51 +13:00
}
2016-06-15 18:43:10 +12:00
void TSelection::notifyView() {
if (m_view) m_view->onSelectionChanged();
2016-03-19 06:57:51 +13:00
}