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