|
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 |
|
|
|
e280ae |
#ifdef _MSC_VER
|
|
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 |
d1f6c4 |
class DVAPI TPalette final : 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 |
38fd86 |
//! id in the page, or \p -1 if not
|
|
Shinya Kitaoka |
38fd86 |
//! found.
|
|
Shinya Kitaoka |
120a6e |
TColorStyle *getStyle(int indexInPage) const; //!< Returns the \a index-th
|
|
Shinya Kitaoka |
38fd86 |
//! style in the page, or \p 0
|
|
Shinya Kitaoka |
38fd86 |
//! 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 |
38fd86 |
//! the \a back
|
|
manongjohn |
649b9a |
//! of the page).
|
|
manongjohn |
649b9a |
/*!
|
|
manongjohn |
649b9a |
\warning The supplied style must have been allocated with \a new.
|
|
manongjohn |
649b9a |
\warning Style ownership is surrendered to the palette.
|
|
manongjohn |
649b9a |
\return The insertion index in the page, or \p -1 on failure.
|
|
manongjohn |
649b9a |
In case of failure, the supplied style is \a deleted.
|
|
manongjohn |
649b9a |
*/
|
|
Shinya Kitaoka |
120a6e |
int addStyle(TColorStyle *style); //!< Adds the specified style to the
|
|
Shinya Kitaoka |
38fd86 |
//! palette, and assigns it
|
|
Shinya Kitaoka |
38fd86 |
//! 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 |
38fd86 |
//! and assigns it
|
|
Shinya Kitaoka |
38fd86 |
//! to this page.
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void insertStyle(int indexInPage, int styleId); //!< Inserts the supplied
|
|
Shinya Kitaoka |
38fd86 |
//! style id at the
|
|
Shinya Kitaoka |
38fd86 |
//! specified position
|
|
Shinya Kitaoka |
38fd86 |
//! 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 |
38fd86 |
//! supplied style in
|
|
Shinya Kitaoka |
38fd86 |
//! the palette, and
|
|
Shinya Kitaoka |
38fd86 |
//! 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 |
38fd86 |
//! color style in the
|
|
Shinya Kitaoka |
38fd86 |
//! palette, and assigns
|
|
Shinya Kitaoka |
38fd86 |
//! 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 |
38fd86 |
//! 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 |
38fd86 |
//! 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 |
38fd86 |
//! 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.
|
|
shun_iwasawa |
4635d8 |
|
|
shun_iwasawa |
4635d8 |
int m_shortcutScopeIndex;
|
|
shun_iwasawa |
4635d8 |
|
|
manongjohn |
649b9a |
int m_currentStyleId;
|
|
manongjohn |
649b9a |
|
|
shun-iwasawa |
1b50d3 |
bool m_areRefLevelFidsSpecified = false;
|
|
shun-iwasawa |
1b50d3 |
|
|
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 |
38fd86 |
//! save textures in \e
|
|
Shinya Kitaoka |
38fd86 |
//! 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 |
38fd86 |
//! 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 |
38fd86 |
//! 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 |
38fd86 |
//! 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 |
38fd86 |
//! palette (but in no page).
|
|
Shinya Kitaoka |
120a6e |
int addStyle(const TPixelRGBM32 &color); //!< Adds a solid color style to the
|
|
Shinya Kitaoka |
38fd86 |
//! 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 |
38fd86 |
//! style with the
|
|
Shinya Kitaoka |
38fd86 |
//! 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 |
38fd86 |
//! 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 |
473e70 |
void loadData(TIStream &is) override; //!< I/O palette save function.
|
|
Shinya Kitaoka |
473e70 |
void saveData(TOStream &os) override; //!< 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 |
|
|
shun-iwasawa |
1b50d3 |
void setRefLevelFids(const std::vector<tframeid> fids,</tframeid>
|
|
shun-iwasawa |
1b50d3 |
bool specified); //!< Associates the
|
|
shun-iwasawa |
1b50d3 |
//! list of frames \e
|
|
shun-iwasawa |
1b50d3 |
//! fids to this palette.
|
|
shun-iwasawa |
1b50d3 |
//! When specified == true fids were specified by user on loading.
|
|
Shinya Kitaoka |
120a6e |
std::vector<tframeid> getRefLevelFids(); //!< Returns the list of frames</tframeid>
|
|
Shinya Kitaoka |
38fd86 |
//! 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 |
38fd86 |
//! styles an animation table
|
|
Shinya Kitaoka |
38fd86 |
//! 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 |
38fd86 |
//! palette.
|
|
Shinya Kitaoka |
120a6e |
void setRefImg(const TImageP &img); //!< Associates an image to this palette,
|
|
Shinya Kitaoka |
38fd86 |
//! 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 |
38fd86 |
//! specified frame is a \a
|
|
Shinya Kitaoka |
38fd86 |
//! keyframe in styleId's
|
|
Shinya Kitaoka |
38fd86 |
//! 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 |
38fd86 |
void setKeyframe(int styleId, int frame); //!< Sets a keyframe at the
|
|
Shinya Kitaoka |
38fd86 |
//! specified frame of styleId's
|
|
Shinya Kitaoka |
38fd86 |
//! animation.
|
|
Shinya Kitaoka |
120a6e |
void clearKeyframe(int styleId, int frame); //!< Deletes the keyframe at the
|
|
Shinya Kitaoka |
38fd86 |
//! specified frame of styleId's
|
|
Shinya Kitaoka |
38fd86 |
//! 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 |
|
|
shun_iwasawa |
9cbd0e |
bool hasPickedPosStyle(); // Returns true if there is at least one style with
|
|
shun_iwasawa |
9cbd0e |
// picked pos value
|
|
shun_iwasawa |
9cbd0e |
|
|
shun_iwasawa |
beb305 |
void nextShortcutScope(bool invert);
|
|
shun_iwasawa |
4635d8 |
|
|
manongjohn |
649b9a |
void setCurrentStyleId(int id) { m_currentStyleId = id; }
|
|
manongjohn |
649b9a |
int getCurrentStyleId() const { return m_currentStyleId; }
|
|
manongjohn |
649b9a |
|
|
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 |
|
|
|
e280ae |
#ifdef _MSC_VER
|
|
Toshihiro Shimizu |
890ddd |
#pragma warning(pop)
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif // TPALETTE_H
|