| 1 |
/* |
| 2 |
* SPDX-FileCopyrightText: 2020 Mathias Wein <[email protected]> |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: GPL-3.0-or-later |
| 5 |
*/ |
| 6 |
|
| 7 |
#ifndef WGCOLORPATCHES_H |
| 8 |
#define WGCOLORPATCHES_H |
| 9 |
|
| 10 |
#include "WGSelectorWidgetBase.h" |
| 11 |
|
| 12 |
#include <kis_types.h> |
| 13 |
|
| 14 |
class KisUniqueColorSet; |
| 15 |
class KoColorDisplayRendererInterface; |
| 16 |
class QToolButton; |
| 17 |
|
| 18 |
namespace WGConfig { |
| 19 |
struct ColorPatches; |
| 20 |
} |
| 21 |
|
| 22 |
class WGColorPatches : public WGSelectorWidgetBase |
| 23 |
{ |
| 24 |
Q_OBJECT |
| 25 |
public: |
| 26 |
enum Preset { |
| 27 |
None, |
| 28 |
History, |
| 29 |
CommonColors |
| 30 |
}; |
| 31 |
|
| 32 |
WGColorPatches(WGSelectorDisplayConfigSP displayConfig, KisUniqueColorSet *history, QWidget *parent = nullptr); |
| 33 |
|
| 34 |
KisUniqueColorSet* colorHistory() const; |
| 35 |
void updateSettings() override; |
| 36 |
void setPreset(Preset preset); |
| 37 |
QPoint popupOffset() const override; |
| 38 |
/*! set buttons, that should be drawn additionally to the patches |
| 39 |
* this class takes ownership of them and will delete them |
| 40 |
* they will be resized to the patchsize */ |
| 41 |
void setAdditionalButtons(QList<QToolButton*> buttonList); |
| 42 |
void setColorHistory(KisUniqueColorSet *history); |
| 43 |
public Q_SLOTS: |
| 44 |
void updateIcons(); |
| 45 |
protected: |
| 46 |
bool event(QEvent *event) override; |
| 47 |
bool eventFilter(QObject *watched, QEvent *e) override; |
| 48 |
void mouseMoveEvent(QMouseEvent *event) override; |
| 49 |
void mousePressEvent(QMouseEvent *event) override; |
| 50 |
void mouseReleaseEvent(QMouseEvent *event) override; |
| 51 |
void wheelEvent(QWheelEvent *event) override; |
| 52 |
void contentPaintEvent(QPaintEvent *event); |
| 53 |
void resizeEvent(QResizeEvent *event) override; |
| 54 |
QSize sizeHint() const override; |
| 55 |
|
| 56 |
int indexAt(const QPoint &widgetPos) const; |
| 57 |
QRect patchRect(int gridIndex) const; |
| 58 |
QPoint scrollOffset() const; |
| 59 |
void updateMetrics(); |
| 60 |
QToolButton* fetchButton(QList<QToolButton*> &recycleList); |
| 61 |
void reconnectButtons(KisUniqueColorSet *oldSet, KisUniqueColorSet *newSet); |
| 62 |
|
| 63 |
private: |
| 64 |
QPointer<KisUniqueColorSet> m_colors; |
| 65 |
QList<QToolButton*> m_buttonList; |
| 66 |
Qt::Orientation m_orientation {Qt::Horizontal}; |
| 67 |
const WGConfig::ColorPatches *m_configSource {0}; |
| 68 |
QWidget *m_viewport {0}; |
| 69 |
QWidget *m_contentWidget {0}; |
| 70 |
int m_numLines {1}; |
| 71 |
int m_patchesPerLine {30}; |
| 72 |
int m_totalLines {1}; |
| 73 |
int m_patchWidth {16}; |
| 74 |
int m_patchHeight {16}; |
| 75 |
int m_patchCount {30}; |
| 76 |
int m_scrollValue {0}; |
| 77 |
int m_maxScroll {0}; |
| 78 |
int m_mouseIndex {-1}; |
| 79 |
bool m_allowScrolling {true}; |
| 80 |
bool m_scrollInline {true}; |
| 81 |
Preset m_preset {None}; |
| 82 |
|
| 83 |
Q_SIGNALS: |
| 84 |
void sigColorChanged(const KoColor &color); |
| 85 |
|
| 86 |
}; |
| 87 |
|
| 88 |
#endif // WGCOLORPATCHES_H |