qskinny/skins/material/QskMaterialSkin.cpp

756 lines
20 KiB
C++
Raw Normal View History

2017-07-21 18:21:34 +02:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/
#include "QskMaterialSkin.h"
2019-12-15 13:57:19 +01:00
#include <QskBox.h>
#include <QskDialogButton.h>
2018-08-03 08:15:28 +02:00
#include <QskDialogButtonBox.h>
#include <QskFocusIndicator.h>
2018-06-12 08:20:48 +02:00
#include <QskInputPanelBox.h>
#include <QskListView.h>
2017-07-21 18:21:34 +02:00
#include <QskPageIndicator.h>
#include <QskPushButton.h>
2020-08-01 17:51:45 +02:00
#include <QskProgressBar.h>
#include <QskScrollView.h>
#include <QskSeparator.h>
2017-07-21 18:21:34 +02:00
#include <QskSlider.h>
#include <QskSubWindow.h>
2017-07-21 18:21:34 +02:00
#include <QskTabBar.h>
2018-08-03 08:15:28 +02:00
#include <QskTabButton.h>
2017-07-21 18:21:34 +02:00
#include <QskTabView.h>
#include <QskTextInput.h>
2018-08-03 08:15:28 +02:00
#include <QskTextLabel.h>
#include <QskVirtualKeyboard.h>
2017-07-21 18:21:34 +02:00
#include <QskSkinlet.h>
2018-08-03 08:15:28 +02:00
#include <QskAnimationHint.h>
2017-07-21 18:21:34 +02:00
#include <QskAspect.h>
2018-08-03 08:15:28 +02:00
#include <QskBoxBorderColors.h>
#include <QskBoxBorderMetrics.h>
#include <QskBoxShapeMetrics.h>
2017-07-21 18:21:34 +02:00
#include <QskFunctions.h>
#include <QskMargins.h>
2018-08-03 08:15:28 +02:00
#include <QskNamespace.h>
#include <QskRgbValue.h>
2017-07-21 18:21:34 +02:00
#if 1
// should be defined in the public header, so that
// application code can avoid conflicts
static const int ButtonFontRole = QskSkin::HugeFont + 77;
2017-07-21 18:21:34 +02:00
#endif
static const int qskDuration = 150;
static inline QColor qskShadedColor( const QColor color, qreal opacity )
{
QColor c = color;
2017-12-07 17:04:05 +01:00
c.setAlphaF( opacity );
2017-07-21 18:21:34 +02:00
return c;
}
namespace
{
class ColorPalette
{
2018-08-03 08:15:28 +02:00
public:
2020-08-15 13:29:17 +02:00
ColorPalette( const QColor base = QColor::fromRgba( QskRgb::Grey100 ),
const QColor& accent = QColor::fromRgba( QskRgb::Blue500 ),
const QColor& contrast = QColor::fromRgba( QskRgb::White ) )
2017-07-21 18:21:34 +02:00
{
baseColor = base;
accentColor = accent;
contrastColor = contrast;
darker125 = baseColor.darker( 125 );
darker150 = baseColor.darker( 150 );
darker200 = baseColor.darker( 200 );
lighter125 = baseColor.lighter( 125 );
lighter150 = baseColor.lighter( 150 );
lighter200 = baseColor.lighter( 200 );
textColor = ( baseColor.value() > 128 )
2020-08-15 13:29:17 +02:00
? QskRgb::Black : QskRgb::White;
2017-07-21 18:21:34 +02:00
}
QColor accentColor;
QColor contrastColor;
QColor baseColor;
QColor lighter125;
QColor lighter150;
QColor lighter200;
QColor darker125;
QColor darker150;
QColor darker200;
QColor textColor;
};
}
class QskMaterialSkin::PrivateData
{
2018-08-03 08:15:28 +02:00
public:
2017-07-21 18:21:34 +02:00
ColorPalette palette;
};
2018-08-03 08:15:28 +02:00
QskMaterialSkin::QskMaterialSkin( QObject* parent )
: Inherited( parent )
, m_data( new PrivateData() )
2017-07-21 18:21:34 +02:00
{
2020-08-15 13:29:17 +02:00
m_data->palette = ColorPalette( QskRgb::Grey100,
QskRgb::Blue500, QskRgb::White );
2017-07-21 18:21:34 +02:00
// Default theme colors
setupFonts( "Roboto" );
auto buttonFont = font( QskSkin::DefaultFont );
buttonFont.setCapitalization( QFont::AllUppercase );
setFont( ButtonFontRole, buttonFont );
initHints();
}
QskMaterialSkin::~QskMaterialSkin()
{
}
void QskMaterialSkin::initHints()
{
initCommonHints();
2019-12-15 13:57:19 +01:00
initBoxHints();
initDialogButtonBoxHints();
initDialogButtonHints();
2017-07-21 18:21:34 +02:00
initFocusIndicatorHints();
initInputPanelHints();
initVirtualKeyboardHints();
initListViewHints();
2017-07-21 18:21:34 +02:00
initPageIndicatorHints();
initPopupHints();
2020-08-01 17:51:45 +02:00
initProgressBarHints();
initPushButtonHints();
initScrollViewHints();
initSeparatorHints();
2017-07-21 18:21:34 +02:00
initSliderHints();
initSubWindowHints();
2017-07-21 18:21:34 +02:00
initTabButtonHints();
initTabBarHints();
initTabViewHints();
initTextLabelHints();
initTextInputHints();
2017-07-21 18:21:34 +02:00
}
void QskMaterialSkin::resetColors( const QColor& accent )
{
m_data->palette = ColorPalette( m_data->palette.baseColor,
accent, m_data->palette.contrastColor );
initHints();
}
void QskMaterialSkin::initCommonHints()
{
using namespace QskAspect;
using Q = QskControl;
2020-08-06 09:28:18 +02:00
const auto& pal = m_data->palette;
2017-07-21 18:21:34 +02:00
setMargins( Control | Padding, 4 );
2017-07-21 18:21:34 +02:00
setGradient( Control, pal.baseColor );
2017-07-21 18:21:34 +02:00
setColor( Control | StyleColor, pal.textColor );
setColor( Control | StyleColor | Q::Disabled,
qskShadedColor( m_data->palette.textColor, 0.6 ) );
}
2019-12-15 13:57:19 +01:00
void QskMaterialSkin::initBoxHints()
{
using namespace QskAspect;
using Q = QskBox;
2020-08-06 09:28:18 +02:00
const auto& pal = m_data->palette;
2019-12-15 13:57:19 +01:00
setGradient( Q::Panel, pal.baseColor );
setBoxShape( Q::Panel, 4 );
setBoxBorderMetrics( Q::Panel, 0 );
}
2017-07-21 18:21:34 +02:00
void QskMaterialSkin::initPopupHints()
{
using namespace QskAspect;
using Q = QskPopup;
2020-08-06 09:28:18 +02:00
const auto& pal = m_data->palette;
2017-07-21 18:21:34 +02:00
setSkinHint( Q::Overlay | QskAspect::Style, true );
const QskGradient gradient( QskGradient::Vertical,
qskShadedColor( pal.accentColor, 0.45 ), qskShadedColor( pal.accentColor, 0.7 ) );
setGradient( Q::Overlay, gradient );
2017-07-21 18:21:34 +02:00
}
void QskMaterialSkin::initTextLabelHints()
{
using namespace QskAspect;
using Q = QskTextLabel;
2020-08-06 09:28:18 +02:00
const auto& pal = m_data->palette;
2017-07-21 18:21:34 +02:00
setSkinHint( Q::Text | Alignment, Qt::AlignCenter );
2018-08-03 08:15:28 +02:00
setColor( Q::Text, pal.textColor );
2019-12-15 13:57:19 +01:00
setMargins( Q::Panel | Padding, 5 );
setBoxShape( Q::Panel, 4 );
setBoxBorderMetrics( Q::Panel, 2 );
setBoxBorderColors( Q::Panel, pal.darker125 );
setGradient( Q::Panel, pal.baseColor );
2017-07-21 18:21:34 +02:00
}
void QskMaterialSkin::initTextInputHints()
{
using namespace QskAspect;
using Q = QskTextInput;
setSkinHint( Q::Text | Alignment,
2018-08-03 08:15:28 +02:00
static_cast< int >( Qt::AlignLeft | Qt::AlignTop ) );
2020-08-06 09:28:18 +02:00
const auto& pal = m_data->palette;
2018-08-03 08:15:28 +02:00
setColor( Q::Text, pal.textColor );
setColor( Q::PanelSelected, pal.accentColor );
setColor( Q::TextSelected, pal.contrastColor );
setMargins( Q::Panel | Padding, 5 );
setBoxShape( Q::Panel, 4 );
setBoxBorderMetrics( Q::Panel, 2 );
setBoxBorderColors( Q::Panel, pal.darker125 );
setGradient( Q::Panel, pal.baseColor );
}
2020-08-01 17:51:45 +02:00
void QskMaterialSkin::initProgressBarHints()
2020-07-31 16:57:22 +02:00
{
using namespace QskAspect;
2020-08-15 13:29:17 +02:00
using namespace QskRgb;
2020-08-01 17:51:45 +02:00
using Q = QskProgressBar;
2020-07-31 16:57:22 +02:00
2020-08-06 09:28:18 +02:00
const auto& pal = m_data->palette;
2020-07-31 16:57:22 +02:00
2020-08-06 09:28:18 +02:00
for ( auto subControl : { Q::Groove, Q::Bar } )
2020-12-05 15:09:31 +01:00
{
2020-08-06 09:28:18 +02:00
setMetric( subControl | Size, 5 );
setMargins( subControl | Padding, 0 );
2020-12-05 15:09:31 +01:00
2020-08-06 09:28:18 +02:00
setBoxShape( subControl, 0 );
setBoxBorderMetrics( subControl, 0 );
2020-12-05 15:09:31 +01:00
}
2020-07-31 16:57:22 +02:00
2020-08-06 09:28:18 +02:00
setGradient( Q::Groove, Grey );
setMetric( Q::Groove | Size, 5 );
2020-08-03 08:02:13 +02:00
setGradient( Q::Bar, pal.accentColor );
2020-07-31 16:57:22 +02:00
}
2017-07-21 18:21:34 +02:00
void QskMaterialSkin::initFocusIndicatorHints()
{
using namespace QskAspect;
using Q = QskFocusIndicator;
2020-08-06 09:28:18 +02:00
const auto& pal = m_data->palette;
2017-07-21 18:21:34 +02:00
setMargins( Q::Panel | Padding, 5 );
2017-10-18 20:00:06 +02:00
setBoxShape( Q::Panel, 4 );
setBoxBorderMetrics( Q::Panel, 2 );
setBoxBorderColors( Q::Panel, pal.accentColor );
setGradient( Q::Panel, QskGradient() );
2017-07-21 18:21:34 +02:00
}
void QskMaterialSkin::initSeparatorHints()
{
using namespace QskAspect;
using Q = QskSeparator;
2020-08-06 09:28:18 +02:00
const auto& pal = m_data->palette;
2017-07-21 18:21:34 +02:00
for ( auto placement : { Horizontal, Vertical } )
{
const Aspect aspect = Q::Panel | placement;
setMetric( aspect | Size, 4 );
2017-10-18 20:00:06 +02:00
setBoxShape( Q::Panel, 0 );
setBoxBorderMetrics( Q::Panel, 0 );
setGradient( aspect, pal.baseColor );
}
2017-07-21 18:21:34 +02:00
}
void QskMaterialSkin::initPageIndicatorHints()
{
using namespace QskAspect;
using Q = QskPageIndicator;
2020-08-06 09:28:18 +02:00
const auto& pal = m_data->palette;
2017-07-21 18:21:34 +02:00
for ( auto subControl : { Q::Bullet, Q::Highlighted } )
{
setMetric( subControl | Size, qskDpiScaled( 10 ) );
// circles, without border
2017-10-18 20:00:06 +02:00
setBoxShape( subControl, 100, Qt::RelativeSize );
setBoxBorderMetrics( subControl, 0 );
const QColor color = ( subControl == Q::Bullet )
? pal.lighter150 : pal.accentColor;
setGradient( subControl, color );
setBoxBorderColors( subControl, color );
2017-07-21 18:21:34 +02:00
}
// no visible background panel
2017-10-18 20:00:06 +02:00
setBoxBorderMetrics( Q::Panel, 0 );
setGradient( Q::Panel, QskGradient() );
2017-07-21 18:21:34 +02:00
setMetric( Q::Panel | Spacing, 3 );
2017-07-21 18:21:34 +02:00
}
void QskMaterialSkin::initPushButtonHints()
{
using namespace QskAspect;
2020-08-15 13:29:17 +02:00
using namespace QskRgb;
2017-07-21 18:21:34 +02:00
using Q = QskPushButton;
2020-08-06 09:28:18 +02:00
const auto& pal = m_data->palette;
2017-07-21 18:21:34 +02:00
2017-10-19 18:07:29 +02:00
setMetric( Q::Panel | MinimumWidth, qskDpiScaled( 75.0 ) );
setMetric( Q::Panel | MinimumHeight, qskDpiScaled( 23.0 ) );
setMetric( Q::Panel | Spacing, 4 );
2017-07-21 18:21:34 +02:00
const QskMargins margin( 4, 3 );
const QskMargins padding( 10, 6 );
setMargins( Q::Panel | Margin, margin );
setMargins( Q::Panel | Padding, padding );
2017-07-21 18:21:34 +02:00
const QskBoxBorderColors borderColors( Grey400, Grey300, Grey400, Grey600 );
2017-07-21 18:21:34 +02:00
QskBoxBorderColors noBorderColors = borderColors;
noBorderColors.setAlpha( 0 );
2017-07-21 18:21:34 +02:00
2017-10-18 20:00:06 +02:00
setBoxShape( Q::Panel, 0 );
setBoxBorderMetrics( Q::Panel, QskMargins( 1, 2, 1, 2 ) );
setBoxBorderColors( Q::Panel, noBorderColors );
2017-07-21 18:21:34 +02:00
setGradient( Q::Panel, White );
setGradient( Q::Panel | Q::Flat, White & ColorMask );
2017-07-21 18:21:34 +02:00
setColor( Q::Text, pal.textColor );
setColor( Q::Text | Q::Disabled, qskShadedColor( pal.textColor, 0.6 ) );
setFontRole( Q::Text, ButtonFontRole );
setSkinHint( Q::Text | Alignment, Qt::AlignCenter );
2017-07-21 18:21:34 +02:00
for ( auto state1 : { NoState, Q::Checkable, Q::Focused, Q::Focused | Q::Checkable } )
2017-07-21 18:21:34 +02:00
{
setBoxBorderColors( Q::Panel | Q::Hovered | state1, borderColors );
setBoxBorderColors( Q::Panel | Q::Hovered | Q::Flat | state1, borderColors );
2017-07-21 18:21:34 +02:00
for ( auto state2 : { NoState, Q::Hovered } )
{
for ( auto state3 : { Q::Pressed, Q::Checked, Q::Checked | Q::Pressed } )
{
const auto states = state1 | state2 | state3;
2017-07-21 18:21:34 +02:00
setGradient( Q::Panel | states, pal.accentColor );
setColor( Q::Text | states, White );
2017-07-21 18:21:34 +02:00
setGradient( Q::Panel | Q::Flat | states, pal.accentColor );
setColor( Q::Text | Q::Flat | states, White );
}
}
2017-07-21 18:21:34 +02:00
}
setAnimation( Q::Panel | Color, qskDuration );
setAnimation( Q::Panel | Metric, qskDuration );
setAnimation( Q::Text | Color, qskDuration );
2017-07-21 18:21:34 +02:00
}
void QskMaterialSkin::initDialogButtonHints()
{
using namespace QskAspect;
2020-08-15 13:29:17 +02:00
using namespace QskRgb;
2017-07-21 18:21:34 +02:00
using Q = QskDialogButton;
2020-08-06 09:28:18 +02:00
const auto& pal = m_data->palette;
2017-07-21 18:21:34 +02:00
setMetric( Q::Panel | MinimumWidth, 30 );
setMetric( Q::Panel | MinimumHeight, 16 );
setMetric( Q::Panel | Spacing, 4 );
2017-07-21 18:21:34 +02:00
const QskMargins margin( 4, 3 );
const QskMargins padding( 10, 6 );
2017-07-21 18:21:34 +02:00
setMargins( Q::Panel | Margin, margin );
setMargins( Q::Panel | Padding, padding );
2017-07-21 18:21:34 +02:00
const QskBoxBorderColors borderColors( Grey400, Grey300, Grey400, Grey600 );
2017-07-21 18:21:34 +02:00
QskBoxBorderColors noBorderColors = borderColors;
noBorderColors.setAlpha( 0 );
2017-07-21 18:21:34 +02:00
2017-10-18 20:00:06 +02:00
setBoxShape( Q::Panel, 0 );
setBoxBorderMetrics( Q::Panel, QskMargins( 1, 2, 1, 2 ) );
setBoxBorderColors( Q::Panel, noBorderColors );
2017-07-21 18:21:34 +02:00
setGradient( Q::Panel, White );
setColor( Q::Text, pal.textColor );
setColor( Q::Text | Q::Disabled, qskShadedColor( pal.textColor, 0.6 ) );
setFontRole( Q::Text, ButtonFontRole );
setSkinHint( Q::Text | Alignment, Qt::AlignCenter );
2017-07-21 18:21:34 +02:00
for ( auto state1 : { NoState, Q::Checkable, Q::Focused, Q::Focused | Q::Checkable } )
{
setBoxBorderColors( Q::Panel | Q::Hovered | state1, borderColors );
2017-07-21 18:21:34 +02:00
for ( auto state2 : { NoState, Q::Hovered } )
{
for ( auto state3 : { Q::Pressed, Q::Checked, Q::Checked | Q::Pressed } )
{
const auto states = state1 | state2 | state3;
2017-07-21 18:21:34 +02:00
setGradient( Q::Panel | states, pal.accentColor );
setColor( Q::Text | states, White );
}
}
}
2017-07-21 18:21:34 +02:00
setAnimation( Q::Panel | Color, qskDuration );
setAnimation( Q::Panel | Metric, qskDuration );
setAnimation( Q::Text | Color, qskDuration );
2017-07-21 18:21:34 +02:00
}
void QskMaterialSkin::initDialogButtonBoxHints()
{
using namespace QskAspect;
using Q = QskDialogButtonBox;
2020-08-06 09:28:18 +02:00
const auto& pal = m_data->palette;
setGradient( Q::Panel, pal.baseColor );
2017-10-18 20:00:06 +02:00
setBoxShape( Q::Panel, 0 );
setBoxBorderMetrics( Q::Panel, 0 );
2017-07-21 18:21:34 +02:00
}
void QskMaterialSkin::initSliderHints()
{
using namespace QskAspect;
2020-08-15 13:29:17 +02:00
using namespace QskRgb;
2017-07-21 18:21:34 +02:00
using Q = QskSlider;
2020-08-06 09:28:18 +02:00
const auto& pal = m_data->palette;
2017-07-21 18:21:34 +02:00
const qreal dim = 30;
// Panel
2017-07-21 18:21:34 +02:00
setMetric( Q::Panel | Size, dim );
2017-10-18 20:00:06 +02:00
setBoxShape( Q::Panel, 0 );
setBoxBorderMetrics( Q::Panel, 0 );
setGradient( Q::Panel, QskGradient() );
setMargins( Q::Panel | Horizontal | Padding, QskMargins( 0.5 * dim, 0 ) );
setMargins( Q::Panel | Vertical | Padding, QskMargins( 0, 0.5 * dim ) );
// Groove, Fill
2017-07-21 18:21:34 +02:00
for ( auto subControl : { Q::Groove, Q::Fill } )
{
setMetric( subControl | Size, 5 );
setMargins( subControl | Padding, 0 );
2017-10-18 20:00:06 +02:00
setBoxShape( subControl, 0 );
setBoxBorderMetrics( subControl, 0 );
2017-07-21 18:21:34 +02:00
}
setGradient( Q::Groove, Grey );
setGradient( Q::Fill, pal.accentColor );
setBoxBorderColors( Q::Fill, pal.accentColor );
2017-07-21 18:21:34 +02:00
// handle
2017-10-18 20:00:06 +02:00
setBoxShape( Q::Handle, 100, Qt::RelativeSize );
setBoxBorderMetrics( Q::Handle, 4 );
2017-07-21 18:21:34 +02:00
// handle expanding, when being pressed
setMetric( Q::Handle | Size, 0.6 * dim );
setMetric( Q::Handle | Size | Q::Pressed, dim );
2017-07-21 18:21:34 +02:00
setGradient( Q::Handle | Q::Disabled, Grey );
setBoxBorderColors( Q::Handle | Q::Disabled, Grey );
2017-07-21 18:21:34 +02:00
// should be transparent, but the current renderer doesn't "cut out" the background
setGradient( Q::Handle, pal.accentColor );
2020-08-06 09:28:18 +02:00
setGradient( Q::Handle | Q::Pressed, pal.accentColor );
2017-07-21 18:21:34 +02:00
for ( auto state : { NoState, Q::Pressed, Q::Pressed | Q::Hovered } )
{
setBoxBorderColors( Q::Handle | state, pal.accentColor );
2017-07-21 18:21:34 +02:00
}
for ( auto state : { NoState, Q::Pressed, Q::Pressed | Q::Hovered } )
{
QskAspect::Aspect aspect = Q::Handle | Q::Minimum | state;
setGradient( aspect, Grey300 );
setBoxBorderColors( aspect, Grey );
2017-07-21 18:21:34 +02:00
}
setAnimation( Q::Handle | Metric, qskDuration );
setAnimation( Q::Handle | Color, qskDuration );
// move the handle smoothly, when using keys
setAnimation( Q::Handle | Metric | Position, 2 * qskDuration );
setAnimation( Q::Handle | Metric | Position | Q::Pressed, 0 );
2017-07-21 18:21:34 +02:00
}
void QskMaterialSkin::initTabButtonHints()
{
using namespace QskAspect;
using Q = QskTabButton;
2020-08-06 09:28:18 +02:00
const auto& pal = m_data->palette;
2017-07-21 18:21:34 +02:00
setMetric( Q::Panel | MinimumWidth, 30 );
setMetric( Q::Panel | MinimumHeight, 16 );
2019-06-19 13:59:07 +02:00
for ( const auto placement : { Left, Right, Top, Bottom } )
{
const Aspect aspect = Q::Panel | placement;
Qt::Edge edge;
switch( placement )
{
case Left:
edge = Qt::RightEdge;
break;
case Right:
edge = Qt::LeftEdge;
break;
case Top:
edge = Qt::BottomEdge;
break;
case Bottom:
edge = Qt::TopEdge;
break;
default:
2019-06-19 13:59:07 +02:00
edge = Qt::Edge( 0 ); // making gcc4 happy
}
2020-08-15 13:29:17 +02:00
setGradient( aspect, QskRgb::White );
// The highlighted button has a accented bar at one edge
2017-10-18 20:00:06 +02:00
setBoxShape( aspect, 0 );
QskBoxBorderMetrics border;
border.setWidthAt( edge, 3 );
2017-10-18 20:00:06 +02:00
setBoxBorderMetrics( aspect, border );
2020-08-15 13:29:17 +02:00
QskBoxBorderColors borderColors( QskRgb::White );
setBoxBorderColors( aspect, borderColors );
2017-07-21 18:21:34 +02:00
borderColors.setColorsAt( edge, pal.accentColor );
for ( auto state : { Q::Checked, Q::Pressed, Q::Checkable | Q::Hovered } )
2019-04-17 15:38:43 +02:00
setBoxBorderColors( aspect | state, borderColors );
}
2017-07-21 18:21:34 +02:00
setAnimation( Q::Panel | Color, qskDuration );
2017-07-21 18:21:34 +02:00
// text
setFontRole( Q::Text, ButtonFontRole );
2017-07-21 18:21:34 +02:00
setSkinHint( Q::Text | QskAspect::Alignment, Qt::AlignCenter );
setColor( Q::Text, pal.textColor );
setColor( Q::Text | Q::Checkable | Q::Disabled, qskShadedColor( pal.textColor, 0.6 ) );
2020-08-15 13:29:17 +02:00
setColor( Q::Text | Q::Disabled, QskRgb::Grey600 );
2017-07-21 18:21:34 +02:00
}
void QskMaterialSkin::initTabBarHints()
{
using namespace QskAspect;
using Q = QskTabBar;
2017-10-18 20:00:06 +02:00
setBoxShape( Q::Panel, 0 );
setBoxBorderMetrics( Q::Panel, 0 );
setGradient( Q::Panel, QskGradient() );
2020-03-13 07:39:31 +01:00
// when flicking
setAnimation( Q::Panel | Metric, QskAnimationHint( 200, QEasingCurve::InCubic ) );
2017-07-21 18:21:34 +02:00
}
void QskMaterialSkin::initTabViewHints()
{
using namespace QskAspect;
using Q = QskTabView;
2020-08-06 09:28:18 +02:00
const auto& pal = m_data->palette;
2017-10-18 20:00:06 +02:00
setBoxShape( Q::Page, 0 );
setBoxBorderMetrics( Q::Page, 0 );
setGradient( Q::Page, pal.darker150 );
setBoxBorderColors( Q::Page, pal.baseColor );
setAnimation( Q::Page, qskDuration );
2017-07-21 18:21:34 +02:00
}
void QskMaterialSkin::initInputPanelHints()
{
using namespace QskAspect;
2018-06-12 08:20:48 +02:00
using Q = QskInputPanelBox;
2020-08-06 09:28:18 +02:00
const auto& pal = m_data->palette;
setBoxShape( Q::Panel, 0 );
setBoxBorderMetrics( Q::Panel, 0 );
setGradient( Q::Panel, pal.darker150 );
setBoxBorderColors( Q::Panel, pal.baseColor );
}
void QskMaterialSkin::initVirtualKeyboardHints()
2017-07-21 18:21:34 +02:00
{
using namespace QskAspect;
2018-04-06 17:30:24 +02:00
using Q = QskVirtualKeyboard;
2017-07-21 18:21:34 +02:00
2020-08-06 09:28:18 +02:00
const auto& pal = m_data->palette;
2017-07-21 18:21:34 +02:00
// key panel
2018-04-06 17:30:24 +02:00
setMargins( Q::ButtonPanel | Margin, 2 );
2017-07-21 18:21:34 +02:00
2018-04-06 17:30:24 +02:00
setBoxShape( Q::ButtonPanel, 20.0, Qt::RelativeSize );
setBoxBorderMetrics( Q::ButtonPanel, 2 );
2017-07-21 18:21:34 +02:00
2018-04-06 17:30:24 +02:00
setGradient( Q::ButtonPanel, pal.darker125 );
setBoxBorderColors( Q::ButtonPanel, pal.baseColor );
2017-07-21 18:21:34 +02:00
for ( auto state : { NoState, Q::Focused } )
2018-04-06 17:30:24 +02:00
setBoxBorderColors( Q::ButtonPanel | QskPushButton::Pressed | state, pal.accentColor );
2017-07-21 18:21:34 +02:00
2018-04-06 17:30:24 +02:00
setAnimation( Q::ButtonPanel | Color, qskDuration );
setAnimation( Q::ButtonPanel | Metric, qskDuration );
2017-07-21 18:21:34 +02:00
// panel
2017-10-18 20:00:06 +02:00
setBoxShape( Q::Panel, 0 );
setBoxBorderMetrics( Q::Panel, 0 );
setGradient( Q::Panel, pal.darker150 );
setBoxBorderColors( Q::Panel, pal.baseColor );
2017-07-21 18:21:34 +02:00
}
void QskMaterialSkin::initScrollViewHints()
{
using namespace QskAspect;
using Q = QskScrollView;
2020-08-06 09:28:18 +02:00
const auto& pal = m_data->palette;
2017-07-21 18:21:34 +02:00
setMetric( Q::Panel | Spacing, 2 );
2017-10-18 20:00:06 +02:00
setBoxShape( Q::Viewport, 5 );
setBoxBorderMetrics( Q::Viewport, 1 );
2020-08-15 13:29:17 +02:00
setGradient( Q::Viewport, QskRgb::White );
setBoxBorderColors( Q::Viewport, Qt::black );
2017-07-21 18:21:34 +02:00
for ( auto subControl : { Q::HorizontalScrollBar, Q::VerticalScrollBar } )
{
setMetric( subControl | Size, 12 );
setMargins( subControl | Padding, 0 );
}
2017-07-21 18:21:34 +02:00
setMetric( Q::HorizontalScrollHandle | MinimumWidth, qskDpiScaled( 40.0 ) );
setMetric( Q::VerticalScrollHandle | MinimumHeight, qskDpiScaled( 40.0 ) );
for ( auto subControl : { Q::HorizontalScrollHandle, Q::VerticalScrollHandle } )
{
2017-10-18 20:00:06 +02:00
setBoxShape( subControl, 3 );
setBoxBorderMetrics( subControl, 1 );
setGradient( subControl, pal.accentColor );
2020-08-15 13:29:17 +02:00
setBoxBorderColors( subControl, QskRgb::White );
2017-07-21 18:21:34 +02:00
setAnimation( subControl | Color, qskDuration );
}
2017-07-21 18:21:34 +02:00
for ( auto subControl : {
2017-07-21 18:21:34 +02:00
Q::HorizontalScrollHandle | Q::HorizontalHandlePressed,
Q::VerticalScrollHandle | Q::VerticalHandlePressed } )
{
setGradient( subControl, pal.accentColor );
setBoxBorderColors( subControl, pal.accentColor );
2017-07-21 18:21:34 +02:00
}
2018-01-16 12:13:38 +01:00
// when changing the position by QskScrollView::scrollTo
setAnimation( Q::Viewport | Metric, QskAnimationHint( 200, QEasingCurve::InCubic ) );
2017-07-21 18:21:34 +02:00
}
void QskMaterialSkin::initListViewHints()
{
using namespace QskAspect;
using Q = QskListView;
2020-08-06 09:28:18 +02:00
const auto& pal = m_data->palette;
2017-07-21 18:21:34 +02:00
// padding for each cell
setMargins( Q::Cell | Padding, QskMargins( 4, 8 ) );
2017-07-21 18:21:34 +02:00
setColor( Q::Cell, pal.baseColor );
setColor( Q::Text, pal.textColor );
2017-07-21 18:21:34 +02:00
setColor( Q::CellSelected, pal.accentColor );
setColor( Q::TextSelected, pal.contrastColor );
}
void QskMaterialSkin::initSubWindowHints()
{
using namespace QskAspect;
using Q = QskSubWindow;
2020-08-06 09:28:18 +02:00
const auto& pal = m_data->palette;
2017-07-21 18:21:34 +02:00
2018-10-29 20:11:48 +01:00
// Panel
2017-07-21 18:21:34 +02:00
2018-10-29 20:11:48 +01:00
setSkinHint( Q::Panel | Decoration, true );
setMargins( Q::Panel | Padding, 10 );
2017-10-18 20:00:06 +02:00
setBoxShape( Q::Panel, 0 );
setBoxBorderMetrics( Q::Panel, 2 );
setGradient( Q::Panel, pal.baseColor );
2017-07-21 18:21:34 +02:00
QskBoxBorderColors colors;
colors.setColorsAt( Qt::TopEdge | Qt::LeftEdge, pal.lighter125 );
colors.setColorsAt( Qt::RightEdge | Qt::BottomEdge, pal.darker200 );
2017-07-21 18:21:34 +02:00
setBoxBorderColors( Q::Panel, colors );
2017-07-21 18:21:34 +02:00
2018-10-29 20:11:48 +01:00
// TitleBar
setGradient( Q::TitleBar, pal.darker200 );
setGradient( Q::TitleBar | Q::Focused, pal.accentColor );
2017-07-21 18:21:34 +02:00
2018-10-29 20:11:48 +01:00
// TitleBarText
setFontRole( Q::TitleBarText, QskSkin::SmallFont );
setSkinHint( Q::TitleBarText | Alignment,
2019-01-07 09:13:53 +01:00
static_cast< int >( Qt::AlignLeft | Qt::AlignVCenter ) );
2018-10-29 20:11:48 +01:00
for ( auto subControl : { Q::Panel, Q::TitleBar, Q::TitleBarText } )
setAnimation( subControl | Color, qskDuration );
2017-07-21 18:21:34 +02:00
}
#include "moc_QskMaterialSkin.cpp"