From 55822841a272e5eaeaa18cdd88de8bba174a4836 Mon Sep 17 00:00:00 2001 From: shun-iwasawa Date: Aug 02 2019 09:06:02 +0000 Subject: fix update styleeditor on picking style (#2615) --- diff --git a/toonz/sources/include/toonz/tapplication.h b/toonz/sources/include/toonz/tapplication.h index 3386376..0948e3c 100644 --- a/toonz/sources/include/toonz/tapplication.h +++ b/toonz/sources/include/toonz/tapplication.h @@ -49,7 +49,8 @@ public: // Current Palette (PaletteController) methods virtual TColorStyle *getCurrentLevelStyle() const = 0; virtual int getCurrentLevelStyleIndex() const = 0; - virtual void setCurrentLevelStyleIndex(int index) = 0; + virtual void setCurrentLevelStyleIndex(int index, + bool forceUpdate = false) = 0; }; #endif // TAPPLICATION_H diff --git a/toonz/sources/tnztools/stylepickertool.cpp b/toonz/sources/tnztools/stylepickertool.cpp index b8b7d77..fc5fe81 100644 --- a/toonz/sources/tnztools/stylepickertool.cpp +++ b/toonz/sources/tnztools/stylepickertool.cpp @@ -63,14 +63,15 @@ StylePickerTool::StylePickerTool() void StylePickerTool::leftButtonDown(const TPointD &pos, const TMouseEvent &e) { m_oldStyleId = m_currentStyleId = getApplication()->getCurrentLevelStyleIndex(); - pick(pos, e); + pick(pos, e, false); } void StylePickerTool::leftButtonDrag(const TPointD &pos, const TMouseEvent &e) { pick(pos, e); } -void StylePickerTool::pick(const TPointD &pos, const TMouseEvent &e) { +void StylePickerTool::pick(const TPointD &pos, const TMouseEvent &e, + bool isDragging) { // Area = 0, Line = 1, All = 2 int modeValue = m_colorType.getIndex(); @@ -132,7 +133,8 @@ void StylePickerTool::pick(const TPointD &pos, const TMouseEvent &e) { ->getSelection() ->selectNone(); /*-- StyleIdの移動 --*/ - getApplication()->setCurrentLevelStyleIndex(superPicked_StyleId); + getApplication()->setCurrentLevelStyleIndex(superPicked_StyleId, + !isDragging); return; } } @@ -181,7 +183,12 @@ void StylePickerTool::pick(const TPointD &pos, const TMouseEvent &e) { if (styleSelection) styleSelection->selectNone(); } - getApplication()->setCurrentLevelStyleIndex(styleId); + // When clicking and switching between studio palette and level palette, the + // signal broadcastColorStyleSwitched is not emitted if the picked style is + // previously selected one. + // Therefore here I set the "forceEmit" flag to true in order to emit the + // signal whenever the picking with mouse press. + getApplication()->setCurrentLevelStyleIndex(styleId, !isDragging); } void StylePickerTool::mouseMove(const TPointD &pos, const TMouseEvent &e) { diff --git a/toonz/sources/tnztools/stylepickertool.h b/toonz/sources/tnztools/stylepickertool.h index de3fb68..65a46c7 100644 --- a/toonz/sources/tnztools/stylepickertool.h +++ b/toonz/sources/tnztools/stylepickertool.h @@ -36,7 +36,7 @@ public: void leftButtonDrag(const TPointD &pos, const TMouseEvent &e) override; - void pick(const TPointD &pos, const TMouseEvent &e); + void pick(const TPointD &pos, const TMouseEvent &e, bool isDragging = true); void mouseMove(const TPointD &pos, const TMouseEvent &e) override; diff --git a/toonz/sources/toonz/tapp.cpp b/toonz/sources/toonz/tapp.cpp index 8318336..023c520 100644 --- a/toonz/sources/toonz/tapp.cpp +++ b/toonz/sources/toonz/tapp.cpp @@ -267,8 +267,9 @@ int TApp::getCurrentLevelStyleIndex() const { //----------------------------------------------------------------------------- -void TApp::setCurrentLevelStyleIndex(int index) { - m_paletteController->getCurrentLevelPalette()->setStyleIndex(index); +void TApp::setCurrentLevelStyleIndex(int index, bool forceUpdate) { + m_paletteController->getCurrentLevelPalette()->setStyleIndex(index, + forceUpdate); } //----------------------------------------------------------------------------- diff --git a/toonz/sources/toonz/tapp.h b/toonz/sources/toonz/tapp.h index ae97c52..ec5695a 100644 --- a/toonz/sources/toonz/tapp.h +++ b/toonz/sources/toonz/tapp.h @@ -160,7 +160,7 @@ public: int getCurrentLevelStyleIndex() const override; - void setCurrentLevelStyleIndex(int index) override; + void setCurrentLevelStyleIndex(int index, bool forceUpdate = false) override; void setMainWindow(QMainWindow *mainWindow) { m_mainWindow = mainWindow; } /*! diff --git a/toonz/sources/toonzlib/tpalettehandle.cpp b/toonz/sources/toonzlib/tpalettehandle.cpp index 7a310b1..a653b5b 100644 --- a/toonz/sources/toonzlib/tpalettehandle.cpp +++ b/toonz/sources/toonzlib/tpalettehandle.cpp @@ -153,8 +153,9 @@ void TPaletteHandle::setPalette(TPalette *palette, int styleIndex) { } //----------------------------------------------------------------------------- -// forceEmit flag is used in PageViewer. +// forceEmit flag is used in PageViewer and StylePicker tool. // See the function PageViewer::setCurrentStyleIndex() in paletteviewergui.cpp +// Also see the function StylePickerTool::pick() in stylepickertool.cpp void TPaletteHandle::setStyleIndex(int index, bool forceEmit) { if (m_styleIndex != index || m_styleParamIndex != 0 || forceEmit) {