KisGradientSlider.h 2.48 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
 * This file is part of Krita
 *
 * Copyright (c) 2006 Frederic Coiffier <fcoiffie@gmail.com>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

21 22
#ifndef KIS_GRADIENT_SLIDER_H
#define KIS_GRADIENT_SLIDER_H
23 24 25

// Qt includes.

26 27 28 29
#include <QWidget>
#include <QColor>
#include <QList>
#include <QPair>
30

31
#include "kritawidgets_export.h"
32

Boudewijn Rempt's avatar
Boudewijn Rempt committed
33 34 35 36
/**
 * @brief The KisGradientSlider class is a numerical slider that paints a light-dark
 * gradient for use in filters and histograms.
 */
37
class KRITAWIDGETS_EXPORT KisGradientSlider : public QWidget
38
{
Boudewijn Rempt's avatar
Boudewijn Rempt committed
39
    Q_OBJECT
40 41 42 43

    typedef enum {
        BlackCursor,
        GammaCursor,
44 45
        WhiteCursor,
        None
46 47 48
    } eCursor;

public:
49 50
    KisGradientSlider(QWidget *parent = 0);

51
    ~KisGradientSlider() override;
52

53 54
    int black() const;
    int white() const;
55

56
public Q_SLOTS:
57 58 59
    void slotModifyBlack(int);
    void slotModifyWhite(int);
    void slotModifyGamma(double);
60

61
Q_SIGNALS:
62 63 64
    void sigModifiedBlack(int);
    void sigModifiedWhite(int);
    void sigModifiedGamma(double);
65 66

protected:
67 68 69 70 71
    void paintEvent(QPaintEvent *) override;
    void resizeEvent(QResizeEvent *) override;
    void mousePressEvent(QMouseEvent * e) override;
    void mouseReleaseEvent(QMouseEvent * e) override;
    void mouseMoveEvent(QMouseEvent * e) override;
72 73 74 75

private:
    void calculateCursorPositions();
    unsigned int calculateGammaCursor();
76 77 78 79 80

public:
    void enableGamma(bool b);
    double getGamma(void);

81 82
    void enableWhite(bool b);

83 84
    void setInverted(bool b);

85
private:
86 87
    int m_leftmost;
    int m_rightmost;
88 89
    eCursor m_grabCursor;
    double m_scalingFactor;
90

91 92 93 94 95 96
    int m_blackCursor;
    int m_whiteCursor;
    int m_gammaCursor;

    int m_black;
    int m_white;
97 98

    double m_gamma;
99
    bool m_gammaEnabled;
100
    bool m_whiteEnabled;
101
    bool m_feedback;
102
    bool m_inverted;
103 104
};

105
#endif /* KIS_GRADIENT_SLIDER_H */