diff --git a/toonz/sources/include/toonz/txshzeraryfxcolumn.h b/toonz/sources/include/toonz/txshzeraryfxcolumn.h index 07730a3..9cdcfeb 100644 --- a/toonz/sources/include/toonz/txshzeraryfxcolumn.h +++ b/toonz/sources/include/toonz/txshzeraryfxcolumn.h @@ -37,7 +37,11 @@ class DVAPI TXshZeraryFxColumn final : public TXshCellColumn { TZeraryColumnFx *m_zeraryColumnFx; TXshZeraryFxLevel *m_zeraryFxLevel; + bool m_iconVisible; + public: + bool isIconVisible() { return m_iconVisible; } + void setIconVisible(bool visible) { m_iconVisible = visible; } /*! Constructs a TXshZeraryFxColumn with default value. */ diff --git a/toonz/sources/include/toonzqt/fxiconmanager.h b/toonz/sources/include/toonzqt/fxiconmanager.h index 25c2b09..8d84466 100644 --- a/toonz/sources/include/toonzqt/fxiconmanager.h +++ b/toonz/sources/include/toonzqt/fxiconmanager.h @@ -8,6 +8,17 @@ #define FXICONMANAGER_H #include "tcommon.h" +#include + +#undef DVAPI +#undef DVVAR +#ifdef TOONZQT_EXPORTS +#define DVAPI DV_EXPORT_API +#define DVVAR DV_EXPORT_VAR +#else +#define DVAPI DV_IMPORT_API +#define DVVAR DV_IMPORT_VAR +#endif class QPixmap; @@ -136,13 +147,17 @@ const struct { {0, 0}}; }; -class FxIconPixmapManager { // singleton +class DVAPI FxIconPixmapManager final : public QObject { // singleton + Q_OBJECT + +public: std::map m_pms; +public: FxIconPixmapManager(); + ~FxIconPixmapManager(); -public: static FxIconPixmapManager *instance(); const QPixmap &getFxIconPm(std::string type); diff --git a/toonz/sources/toonz/xshcolumnviewer.cpp b/toonz/sources/toonz/xshcolumnviewer.cpp index bf31ee1..5562eed 100644 --- a/toonz/sources/toonz/xshcolumnviewer.cpp +++ b/toonz/sources/toonz/xshcolumnviewer.cpp @@ -17,6 +17,7 @@ #include "toonzqt/gutil.h" #include "toonzqt/icongenerator.h" #include "toonzqt/intfield.h" +#include "toonzqt/fxiconmanager.h" // TnzLib includes #include "toonz/txshcolumn.h" @@ -1061,29 +1062,18 @@ void ColumnArea::DrawHeader::drawThumbnail(QPixmap &iconPixmap) const { // All other thumbnails p.setPen(m_viewer->getTextColor()); - // for zerary fx, display fxId here instead of thumbnail - TXshZeraryFxColumn *zColumn = dynamic_cast(column); - if (zColumn) { - QFont lastfont = p.font(); - QFont font("Verdana", 8); - p.setFont(font); - - TFx *fx = zColumn->getZeraryColumnFx()->getZeraryFx(); - QString fxName = QString::fromStdWString(fx->getFxId()); - p.drawText(thumbnailImageRect, Qt::TextWrapAnywhere | Qt::TextWordWrap, - fxName); - p.setFont(lastfont); + TXshLevelColumn *levelColumn = column->getLevelColumn(); + TXshMeshColumn *meshColumn = column->getMeshColumn(); + TXshZeraryFxColumn *zColumn = dynamic_cast(column); + + if (Preferences::instance()->getColumnIconLoadingPolicy() == + Preferences::LoadOnDemand && + ((levelColumn && !levelColumn->isIconVisible()) || + (meshColumn && !meshColumn->isIconVisible()) || + (zColumn && !zColumn->isIconVisible())) && + col >= 0) { + // display nothing } else { - TXshLevelColumn *levelColumn = column->getLevelColumn(); - TXshMeshColumn *meshColumn = column->getMeshColumn(); - - if (Preferences::instance()->getColumnIconLoadingPolicy() == - Preferences::LoadOnDemand && - ((levelColumn && !levelColumn->isIconVisible()) || - (meshColumn && !meshColumn->isIconVisible())) && - col >= 0) { - // display nothing - } else { if (!iconPixmap.isNull()) { p.drawPixmap(thumbnailImageRect, iconPixmap); } @@ -1092,6 +1082,8 @@ void ColumnArea::DrawHeader::drawThumbnail(QPixmap &iconPixmap) const { levelColumn->setIconVisible(true); else if (meshColumn) meshColumn->setIconVisible(true); + else if (zColumn) + zColumn->setIconVisible(true); } } } @@ -1651,21 +1643,28 @@ QPixmap ColumnArea::getColumnIcon(int columnIndex) { if (!xl) return QPixmap(); else { - bool onDemand = false; + TXshColumn *column = xsh->getColumn(columnIndex); + TXshZeraryFxColumn *zColumn = dynamic_cast(column); + bool onDemand = false; if (Preferences::instance()->getColumnIconLoadingPolicy() == Preferences::LoadOnDemand) { onDemand = m_viewer->getCurrentColumn() != columnIndex; if (!onDemand) { - TXshColumn *column = xsh->getColumn(columnIndex); + TXshLevelColumn *levelColumn = column->getLevelColumn(); TXshMeshColumn *meshColumn = column->getMeshColumn(); if ((levelColumn && !levelColumn->isIconVisible()) || - (meshColumn && !meshColumn->isIconVisible())) + (meshColumn && !meshColumn->isIconVisible()) || + (zColumn && !zColumn->isIconVisible())) return QPixmap(); } } QPixmap icon = - IconGenerator::instance()->getIcon(xl, cell.m_frameId, false, onDemand); + zColumn + ? FxIconPixmapManager::instance()->getFxIconPm( + zColumn->getZeraryColumnFx()->getZeraryFx()->getFxType()) + : IconGenerator::instance()->getIcon(xl, cell.m_frameId, false, + onDemand); QRect thumbnailImageRect = o->rect(PredefinedRect::THUMBNAIL); if (thumbnailImageRect.isEmpty()) return QPixmap(); return scalePixmapKeepingAspectRatio(icon, thumbnailImageRect.size()); @@ -2229,6 +2228,8 @@ void ColumnArea::mousePressEvent(QMouseEvent *event) { // toggle columnIcon visibility with alt+click TXshLevelColumn *levelColumn = column->getLevelColumn(); TXshMeshColumn *meshColumn = column->getMeshColumn(); + TXshZeraryFxColumn *zColumn = + dynamic_cast(column); if (Preferences::instance()->getColumnIconLoadingPolicy() == Preferences::LoadOnDemand && (event->modifiers() & Qt::AltModifier)) { @@ -2236,6 +2237,8 @@ void ColumnArea::mousePressEvent(QMouseEvent *event) { levelColumn->setIconVisible(!levelColumn->isIconVisible()); else if (meshColumn) meshColumn->setIconVisible(!meshColumn->isIconVisible()); + else if (zColumn) + zColumn->setIconVisible(!zColumn->isIconVisible()); } } } diff --git a/toonz/sources/toonzlib/txshzeraryfxcolumn.cpp b/toonz/sources/toonzlib/txshzeraryfxcolumn.cpp index ccc5388..03c125f 100644 --- a/toonz/sources/toonzlib/txshzeraryfxcolumn.cpp +++ b/toonz/sources/toonzlib/txshzeraryfxcolumn.cpp @@ -15,7 +15,8 @@ TXshZeraryFxColumn::TXshZeraryFxColumn(int frameCount) : m_zeraryColumnFx(new TZeraryColumnFx()) - , m_zeraryFxLevel(new TXshZeraryFxLevel()) { + , m_zeraryFxLevel(new TXshZeraryFxLevel()) + , m_iconVisible(false) { m_zeraryColumnFx->addRef(); m_zeraryColumnFx->setColumn(this); m_zeraryFxLevel->addRef(); diff --git a/toonz/sources/toonzqt/CMakeLists.txt b/toonz/sources/toonzqt/CMakeLists.txt index eb8536a..6c8451e 100644 --- a/toonz/sources/toonzqt/CMakeLists.txt +++ b/toonz/sources/toonzqt/CMakeLists.txt @@ -27,6 +27,7 @@ set(MOC_HEADERS ../include/toonzqt/functiontreeviewer.h ../include/toonzqt/functionviewer.h ../include/toonzqt/fxhistogramrender.h + ../include/toonzqt/fxiconmanager.h ../include/toonzqt/fxschematicnode.h ../include/toonzqt/fxschematicscene.h ../include/toonzqt/fxselection.h @@ -87,7 +88,6 @@ set(HEADERS ../include/toonzqt/dvmimedata.h ../include/toonzqt/flipconsoleowner.h ../include/toonzqt/freelayout.h - ../include/toonzqt/fxiconmanager.h ../include/toonzqt/fxtypes.h ../include/toonzqt/glwidget_for_highdpi.h ../include/toonzqt/lutcalibrator.h diff --git a/toonz/sources/toonzqt/fxiconmanager.cpp b/toonz/sources/toonzqt/fxiconmanager.cpp index a423a0a..d5da64a 100644 --- a/toonz/sources/toonzqt/fxiconmanager.cpp +++ b/toonz/sources/toonzqt/fxiconmanager.cpp @@ -4,6 +4,8 @@ FxIconPixmapManager::FxIconPixmapManager() {} +FxIconPixmapManager::~FxIconPixmapManager() {} + FxIconPixmapManager *FxIconPixmapManager::instance() { static FxIconPixmapManager _instance; return &_instance;