1 /*
2  *  dlg_colorrange.h -- part of KimageShop^WKrayon^WKrita
3  *
4  *  Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org>
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20 #ifndef DLG_COLORRANGE
21 #define DLG_COLORRANGE
22 
23 #include <QCursor>
24 
25 #include <KoDialog.h>
26 
27 #include <kis_selection.h> // For enums
28 #include <kis_pixel_selection.h>
29 #include <kis_types.h>
30 #include <kis_global.h>
31 
32 #include "ui_wdg_colorrange.h"
33 
34 class KisViewManager;
35 class DlgColorRange;
36 
37 enum enumAction {
38     REDS,
39     YELLOWS,
40     GREENS,
41     CYANS,
42     BLUES,
43     MAGENTAS,
44     HIGHLIGHTS,
45     MIDTONES,
46     SHADOWS
47 };
48 
49 class WdgColorRange : public QWidget, public Ui::WdgColorRange
50 {
51     Q_OBJECT
52 
53 public:
WdgColorRange(QWidget * parent)54     WdgColorRange(QWidget *parent) : QWidget(parent) {
55         setupUi(this);
56     }
57 };
58 
59 /**
60 * This dialog allows the user to create a selection mask based
61 * on a (range of) colors.
62 */
63 class DlgColorRange: public KoDialog
64 {
65 
66     Q_OBJECT
67 
68 public:
69 
70     DlgColorRange(KisViewManager *viewManager, QWidget *parent = 0);
71     ~DlgColorRange() override;
72 
73 private Q_SLOTS:
74 
75     void okClicked();
76     void cancelClicked();
77 
78     void slotInvertClicked();
79     void slotSelectionTypeChanged(int index);
80     void slotSubtract(bool on);
81     void slotAdd(bool on);
82     void slotSelectClicked();
83     void slotDeselectClicked();
84 
85 private:
86     QImage createMask(KisSelectionSP selection, KisPaintDeviceSP layer);
87 
88 private:
89 
90     WdgColorRange *m_page;
91     int m_selectionCommandsAdded;
92     KisViewManager *m_viewManager;
93     SelectionAction m_mode;
94     QCursor m_oldCursor;
95     enumAction m_currentAction;
96     bool m_invert;
97 };
98 
99 
100 #endif // DLG_COLORRANGE
101