1 #pragma once
2 
3 #ifndef STYLESELECTION_INCLUDED
4 #define STYLESELECTION_INCLUDED
5 
6 #include "toonzqt/selection.h"
7 #include "toonz/tpalettehandle.h"
8 #include "tpalette.h"
9 #include <set>
10 #include <QString>
11 
12 class QByteArray;
13 
14 #undef DVAPI
15 #undef DVVAR
16 #ifdef TOONZQT_EXPORTS
17 #define DVAPI DV_EXPORT_API
18 #define DVVAR DV_EXPORT_VAR
19 #else
20 #define DVAPI DV_IMPORT_API
21 #define DVVAR DV_IMPORT_VAR
22 #endif
23 
24 class TXsheetHandle;
25 class TXshLevelHandle;
26 
27 //=============================================================================
28 // TStyleSelection
29 //-----------------------------------------------------------------------------
30 
31 class DVAPI TStyleSelection final : public TSelection {
32   TPaletteHandle *m_paletteHandle;
33 
34   // Used to change level palette; in other palette (cleanup, ...) xsheetHandle
35   // is not necessary.
36   TXsheetHandle *m_xsheetHandle;
37   // for clearing cache when the pastestyle command is executed
38   TXshLevelHandle *m_levelHandle;
39 
40   int m_pageIndex;
41   std::set<int> m_styleIndicesInPage;
42 
43 public:
44   TStyleSelection();
TStyleSelection(TStyleSelection * styleSelection)45   TStyleSelection(TStyleSelection *styleSelection)
46       : m_paletteHandle(styleSelection->getPaletteHandle())
47       , m_pageIndex(styleSelection->getPageIndex())
48       , m_styleIndicesInPage(styleSelection->getIndicesInPage()) {}
49   ~TStyleSelection();
50 
51   void select(int pageIndex);
52   void select(int pageIndex, int styleIndexInPage, bool on);
53   bool isSelected(int pageIndex, int styleIndexInPage) const;
54   bool isPageSelected(int pageIndex) const;
55   bool canHandleStyles();
56   void selectNone() override;
57   bool isEmpty() const override;
58   int getStyleCount() const;
getPaletteHandle()59   TPaletteHandle *getPaletteHandle() const { return m_paletteHandle; }
setPaletteHandle(TPaletteHandle * paletteHandle)60   void setPaletteHandle(TPaletteHandle *paletteHandle) {
61     m_paletteHandle = paletteHandle;
62   }
getPalette()63   TPalette *getPalette() const { return m_paletteHandle->getPalette(); }
getPageIndex()64   int getPageIndex() const { return m_pageIndex; }
getIndicesInPage()65   const std::set<int> &getIndicesInPage() const { return m_styleIndicesInPage; }
66 
67   void getIndices(std::set<int> &indices) const;
68 
69   // Used to change level palette; in other palette (cleanup, ...) xsheetHandle
70   // is not necessary.
setXsheetHandle(TXsheetHandle * xsheetHandle)71   void setXsheetHandle(TXsheetHandle *xsheetHandle) {
72     m_xsheetHandle = xsheetHandle;
73   }
getXsheetHandle()74   TXsheetHandle *getXsheetHandle() const { return m_xsheetHandle; }
setLevelHandle(TXshLevelHandle * levelHandle)75   void setLevelHandle(TXshLevelHandle *levelHandle) {
76     m_levelHandle = levelHandle;
77   }
78 
79   // commands
80   void cutStyles();
81   void copyStyles();
82   void pasteStyles();
83   void pasteStylesValues(bool pasteName, bool pasteColor = true);
84   void pasteStylesValue();
85   void pasteStylesColor();
86   void pasteStylesName();
87   void deleteStyles();
88   void eraseUnusedStyle();
89   void blendStyles();
90   void toggleLink();
91   void eraseToggleLink();
92 
93   void enableCommands() override;
94 
95   void toggleKeyframe(int frame);
96 
97   // remove link from the studio palette (if linked)
98   void removeLink();
99   // get back the style from the studio palette (if linked)
100   void getBackOriginalStyle();
101   // return true if there is at least one linked style in the selection
102   bool hasLinkedStyle();
103 };
104 
105 #endif  // STYLESELECTION_INCLUDED
106