From 75e23d520d4dae9c81e0c0305f0e325142e0e103 Mon Sep 17 00:00:00 2001 From: manongjohn <19245851+manongjohn@users.noreply.github.com> Date: Fri, 2 Dec 2022 15:24:24 -0500 Subject: [PATCH] Fix moving styles in palette --- toonz/sources/common/tvrender/tpalette.cpp | 7 ++++--- toonz/sources/include/tpalette.h | 6 ++++-- toonz/sources/toonzlib/palettecmd.cpp | 6 +++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/toonz/sources/common/tvrender/tpalette.cpp b/toonz/sources/common/tvrender/tpalette.cpp index f0e2c198..c1371b53 100644 --- a/toonz/sources/common/tvrender/tpalette.cpp +++ b/toonz/sources/common/tvrender/tpalette.cpp @@ -202,15 +202,16 @@ void TPalette::Page::insertStyle(int indexInPage, TPixel32 color) { //------------------------------------------------------------------- -void TPalette::Page::removeStyle(int indexInPage) { +void TPalette::Page::removeStyle(int indexInPage, bool flagOnly) { if (indexInPage < 0 || indexInPage >= getStyleCount()) return; assert(m_palette); int styleId = getStyleId(indexInPage); assert(0 <= styleId && styleId < m_palette->getStyleCount()); assert(m_palette->m_styles[styleId].first == this); m_palette->m_styles[styleId].first = 0; - m_palette->m_styles[styleId].second = - TColorStyleP(new TSolidColorStyle(TPixel32::Black)); + if (!flagOnly) + m_palette->m_styles[styleId].second = + TColorStyleP(new TSolidColorStyle(TPixel32::Black)); m_styleIds.erase(m_styleIds.begin() + indexInPage); } diff --git a/toonz/sources/include/tpalette.h b/toonz/sources/include/tpalette.h index 869ef819..83da87bd 100644 --- a/toonz/sources/include/tpalette.h +++ b/toonz/sources/include/tpalette.h @@ -163,8 +163,10 @@ public: //! its //! id at the specified position in the page. - void removeStyle(int indexInPage); //!< Removes the style at the specified - //! position from this page. + void removeStyle( + int indexInPage, + bool flagOnly = false); //!< Removes the style at the specified + //! position from this page. int search(int styleId) const; //!< Returns the page position of the specified style id, //! or \p -1 if it cannot be found on the page. diff --git a/toonz/sources/toonzlib/palettecmd.cpp b/toonz/sources/toonzlib/palettecmd.cpp index 47dee647..1bc38fdd 100644 --- a/toonz/sources/toonzlib/palettecmd.cpp +++ b/toonz/sources/toonzlib/palettecmd.cpp @@ -212,7 +212,7 @@ public: int k; for (k = 0; k < count; k++) { styles.push_back(dstPage->getStyleId(h)); - dstPage->removeStyle(h); + dstPage->removeStyle(h, true); } k = 0; for (i = m_srcIndicesInPage.begin(); i != m_srcIndicesInPage.end(); @@ -235,7 +235,7 @@ public: int index = *i; if (m_dstPageIndex == m_srcPageIndex && index < k) k--; styles.push_back(srcPage->getStyleId(index)); - srcPage->removeStyle(index); + srcPage->removeStyle(index, true); } for (j = styles.begin(); j != styles.end(); ++j) dstPage->insertStyle(k, *j); @@ -300,7 +300,7 @@ public: assert(page); int indexInPage = page->search(m_styleId); assert(indexInPage >= 0); - page->removeStyle(indexInPage); + page->removeStyle(indexInPage, true); m_paletteHandle->notifyPaletteChanged(); } void redo() const override {