1 #pragma once
2 
3 #ifndef PALETTECONTROLLER_INCLUDED
4 #define PALETTECONTROLLER_INCLUDED
5 
6 // TnzCore includes
7 #include "tcommon.h"
8 #include "tpixel.h"
9 
10 // Qt includes
11 #include <QObject>
12 
13 #undef DVAPI
14 #undef DVVAR
15 #ifdef TOONZLIB_EXPORTS
16 #define DVAPI DV_EXPORT_API
17 #define DVVAR DV_EXPORT_VAR
18 #else
19 #define DVAPI DV_IMPORT_API
20 #define DVVAR DV_IMPORT_VAR
21 #endif
22 
23 //=====================================================
24 
25 //    Forward declarations
26 
27 class TPaletteHandle;
28 
29 //=====================================================
30 
31 //************************************************************************
32 //    PaletteController  declaration
33 //************************************************************************
34 
35 class DVAPI PaletteController final : public QObject {
36   Q_OBJECT
37 
38   TPaletteHandle *m_currentLevelPalette;  //!< (\p owned) Handle to the palette
39                                           //! of current level.
40   TPaletteHandle *m_currentCleanupPalette;  //!< (\p owned) Handle to the
41                                             //! palette of current cleanup
42   //! settings.
43   TPaletteHandle *m_currentPalette;  //!< (\p owned) Handle to the palette of
44                                      //! currently selected object.
45 
46   TPaletteHandle *m_originalCurrentPalette;  //!< Pointer to the \a original
47   //! current palette handle specified
48   //! on
49   //!  the last setCurrentPalette() invocation.
50   TPixel32 m_colorSample;
51   bool m_colorAutoApplyEnabled;
52 
53 public:
54   PaletteController();
55   ~PaletteController();
56 
getCurrentLevelPalette()57   TPaletteHandle *getCurrentLevelPalette() const {
58     return m_currentLevelPalette;
59   }
getCurrentCleanupPalette()60   TPaletteHandle *getCurrentCleanupPalette() const {
61     return m_currentCleanupPalette;
62   }
getCurrentPalette()63   TPaletteHandle *getCurrentPalette() const { return m_currentPalette; }
64 
65   void setCurrentPalette(TPaletteHandle *paletteHandle);
66 
67   // centralized handling of color auto-apply. see StyleEditor.
68   // when ColorAutoApply is disabled then changes should made on the ColorSample
69   // instead than on the current style. (see rgb color picker)
70   void enableColorAutoApply(bool enabled);
isColorAutoApplyEnabled()71   bool isColorAutoApplyEnabled() const { return m_colorAutoApplyEnabled; }
72 
73   void setColorSample(const TPixel32 &color);
getColorSample()74   TPixel32 getColorSample() const { return m_colorSample; }
75 
76   // used for "passive pick" feature in the tool options bar of the rgb picker
77   // tool
notifyColorPassivePicked(const QColor & col)78   void notifyColorPassivePicked(const QColor &col) {
79     emit colorPassivePicked(col);
80   }
81   // used for "passive pick" feature in the tool options bar of the style picker
82   // tool
notifyStylePassivePicked(const int ink,const int paint,const int tone)83   void notifyStylePassivePicked(const int ink, const int paint,
84                                 const int tone) {
85     emit stylePassivePicked(ink, paint, tone);
86   }
87 
88 public slots:
89 
90   void editLevelPalette();
91   void editCleanupPalette();
92   // void setColorCheckIndex();// sets the  index to be used to perform the
93   // inkCheck and paintcheck;
94 
95 signals:
96 
97   void colorAutoApplyEnabled(bool enabled);
98   void colorSampleChanged(const TPixel32 &);
99   void checkPaletteLock();
100 
101   // used for "passive pick" feature in the tool options bar of the rgb picker
102   // tool
103   void colorPassivePicked(const QColor &);
104   // used for "passive pick" feature in the tool options bar of the style picker
105   // tool
106   void stylePassivePicked(const int, const int, const int);
107 };
108 
109 #endif  // PALETTECONTROLLER_INCLUDED
110