2018-11-30 21:33:46 +02:00
/*
* Copyright 2018 Michail Vourlakos < mvourlakos @ gmail . com >
*
* This file is part of Latte - Dock
*
* Latte - Dock is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation ; either version 2 of
* the License , or ( at your option ) any later version .
*
* Latte - Dock is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < http : //www.gnu.org/licenses/>.
*/
# ifndef EFFECTS_H
# define EFFECTS_H
2018-12-02 02:05:52 +02:00
// Qt
2018-11-30 21:33:46 +02:00
# include <QObject>
# include <QPointer>
2019-03-08 23:43:08 +02:00
# include <QQuickView>
2018-11-30 21:33:46 +02:00
# include <QRect>
2018-12-02 02:05:52 +02:00
// Plasma
2018-11-30 21:33:46 +02:00
# include <Plasma/FrameSvg>
# include <Plasma/Theme>
namespace Latte {
2018-12-06 12:15:58 +02:00
class View ;
2018-11-30 21:33:46 +02:00
}
namespace Latte {
2018-12-06 11:37:14 +02:00
namespace ViewPart {
2018-11-30 21:33:46 +02:00
class Effects : public QObject
{
Q_OBJECT
2018-12-01 09:42:09 +02:00
Q_PROPERTY ( bool animationsBlocked READ animationsBlocked NOTIFY animationsBlockedChanged )
2018-11-30 21:33:46 +02:00
Q_PROPERTY ( bool drawShadows READ drawShadows WRITE setDrawShadows NOTIFY drawShadowsChanged )
Q_PROPERTY ( bool drawEffects READ drawEffects WRITE setDrawEffects NOTIFY drawEffectsChanged )
2019-03-08 23:43:08 +02:00
Q_PROPERTY ( bool settingsMaskSubtracted READ settingsMaskSubtracted WRITE setSettingsMaskSubtracted NOTIFY settingsMaskSubtractedChanged )
2018-11-30 21:33:46 +02:00
2018-12-01 00:52:05 +02:00
//! thickness shadow size when is drawn inside the window from qml
2019-03-09 12:23:51 +02:00
Q_PROPERTY ( int editShadow READ editShadow WRITE setEditShadow NOTIFY editShadowChanged )
2018-12-01 00:52:05 +02:00
Q_PROPERTY ( int innerShadow READ innerShadow WRITE setInnerShadow NOTIFY innerShadowChanged )
2020-05-10 16:49:43 +03:00
Q_PROPERTY ( float backgroundOpacity READ backgroundOpacity WRITE setBackgroundOpacity NOTIFY backgroundOpacityChanged )
2018-12-01 00:26:56 +02:00
Q_PROPERTY ( QRect mask READ mask WRITE setMask NOTIFY maskChanged )
Q_PROPERTY ( QRect rect READ rect WRITE setRect NOTIFY rectChanged )
2018-11-30 21:33:46 +02:00
Q_PROPERTY ( Plasma : : FrameSvg : : EnabledBorders enabledBorders READ enabledBorders NOTIFY enabledBordersChanged )
public :
2018-12-06 12:15:58 +02:00
Effects ( Latte : : View * parent ) ;
2018-11-30 21:33:46 +02:00
virtual ~ Effects ( ) ;
2018-12-01 09:42:09 +02:00
bool animationsBlocked ( ) const ;
void setAnimationsBlocked ( bool blocked ) ;
2018-11-30 21:33:46 +02:00
bool drawShadows ( ) const ;
void setDrawShadows ( bool draw ) ;
bool drawEffects ( ) const ;
void setDrawEffects ( bool draw ) ;
2020-03-02 18:44:40 +02:00
void setForceTopBorder ( bool draw ) ;
void setForceBottomBorder ( bool draw ) ;
2018-11-30 21:33:46 +02:00
2019-03-08 23:43:08 +02:00
bool settingsMaskSubtracted ( ) const ;
void setSettingsMaskSubtracted ( bool enabled ) ;
2019-03-09 12:23:51 +02:00
int editShadow ( ) const ;
void setEditShadow ( int shadow ) ;
2018-12-01 00:52:05 +02:00
int innerShadow ( ) const ;
void setInnerShadow ( int shadow ) ;
2020-05-10 16:49:43 +03:00
float backgroundOpacity ( ) const ;
void setBackgroundOpacity ( float opacity ) ;
2018-12-01 00:26:56 +02:00
QRect mask ( ) const ;
void setMask ( QRect area ) ;
2018-11-30 21:33:46 +02:00
2018-12-01 00:26:56 +02:00
QRect rect ( ) const ;
void setRect ( QRect area ) ;
2018-11-30 21:33:46 +02:00
Plasma : : FrameSvg : : EnabledBorders enabledBorders ( ) const ;
public slots :
2019-04-16 23:51:06 +03:00
Q_INVOKABLE void forceMaskRedraw ( ) ;
2018-12-01 10:18:56 +02:00
void clearShadows ( ) ;
void updateShadows ( ) ;
2018-11-30 21:33:46 +02:00
void updateEffects ( ) ;
void updateEnabledBorders ( ) ;
2019-04-11 16:55:45 +03:00
void updateMask ( ) ;
2018-11-30 21:33:46 +02:00
signals :
2018-12-01 09:42:09 +02:00
void animationsBlockedChanged ( ) ;
2018-12-01 09:29:20 +02:00
void backgroundOpacityChanged ( ) ;
2018-11-30 21:33:46 +02:00
void drawShadowsChanged ( ) ;
void drawEffectsChanged ( ) ;
2019-03-09 12:23:51 +02:00
void editShadowChanged ( ) ;
2018-11-30 21:33:46 +02:00
void enabledBordersChanged ( ) ;
2018-12-01 00:26:56 +02:00
void maskChanged ( ) ;
2018-12-01 00:52:05 +02:00
void innerShadowChanged ( ) ;
2018-12-01 00:26:56 +02:00
void rectChanged ( ) ;
2019-03-08 23:43:08 +02:00
void settingsMaskSubtractedChanged ( ) ;
2018-11-30 21:33:46 +02:00
private slots :
void init ( ) ;
2019-03-08 23:43:08 +02:00
2019-06-16 15:31:37 +03:00
void updateBackgroundContrastValues ( ) ;
2019-03-08 23:43:08 +02:00
private :
2019-06-16 15:31:37 +03:00
qreal currentMidValue ( const qreal & max , const qreal & factor , const qreal & min ) const ;
2019-03-08 23:43:08 +02:00
QRegion subtractedMask ( ) ;
QRegion subtrackedMaskFromWindow ( QRegion initialRegion , QQuickView * window ) ;
2018-11-30 21:33:46 +02:00
private :
2018-12-01 09:42:09 +02:00
bool m_animationsBlocked { false } ;
2018-11-30 21:33:46 +02:00
bool m_drawShadows { true } ;
bool m_drawEffects { false } ;
2020-03-02 18:44:40 +02:00
bool m_forceTopBorder { false } ;
bool m_forceBottomBorder { false } ;
2019-03-08 23:43:08 +02:00
bool m_settingsMaskSubtracted { false } ;
2018-11-30 21:33:46 +02:00
2019-03-09 12:23:51 +02:00
int m_editShadow { 0 } ;
2018-12-01 00:52:05 +02:00
int m_innerShadow { 0 } ;
2020-05-10 16:49:43 +03:00
float m_backgroundOpacity { 1.0 } ;
2019-06-16 15:31:37 +03:00
qreal m_backEffectContrast { 1 } ;
qreal m_backEffectIntesity { 1 } ;
qreal m_backEffectSaturation { 1 } ;
2018-12-01 00:26:56 +02:00
QRect m_rect ;
QRect m_mask ;
2018-11-30 21:33:46 +02:00
2018-12-06 12:15:58 +02:00
QPointer < Latte : : View > m_view ;
2018-11-30 21:33:46 +02:00
Plasma : : Theme m_theme ;
//only for the mask on disabled compositing, not to actually paint
Plasma : : FrameSvg * m_background { nullptr } ;
//only for the mask, not to actually paint
Plasma : : FrameSvg : : EnabledBorders m_enabledBorders { Plasma : : FrameSvg : : AllBorders } ;
} ;
}
}
# endif