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.
This commit is contained in:
parent
e793067ab6
commit
15b84c54f8
3 changed files with 49 additions and 0 deletions
|
@ -385,6 +385,8 @@ void Scene::paintWindow(Window* w, int mask, QRegion region, WindowQuadList quad
|
||||||
EffectWindowImpl *thumb = it.value().data();
|
EffectWindowImpl *thumb = it.value().data();
|
||||||
WindowPaintData thumbData(thumb);
|
WindowPaintData thumbData(thumb);
|
||||||
thumbData.setOpacity(data.opacity());
|
thumbData.setOpacity(data.opacity());
|
||||||
|
thumbData.setBrightness(data.brightness() * item->brightness());
|
||||||
|
thumbData.setSaturation(data.saturation() * item->saturation());
|
||||||
|
|
||||||
const QRect visualThumbRect(thumb->expandedGeometry());
|
const QRect visualThumbRect(thumb->expandedGeometry());
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,8 @@ ThumbnailItem::ThumbnailItem(QDeclarativeItem* parent)
|
||||||
, m_clip(true)
|
, m_clip(true)
|
||||||
, m_parent(QWeakPointer<EffectWindowImpl>())
|
, m_parent(QWeakPointer<EffectWindowImpl>())
|
||||||
, m_parentWindow(0)
|
, m_parentWindow(0)
|
||||||
|
, m_brightness(1.0)
|
||||||
|
, m_saturation(1.0)
|
||||||
{
|
{
|
||||||
setFlags(flags() & ~QGraphicsItem::ItemHasNoContents);
|
setFlags(flags() & ~QGraphicsItem::ItemHasNoContents);
|
||||||
Q_ASSERT(Compositor::isCreated());
|
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
|
} // namespace KWin
|
||||||
|
|
|
@ -36,6 +36,8 @@ class ThumbnailItem : public QDeclarativeItem
|
||||||
Q_PROPERTY(qulonglong wId READ wId WRITE setWId NOTIFY wIdChanged SCRIPTABLE true)
|
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(bool clip READ isClip WRITE setClip NOTIFY clipChanged SCRIPTABLE true)
|
||||||
Q_PROPERTY(qulonglong parentWindow READ parentWindow WRITE setParentWindow)
|
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:
|
public:
|
||||||
explicit ThumbnailItem(QDeclarativeItem *parent = 0);
|
explicit ThumbnailItem(QDeclarativeItem *parent = 0);
|
||||||
virtual ~ThumbnailItem();
|
virtual ~ThumbnailItem();
|
||||||
|
@ -53,9 +55,18 @@ public:
|
||||||
return m_parentWindow;
|
return m_parentWindow;
|
||||||
}
|
}
|
||||||
void setParentWindow(qulonglong parentWindow);
|
void setParentWindow(qulonglong parentWindow);
|
||||||
|
qreal brightness() const;
|
||||||
|
qreal saturation() const;
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
void setBrightness(qreal brightness);
|
||||||
|
void setSaturation(qreal saturation);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void wIdChanged(qulonglong wid);
|
void wIdChanged(qulonglong wid);
|
||||||
void clipChanged(bool clipped);
|
void clipChanged(bool clipped);
|
||||||
|
void brightnessChanged();
|
||||||
|
void saturationChanged();
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void init();
|
void init();
|
||||||
void effectWindowAdded();
|
void effectWindowAdded();
|
||||||
|
@ -67,8 +78,22 @@ private:
|
||||||
bool m_clip;
|
bool m_clip;
|
||||||
QWeakPointer<EffectWindowImpl> m_parent;
|
QWeakPointer<EffectWindowImpl> m_parent;
|
||||||
qulonglong m_parentWindow;
|
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
|
} // KWin
|
||||||
|
|
||||||
#endif // KWIN_THUMBNAILITEM_H
|
#endif // KWIN_THUMBNAILITEM_H
|
||||||
|
|
Loading…
Reference in a new issue