1 #pragma once 2 3 #ifndef TXshPaletteLevel_INCLUDED 4 #define TXshPaletteLevel_INCLUDED 5 6 #include "toonz/txshlevel.h" 7 #include "tpalette.h" 8 #include <map> 9 #include <set> 10 11 #undef DVAPI 12 #undef DVVAR 13 #ifdef TOONZLIB_EXPORTS 14 #define DVAPI DV_EXPORT_API 15 #define DVVAR DV_EXPORT_VAR 16 #else 17 #define DVAPI DV_IMPORT_API 18 #define DVVAR DV_IMPORT_VAR 19 #endif 20 21 class TContentHistory; 22 23 //============================================================================= 24 //! The TXshPaletteLevel class represents a palette uncoupled from a level 25 /*!Inherits \b TXshLevel. 26 \n A palette can be loaded in the xsheet and subsequently can be used as 27 "external palette". The number of frames of the palette-level depends on 28 the palette animation. 29 30 */ 31 //============================================================================= 32 33 class DVAPI TXshPaletteLevel final : public TXshLevel { 34 private: 35 PERSIST_DECLARATION(TXshPaletteLevel) 36 37 TFilePath m_path; 38 TPalette *m_palette; 39 TContentHistory *m_contentHistory; 40 41 DECLARE_CLASS_CODE 42 43 public: 44 /*! 45 Constructs a TXshPaletteLevel with \b name 46 */ 47 TXshPaletteLevel(std::wstring name = L""); 48 49 /*! 50 Destroys the TXshPaletteLevel object. 51 */ 52 ~TXshPaletteLevel(); 53 54 /*! 55 Return the \b TXshPaletteLevel level (overridden from TXshLevel) 56 */ getPaletteLevel()57 TXshPaletteLevel *getPaletteLevel() override { return this; } 58 59 /*! 60 Return the \b TPalette 61 \sa setPalette() 62 */ 63 TPalette *getPalette() const; 64 65 /*! 66 Set the level palette to \b palette. 67 \sa getPalette() 68 */ 69 void setPalette(TPalette *palette); 70 71 /*! 72 Return level path. 73 \sa setPath() 74 */ getPath()75 TFilePath getPath() const override { return m_path; } 76 77 /*! 78 Set level path. 79 \sa getPath() 80 */ 81 void setPath(const TFilePath &path); 82 83 //! Returns the frame count. It depends on the palette animation: 84 //! for a not-animated palette getFrameCount() == 1 85 int getFrameCount() const override; 86 87 void loadData(TIStream &is) override; 88 void saveData(TOStream &os) override; 89 90 void load() override; 91 void save() override; 92 void save(const TFilePath &fp); 93 94 //! note gets the contentHistory. can be 0 getContentHistory()95 const TContentHistory *getContentHistory() const { return m_contentHistory; } getContentHistory()96 TContentHistory *getContentHistory() { return m_contentHistory; } 97 98 //! destroys the old contentHistory and replaces it with the new one. Gets 99 //! ownership 100 void setContentHistory(TContentHistory *contentHistory); 101 102 private: 103 // not implemented 104 TXshPaletteLevel(const TXshPaletteLevel &); 105 TXshPaletteLevel &operator=(const TXshPaletteLevel &); 106 }; 107 108 #ifdef _WIN32 109 template class DV_EXPORT_API TSmartPointerT<TXshPaletteLevel>; 110 #endif 111 typedef TSmartPointerT<TXshPaletteLevel> TXshPaletteLevelP; 112 113 #endif 114