| #pragma once |
| |
| #ifndef TPALETTE_H |
| #define TPALETTE_H |
| |
| |
| #include "tpersist.h" |
| #include "timage.h" |
| #include "tfilepath.h" |
| #include "tpixel.h" |
| #include "tcolorstyles.h" |
| |
| |
| #include <QMutex> |
| |
| #undef DVAPI |
| #undef DVVAR |
| #ifdef TVRENDER_EXPORTS |
| #define DVAPI DV_EXPORT_API |
| #define DVVAR DV_EXPORT_VAR |
| #else |
| #define DVAPI DV_IMPORT_API |
| #define DVVAR DV_IMPORT_VAR |
| #endif |
| |
| #ifdef _WIN32 |
| #pragma warning(push) |
| #pragma warning(disable : 4251) |
| #endif |
| |
| |
| |
| |
| |
| class TPixelRGBM32; |
| |
| typedef TSmartPointerT<TPalette> TPaletteP; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| class DVAPI TPalette final : public TPersist, public TSmartObject { |
| DECLARE_CLASS_CODE |
| PERSIST_DECLARATION(TPalette); |
| |
| public: |
| |
| |
| |
| |
| class DVAPI Page { |
| friend class TPalette; |
| |
| private: |
| std::wstring m_name; |
| int m_index; |
| TPalette *m_palette; |
| std::vector<int> m_styleIds; |
| |
| public: |
| Page(std::wstring name); |
| |
| std::wstring getName() const { |
| return m_name; |
| } |
| void setName(std::wstring name) { |
| m_name = name; |
| } |
| |
| TPalette *getPalette() const { |
| return m_palette; |
| } |
| |
| int getIndex() const { |
| return m_index; |
| } |
| |
| int getStyleCount() const { |
| return (int)m_styleIds.size(); |
| } |
| |
| int getStyleId(int indexInPage) const; |
| |
| |
| TColorStyle *getStyle(int indexInPage) const; |
| |
| |
| |
| |
| int addStyle(int styleId); |
| |
| |
| |
| |
| |
| |
| |
| |
| int addStyle(TColorStyle *style); |
| |
| |
| |
| int addStyle(TPixel32 color); |
| |
| |
| |
| void insertStyle(int indexInPage, int styleId); |
| |
| |
| |
| |
| void insertStyle(int indexInPage, TColorStyle *style); |
| |
| |
| |
| |
| void insertStyle(int indexInPage, TPixel32 color); |
| |
| |
| |
| |
| |
| void removeStyle(int indexInPage); |
| |
| int search(int styleId) |
| const; |
| |
| int search(TColorStyle *style) |
| const; |
| |
| }; |
| |
| private: |
| typedef std::map<int, TColorStyleP> |
| StyleAnimation; |
| typedef std::map<int, StyleAnimation> |
| StyleAnimationTable; |
| |
| friend class Page; |
| |
| private: |
| std::wstring m_globalName; |
| std::wstring m_paletteName; |
| |
| int m_version; |
| std::vector<Page *> m_pages; |
| std::vector<std::pair<Page *, TColorStyleP>> m_styles; |
| std::map<int, int> m_shortcuts; |
| StyleAnimationTable |
| m_styleAnimationTable; |
| int m_currentFrame; |
| bool m_isCleanupPalette; |
| |
| |
| TImageP m_refImg; |
| TFilePath m_refImgPath; |
| std::vector<TFrameId> m_refLevelFids; |
| |
| bool m_dirtyFlag; |
| QMutex m_mutex; |
| |
| bool m_isLocked; |
| bool m_askOverwriteFlag; |
| |
| |
| |
| |
| |
| |
| |
| |
| int m_shortcutScopeIndex; |
| |
| public: |
| TPalette(); |
| ~TPalette(); |
| |
| TPalette *clone() |
| const; |
| |
| static void setRootDir(const TFilePath &fp); |
| |
| |
| static TFilePath getRootDir(); |
| |
| std::wstring getGlobalName() const { |
| return m_globalName; |
| } |
| void setGlobalName(std::wstring name) { |
| m_globalName = name; |
| } |
| |
| void setDirtyFlag(bool dirtyFlag) |
| |
| { |
| m_dirtyFlag = dirtyFlag; |
| |
| m_askOverwriteFlag = dirtyFlag; |
| } |
| bool getDirtyFlag() { |
| return m_dirtyFlag; |
| } |
| |
| |
| TColorStyle *getStyle(int styleId) |
| const; |
| |
| int getStyleCount() const { |
| return (int)m_styles.size(); |
| } |
| int getStyleInPagesCount() |
| const; |
| |
| int getFirstUnpagedStyle() const; |
| |
| |
| |
| |
| |
| |
| |
| int addStyle(TColorStyle *style); |
| |
| int addStyle(const TPixelRGBM32 &color); |
| |
| |
| |
| |
| |
| |
| void setStyle( |
| int styleId, |
| TColorStyle *style); |
| void setStyle(int styleId, const TPixelRGBM32 &color); |
| |
| |
| |
| int getPageCount() const; |
| |
| Page *getPage(int pageIndex); |
| |
| const Page *getPage(int pageIndex) const; |
| |
| |
| |
| |
| Page *addPage( |
| std::wstring name); |
| void erasePage(int index); |
| |
| void movePage(Page *page, int dstPageIndex); |
| |
| |
| Page *getStylePage(int styleId) |
| const; |
| |
| |
| |
| |
| |
| |
| int getClosestStyle(const TPixelRGBM32 &color) |
| const; |
| |
| |
| void loadData(TIStream &is) override; |
| void saveData(TOStream &os) override; |
| |
| int getVersion() const { |
| return m_version; |
| } |
| void setVersion(int v) { |
| m_version = v; |
| } |
| |
| void setRefLevelFids(const std::vector<TFrameId> fids); |
| |
| |
| |
| std::vector<TFrameId> getRefLevelFids(); |
| |
| |
| |
| void assign(const TPalette *src, |
| bool isFromStudioPalette = false); |
| |
| |
| |
| |
| |
| void merge(const TPalette *src, |
| bool isFromStudioPalette = |
| false); |
| |
| |
| |
| void setAskOverwriteFlag( |
| bool askOverwriteFlag) { |
| m_askOverwriteFlag = askOverwriteFlag; |
| } |
| bool getAskOverwriteFlag() { |
| return m_askOverwriteFlag; |
| } |
| |
| void setIsCleanupPalette( |
| bool on); |
| bool isCleanupPalette() const { |
| return m_isCleanupPalette; |
| } |
| |
| const TImageP &getRefImg() const { |
| return m_refImg; |
| } |
| |
| void setRefImg(const TImageP &img); |
| |
| |
| |
| const TFilePath getRefImgPath() const { |
| return m_refImgPath; |
| } |
| void setRefImgPath( |
| const TFilePath &fp); |
| |
| bool isAnimated() const; |
| |
| |
| int getFrame() const; |
| void setFrame(int frame); |
| |
| bool isKeyframe(int styleId, int frame) const; |
| |
| |
| |
| int getKeyframeCount(int styleId) |
| const; |
| |
| int getKeyframe(int styleId, int index) |
| const; |
| |
| void setKeyframe(int styleId, int frame); |
| |
| |
| void clearKeyframe(int styleId, int frame); |
| |
| |
| |
| |
| |
| |
| int getShortcutValue( |
| int key) const; |
| |
| |
| |
| |
| int getStyleShortcut( |
| int styleId) const; |
| |
| void setShortcutValue( |
| int key, int styleId); |
| |
| void setPaletteName(std::wstring name) { |
| m_paletteName = name; |
| } |
| std::wstring getPaletteName() const { |
| return m_paletteName; |
| } |
| |
| QMutex *mutex() { return &m_mutex; } |
| |
| bool isLocked() const { |
| return m_isLocked; |
| } |
| void setIsLocked(bool lock) |
| { |
| m_isLocked = lock; |
| } |
| |
| bool hasPickedPosStyle(); |
| |
| |
| void nextShortcutScope(bool invert); |
| |
| public: |
| |
| |
| |
| bool getFxRects(const TRect &rect, TRect &rectIn, TRect &rectOut); |
| |
| private: |
| |
| TPalette(const TPalette &); |
| TPalette &operator=(const TPalette &); |
| }; |
| |
| |
| |
| #ifdef _WIN32 |
| template class DVAPI TSmartPointerT<TPalette>; |
| #endif |
| |
| |
| |
| #ifdef _WIN32 |
| #pragma warning(pop) |
| #endif |
| |
| #endif |