~stolowski/unity-2d/hud-mouse-steals-focus-fix

« back to all changes in this revision

Viewing changes to libunity-2d-private/src/colorizeeffect.h

Compute the wallpaper average color and use it to colorize the launcher's, panel's and dash's background. Thanks to Florian Boucault. Fixes: https://bugs.launchpad.net/bugs/960194. Approved by Michał Sawicz.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2012 Canonical, Ltd.
 
3
 *
 
4
 * Authors:
 
5
 *  Florian Boucault <florian.boucault@canonical.com>
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation; version 3.
 
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, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
 
 
20
#ifndef COLORIZEEFFECT_H
 
21
#define COLORIZEEFFECT_H
 
22
 
 
23
#include <QGraphicsEffect>
 
24
#include <QColor>
 
25
 
 
26
class ColorizeEffect : public QGraphicsEffect
 
27
{
 
28
    Q_OBJECT
 
29
 
 
30
    Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
 
31
    Q_PROPERTY(qreal saturation READ saturation WRITE setSaturation NOTIFY saturationChanged)
 
32
 
 
33
public:
 
34
    explicit ColorizeEffect(QObject *parent = 0);
 
35
 
 
36
    // getters
 
37
    QColor color() const;
 
38
    qreal saturation() const;
 
39
 
 
40
    // setters
 
41
    void setColor(const QColor &color);
 
42
    void setSaturation(qreal saturation);
 
43
 
 
44
Q_SIGNALS:
 
45
    void colorChanged(const QColor &color);
 
46
    void saturationChanged(qreal saturation);
 
47
 
 
48
protected:
 
49
    void draw(QPainter *painter);
 
50
    void sourceChanged(ChangeFlags flags);
 
51
 
 
52
private:
 
53
    QColor m_color;
 
54
    qreal m_saturation;
 
55
 
 
56
    // caching of intermediary renderings
 
57
    QPixmap m_tintedPixmap;
 
58
};
 
59
 
 
60
#endif // COLORIZEEFFECT_H