From 93987bd92fcc239555c06e5327383f5d0915284d Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Fri, 27 Aug 2021 09:45:24 +0200 Subject: [PATCH] minor adjustments --- skins/material/QskMaterialSkin.cpp | 37 ++++++++++++++++--------- src/controls/QskSwitchButtonSkinlet.cpp | 7 ++--- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/skins/material/QskMaterialSkin.cpp b/skins/material/QskMaterialSkin.cpp index 94a8a1d0..f8328822 100644 --- a/skins/material/QskMaterialSkin.cpp +++ b/skins/material/QskMaterialSkin.cpp @@ -522,21 +522,32 @@ void Editor::setupSwitchButton() setBoxShape( Q::Ripple, 100, Qt::RelativeSize ); setStrutSize( Q::Ripple, 2 * handleSize, 2 * handleSize ); - setGradient( Q::Ripple, QColor(0,0,0,0) ); + setGradient( Q::Ripple, QskRgb::Transparent ); - setGradient( Q::Ripple | Q::Checked | Q::Hovered, - QColor(m_pal.accentColor.red(), m_pal.accentColor.green(), m_pal.accentColor.blue(), 50) ); - setGradient( Q::Ripple | Q::Checked | Q::Focused, - QColor(m_pal.accentColor.red(), m_pal.accentColor.green(), m_pal.accentColor.blue(), 100) ); - setGradient( Q::Ripple | Q::Checked | Q::Pressed, - QColor(m_pal.accentColor.red(), m_pal.accentColor.green(), m_pal.accentColor.blue(), 150) ); + for ( auto state : { Q::Hovered, Q::Focused, Q::Pressed } ) + { + auto weak = m_pal.darker125; + auto strong = m_pal.accentColor; - setGradient( Q::Ripple | Q::Hovered, - QColor(m_pal.darker125.red(), m_pal.darker125.green(), m_pal.darker125.blue(), 100 ) ); - setGradient( Q::Ripple | Q::Focused, - QColor(m_pal.darker125.red(), m_pal.darker125.green(), m_pal.darker125.blue(), 150 ) ); - setGradient( Q::Ripple | Q::Pressed, - QColor(m_pal.darker125.red(), m_pal.darker125.green(), m_pal.darker125.blue(), 200) ); + if ( state == Q::Hovered ) + { + weak.setAlpha( 100 ); + strong.setAlpha( 50 ); + } + else if ( state == Q::Focused ) + { + weak.setAlpha( 150 ); + strong.setAlpha( 100 ); + } + else + { + weak.setAlpha( 200 ); + strong.setAlpha( 150 ); + } + + setGradient( Q::Ripple | state, weak ); + setGradient( Q::Ripple | Q::Checked | state, strong ); + } for( auto state : { A::NoState, Q::Disabled } ) { diff --git a/src/controls/QskSwitchButtonSkinlet.cpp b/src/controls/QskSwitchButtonSkinlet.cpp index e5dfe7d0..a3b107ba 100644 --- a/src/controls/QskSwitchButtonSkinlet.cpp +++ b/src/controls/QskSwitchButtonSkinlet.cpp @@ -3,9 +3,8 @@ * This file may be used under the terms of the QSkinny License, Version 1.0 *****************************************************************************/ -#include "QskSwitchButton.h" #include "QskSwitchButtonSkinlet.h" -#include "QskSGNode.h" +#include "QskSwitchButton.h" static inline qreal qskEffectivePosition( const QskSwitchButton* switchButton ) { @@ -64,11 +63,11 @@ QSizeF QskSwitchButtonSkinlet::sizeHint( const QskSkinnable* skinnable, if ( which != Qt::PreferredSize ) return QSizeF(); - auto groovehint = skinnable->strutSizeHint( QskSwitchButton::Groove ); + auto grooveHint = skinnable->strutSizeHint( QskSwitchButton::Groove ); auto handleHint = skinnable->strutSizeHint( QskSwitchButton::Handle ); auto rippleHint = skinnable->strutSizeHint( QskSwitchButton::Ripple ); - auto hint = groovehint.expandedTo( groovehint + rippleHint - handleHint ); + auto hint = grooveHint.expandedTo( grooveHint + rippleHint - handleHint ); hint = hint.expandedTo( rippleHint ); hint = hint.expandedTo( handleHint );