refactor:move shadow to Effects

-rename also to shadow to innerShadow for
better naming. This shadow is used when the
shadow is drawn inside the window from qml
side, such examples are the dock case and the
editVisual case
pull/3/head
Michail Vourlakos 6 years ago
parent 253ca3085a
commit 3de7993b8d

@ -199,7 +199,6 @@ void DockView::init()
connect(&m_theme, &Plasma::Theme::themeChanged, this, &DockView::themeHasShadowChanged);
connect(this, SIGNAL(normalThicknessChanged()), corona(), SIGNAL(availableScreenRectChanged()));
connect(this, SIGNAL(shadowChanged()), corona(), SIGNAL(availableScreenRectChanged()));
connect(m_menuManager, &DockMenuManager::contextMenuChanged, this, &DockView::contextMenuIsShownChanged);
@ -488,9 +487,9 @@ bool DockView::contextMenuIsShown() const
int DockView::currentThickness() const
{
if (formFactor() == Plasma::Types::Vertical) {
return m_effects->mask().isNull() ? width() : m_effects->mask().width() - m_shadow;
return m_effects->mask().isNull() ? width() : m_effects->mask().width() - m_effects->innerShadow();
} else {
return m_effects->mask().isNull() ? height() : m_effects->mask().height() - m_shadow;
return m_effects->mask().isNull() ? height() : m_effects->mask().height() - m_effects->innerShadow();
}
}
@ -757,21 +756,6 @@ void DockView::setDockTransparency(int transparency)
emit dockTransparencyChanged();
}
int DockView::shadow() const
{
return m_shadow;
}
void DockView::setShadow(int shadow)
{
if (m_shadow == shadow)
return;
m_shadow = shadow;
emit shadowChanged();
}
int DockView::fontPixelSize() const
{
return m_fontPixelSize;

@ -89,7 +89,6 @@ class DockView : public PlasmaQuick::ContainmentView
Q_PROPERTY(int maxThickness READ maxThickness WRITE setMaxThickness NOTIFY maxThicknessChanged)
Q_PROPERTY(int normalThickness READ normalThickness WRITE setNormalThickness NOTIFY normalThicknessChanged)
Q_PROPERTY(int offset READ offset WRITE setOffset NOTIFY offsetChanged)
Q_PROPERTY(int shadow READ shadow WRITE setShadow NOTIFY shadowChanged)
Q_PROPERTY(QString currentScreen READ currentScreen NOTIFY currentScreenChanged)
@ -165,9 +164,6 @@ public:
int offset() const;
void setOffset(int offset);
int shadow() const;
void setShadow(int shadow);
int alignment() const;
void setAlignment(int alignment);
@ -267,7 +263,6 @@ signals:
void visibilityChanged();
void positionerChanged();
void screenGeometryChanged();
void shadowChanged();
void themeChanged();
void themeHasShadowChanged();
void totalDocksCountChanged();
@ -308,7 +303,6 @@ private:
int m_maxThickness{24};
int m_normalThickness{24};
int m_offset{0};
int m_shadow{0};
float m_maxLength{1};
Dock::Alignment m_alignment{Dock::Center};

@ -55,6 +55,8 @@ void Effects::init()
connect(m_view, &Latte::DockView::alignmentChanged, this, &Effects::updateEnabledBorders);
connect(m_view, &Latte::DockView::behaveAsPlasmaPanelChanged, this, &Effects::updateEffects);
connect(m_view, &Latte::DockView::dockTransparencyChanged, this, &Effects::updateEffects);
connect(this, SIGNAL(innerShadowChanged()), m_view->corona(), SIGNAL(availableScreenRectChanged()));
}
bool Effects::drawShadows() const
@ -109,6 +111,21 @@ void Effects::setForceDrawCenteredBorders(bool draw)
m_forceDrawCenteredBorders = draw;
}
int Effects::innerShadow() const
{
return m_innerShadow;
}
void Effects::setInnerShadow(int shadow)
{
if (m_innerShadow == shadow)
return;
m_innerShadow = shadow;
emit innerShadowChanged();
}
QRect Effects::rect() const
{
return m_rect;

@ -40,6 +40,9 @@ class Effects: public QObject
Q_PROPERTY(bool drawShadows READ drawShadows WRITE setDrawShadows NOTIFY drawShadowsChanged)
Q_PROPERTY(bool drawEffects READ drawEffects WRITE setDrawEffects NOTIFY drawEffectsChanged)
//! thickness shadow size when is drawn inside the window from qml
Q_PROPERTY(int innerShadow READ innerShadow WRITE setInnerShadow NOTIFY innerShadowChanged)
Q_PROPERTY(QRect mask READ mask WRITE setMask NOTIFY maskChanged)
Q_PROPERTY(QRect rect READ rect WRITE setRect NOTIFY rectChanged)
@ -58,6 +61,9 @@ public:
bool forceDrawCenteredBorders() const;
void setForceDrawCenteredBorders(bool draw);
int innerShadow() const;
void setInnerShadow(int shadow);
QRect mask() const;
void setMask(QRect area);
@ -75,6 +81,7 @@ signals:
void drawEffectsChanged();
void enabledBordersChanged();
void maskChanged();
void innerShadowChanged();
void rectChanged();
private slots:
@ -85,6 +92,8 @@ private:
bool m_drawEffects{false};
bool m_forceDrawCenteredBorders{false};
int m_innerShadow{0};
QRect m_rect;
QRect m_mask;

@ -108,14 +108,14 @@ void Positioner::init()
}
});
connect(m_view, &Latte::DockView::shadowChanged, this, [&]() {
if (m_view->behaveAsPlasmaPanel()) {
connect(m_view->effects(), &Latte::View::Effects::drawShadowsChanged, this, [&]() {
if (!m_view->behaveAsPlasmaPanel()) {
syncGeometry();
}
});
connect(m_view->effects(), &Latte::View::Effects::drawShadowsChanged, this, [&]() {
if (!m_view->behaveAsPlasmaPanel()) {
connect(m_view->effects(), &Latte::View::Effects::innerShadowChanged, this, [&]() {
if (m_view->behaveAsPlasmaPanel()) {
syncGeometry();
}
});
@ -456,7 +456,7 @@ void Positioner::updatePosition(QRect availableScreenRect)
float offs = static_cast<float>(m_view->offset());
return static_cast<int>(length * ((1 - m_view->maxLength()) / 2) + length * (offs / 100));
};
int cleanThickness = m_view->normalThickness() - m_view->shadow();
int cleanThickness = m_view->normalThickness() - m_view->effects()->innerShadow();
switch (m_view->location()) {
case Plasma::Types::TopEdge:

@ -446,7 +446,7 @@ QRegion DockCorona::availableScreenRegionWithCriteria(int id, QString forLayout)
for (const auto *view : *views) {
if (view && view->containment() && view->screen() == screen
&& view->visibility() && (view->visibility()->mode() != Latte::Dock::AutoHide)) {
int realThickness = view->normalThickness() - view->shadow();
int realThickness = view->normalThickness() - view->effects()->innerShadow();
// Usually availableScreenRect is used by the desktop,
// but Latte don't have desktop, then here just

@ -177,18 +177,6 @@ Item{
initializeEditPosition();
}
onEditAnimationEndedChanged: {
if (!dock) {
return;
}
if (editAnimationEnded && !root.behaveAsPlasmaPanel) {
dock.shadow = root.editShadow;
} else {
dock.shadow = root.panelShadow;
}
}
onXChanged: updateEffectsArea();
onYChanged: updateEffectsArea();

@ -141,10 +141,16 @@ Item{
}
Binding{
target: dock
property:"shadow"
when: dock
value: root.panelShadow
target: dock && dock.effects ? dock.effects : null
property:"innerShadow"
when: dock && dock.effects
value: {
if (editModeVisual.editAnimationEnded && !root.behaveAsPlasmaPanel) {
return root.editShadow;
} else {
return root.panelShadow;
}
}
}
Binding{

Loading…
Cancel
Save