Changeset View
Changeset View
Standalone View
Standalone View
plugins/tools/basictools/kis_tool_colorpicker.h
Context not available. | |||||
27 | #include "ui_wdgcolorpicker.h" | 27 | #include "ui_wdgcolorpicker.h" | ||
---|---|---|---|---|---|
28 | #include "kis_tool.h" | 28 | #include "kis_tool.h" | ||
29 | #include <kis_icon.h> | 29 | #include <kis_icon.h> | ||
30 | #include "kis_tool_utils.h" | ||||
30 | 31 | | |||
31 | class KoResource; | 32 | class KoResource; | ||
32 | class KoColorSet; | 33 | class KoColorSet; | ||
Context not available. | |||||
48 | class KisToolColorPicker : public KisTool | 49 | class KisToolColorPicker : public KisTool | ||
49 | { | 50 | { | ||
50 | Q_OBJECT | 51 | Q_OBJECT | ||
51 | Q_PROPERTY(bool toForeground READ toForeground WRITE setToForeground NOTIFY toForegroundChanged) | | |||
52 | 52 | | |||
53 | public: | 53 | public: | ||
54 | KisToolColorPicker(KoCanvasBase *canvas); | 54 | KisToolColorPicker(KoCanvasBase *canvas); | ||
55 | ~KisToolColorPicker() override; | 55 | ~KisToolColorPicker() override; | ||
56 | 56 | | |||
57 | public: | | |||
58 | struct Configuration { | | |||
59 | Configuration(); | | |||
60 | | ||||
61 | bool toForegroundColor; | | |||
62 | bool updateColor; | | |||
63 | bool addPalette; | | |||
64 | bool normaliseValues; | | |||
65 | bool sampleMerged; | | |||
66 | int radius; | | |||
67 | int blend; | | |||
68 | | ||||
69 | void save(ToolActivation activation) const; | | |||
70 | void load(ToolActivation activation); | | |||
71 | }; | | |||
72 | | ||||
73 | public: | | |||
74 | QWidget* createOptionWidget() override; | 57 | QWidget* createOptionWidget() override; | ||
75 | 58 | | |||
76 | void beginPrimaryAction(KoPointerEvent *event) override; | 59 | void beginPrimaryAction(KoPointerEvent *event) override; | ||
77 | void continuePrimaryAction(KoPointerEvent *event) override; | 60 | void continuePrimaryAction(KoPointerEvent *event) override; | ||
78 | void endPrimaryAction(KoPointerEvent *event) override; | 61 | void endPrimaryAction(KoPointerEvent *event) override; | ||
79 | 62 | | |||
80 | void paint(QPainter &gc, const KoViewConverter &converter) override; | 63 | void beginAlternateAction(KoPointerEvent *event, AlternateAction action) override; | ||
81 | 64 | | |||
82 | bool toForeground() const; | 65 | void paint(QPainter &gc, const KoViewConverter &converter) override; | ||
83 | 66 | | |||
84 | Q_SIGNALS: | 67 | Q_SIGNALS: | ||
85 | void toForegroundChanged(); | 68 | void toForegroundChanged(); | ||
86 | 69 | | |||
70 | public Q_SLOTS: | ||||
71 | void slotSetSamplingSource(int); | ||||
72 | void slotSetUpdate(bool); | ||||
73 | void slotNormalizeColorData(bool); | ||||
74 | void slotChangeRadius(int); | ||||
75 | void slotChangeMix(int); | ||||
76 | | ||||
87 | protected: | 77 | protected: | ||
88 | void activate(ToolActivation activation, const QSet<KoShape*> &) override; | 78 | void activate(ToolActivation activation, const QSet<KoShape*> &) override; | ||
89 | void deactivate() override; | 79 | void deactivate() override; | ||
90 | 80 | | |||
91 | public Q_SLOTS: | | |||
92 | void setToForeground(bool newValue); | | |||
93 | void slotSetUpdateColor(bool); | | |||
94 | void slotSetNormaliseValues(bool); | | |||
95 | void slotSetAddPalette(bool); | | |||
96 | void slotChangeRadius(int); | | |||
97 | void slotChangeBlend(int); | | |||
98 | void slotAddPalette(KoResource* resource); | | |||
99 | void slotSetColorSource(int value); | | |||
100 | | ||||
101 | private: | 81 | private: | ||
102 | void displayPickedColor(); | 82 | void displayPickedColor(); | ||
103 | bool pickColor(const QPointF& pos); | 83 | bool pickColor(const QPointF& pos, bool pure = false); | ||
104 | void updateOptionWidget(); | 84 | void updateCursor(KisPickerUtils::SamplingSource source); | ||
105 | 85 | void updateOptionsWidget(); | |||
106 | // Configuration | | |||
107 | QScopedPointer<KisToolUtils::ColorPickerConfig> m_config; | | |||
108 | 86 | | |||
87 | QScopedPointer<KisPickerUtils::ColorPickerConfig> m_config; | ||||
109 | ToolActivation m_toolActivationSource; | 88 | ToolActivation m_toolActivationSource; | ||
110 | bool m_isActivated; | 89 | bool m_isActivated; | ||
111 | | ||||
112 | KoColor m_pickedColor; | 90 | KoColor m_pickedColor; | ||
113 | 91 | QTimer m_resampleDelayTimer; | |||
114 | // Used to skip some tablet events and update color less often | | |||
115 | QTimer m_colorPickerDelayTimer; | | |||
116 | | ||||
117 | ColorPickerOptionsWidget *m_optionsWidget; | 92 | ColorPickerOptionsWidget *m_optionsWidget; | ||
118 | | ||||
119 | QList<KoColorSet*> m_palettes; | 93 | QList<KoColorSet*> m_palettes; | ||
120 | }; | 94 | }; | ||
121 | 95 | | |||
Context not available. | |||||
124 | public: | 98 | public: | ||
125 | KisToolColorPickerFactory() | 99 | KisToolColorPickerFactory() | ||
126 | : KoToolFactoryBase("KritaSelected/KisToolColorPicker") { | 100 | : KoToolFactoryBase("KritaSelected/KisToolColorPicker") { | ||
127 | setToolTip(i18n("Color Selector Tool")); | 101 | setToolTip(i18n("Color Picker Tool")); | ||
128 | setSection(TOOL_TYPE_FILL); | 102 | setSection(TOOL_TYPE_FILL); | ||
129 | setPriority(2); | 103 | setPriority(2); | ||
130 | setIconName(koIconNameCStr("krita_tool_color_picker")); | 104 | setIconName(koIconNameCStr("krita_tool_color_picker")); | ||
Context not available. |