Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef TPALETTE_H
Toshihiro Shimizu 890ddd
#define TPALETTE_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzCore includes
Toshihiro Shimizu 890ddd
#include "tpersist.h"
Toshihiro Shimizu 890ddd
#include "timage.h"
Toshihiro Shimizu 890ddd
#include "tfilepath.h"
Toshihiro Shimizu 890ddd
#include "tpixel.h"
Toshihiro Shimizu 890ddd
#include "tcolorstyles.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// Qt includes
Toshihiro Shimizu 890ddd
#include <qmutex></qmutex>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TVRENDER_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Shinya Kitaoka 9f5a1b
#ifdef _WIN32
Toshihiro Shimizu 890ddd
#pragma warning(push)
Toshihiro Shimizu 890ddd
#pragma warning(disable : 4251)
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=========================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//    Forward declarations
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class TPixelRGBM32;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
typedef TSmartPointerT<tpalette> TPaletteP;</tpalette>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=========================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//*****************************************************************************************
Toshihiro Shimizu 890ddd
//    TPalette  declaration
Toshihiro Shimizu 890ddd
//*****************************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
  \brief    The class representing a Toonz palette object.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
  \par Rationale
Shinya Kitaoka 120a6e
    A palette is a collection of color styles that adds a level of
Shinya Kitaoka 120a6e
indirection
Toshihiro Shimizu 890ddd
    on color selections when drawing certain graphical objects.
Toshihiro Shimizu 890ddd
\n
Shinya Kitaoka 120a6e
    Palette-based objects store style identifiers into an associated
Shinya Kitaoka 120a6e
palette object,
Shinya Kitaoka 120a6e
    rather than the colors directly. When a color needs to be accessed, the
Shinya Kitaoka 120a6e
palette
Shinya Kitaoka 120a6e
    objects is queried for a style id, and the associated \a style is
Shinya Kitaoka 120a6e
returned.
Toshihiro Shimizu 890ddd
\n
Shinya Kitaoka 120a6e
    A TColorStyle instance generalizes the notion of \a color, providing the
Shinya Kitaoka 120a6e
ability to
Toshihiro Shimizu 890ddd
    reduce a style instance to a color, \a and specialized drawing functions for
Toshihiro Shimizu 890ddd
    vector graphics objects.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
  \par Reserved colors
Shinya Kitaoka 120a6e
    A palette object has two fixed \a reserved styles - which cannot be
Shinya Kitaoka 120a6e
removed - at
Shinya Kitaoka 120a6e
    indexes \p 0 and \p1. Index \p 0 is reserved for the \b transparent color.
Shinya Kitaoka 120a6e
Index \p 1
Toshihiro Shimizu 890ddd
    is reserved for the \b ink color, initialized by default to black.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
  \par Syntax
Shinya Kitaoka 120a6e
    A palette is supposedly created on the heap, to the point that, in
Shinya Kitaoka 120a6e
current
Shinya Kitaoka 120a6e
    implementation, copy and assignment are \a forbidden. This behavior is
Shinya Kitaoka 120a6e
somewhat
Shinya Kitaoka 120a6e
    inconsitent since a palette \b is currently \a clonable and \a assignable
Shinya Kitaoka 120a6e
with the
Shinya Kitaoka 120a6e
    appropriate functions. Normalization to common C++ syntax should be enforced
