1 #pragma once 2 3 #ifndef TPALETTEHANDLE_H 4 #define TPALETTEHANDLE_H 5 6 // TnzCore includes 7 #include "tcommon.h" 8 #include "tpalette.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 // TPaletteHandle 25 //----------------------------------------------------------------------------- 26 27 class DVAPI TPaletteHandle final : public QObject { 28 Q_OBJECT 29 30 TPalette *m_palette; 31 32 int m_styleIndex; 33 int m_styleParamIndex; 34 35 public: 36 TPaletteHandle(); 37 ~TPaletteHandle(); 38 39 TPalette *getPalette() const; 40 41 int getStyleIndex() const; 42 43 int getStyleParamIndex() const; 44 45 TColorStyle *getStyle() const; 46 47 void setPalette(TPalette *palette, int styleIndex = -1); 48 49 void setStyleIndex(int index, bool forceEmit = false); 50 51 void setStyleParamIndex(int index); 52 53 public: notifyPaletteSwitched()54 void notifyPaletteSwitched() { emit paletteSwitched(); } 55 void notifyPaletteChanged(); 56 void notifyPaletteTitleChanged(); 57 void notifyColorStyleSwitched(); 58 // unchange the dirty flag when undo operation 59 void notifyColorStyleChanged(bool onDragging = true, 60 bool setDirtyFlag = true); 61 notifyPaletteDirtyFlagChanged()62 void notifyPaletteDirtyFlagChanged() { emit paletteDirtyFlagChanged(); } notifyPaletteLockChanged()63 void notifyPaletteLockChanged() { emit paletteLockChanged(); } 64 65 void toggleAutopaint(); 66 67 public: 68 signals: 69 70 void paletteSwitched(); 71 void paletteChanged(); 72 void paletteTitleChanged(); 73 void colorStyleSwitched(); 74 void colorStyleChanged(bool); 75 void colorStyleChangedOnMouseRelease(); 76 void paletteDirtyFlagChanged(); 77 void paletteLockChanged(); 78 79 private: 80 friend class PaletteController; 81 82 bool connectBroadcasts(const QObject *receiver); 83 bool disconnectBroadcasts(const QObject *receiver); 84 85 private: 86 signals: 87 88 // Internal broadcaster signals to multiple palette handles. 89 // Do not connect to user code. 90 91 void broadcastPaletteChanged(); 92 void broadcastPaletteTitleChanged(); 93 void broadcastColorStyleSwitched(); 94 void broadcastColorStyleChanged(bool); 95 void broadcastColorStyleChangedOnMouseRelease(); 96 }; 97 98 #endif // TPALETTEHANDLE_H 99