diff --git a/kdecoration/breezedecoration.cpp b/kdecoration/breezedecoration.cpp --- a/kdecoration/breezedecoration.cpp +++ b/kdecoration/breezedecoration.cpp @@ -65,8 +65,8 @@ //________________________________________________________________ static int g_sDecoCount = 0; - static int g_shadowSize = 0; - static int g_shadowStrength = 0; + static int g_shadowSizeEnum = InternalSettings::ShadowLarge; + static int g_shadowStrength = 90; static QColor g_shadowColor = Qt::black; static QSharedPointer g_sShadow; @@ -626,52 +626,74 @@ // assign global shadow if exists and parameters match if( !g_sShadow || - g_shadowSize != m_internalSettings->shadowSize() || + g_shadowSizeEnum != m_internalSettings->shadowSize() || g_shadowStrength != m_internalSettings->shadowStrength() || g_shadowColor != m_internalSettings->shadowColor() ) { // assign parameters - g_shadowSize = m_internalSettings->shadowSize(); + g_shadowSizeEnum = m_internalSettings->shadowSize(); g_shadowStrength = m_internalSettings->shadowStrength(); g_shadowColor = m_internalSettings->shadowColor(); - const int shadowOffset = qMax( 6*g_shadowSize/16, Metrics::Shadow_Overlap*2 ); + + // shadow size from enum + int shadowSize = 0; + switch( g_shadowSizeEnum ) + { + default: + case InternalSettings::ShadowLarge: shadowSize = 64; break; + + case InternalSettings::ShadowNone: shadowSize = Metrics::Shadow_Overlap + 1; break; + case InternalSettings::ShadowSmall: shadowSize = 16; break; + case InternalSettings::ShadowMedium: shadowSize = 32; break; + case InternalSettings::ShadowVeryLarge: shadowSize = 96; break; + } + + // offset + int shadowOffset = (g_shadowSizeEnum == InternalSettings::ShadowNone) ? 0 : qMax( 6*shadowSize/16, Metrics::Shadow_Overlap*2 ); // create image - QImage image(2*g_shadowSize, 2*g_shadowSize, QImage::Format_ARGB32_Premultiplied); + QImage image(2*shadowSize, 2*shadowSize, QImage::Format_ARGB32_Premultiplied); image.fill(Qt::transparent); - // create gradient - // gaussian delta function - auto alpha = [](qreal x) { return std::exp( -x*x/0.15 ); }; + // painter + QPainter painter(&image); + painter.setRenderHint( QPainter::Antialiasing, true ); // color calculation delta function auto gradientStopColor = [](QColor color, int alpha) { color.setAlpha(alpha); return color; }; - QRadialGradient radialGradient( g_shadowSize, g_shadowSize, g_shadowSize ); - for( int i = 0; i < 10; ++i ) + // create gradient + if( g_shadowSizeEnum != InternalSettings::ShadowNone ) { - const qreal x( qreal( i )/9 ); - radialGradient.setColorAt(x, gradientStopColor( g_shadowColor, alpha(x)*g_shadowStrength ) ); - } - radialGradient.setColorAt(1, gradientStopColor( g_shadowColor, 0 ) ); + // gaussian lambda function + auto alpha = [](qreal x) { return std::exp( -x*x/0.15 ); }; - // fill - QPainter painter(&image); - painter.setRenderHint( QPainter::Antialiasing, true ); - painter.fillRect( image.rect(), radialGradient); + QRadialGradient radialGradient( shadowSize, shadowSize, shadowSize ); + for( int i = 0; i < 10; ++i ) + { + const qreal x( qreal( i )/9 ); + radialGradient.setColorAt(x, gradientStopColor( g_shadowColor, alpha(x)*g_shadowStrength ) ); + } + + radialGradient.setColorAt(1, gradientStopColor( g_shadowColor, 0 ) ); + + // fill + painter.fillRect( image.rect(), radialGradient); + + } // contrast pixel QRectF innerRect = QRectF( - g_shadowSize - Metrics::Shadow_Overlap, g_shadowSize - shadowOffset - Metrics::Shadow_Overlap, + shadowSize - Metrics::Shadow_Overlap, shadowSize - shadowOffset - Metrics::Shadow_Overlap, 2*Metrics::Shadow_Overlap, shadowOffset + 2*Metrics::Shadow_Overlap ); - painter.setPen( gradientStopColor( g_shadowColor, g_shadowStrength*0.5 ) ); + painter.setPen( gradientStopColor( g_shadowColor, (g_shadowSizeEnum == InternalSettings::ShadowNone) ? g_shadowStrength:(g_shadowStrength*0.5) ) ); painter.setBrush( Qt::NoBrush ); painter.drawRoundedRect( innerRect, -0.5 + Metrics::Frame_FrameRadius, -0.5 + Metrics::Frame_FrameRadius ); @@ -685,12 +707,12 @@ g_sShadow = QSharedPointer::create(); g_sShadow->setPadding( QMargins( - g_shadowSize - Metrics::Shadow_Overlap, - g_shadowSize - shadowOffset - Metrics::Shadow_Overlap, - g_shadowSize - Metrics::Shadow_Overlap, - g_shadowSize - Metrics::Shadow_Overlap ) ); + shadowSize - Metrics::Shadow_Overlap, + shadowSize - shadowOffset - Metrics::Shadow_Overlap, + shadowSize - Metrics::Shadow_Overlap, + shadowSize - Metrics::Shadow_Overlap ) ); - g_sShadow->setInnerShadowRect(QRect( g_shadowSize, g_shadowSize, 1, 1) ); + g_sShadow->setInnerShadowRect(QRect( shadowSize, shadowSize, 1, 1) ); // assign image g_sShadow->setShadow(image); diff --git a/kdecoration/breezesettingsdata.kcfg b/kdecoration/breezesettingsdata.kcfg --- a/kdecoration/breezesettingsdata.kcfg +++ b/kdecoration/breezesettingsdata.kcfg @@ -6,17 +6,22 @@ - 90 25 255 - - 64 - 6 - 100 + + + + + + + + + + ShadowLarge diff --git a/kdecoration/config/breezeconfigwidget.cpp b/kdecoration/config/breezeconfigwidget.cpp --- a/kdecoration/config/breezeconfigwidget.cpp +++ b/kdecoration/config/breezeconfigwidget.cpp @@ -59,7 +59,7 @@ connect( m_ui.animationsDuration, SIGNAL(valueChanged(int)), SLOT(updateChanged()) ); // track shadows changes - connect( m_ui.shadowSize, SIGNAL(valueChanged(int)), SLOT(updateChanged()) ); + connect( m_ui.shadowSize, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) ); connect( m_ui.shadowStrength, SIGNAL(valueChanged(int)), SLOT(updateChanged()) ); connect( m_ui.shadowColor, SIGNAL(changed(QColor)), SLOT(updateChanged()) ); @@ -88,7 +88,9 @@ m_ui.drawTitleBarSeparator->setChecked( m_internalSettings->drawTitleBarSeparator() ); // load shadows - m_ui.shadowSize->setValue( m_internalSettings->shadowSize() ); + if( m_internalSettings->shadowSize() <= InternalSettings::ShadowLarge ) m_ui.shadowSize->setCurrentIndex( m_internalSettings->shadowSize() ); + else m_ui.shadowSize->setCurrentIndex( InternalSettings::ShadowLarge ); + m_ui.shadowStrength->setValue( qRound(qreal(m_internalSettings->shadowStrength()*100)/255 ) ); m_ui.shadowColor->setColor( m_internalSettings->shadowColor() ); @@ -119,7 +121,7 @@ m_internalSettings->setAnimationsDuration( m_ui.animationsDuration->value() ); m_internalSettings->setDrawTitleBarSeparator(m_ui.drawTitleBarSeparator->isChecked()); - m_internalSettings->setShadowSize( m_ui.shadowSize->value() ); + m_internalSettings->setShadowSize( m_ui.shadowSize->currentIndex() ); m_internalSettings->setShadowStrength( qRound( qreal(m_ui.shadowStrength->value()*255)/100 ) ); m_internalSettings->setShadowColor( m_ui.shadowColor->color() ); @@ -166,7 +168,7 @@ m_ui.animationsDuration->setValue( m_internalSettings->animationsDuration() ); m_ui.drawTitleBarSeparator->setChecked( m_internalSettings->drawTitleBarSeparator() ); - m_ui.shadowSize->setValue( m_internalSettings->shadowSize() ); + m_ui.shadowSize->setCurrentIndex( m_internalSettings->shadowSize() ); m_ui.shadowStrength->setValue( qRound(qreal(m_internalSettings->shadowStrength()*100)/255 ) ); m_ui.shadowColor->setColor( m_internalSettings->shadowColor() ); @@ -195,7 +197,7 @@ else if( m_ui.animationsDuration->value() != m_internalSettings->animationsDuration() ) modified = true; // shadows - else if( m_ui.shadowSize->value() != m_internalSettings->shadowSize() ) modified = true; + else if( m_ui.shadowSize->currentIndex() != m_internalSettings->shadowSize() ) modified = true; else if( qRound( qreal(m_ui.shadowStrength->value()*255)/100 ) != m_internalSettings->shadowStrength() ) modified = true; else if( m_ui.shadowColor->color() != m_internalSettings->shadowColor() ) modified = true; diff --git a/kdecoration/config/ui/breezeconfigurationui.ui b/kdecoration/config/ui/breezeconfigurationui.ui --- a/kdecoration/config/ui/breezeconfigurationui.ui +++ b/kdecoration/config/ui/breezeconfigurationui.ui @@ -11,16 +11,7 @@ - - 0 - - - 0 - - - 0 - - + 0 @@ -73,7 +64,7 @@ - Normal + Medium @@ -263,16 +254,32 @@ - - - px - - - 6 - - - 64 - + + + + None + + + + + Small + + + + + Medium + + + + + Large + + + + + Very Large + + diff --git a/kstyle/breeze.kcfg b/kstyle/breeze.kcfg --- a/kstyle/breeze.kcfg +++ b/kstyle/breeze.kcfg @@ -15,10 +15,16 @@ 255 - - 64 - 6 - 100 + + + + + + + + + + ShadowLarge diff --git a/kstyle/breezeshadowhelper.cpp b/kstyle/breezeshadowhelper.cpp --- a/kstyle/breezeshadowhelper.cpp +++ b/kstyle/breezeshadowhelper.cpp @@ -46,6 +46,27 @@ #include #endif +namespace +{ + + int shadowSize( int shadowSizeEnum ) + { + + switch( shadowSizeEnum ) + { + default: + case Breeze::StyleConfigData::ShadowLarge: return 16; + case Breeze::StyleConfigData::ShadowNone: return 0; + case Breeze::StyleConfigData::ShadowSmall: return 12; + case Breeze::StyleConfigData::ShadowMedium: return 14; + case Breeze::StyleConfigData::ShadowVeryLarge: return 24; + } + + } + + +} + namespace Breeze { @@ -217,14 +238,14 @@ //_______________________________________________________ TileSet ShadowHelper::shadowTiles() { - if( !_shadowTiles.isValid() ) + // metrics + const int shadowSize = ::shadowSize( StyleConfigData::shadowSize() ); + if( !shadowSize ) return TileSet(); + else if( !_shadowTiles.isValid() ) { const QPalette palette( QApplication::palette() ); const QColor shadowColor( StyleConfigData::shadowColor() ); - - // metrics - const int shadowSize = StyleConfigData::shadowSize()*12/16; const int shadowOffset = qMax( shadowSize/2, Metrics::Shadow_Overlap*2 ); const int shadowStrength = StyleConfigData::shadowStrength(); @@ -509,7 +530,8 @@ const qreal devicePixelRatio( _helper.devicePixelRatio( _shadowTiles.pixmap( 0 ) ) ); // metrics - const int shadowSize = StyleConfigData::shadowSize()*12/16; + const int shadowSize = ::shadowSize( StyleConfigData::shadowSize() ); + if( !shadowSize ) return QMargins(); const int shadowOffset = qMax( shadowSize/2, Metrics::Shadow_Overlap*2 ); // define shadows padding