Shinya Kitaoka 120a6e
ASAP.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
\sa The TColorStyle class.
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI TPalette : public TPersist, public TSmartObject {
Shinya Kitaoka 120a6e
  DECLARE_CLASS_CODE
Shinya Kitaoka 120a6e
  PERSIST_DECLARATION(TPalette);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
          \brief A palette page is a restricted view of a palette instance.
Shinya Kitaoka 120a6e
  */
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  class DVAPI Page {
Shinya Kitaoka 120a6e
    friend class TPalette;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  private:
Shinya Kitaoka 120a6e
    std::wstring m_name;  //!< Name of the page to be displayed.
Shinya Kitaoka 120a6e
    int m_index;  //!< Index of the page in the palette's pages collection.
Shinya Kitaoka 120a6e
    TPalette *m_palette;  //!< (\p not \p owned)  Palette the page refers to.
Shinya Kitaoka 120a6e
    std::vector<int> m_styleIds;  //!< Palette style ids contained in the page.</int>
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  public:
Shinya Kitaoka 120a6e
    Page(std::wstring name);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    std::wstring getName() const {
Shinya Kitaoka 120a6e
      return m_name;
Shinya Kitaoka 120a6e
    }  //!< Returns the name of the page.
Shinya Kitaoka 120a6e
    void setName(std::wstring name) {
Shinya Kitaoka 120a6e
      m_name = name;
Shinya Kitaoka 120a6e
    }  //!< Sets the name of the page.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    TPalette *getPalette() const {
Shinya Kitaoka 120a6e
      return m_palette;
Shinya Kitaoka 120a6e
    }  //!< Returns a pointer to the palette that contains this page.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    int getIndex() const {
Shinya Kitaoka 120a6e
      return m_index;
Shinya Kitaoka 120a6e
    }  //!< Returns the page index in the palette.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    int getStyleCount() const {
Shinya Kitaoka 120a6e
      return (int)m_styleIds.size();
Shinya Kitaoka 120a6e
    }  //!< Returns the number of the styles contained in the page.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    int getStyleId(int indexInPage) const;  //!< Returns the \a index-th style
Shinya Kitaoka 120a6e
                                            //!id in the page, or \p -1 if not
Shinya Kitaoka 120a6e
                                            //!found.
Shinya Kitaoka 120a6e
    TColorStyle *getStyle(int indexInPage) const;  //!< Returns the \a index-th
Shinya Kitaoka 120a6e
                                                   //!style in the page, or \p 0
Shinya Kitaoka 120a6e
                                                   //!if not found.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    //! \return The insertion index in the page, or \p -1 on failure
Shinya Kitaoka 120a6e
    int addStyle(int styleId);  //!< Adds the specified style Id to the page (at
Shinya Kitaoka 120a6e
                                //!the \a back
Shinya Kitaoka 120a6e
                                //!  of the page).
