File indexing completed on 2025-01-26 04:09:58

0001 /*
0002  * SPDX-FileCopyrightText: 2023 Sharaf Zaman <shzam@sdf.org>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 #ifndef __KISCOLORPATCHESTABLEVIEW_H_
0008 #define __KISCOLORPATCHESTABLEVIEW_H_
0009 
0010 #include <QAbstractItemModel>
0011 #include <QScroller>
0012 #include <QTableView>
0013 
0014 #include <KisKineticScroller.h>
0015 #include <KoColor.h>
0016 
0017 class KoColor;
0018 class KisCanvas2;
0019 
0020 class KisColorPatchesTableView : public QTableView
0021 {
0022     Q_OBJECT
0023 public:
0024     KisColorPatchesTableView(const QString &configPrefix, QWidget *parent = nullptr);
0025     ~KisColorPatchesTableView() override;
0026 
0027     void setColors(const QList<KoColor> &colors);
0028     void addColorPatch(const KoColor &color);
0029     QList<KoColor> colors() const;
0030     boost::optional<KoColor> colorPatchAt(const QPoint &pos) const;
0031 
0032     QSize cellSize() const;
0033     int patchCount() const;
0034     void reloadWidgetConfig();
0035 
0036     void wheelEvent(QWheelEvent *event) override;
0037     void mousePressEvent(QMouseEvent *event) override;
0038     void mouseReleaseEvent(QMouseEvent *event) override;
0039 
0040 public Q_SLOTS:
0041     void slotScrollerStateChanged(QScroller::State state)
0042     {
0043         KisKineticScroller::updateCursor(this, state);
0044     }
0045 
0046 private:
0047     void redraw();
0048 
0049 private:
0050     struct Private;
0051     QScopedPointer<Private> m_d;
0052 };
0053 
0054 #endif // __KISCOLORPATCHESTABLEVIEW_H_