OpenToonz - An open-source full-featured 2D animation creation software
C
organize palette 2
shun_iwasawa48c6711cad1f
diff --git a/toonz/sources/include/toonz/palettecmd.h b/toonz/sources/include/toonz/palettecmd.hindex bca5440c9..cc37f9d27 100644--- a/toonz/sources/include/toonz/palettecmd.h+++ b/toonz/sources/include/toonz/palettecmd.h@@ -88,6 +88,9 @@ DVAPI void renamePalettePage(TPaletteHandle *paletteHandle, int pageIndex,DVAPI void renamePaletteStyle(TPaletteHandle *paletteHandle,const std::wstring &newName);+/* called in ColorModelViewer::pick() - move selected style to the first page */+DVAPI void organizePaletteStyle(TPaletteHandle *paletteHandle, int styleId);+} // namespace#endifdiff --git a/toonz/sources/toonz/colormodelviewer.cpp b/toonz/sources/toonz/colormodelviewer.cppindex 69e207fd2..474a3e03c 100644--- a/toonz/sources/toonz/colormodelviewer.cpp+++ b/toonz/sources/toonz/colormodelviewer.cpp@@ -308,10 +308,16 @@ void ColorModelViewer::pick(const QPoint &p) {}/*- if the Style Picker too is current and "organize palette" is activated,+ if the Style Picker tool is current and "organize palette" is activated,then move the picked style to the first page of the palette.*/- //TODO: write organize palette operation here (maybe implement in PaletteCmd)+ TTool *tool = TApp::instance()->getCurrentTool()->getTool();+ if (tool->getName() == "T_StylePicker"){+ StylePickerTool* spTool = dynamic_cast<StylePickerTool*>(tool);+ if (spTool && spTool->isOrganizePaletteActive()){+ PaletteCmd::organizePaletteStyle(ph, styleIndex);+ }+ }ph->setStyleIndex(styleIndex);}diff --git a/toonz/sources/toonzlib/palettecmd.cpp b/toonz/sources/toonzlib/palettecmd.cppindex 30a03904b..5c375bd9a 100644--- a/toonz/sources/toonzlib/palettecmd.cpp+++ b/toonz/sources/toonzlib/palettecmd.cpp@@ -1168,3 +1168,26 @@ void PaletteCmd::renamePaletteStyle(TPaletteHandle *paletteHandle,paletteHandle->notifyColorStyleChanged(false);TUndoManager::manager()->add(undo);}++//=============================================================================+// organizePaletteStyle+// called in ColorModelViewer::pick() - move selected style to the first page+//-----------------------------------------------------------------------------+void PaletteCmd::organizePaletteStyle(TPaletteHandle *paletteHandle, int styleId){+ if (!paletteHandle) return;+ TPalette *palette = paletteHandle->getPalette();+ if (!palette) return;+ // if the style is already in the first page, then do nothing+ TPalette::Page* page = palette->getStylePage(styleId);+ if (!page || page->getIndex() == 0) return;++ int indexInPage = page->search(styleId);++ /*+ just call arrangeStyles as tentative implementation.+ TODO: store the picked position into the style name somehow+ */+ arrangeStyles(paletteHandle, 0, palette->getPage(0)->getStyleCount(),+ page->getIndex(), { indexInPage });++}