mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-24 17:33:50 +03:00
new Effects API for mask United/Subtracted regions
--View::Effects now provides in API in order for elements to publish regions that need to be added or removed from View::mask(). A good example for this is View Config windows that must remove a rectangle for their bottom edge in order for users to have fully access to their action buttons at the bottom.
This commit is contained in:
parent
54ea58c215
commit
614bb7014f
@ -54,6 +54,9 @@ void Effects::init()
|
||||
connect(this, &Effects::enabledBordersChanged, this, &Effects::updateEffects);
|
||||
connect(this, &Effects::rectChanged, this, &Effects::updateEffects);
|
||||
|
||||
connect(this, &Effects::subtractedMaskRegionsChanged, this, &Effects::updateMask);
|
||||
connect(this, &Effects::unitedMaskRegionsChanged, this, &Effects::updateMask);
|
||||
|
||||
connect(this, &Effects::drawShadowsChanged, this, [&]() {
|
||||
if (m_view->behaveAsPlasmaPanel()) {
|
||||
updateEnabledBorders();
|
||||
@ -67,7 +70,6 @@ void Effects::init()
|
||||
connect(m_view, &Latte::View::behaveAsPlasmaPanelChanged, this, &Effects::updateShadows);
|
||||
connect(m_view, &Latte::View::configWindowGeometryChanged, this, &Effects::updateMask);
|
||||
|
||||
|
||||
connect(&m_theme, &Plasma::Theme::themeChanged, this, [&]() {
|
||||
auto background = m_background;
|
||||
m_background = new Plasma::FrameSvg(this);
|
||||
@ -245,13 +247,68 @@ void Effects::forceMaskRedraw()
|
||||
updateMask();
|
||||
}
|
||||
|
||||
void Effects::setSubtractedMaskRegion(const QString ®ionid, const QRegion ®ion)
|
||||
{
|
||||
if (!m_subtractedMaskRegions.contains(regionid) || m_subtractedMaskRegions[regionid] != region) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_subtractedMaskRegions[regionid] = region;
|
||||
emit subtractedMaskRegionsChanged();
|
||||
}
|
||||
|
||||
void Effects::removeSubtractedMaskRegion(const QString ®ionid)
|
||||
{
|
||||
if (!m_subtractedMaskRegions.contains(regionid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_subtractedMaskRegions.remove(regionid);
|
||||
emit subtractedMaskRegionsChanged();
|
||||
}
|
||||
|
||||
void Effects::setUnitedMaskRegion(const QString ®ionid, const QRegion ®ion)
|
||||
{
|
||||
if (!m_unitedMaskRegions.contains(regionid) || m_unitedMaskRegions[regionid] != region) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_unitedMaskRegions[regionid] = region;
|
||||
emit unitedMaskRegionsChanged();
|
||||
}
|
||||
|
||||
void Effects::removeUnitedMaskRegion(const QString ®ionid)
|
||||
{
|
||||
if (!m_unitedMaskRegions.contains(regionid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_unitedMaskRegions.remove(regionid);
|
||||
emit unitedMaskRegionsChanged();
|
||||
}
|
||||
|
||||
QRegion Effects::maskCombinedRegion()
|
||||
{
|
||||
QRegion region = m_mask;
|
||||
|
||||
for(auto subregion : m_subtractedMaskRegions) {
|
||||
region = region.subtracted(subregion);
|
||||
}
|
||||
|
||||
for(auto subregion : m_unitedMaskRegions) {
|
||||
region = region.united(subregion);
|
||||
}
|
||||
|
||||
return region;
|
||||
}
|
||||
|
||||
void Effects::updateMask()
|
||||
{
|
||||
if (KWindowSystem::compositingActive()) {
|
||||
if (m_view->behaveAsPlasmaPanel()) {
|
||||
m_view->setMask(QRect());
|
||||
} else {
|
||||
m_view->setMask(m_mask);
|
||||
m_view->setMask(maskCombinedRegion());
|
||||
}
|
||||
} else {
|
||||
//! this is used when compositing is disabled and provides
|
||||
|
@ -90,6 +90,10 @@ public:
|
||||
|
||||
public slots:
|
||||
Q_INVOKABLE void forceMaskRedraw();
|
||||
Q_INVOKABLE void setSubtractedMaskRegion(const QString ®ionid, const QRegion ®ion);
|
||||
Q_INVOKABLE void removeSubtractedMaskRegion(const QString ®ionid);
|
||||
Q_INVOKABLE void setUnitedMaskRegion(const QString ®ionid, const QRegion ®ion);
|
||||
Q_INVOKABLE void removeUnitedMaskRegion(const QString ®ionid);
|
||||
|
||||
void clearShadows();
|
||||
void updateShadows();
|
||||
@ -108,6 +112,9 @@ signals:
|
||||
void innerShadowChanged();
|
||||
void rectChanged();
|
||||
|
||||
void subtractedMaskRegionsChanged();
|
||||
void unitedMaskRegionsChanged();
|
||||
|
||||
private slots:
|
||||
void init();
|
||||
|
||||
@ -115,6 +122,7 @@ private slots:
|
||||
|
||||
private:
|
||||
qreal currentMidValue(const qreal &max, const qreal &factor, const qreal &min) const;
|
||||
QRegion maskCombinedRegion();
|
||||
|
||||
private:
|
||||
bool m_animationsBlocked{false};
|
||||
@ -143,6 +151,10 @@ private:
|
||||
|
||||
//only for the mask, not to actually paint
|
||||
Plasma::FrameSvg::EnabledBorders m_enabledBorders{Plasma::FrameSvg::AllBorders};
|
||||
|
||||
//! Subtracted and United Mask regions
|
||||
QHash<QString, QRegion> m_subtractedMaskRegions;
|
||||
QHash<QString, QRegion> m_unitedMaskRegions;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user