Shinya Kitaoka 120a6e
    /*!
Shinya Kitaoka 120a6e
\warning  The supplied style must have been allocated with \a new.
Shinya Kitaoka 120a6e
\warning  Style ownership is surrendered to the palette.
Shinya Kitaoka 120a6e
\return   The insertion index in the page, or \p -1 on failure.
Shinya Kitaoka 120a6e
    In case of failure, the supplied style is \a deleted.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
    int addStyle(TColorStyle *style);  //!< Adds the specified style to the
Shinya Kitaoka 120a6e
                                       //!palette, and assigns it
Shinya Kitaoka 120a6e
                                       //!  to this page.
Shinya Kitaoka 120a6e
    //! \return The insertion index in the page, or \p -1 on failure
Shinya Kitaoka 120a6e
    int addStyle(TPixel32 color);  //!< Add a solid color style to the palette,
Shinya Kitaoka 120a6e
                                   //!and assigns it
Shinya Kitaoka 120a6e
                                   //!  to this page.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    void insertStyle(int indexInPage, int styleId);  //!< Inserts the supplied
Shinya Kitaoka 120a6e
                                                     //!style id at the
Shinya Kitaoka 120a6e
                                                     //!specified position
Shinya Kitaoka 120a6e
                                                     //!  in the page.
Shinya Kitaoka 120a6e
    //! \sa The specifics of addStyle(TColorStyle*) apply here.
Shinya Kitaoka 120a6e
    void insertStyle(int indexInPage, TColorStyle *style);  //!< Inserts the
Shinya Kitaoka 120a6e
                                                            //!supplied style in
Shinya Kitaoka 120a6e
                                                            //!the palette, and
Shinya Kitaoka 120a6e
                                                            //!assigns its
Shinya Kitaoka 120a6e
    //!  id at the specified position in the page.
Shinya Kitaoka 120a6e
    void insertStyle(int indexInPage, TPixel32 color);  //!< Inserts a solid
Shinya Kitaoka 120a6e
                                                        //!color style in the
Shinya Kitaoka 120a6e
                                                        //!palette, and assigns
Shinya Kitaoka 120a6e
                                                        //!its
Shinya Kitaoka 120a6e
    //!  id at the specified position in the page.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    void removeStyle(int indexInPage);  //!< Removes the style at the specified
Shinya Kitaoka 120a6e
                                        //!position from this page.
Shinya Kitaoka 120a6e
    int search(int styleId)
Shinya Kitaoka 120a6e
        const;  //!< Returns the page position of the specified style id,
Shinya Kitaoka 120a6e
                //!  or \p -1 if it cannot be found on the page.
Shinya Kitaoka 120a6e
    int search(TColorStyle *style)
Shinya Kitaoka 120a6e
        const;  //!< Returns the page position of the specified style,
Shinya Kitaoka 120a6e
                //!  or \p -1 if it cannot be found on the page.
Shinya Kitaoka 120a6e
  };
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  typedef std::map<int, tcolorstylep=""></int,>
Shinya Kitaoka 120a6e
      StyleAnimation;  //!< Style keyframes list.
Shinya Kitaoka 120a6e
  typedef std::map<int, styleanimation=""></int,>
Shinya Kitaoka 120a6e
      StyleAnimationTable;  //!< Style keyframes list per style id.
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  friend class Page;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  std::wstring m_globalName;   //!< Palette \a global name.
Shinya Kitaoka 120a6e
  std::wstring m_paletteName;  //!< Palette name.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int m_version;                //!< Palette version number.
Shinya Kitaoka 120a6e
  std::vector<page *=""> m_pages;  //!< Pages list.</page>
Shinya Kitaoka 120a6e
  std::vector<std::pair<page *,="" tcolorstylep="">> m_styles;  //!< Styles container.</std::pair<page>
Shinya Kitaoka 120a6e
  std::map<int, int=""> m_shortcuts;</int,>
Shinya Kitaoka 120a6e
  StyleAnimationTable
Shinya Kitaoka 120a6e
      m_styleAnimationTable;  //!< Table of style animations (per style).
Shinya Kitaoka 120a6e
  int m_currentFrame;         //!< Palette's current frame in style animations.
Shinya Kitaoka 120a6e
  bool m_isCleanupPalette;    //!< Whether the palette is used for cleanup
Shinya Kitaoka 120a6e
                              //!purposes.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TImageP m_refImg;
Shinya Kitaoka 120a6e
  TFilePath m_refImgPath;
Shinya Kitaoka 120a6e
  std::vector<tframeid> m_refLevelFids;</tframeid>
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool m_dirtyFlag;  //!< Whether the palette changed and needs to be refreshed.
Shinya Kitaoka 120a6e
  QMutex m_mutex;    //!< Synchronization mutex for multithreading purposes.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool m_isLocked;          //!< Whether the palette is locked.
Shinya Kitaoka 120a6e
  bool m_askOverwriteFlag;  //!< This variable is quite unique. This flag is to
Shinya Kitaoka 120a6e
                            //!acheive following beghavior:
Shinya Kitaoka 120a6e
  //! When saving the level with the palette being edited, ask whether the
Shinya Kitaoka 120a6e
  //! palette
Shinya Kitaoka 120a6e
  //! should be overwitten ONLY ONCE AT THE FIRST TIME.
Shinya Kitaoka 120a6e
  //! The confirmation dialog will not be opened unless the palette is edited
Shinya Kitaoka 120a6e
  //! again,
Shinya Kitaoka 120a6e
  //! even if the palette's dirtyflag is true.
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TPalette();
Shinya Kitaoka 120a6e
  ~TPalette();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TPalette *clone()
Shinya Kitaoka 120a6e
      const;  //!< Allocates a \a new copy of this palette instance.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  static void setRootDir(const TFilePath &fp);  //!< It must be specified to
Shinya Kitaoka 120a6e
                                                //!save textures in \e
Shinya Kitaoka 120a6e
                                                //!fp/textures.
Shinya Kitaoka 120a6e
  static TFilePath getRootDir();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  std::wstring getGlobalName() const {
Shinya Kitaoka 120a6e
    return m_globalName;
Shinya Kitaoka 120a6e
  }  //!< Returns the name of the palette object.
Shinya Kitaoka 120a6e
  void setGlobalName(std::wstring name) {
Shinya Kitaoka 120a6e
    m_globalName = name;
Shinya Kitaoka 120a6e
  }  //!< Assigns the name of the palette.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void setDirtyFlag(bool dirtyFlag)  //!< Declares the palette \a changed with
Shinya Kitaoka 120a6e
                                     //!respect to the last saved state.
Shinya Kitaoka 120a6e
  {
Shinya Kitaoka 120a6e
    m_dirtyFlag = dirtyFlag;
Shinya Kitaoka 120a6e
    // synchronize with the dirty flag
Shinya Kitaoka 120a6e
    m_askOverwriteFlag = dirtyFlag;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  bool getDirtyFlag() {
Shinya Kitaoka 120a6e
    return m_dirtyFlag;
Shinya Kitaoka 120a6e
  }  //!< Returns whether the palette changed with respect to the last saved
Shinya Kitaoka 120a6e
     //!state.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TColorStyle *getStyle(int styleId)
Shinya Kitaoka 120a6e
      const;  //!< Returns a pointer to the color style with the specified id,
Shinya Kitaoka 120a6e
              //!  or \p 0 if said id is not stored in the palette.
Shinya Kitaoka 120a6e
  int getStyleCount() const {
Shinya Kitaoka 120a6e
    return (int)m_styles.size();
Shinya Kitaoka 120a6e
  }  //!< Returns the number of the color styles in the palette.
Shinya Kitaoka 120a6e
  int getStyleInPagesCount()
Shinya Kitaoka 120a6e
      const;  //!< Returns the number of styles contained in palette pages.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int getFirstUnpagedStyle() const;  //!< Returns the styleId of the first style
Shinya Kitaoka 120a6e
                                     //!not in a page (\p -1 if none).
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
          \remark   Style ownserhip is \a surrendered to the palette
Shinya Kitaoka 120a6e
          \return   The styleId associated to the inserted style, or \a -1 on
Shinya Kitaoka 120a6e
     failure.
Toshihiro Shimizu 890ddd
  */
