Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

Default Palettes (#5818)

Abel_You2c14ce0e94aa
diff --git a/stuff/studiopalette/cleanup_default.tpl b/stuff/studiopalette/Global Palettes/Default Palettes/Cleanup_Palette.tpl
similarity index 100%
rename from stuff/studiopalette/cleanup_default.tpl
rename to stuff/studiopalette/Global Palettes/Default Palettes/Cleanup_Palette.tpl
diff --git a/stuff/studiopalette/Global Palettes/Default Palettes/Raster_Drawing_Palette.tpl b/stuff/studiopalette/Global Palettes/Default Palettes/Raster_Drawing_Palette.tpl
new file mode 100644
index 000000000..b20b3f886
--- /dev/null
+++ b/stuff/studiopalette/Global Palettes/Default Palettes/Raster_Drawing_Palette.tpl
@@ -0,0 +1,28 @@
+<palette id='1'>
+
+ <version>
+ 71 0
+ </version>
+ <styles>
+ <style>
+ color_0 3 255 255 255 0
+ </style>
+ <style>
+ color_1 3 0 0 0 255
+ </style>
+ </styles>
+ <stylepages>
+ <page>
+ <name>
+ colors
+ </name>
+ <indices>
+ 0 1
+ </indices>
+ </page>
+ </stylepages>
+ <shortcuts>
+ -1 0 1 -1 -1 -1 -1 -1 -1 -1
+ </shortcuts>
+
+</palette>
diff --git a/stuff/studiopalette/Global Palettes/Default Palettes/Toonz_Raster_Palette.tpl b/stuff/studiopalette/Global Palettes/Default Palettes/Toonz_Raster_Palette.tpl
new file mode 100644
index 000000000..b20b3f886
--- /dev/null
+++ b/stuff/studiopalette/Global Palettes/Default Palettes/Toonz_Raster_Palette.tpl
@@ -0,0 +1,28 @@
+<palette id='1'>
+
+ <version>
+ 71 0
+ </version>
+ <styles>
+ <style>
+ color_0 3 255 255 255 0
+ </style>
+ <style>
+ color_1 3 0 0 0 255
+ </style>
+ </styles>
+ <stylepages>
+ <page>
+ <name>
+ colors
+ </name>
+ <indices>
+ 0 1
+ </indices>
+ </page>
+ </stylepages>
+ <shortcuts>
+ -1 0 1 -1 -1 -1 -1 -1 -1 -1
+ </shortcuts>
+
+</palette>
diff --git a/stuff/studiopalette/Global Palettes/Default Palettes/Toonz_Vector_Palette.tpl b/stuff/studiopalette/Global Palettes/Default Palettes/Toonz_Vector_Palette.tpl
new file mode 100644
index 000000000..b20b3f886
--- /dev/null
+++ b/stuff/studiopalette/Global Palettes/Default Palettes/Toonz_Vector_Palette.tpl
@@ -0,0 +1,28 @@
+<palette id='1'>
+
+ <version>
+ 71 0
+ </version>
+ <styles>
+ <style>
+ color_0 3 255 255 255 0
+ </style>
+ <style>
+ color_1 3 0 0 0 255
+ </style>
+ </styles>
+ <stylepages>
+ <page>
+ <name>
+ colors
+ </name>
+ <indices>
+ 0 1
+ </indices>
+ </page>
+ </stylepages>
+ <shortcuts>
+ -1 0 1 -1 -1 -1 -1 -1 -1 -1
+ </shortcuts>
+
+</palette>
diff --git a/toonz/sources/include/toonzqt/studiopaletteviewer.h b/toonz/sources/include/toonzqt/studiopaletteviewer.h
index b5aa268d0..38cdbb8a1 100644
--- a/toonz/sources/include/toonzqt/studiopaletteviewer.h
+++ b/toonz/sources/include/toonzqt/studiopaletteviewer.h
@@ -135,6 +135,8 @@ public slots:
void deleteItems();
/*! Open a \b PalettesScanPopup. */
void searchForPalette();
+ /*! Open a popup. */
+ void setAsDefault();
/*! Recall \b StudioPaletteCmd::loadIntoCurrentPalette. */
void loadInCurrentPalette();
void loadInCurrentPaletteAndAdaptLevel();
diff --git a/toonz/sources/tcleanupper/tcleanupper.cpp b/toonz/sources/tcleanupper/tcleanupper.cpp
index b62da1ad7..507b4f724 100644
--- a/toonz/sources/tcleanupper/tcleanupper.cpp
+++ b/toonz/sources/tcleanupper/tcleanupper.cpp
@@ -309,7 +309,8 @@ static void searchLevelsToCleanup(
static void addCleanupDefaultPalette(TXshSimpleLevel *sl) {
/*- 元となるパレットはStudioPaletteフォルダに置く -*/
TFilePath palettePath =
- ToonzFolder::getStudioPaletteFolder() + "cleanup_default.tpl";
+ ToonzFolder::getStudioPaletteFolder() +
+ "Global Palettes\\Default Palettes\\Cleanup_Palette.tpl ";
TFileStatus pfs(palettePath);
if (!pfs.doesExist() || !pfs.isReadable()) {
diff --git a/toonz/sources/toonz/cleanuppopup.cpp b/toonz/sources/toonz/cleanuppopup.cpp
index 89c9c9c9a..8d0f7619b 100644
--- a/toonz/sources/toonz/cleanuppopup.cpp
+++ b/toonz/sources/toonz/cleanuppopup.cpp
@@ -192,7 +192,7 @@ Cleanup後にデフォルトPaletteの内容を追加する仕様、Preferences
void addCleanupDefaultPalette(TXshSimpleLevelP sl) {
/*--- CleanupデフォルトパレットはStudioPaletteフォルダ内に入れる ---*/
TFilePath palettePath =
- ToonzFolder::getStudioPaletteFolder() + "cleanup_default.tpl";
+ ToonzFolder::getStudioPaletteFolder() + "Global Palettes\\Default Palettes\\Cleanup_Palette.tpl";
TFileStatus pfs(palettePath);
if (!pfs.doesExist() || !pfs.isReadable()) {
diff --git a/toonz/sources/toonz/convertpopup.cpp b/toonz/sources/toonz/convertpopup.cpp
index c3d8d77e8..51b5e599a 100644
--- a/toonz/sources/toonz/convertpopup.cpp
+++ b/toonz/sources/toonz/convertpopup.cpp
@@ -605,7 +605,7 @@ QFrame *ConvertPopup::createTlvSettings() {
m_appendDefaultPalette->setToolTip(
tr("When activated, styles of the default "
- "palette\n($TOONZSTUDIOPALETTE\\cleanup_default.tpl) will \nbe "
+ "palette\n($TOONZSTUDIOPALETTE\\Global Palettes\\Default Palettes\\Cleanup_Palette.tpl) will \nbe "
"appended to the palette after conversion in \norder to save the "
"effort of creating styles \nbefore color designing."));
diff --git a/toonz/sources/toonzlib/convert2tlv.cpp b/toonz/sources/toonzlib/convert2tlv.cpp
index a937dc6f6..d62282364 100644
--- a/toonz/sources/toonzlib/convert2tlv.cpp
+++ b/toonz/sources/toonzlib/convert2tlv.cpp
@@ -587,7 +587,8 @@ TPalette *Convert2Tlv::buildPalette() {
/*-- Adding styles in the default palette to the result palette, starts here
* --*/
TFilePath palettePath =
- ToonzFolder::getStudioPaletteFolder() + "cleanup_default.tpl";
+ ToonzFolder::getStudioPaletteFolder() +
+ "Global Palettes\\Default Palettes\\Cleanup_Palette.tpl";
TFileStatus pfs(palettePath);
if (!pfs.doesExist() || !pfs.isReadable()) return m_palette;
diff --git a/toonz/sources/toonzlib/fullcolorpalette.cpp b/toonz/sources/toonzlib/fullcolorpalette.cpp
index b3e0ecf7c..875cc9853 100644
--- a/toonz/sources/toonzlib/fullcolorpalette.cpp
+++ b/toonz/sources/toonzlib/fullcolorpalette.cpp
@@ -3,6 +3,7 @@
#include "toonz/fullcolorpalette.h"
#include "toonz/tscenehandle.h"
#include "toonz/toonzscene.h"
+#include "toonz/toonzfolders.h"
#include "tsystem.h"
#include "tstream.h"
#include "tpalette.h"
@@ -48,13 +49,17 @@ TPalette *FullColorPalette::getPalette(ToonzScene *scene) {
TFilePath app("+palettes\\fullcolorPalette.tpl");
fullPath = scene->decodeFilePath(app);
}
+ if (!TSystem::doesExistFileOrLevel(fullPath)) {
+ fullPath = ToonzFolder::getStudioPaletteFolder() +
+ "Global Palettes\\Default Palettes\\Raster_Drawing_Palette.tpl";
+ }
if (TSystem::doesExistFileOrLevel(fullPath)) {
TPalette *app = new TPalette();
TIStream is(fullPath);
is >> app;
m_palette->assign(app);
delete app;
- }
+ }
m_palette->setPaletteName(L"Raster Drawing Palette");
return m_palette;
diff --git a/toonz/sources/toonzlib/txshsimplelevel.cpp b/toonz/sources/toonzlib/txshsimplelevel.cpp
index 8233c0a13..cd83442ad 100644
--- a/toonz/sources/toonzlib/txshsimplelevel.cpp
+++ b/toonz/sources/toonzlib/txshsimplelevel.cpp
@@ -44,6 +44,7 @@
#include <QtCore>
#include "../common/psdlib/psd.h"
+#include "toonz/toonzfolders.h"
//******************************************************************************************
// Global stuff
@@ -1966,16 +1967,60 @@ void TXshSimpleLevel::invalidateFrame(const TFrameId &fid) {
//-----------------------------------------------------------------------------
// note that the palette will always be replaced by the new one.
void TXshSimpleLevel::initializePalette() {
- assert(getScene());
+ ToonzScene *scene = getScene();
+ assert(scene);
+
+ TFilePath fullPath;
+ TPalette *palette = new TPalette();
int type = getType();
- if (type == TZP_XSHLEVEL || type == PLI_XSHLEVEL) setPalette(new TPalette());
- if (type == OVL_XSHLEVEL)
- setPalette(FullColorPalette::instance()->getPalette(getScene()));
- TPalette *palette = getPalette();
+ switch (type) {
+ case TZP_XSHLEVEL:
+ fullPath =
+ scene->decodeFilePath(TFilePath("+palettes\\Toonz_Raster_Palette.tpl"));
+ if (TSystem::doesExistFileOrLevel(fullPath)) {
+ TIStream is(fullPath);
+ is >> palette;
+ } else {
+ TFilePath globalPath(
+ ToonzFolder::getStudioPaletteFolder().getQString().append(
+ "\\Global Palettes\\Default Palettes\\Toonz_Raster_Palette.tpl"));
+ if (TSystem::doesExistFileOrLevel(globalPath)) {
+ TIStream is(globalPath);
+ is >> palette;
+ TSystem::copyFile(fullPath, globalPath);
+ }
+ }
+ break;
+ case PLI_XSHLEVEL:
+ fullPath =
+ scene->decodeFilePath(TFilePath("+palettes\\Toonz_Vector_Palette.tpl"));
+ if (TSystem::doesExistFileOrLevel(fullPath)) {
+ TIStream is(fullPath);
+ is >> palette;
+ } else {
+ TFilePath globalPath(
+ ToonzFolder::getStudioPaletteFolder().getQString().append(
+ "\\Global Palettes\\Default Palettes\\Toonz_Vector_Palette.tpl"));
+ if (TSystem::doesExistFileOrLevel(globalPath)) {
+ TIStream is(globalPath);
+ is >> palette;
+ TSystem::copyFile(fullPath, globalPath);
+ }
+ }
+ break;
+ case OVL_XSHLEVEL:
+ palette = FullColorPalette::instance()->getPalette(getScene());
+ default:
+ break;
+ }
+
+
if (palette && type != OVL_XSHLEVEL) {
palette->setPaletteName(getName());
- palette->setDirtyFlag(true);
}
+
+ palette->setDirtyFlag(true);
+ setPalette(palette);
}
//-----------------------------------------------------------------------------
diff --git a/toonz/sources/toonzqt/dvdialog.cpp b/toonz/sources/toonzqt/dvdialog.cpp
index 2d9c19dc0..ccf80f41a 100644
--- a/toonz/sources/toonzqt/dvdialog.cpp
+++ b/toonz/sources/toonzqt/dvdialog.cpp
@@ -880,7 +880,7 @@ int DVGui::RadioButtonMsgBox(MsgType type, const QString &labelText,
QWidget *parent) {
RadioButtonDialog *dialog =
new RadioButtonDialog(labelText, radioButtonList, parent);
- QString msgBoxTitle = getMsgBoxTitle(DVGui::WARNING);
+ QString msgBoxTitle = getMsgBoxTitle(type);
dialog->setWindowTitle(msgBoxTitle);
return dialog->exec();
}
diff --git a/toonz/sources/toonzqt/studiopaletteviewer.cpp b/toonz/sources/toonzqt/studiopaletteviewer.cpp
index a0c599107..b32cc24b2 100644
--- a/toonz/sources/toonzqt/studiopaletteviewer.cpp
+++ b/toonz/sources/toonzqt/studiopaletteviewer.cpp
@@ -27,6 +27,7 @@
#include "tconvert.h"
#include "tundo.h"
#include "tsystem.h"
+#include "tcolorstyles.h"
#include "../toonz/menubarcommandids.h"
@@ -668,6 +669,78 @@ void StudioPaletteTreeViewer::searchForPalette() {
if (ret == QDialog::Accepted) refresh();
}
+void StudioPaletteTreeViewer::setAsDefault() {
+ TFilePath srcPath = getCurrentItemPath();
+ if (srcPath.isEmpty()) return;
+ StudioPalette *studioPalette = StudioPalette::instance();
+
+ std::string fileName;
+ TFilePath folderPath;
+ TFilePath dstPath;
+
+ QString label =
+ QObject::tr("Set As...");
+ QStringList radioButtons;
+ radioButtons.append(QString("Default Toonz Raster Palette"));
+ radioButtons.append(QString("Default Toonz Vector Palette"));
+ radioButtons.append(QString("Default Raster Drawing Palette"));
+ radioButtons.append(QString("Default Cleanup Palette"));
+
+ int type = DVGui::RadioButtonMsgBox(DVGui::QUESTION,label, radioButtons, this);
+
+ switch (type) {
+ case 1:
+ fileName = "Toonz_Raster_Palette.tpl";
+ break;
+ case 2:
+ fileName = "Toonz_Vector_Palette.tpl";
+ break;
+ case 3:
+ fileName = "Raster_Drawing_Palette.tpl";
+ break;
+ case 4:
+ fileName = "Cleanup_Palette.tpl";
+ folderPath = studioPalette->getLevelPalettesRoot() + "Default Palettes";
+ TSystem::copyFile(folderPath + fileName, srcPath, true);
+ return;
+ default :
+ return;
+ }
+
+ TPalette *srcPalette = studioPalette->getPalette(srcPath);
+ if (!srcPalette) return;
+
+ // Remove all Link
+ for (int i = 0; i < srcPalette->getPageCount(); ++i) {
+ TPalette::Page *page = srcPalette->getPage(i);
+ for (int j = 0; j < page->getStyleCount(); ++j) {
+ TColorStyle *cs = page->getStyle(j);
+ cs->setGlobalName(L"");
+ }
+ }
+
+ // Save Palette
+ folderPath = studioPalette->getProjectPalettesRoot();
+ dstPath = folderPath + fileName;
+ if (TSystem::doesExistFileOrLevel(dstPath))
+ TSystem::removeFileOrLevel(dstPath);
+ TOStream os(dstPath);
+ if(srcPalette)
+ os << srcPalette;
+
+ int policy = DVGui::MsgBox(QString("Apply to Global?"), QString("Yes"),
+ QString("No"), 0, this);
+ if (policy == 1) {
+ folderPath = studioPalette->getLevelPalettesRoot() + "Default Palettes";
+ dstPath = folderPath + fileName;
+ TOStream os(dstPath);
+ if (srcPalette) os << srcPalette;
+ }
+
+ delete srcPalette;
+ refresh();
+}
+
//-----------------------------------------------------------------------------
class InvalidateIconsUndo final : public TUndo {
@@ -906,6 +979,8 @@ void StudioPaletteTreeViewer::contextMenuEvent(QContextMenuEvent *event) {
createMenuAction(menu, "", tr("Delete Folder"), "deleteItems()");
} else if (studioPalette->isPalette(path)) {
if (m_studioPaletteHandle->getPalette()) {
+ createMenuAction(menu, "", tr("Set As..."), "setAsDefault()");
+ menu.addSeparator();
createMenuAction(menu, "MI_LoadIntoCurrentPalette",
tr("Load into Current Palette"),
"loadInCurrentPalette()");
@@ -936,6 +1011,7 @@ void StudioPaletteTreeViewer::contextMenuEvent(QContextMenuEvent *event) {
menu.addSeparator();
createMenuAction(menu, "", tr("Search for Palettes"),
"searchForPalette()");
+ createMenuAction(menu, "", tr("Refresh"), "onRefreshClicked()");
}
menu.exec(event->globalPos());
return;