Support saturation/brightness in ThumbnailItem

Two new properties saturation and brightness are added to the
ThumbnailItem which can be set from QML.

The properties are honoured by the Scene when rendering the thumbnail.
icc-effect-5.14.5
Martin Gräßlin 2013-03-19 09:08:32 +01:00
parent e793067ab6
commit 15b84c54f8
3 changed files with 49 additions and 0 deletions

View File

@ -385,6 +385,8 @@ void Scene::paintWindow(Window* w, int mask, QRegion region, WindowQuadList quad
EffectWindowImpl *thumb = it.value().data();
WindowPaintData thumbData(thumb);
thumbData.setOpacity(data.opacity());
thumbData.setBrightness(data.brightness() * item->brightness());
thumbData.setSaturation(data.saturation() * item->saturation());
const QRect visualThumbRect(thumb->expandedGeometry());

View File

@ -39,6 +39,8 @@ ThumbnailItem::ThumbnailItem(QDeclarativeItem* parent)
, m_clip(true)
, m_parent(QWeakPointer<EffectWindowImpl>())
, m_parentWindow(0)
, m_brightness(1.0)
, m_saturation(1.0)
{
setFlags(flags() & ~QGraphicsItem::ItemHasNoContents);
Q_ASSERT(Compositor::isCreated());
@ -152,4 +154,24 @@ void ThumbnailItem::repaint(KWin::EffectWindow *w)
}
}
void ThumbnailItem::setBrightness(qreal brightness)
{
if (qFuzzyCompare(brightness, m_brightness)) {
return;
}
m_brightness = brightness;
update();
emit brightnessChanged();
}
void ThumbnailItem::setSaturation(qreal saturation)
{
if (qFuzzyCompare(saturation, m_saturation)) {
return;
}
m_saturation = saturation;
update();
emit saturationChanged();
}
} // namespace KWin

View File

@ -36,6 +36,8 @@ class ThumbnailItem : public QDeclarativeItem
Q_PROPERTY(qulonglong wId READ wId WRITE setWId NOTIFY wIdChanged SCRIPTABLE true)
Q_PROPERTY(bool clip READ isClip WRITE setClip NOTIFY clipChanged SCRIPTABLE true)
Q_PROPERTY(qulonglong parentWindow READ parentWindow WRITE setParentWindow)
Q_PROPERTY(qreal brightness READ brightness WRITE setBrightness NOTIFY brightnessChanged)
Q_PROPERTY(qreal saturation READ saturation WRITE setSaturation NOTIFY saturationChanged)
public:
explicit ThumbnailItem(QDeclarativeItem *parent = 0);
virtual ~ThumbnailItem();
@ -53,9 +55,18 @@ public:
return m_parentWindow;
}
void setParentWindow(qulonglong parentWindow);
qreal brightness() const;
qreal saturation() const;
public Q_SLOTS:
void setBrightness(qreal brightness);
void setSaturation(qreal saturation);
Q_SIGNALS:
void wIdChanged(qulonglong wid);
void clipChanged(bool clipped);
void brightnessChanged();
void saturationChanged();
private Q_SLOTS:
void init();
void effectWindowAdded();
@ -67,8 +78,22 @@ private:
bool m_clip;
QWeakPointer<EffectWindowImpl> m_parent;
qulonglong m_parentWindow;
qreal m_brightness;
qreal m_saturation;
};
inline
qreal ThumbnailItem::brightness() const
{
return m_brightness;
}
inline
qreal ThumbnailItem::saturation() const
{
return m_saturation;
}
} // KWin
#endif // KWIN_THUMBNAILITEM_H