Shinya Kitaoka 120a6e
  int addStyle(TColorStyle *style);         //!< Adds the specified style to the
Shinya Kitaoka 120a6e
                                            //!palette (but in no page).
Shinya Kitaoka 120a6e
  int addStyle(const TPixelRGBM32 &color);  //!< Adds a solid color style to the
Shinya Kitaoka 120a6e
                                            //!palette (but in no page).
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
\remark     Style ownserhip is \a surrendered to the palette.
Shinya Kitaoka 120a6e
\remark     Any existing style's animation will be discarded.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  void setStyle(
Shinya Kitaoka 120a6e
      int styleId,
Shinya Kitaoka 120a6e
      TColorStyle *style);  //!< Replaces the style with the specified style id.
Shinya Kitaoka 120a6e
  void setStyle(int styleId, const TPixelRGBM32 &color);  //!< Replaces the
Shinya Kitaoka 120a6e
                                                          //!style with the
Shinya Kitaoka 120a6e
                                                          //!specified style id.
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int getPageCount() const;  //!< Returns the pages count.
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  Page *getPage(int pageIndex);  //!< Returns the \a index-th palette page, or
Shinya Kitaoka 120a6e
                                 //!\p 0 if no such page was found.
Shinya Kitaoka 120a6e
  const Page *getPage(int pageIndex) const;  //!< Const version of getPage(int).
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
\return  A pointer to the newly created page.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  Page *addPage(
Shinya Kitaoka 120a6e
      std::wstring name);     //!< Creates a new page with the specified name.
Shinya Kitaoka 120a6e
  void erasePage(int index);  //!< Deletes the \a index-th page.
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void movePage(Page *page, int dstPageIndex);  //!< Moves the specified page to
Shinya Kitaoka 120a6e
                                                //!a different page index.
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  Page *getStylePage(int styleId)
Shinya Kitaoka 120a6e
      const;  //!< Returns the page containing the specified \a styleId.
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
\note   The distance between colors is calculated with the usual sphrical norm
Shinya Kitaoka 120a6e
between RGBA color components.
Shinya Kitaoka 120a6e
\return The style id of the nearest style, or \p -1 if none was found.
Shinya Kitaoka 120a6e
  */
