|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tpalettehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
// TPaletteHandle
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPaletteHandle::TPaletteHandle()
|
|
Shinya Kitaoka |
120a6e |
: m_palette(0), m_styleIndex(-1), m_styleParamIndex(-1) {
|
|
Shinya Kitaoka |
120a6e |
connectBroadcasts(this);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPaletteHandle::~TPaletteHandle() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPalette *TPaletteHandle::getPalette() const { return m_palette; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int TPaletteHandle::getStyleIndex() const { return m_styleIndex; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int TPaletteHandle::getStyleParamIndex() const { return m_styleParamIndex; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TColorStyle *TPaletteHandle::getStyle() const {
|
|
Shinya Kitaoka |
120a6e |
if (!m_palette || m_styleIndex == -1) return 0;
|
|
Shinya Kitaoka |
120a6e |
return m_palette->getStyle(m_styleIndex);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool TPaletteHandle::connectBroadcasts(const QObject *receiver) {
|
|
Shinya Kitaoka |
120a6e |
bool ret = true;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ret = connect(this, SIGNAL(broadcastPaletteChanged()), receiver,
|
|
Shinya Kitaoka |
120a6e |
SIGNAL(paletteChanged())) &&
|
|
Shinya Kitaoka |
120a6e |
ret;
|
|
Shinya Kitaoka |
120a6e |
ret = connect(this, SIGNAL(broadcastPaletteTitleChanged()), receiver,
|
|
Shinya Kitaoka |
120a6e |
SIGNAL(paletteTitleChanged())) &&
|
|
Shinya Kitaoka |
120a6e |
ret;
|
|
Shinya Kitaoka |
120a6e |
ret = connect(this, SIGNAL(broadcastColorStyleSwitched()), receiver,
|
|
Shinya Kitaoka |
120a6e |
SIGNAL(colorStyleSwitched())) &&
|
|
Shinya Kitaoka |
120a6e |
ret;
|
|
Shinya Kitaoka |
120a6e |
ret = connect(this, SIGNAL(broadcastColorStyleChanged()), receiver,
|
|
Shinya Kitaoka |
120a6e |
SIGNAL(colorStyleChanged())) &&
|
|
Shinya Kitaoka |
120a6e |
ret;
|
|
Shinya Kitaoka |
120a6e |
ret = connect(this, SIGNAL(broadcastColorStyleChangedOnMouseRelease()),
|
|
Shinya Kitaoka |
120a6e |
receiver, SIGNAL(colorStyleChangedOnMouseRelease())) &&
|
|
Shinya Kitaoka |
120a6e |
ret;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return ret;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool TPaletteHandle::disconnectBroadcasts(const QObject *receiver) {
|
|
Shinya Kitaoka |
120a6e |
bool ret = true;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ret = disconnect(this, SIGNAL(broadcastPaletteChanged()), receiver,
|
|
Shinya Kitaoka |
120a6e |
SIGNAL(paletteChanged())) &&
|
|
Shinya Kitaoka |
120a6e |
ret;
|
|
Shinya Kitaoka |
120a6e |
ret = disconnect(this, SIGNAL(broadcastPaletteTitleChanged()), receiver,
|
|
Shinya Kitaoka |
120a6e |
SIGNAL(paletteTitleChanged())) &&
|
|
Shinya Kitaoka |
120a6e |
ret;
|
|
Shinya Kitaoka |
120a6e |
ret = disconnect(this, SIGNAL(broadcastColorStyleSwitched()), receiver,
|
|
Shinya Kitaoka |
120a6e |
SIGNAL(colorStyleSwitched())) &&
|
|
Shinya Kitaoka |
120a6e |
ret;
|
|
Shinya Kitaoka |
120a6e |
ret = disconnect(this, SIGNAL(broadcastColorStyleChanged()), receiver,
|
|
Shinya Kitaoka |
120a6e |
SIGNAL(colorStyleChanged())) &&
|
|
Shinya Kitaoka |
120a6e |
ret;
|
|
Shinya Kitaoka |
120a6e |
ret = disconnect(this, SIGNAL(broadcastColorStyleChangedOnMouseRelease()),
|
|
Shinya Kitaoka |
120a6e |
receiver, SIGNAL(colorStyleChangedOnMouseRelease())) &&
|
|
Shinya Kitaoka |
120a6e |
ret;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return ret;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TPaletteHandle::setPalette(TPalette *palette, int styleIndex) {
|
|
Shinya Kitaoka |
120a6e |
if (m_palette == palette)
|
|
Shinya Kitaoka |
120a6e |
setStyleIndex(styleIndex);
|
|
Shinya Kitaoka |
120a6e |
else {
|
|
Shinya Kitaoka |
120a6e |
m_palette = palette;
|
|
Shinya Kitaoka |
120a6e |
m_styleIndex = styleIndex;
|
|
Shinya Kitaoka |
120a6e |
m_styleParamIndex = 0;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
emit paletteSwitched();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TPaletteHandle::setStyleIndex(int index) {
|
|
Shinya Kitaoka |
120a6e |
// if(m_styleIndex != index)
|
|
Shinya Kitaoka |
120a6e |
// {
|
|
Shinya Kitaoka |
120a6e |
m_styleIndex = index;
|
|
Shinya Kitaoka |
120a6e |
m_styleParamIndex = 0;
|
|
Shinya Kitaoka |
120a6e |
emit broadcastColorStyleSwitched();
|
|
Shinya Kitaoka |
120a6e |
// }
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TPaletteHandle::setStyleParamIndex(int index) {
|
|
Shinya Kitaoka |
120a6e |
if (m_styleParamIndex != index) {
|
|
Shinya Kitaoka |
120a6e |
m_styleParamIndex = index;
|
|
Shinya Kitaoka |
120a6e |
emit broadcastColorStyleSwitched();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TPaletteHandle::notifyPaletteChanged() { emit broadcastPaletteChanged(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TPaletteHandle::notifyPaletteTitleChanged() {
|
|
Shinya Kitaoka |
120a6e |
emit broadcastPaletteTitleChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TPaletteHandle::notifyColorStyleSwitched() {
|
|
Shinya Kitaoka |
120a6e |
emit broadcastColorStyleSwitched();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TPaletteHandle::notifyColorStyleChanged(bool onDragging,
|
|
Shinya Kitaoka |
120a6e |
bool setDirtyFlag) {
|
|
Shinya Kitaoka |
120a6e |
if (setDirtyFlag && getPalette() && !getPalette()->getDirtyFlag())
|
|
Shinya Kitaoka |
120a6e |
getPalette()->setDirtyFlag(true);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
emit broadcastColorStyleChanged();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!onDragging) emit broadcastColorStyleChangedOnMouseRelease();
|
|
Toshihiro Shimizu |
890ddd |
}
|