|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzLib includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/stage2.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tpalettehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tscenehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshlevelhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshlevel.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/palettecontroller.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
PaletteController::PaletteController()
|
|
Toshihiro Shimizu |
890ddd |
: QObject(), m_currentLevelPalette(0), m_currentCleanupPalette(0), m_originalCurrentPalette(0), m_currentPalette(0), m_colorAutoApplyEnabled(true), m_colorSample()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_currentLevelPalette = new TPaletteHandle;
|
|
Toshihiro Shimizu |
890ddd |
m_currentCleanupPalette = new TPaletteHandle;
|
|
Toshihiro Shimizu |
890ddd |
m_currentPalette = new TPaletteHandle;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QObject::connect(m_currentCleanupPalette, SIGNAL(paletteSwitched()), this, SLOT(editCleanupPalette()));
|
|
Toshihiro Shimizu |
890ddd |
QObject::connect(m_currentCleanupPalette, SIGNAL(colorStyleSwitched()), this, SLOT(editCleanupPalette()));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QObject::connect(m_currentLevelPalette, SIGNAL(paletteSwitched()), this, SLOT(editLevelPalette()));
|
|
Toshihiro Shimizu |
890ddd |
QObject::connect(m_currentLevelPalette, SIGNAL(colorStyleSwitched()), this, SLOT(editLevelPalette()));
|
|
Toshihiro Shimizu |
890ddd |
//QObject::connect(m_currentLevelPalette, SIGNAL(colorStyleSwitched()), this, SLOT(setColorCheckIndex()));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QObject::connect(m_currentLevelPalette, SIGNAL(paletteLockChanged()), this, SLOT(editLevelPalette()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
PaletteController::~PaletteController()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
delete m_currentLevelPalette;
|
|
Toshihiro Shimizu |
890ddd |
delete m_currentCleanupPalette;
|
|
Toshihiro Shimizu |
890ddd |
delete m_currentPalette;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void PaletteController::setCurrentPalette(TPaletteHandle *paletteHandle)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
// Current palette redirects to the palette of another palette handle -
|
|
Toshihiro Shimizu |
890ddd |
// namely one of either the current level palette or current cleanup
|
|
Toshihiro Shimizu |
890ddd |
// palette - even though m_currentPalette is a standalone palette handle.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// In order to correctly support the notification system notify*() functions
|
|
Toshihiro Shimizu |
890ddd |
// perform signal BROADCASTING to all palette handles implicitly mapping to
|
|
Toshihiro Shimizu |
890ddd |
// the associated palette:
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (m_originalCurrentPalette) {
|
|
Toshihiro Shimizu |
890ddd |
m_originalCurrentPalette->disconnectBroadcasts(m_currentPalette);
|
|
Toshihiro Shimizu |
890ddd |
m_currentPalette->disconnectBroadcasts(m_originalCurrentPalette);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_originalCurrentPalette = paletteHandle;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (!paletteHandle)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_currentPalette->setPalette(paletteHandle->getPalette(), paletteHandle->getStyleIndex());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_originalCurrentPalette->connectBroadcasts(m_currentPalette);
|
|
Toshihiro Shimizu |
890ddd |
m_currentPalette->connectBroadcasts(m_originalCurrentPalette);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void PaletteController::editLevelPalette()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
setCurrentPalette(m_currentLevelPalette);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void PaletteController::editCleanupPalette()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
setCurrentPalette(m_currentCleanupPalette);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void PaletteController::enableColorAutoApply(bool enabled)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_colorAutoApplyEnabled != enabled) {
|
|
Toshihiro Shimizu |
890ddd |
m_colorAutoApplyEnabled = enabled;
|
|
Toshihiro Shimizu |
890ddd |
emit colorAutoApplyEnabled(m_colorAutoApplyEnabled);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void PaletteController::setColorSample(const TPixel32 &color)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_colorSample != color) {
|
|
Toshihiro Shimizu |
890ddd |
m_colorSample = color;
|
|
Toshihiro Shimizu |
890ddd |
emit colorSampleChanged(m_colorSample);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|