Shinya Kitaoka 120a6e
  int getClosestStyle(const TPixelRGBM32 &color)
Shinya Kitaoka 120a6e
      const;  //!< Returns the index of the style whose main color
Shinya Kitaoka 120a6e
              //!  is nearest to the requested one.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void loadData(TIStream &is);  //!< I/O palette save function.
Shinya Kitaoka 120a6e
  void saveData(TOStream &os);  //!< I/O palette load function.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int getVersion() const {
Shinya Kitaoka 120a6e
    return m_version;
Shinya Kitaoka 120a6e
  }  //!< Returns the palette's version number
Shinya Kitaoka 120a6e
  void setVersion(int v) {
Shinya Kitaoka 120a6e
    m_version = v;
Shinya Kitaoka 120a6e
  }  //!< Sets the palette's version number
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void setRefLevelFids(const std::vector<tframeid> fids);  //!< Associates the</tframeid>
Shinya Kitaoka 120a6e
                                                           //!list of frames \e
Shinya Kitaoka 120a6e
                                                           //!fids to this
Shinya Kitaoka 120a6e
                                                           //!palette.
Shinya Kitaoka 120a6e
  std::vector<tframeid> getRefLevelFids();  //!< Returns the list of frames</tframeid>
Shinya Kitaoka 120a6e
                                            //!associated to this palette.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! \deprecated  Should be substituted by operator=(const TPalette&).
Shinya Kitaoka 120a6e
  void assign(const TPalette *src,
Shinya Kitaoka 120a6e
              bool isFromStudioPalette = false);  //!< Copies src's page, color
Shinya Kitaoka 120a6e
                                                  //!styles an animation table
Shinya Kitaoka 120a6e
                                                  //!to the
Shinya Kitaoka 120a6e
  //!  correspondig features of the palette.
Shinya Kitaoka 120a6e
  //!  if the palette is copied from studio palette, this function will modify
Shinya Kitaoka 120a6e
  //!  the original names.
Shinya Kitaoka 120a6e
  void merge(const TPalette *src,
Shinya Kitaoka 120a6e
             bool isFromStudioPalette =
Shinya Kitaoka 120a6e
                 false);  //!< Adds src's styles and pages to the palette.
Shinya Kitaoka 120a6e
  //!  if the palette is merged from studio palette, this function will modify
Shinya Kitaoka 120a6e
  //!  the original names.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void setAskOverwriteFlag(
Shinya Kitaoka 120a6e
      bool askOverwriteFlag) {  //!< Sets the ask-overwrite flag.
Shinya Kitaoka 120a6e
    m_askOverwriteFlag = askOverwriteFlag;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  bool getAskOverwriteFlag() {
Shinya Kitaoka 120a6e
    return m_askOverwriteFlag;
Shinya Kitaoka 120a6e
  }  //!< Returns the ask-overwrite flag.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void setIsCleanupPalette(
Shinya Kitaoka 120a6e
      bool on);  //!< Sets the palette's identity as a cleanup palette.
Shinya Kitaoka 120a6e
  bool isCleanupPalette() const {
Shinya Kitaoka 120a6e
    return m_isCleanupPalette;
Shinya Kitaoka 120a6e
  }  //!< Returns whether this is a cleanup palette.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  const TImageP &getRefImg() const {
Shinya Kitaoka 120a6e
    return m_refImg;
Shinya Kitaoka 120a6e
  }  //!< Returns an image that represents the frame image associated to this
Shinya Kitaoka 120a6e
     //!palette.
Shinya Kitaoka 120a6e
  void setRefImg(const TImageP &img);  //!< Associates an image to this palette,
Shinya Kitaoka 120a6e
                                       //!that is an image in the frame
Shinya Kitaoka 120a6e
  //!  builded or modified using this palette.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  const TFilePath getRefImgPath() const {
Shinya Kitaoka 120a6e
    return m_refImgPath;
Shinya Kitaoka 120a6e
  }  //!< Returns the file path of the reference image.
Shinya Kitaoka 120a6e
  void setRefImgPath(
Shinya Kitaoka 120a6e
      const TFilePath &fp);  //!< Sets the path filename of the reference image.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool isAnimated() const;  //!< Returns whether this palette is animated
