2
* Copyright (c) 2010 Adam Celarek <kdedev at xibo dot at>
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published by
6
* the Free Software Foundation; version 2 of the License.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
#ifndef KIS_COLOR_PATCHES_H
19
#define KIS_COLOR_PATCHES_H
21
#include "kis_color_selector_base.h"
29
class KisColorPatches : public KisColorSelectorBase
33
explicit KisColorPatches(QString configPrefix, QWidget *parent = 0);
34
enum Direction { Horizontal, Vertical };
36
void setColors(QList<KoColor> colors);
37
QList<KoColor> colors() const {return m_colors;}
38
virtual void setCanvas(KisCanvas2 *canvas) {m_canvas=canvas;}
41
void updateSettings();
44
void paintEvent(QPaintEvent *);
45
void wheelEvent(QWheelEvent *);
46
void resizeEvent(QResizeEvent *);
47
void mouseReleaseEvent(QMouseEvent *);
48
void mousePressEvent(QMouseEvent *);
49
void mouseMoveEvent(QMouseEvent *);
50
int patchCount() const;
51
bool colorAt(const QPoint &, KoColor *result) const;
54
/// set buttons, that should be drawn additionally to the patches
55
/// this class takes ownership of them and will delete them
56
/// they will be resized to the patchsize
57
void setAdditionalButtons(QList<QWidget*> buttonList);
63
QList<KoColor> m_colors;
64
bool m_allowColorListChangeGuard;
67
Direction m_direction;
68
bool m_allowScrolling;
71
QList<QWidget*> m_buttonList;
73
/// returns width of the patchfield, if there are only m_numRows allowed
74
int widthOfAllPatches();
75
/// returns height of the patchfield, if there are only m_numCols allowed
76
int heightOfAllPatches();
78
/// returns height, that is needed to display all patches with the given width
79
int heightForWidth(int width) const;
80
/// returns width, that is needed to display all patches with the given height
81
int widthForHeight(int height) const;
83
/// returns count of colors and buttons
84
int fieldCount() const;
86
QString m_configPrefix;
88
QPoint m_dragStartPos;