diff --git a/toonz/sources/include/toonz/tpalettehandle.h b/toonz/sources/include/toonz/tpalettehandle.h index c2bdd1dc..30539ff0 100644 --- a/toonz/sources/include/toonz/tpalettehandle.h +++ b/toonz/sources/include/toonz/tpalettehandle.h @@ -46,7 +46,7 @@ public: void setPalette(TPalette *palette, int styleIndex = 1); - void setStyleIndex(int index); + void setStyleIndex(int index, bool forceEmit = false); void setStyleParamIndex(int index); diff --git a/toonz/sources/toonzlib/tpalettehandle.cpp b/toonz/sources/toonzlib/tpalettehandle.cpp index 8937b21e..fd0835ec 100644 --- a/toonz/sources/toonzlib/tpalettehandle.cpp +++ b/toonz/sources/toonzlib/tpalettehandle.cpp @@ -142,9 +142,11 @@ void TPaletteHandle::setPalette(TPalette *palette, int styleIndex) { } //----------------------------------------------------------------------------- +// forceEmit flag is used in PageViewer. +// See the function PageViewer::setCurrentStyleIndex() in paletteviewergui.cpp -void TPaletteHandle::setStyleIndex(int index) { - if (m_styleIndex != index || m_styleParamIndex != 0) { +void TPaletteHandle::setStyleIndex(int index, bool forceEmit) { + if (m_styleIndex != index || m_styleParamIndex != 0 || forceEmit) { m_styleIndex = index; m_styleParamIndex = 0; emit broadcastColorStyleSwitched(); diff --git a/toonz/sources/toonzqt/paletteviewergui.cpp b/toonz/sources/toonzqt/paletteviewergui.cpp index 2bb782a3..db6c68e2 100644 --- a/toonz/sources/toonzqt/paletteviewergui.cpp +++ b/toonz/sources/toonzqt/paletteviewergui.cpp @@ -212,7 +212,12 @@ TFrameHandle *PageViewer::getFrameHandle() const { return m_frameHandle; } //----------------------------------------------------------------------------- void PageViewer::setCurrentStyleIndex(int index) { - getPaletteHandle()->setStyleIndex(index); + // When clicking and switching between studio palette and level palette, the + // signal broadcastColorStyleSwitched is not emitted if the clicked style is + // previously selected one. + // Therefore here I introduced the "forceEmit" flag here in order to emit the + // signal whenever the style is clicked. + getPaletteHandle()->setStyleIndex(index, true); } //-----------------------------------------------------------------------------