Shinya Kitaoka 120a6e
                            //!(styles change through time).
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int getFrame() const;      //!< Returns the index of the current frame.
Shinya Kitaoka 120a6e
  void setFrame(int frame);  //!< Sets the index of the current frame.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool isKeyframe(int styleId, int frame) const;  //!< Returns whether the
Shinya Kitaoka 120a6e
                                                  //!specified frame is a \a
Shinya Kitaoka 120a6e
                                                  //!keyframe in styleId's
Shinya Kitaoka 120a6e
                                                  //!animation
Shinya Kitaoka 120a6e
  int getKeyframeCount(int styleId)
Shinya Kitaoka 120a6e
      const;  //!< Returns the keyframes count in styleId's animation.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int getKeyframe(int styleId, int index)
Shinya Kitaoka 120a6e
      const;  //!< Returns the \a index-th frame in styleId's animation,
Shinya Kitaoka 120a6e
              //!  or \p -1 if it couldn't be found.
Shinya Kitaoka 120a6e
  void setKeyframe(int styleId, int frame);    //!< Sets a keyframe at the
Shinya Kitaoka 120a6e
                                               //!specified frame of styleId's
Shinya Kitaoka 120a6e
                                               //!animation.
Shinya Kitaoka 120a6e
  void clearKeyframe(int styleId, int frame);  //!< Deletes the keyframe at the
Shinya Kitaoka 120a6e
                                               //!specified frame of styleId's
Shinya Kitaoka 120a6e
                                               //!animation.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*!
Shinya Kitaoka 120a6e
\note   Key is an integer between 0 and 9 included.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  int getShortcutValue(
Shinya Kitaoka 120a6e
      int key) const;  //!< Returns the style id \a shortcut associated to key,
Shinya Kitaoka 120a6e
                       //!  or \p -1 if it couldn't be found.
Shinya Kitaoka 120a6e
  /*!
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
  */
Shinya Kitaoka 120a6e
  int getStyleShortcut(
Shinya Kitaoka 120a6e
      int styleId) const;  //!< Returns the shortcut associated to styleId, or
Shinya Kitaoka 120a6e
                           //!  or \p -1 if it couldn't be found.
Shinya Kitaoka 120a6e
  void setShortcutValue(
Shinya Kitaoka 120a6e
      int key, int styleId);  //!< Associates the specified key to a styleId.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void setPaletteName(std::wstring name) {
Shinya Kitaoka 120a6e
    m_paletteName = name;
Shinya Kitaoka 120a6e
  }  //!< Sets the name of the palette.
Shinya Kitaoka 120a6e
  std::wstring getPaletteName() const {
Shinya Kitaoka 120a6e
    return m_paletteName;
Shinya Kitaoka 120a6e
  }  //!< Returns the name of the palette.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  QMutex *mutex() { return &m_mutex; }  //!< Returns the palette's mutex
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool isLocked() const {
Shinya Kitaoka 120a6e
    return m_isLocked;
Shinya Kitaoka 120a6e
  }                            //!< Returns whether the palette is locked.
Shinya Kitaoka 120a6e
  void setIsLocked(bool lock)  //!< Sets lock/unlock to the palette.
Shinya Kitaoka 120a6e
  {
Shinya Kitaoka 120a6e
    m_isLocked = lock;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  // Deprecated functions
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  //! \deprecated  Used only once throughout Toonz, should be verified.
Shinya Kitaoka 120a6e
  bool getFxRects(const TRect &rect, TRect &rectIn, TRect &rectOut);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  // Not copyable
Shinya Kitaoka 120a6e
  TPalette(const TPalette &);             //!< Not implemented
Shinya Kitaoka 120a6e
  TPalette &operator=(const TPalette &);  //!< Not implemented
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 9f5a1b
#ifdef _WIN32
Toshihiro Shimizu 890ddd
template class DVAPI TSmartPointerT<tpalette>;</tpalette>
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 9f5a1b
#ifdef _WIN32
Toshihiro Shimizu 890ddd
#pragma warning(pop)
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // TPALETTE_H