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"
|
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
#include <QskDialogButtonBox.h>
|
2018-04-03 10:47:21 +02:00
|
|
|
#include <QskDialogButton.h>
|
|
|
|
#include <QskFocusIndicator.h>
|
|
|
|
#include <QskListView.h>
|
2017-07-21 18:21:34 +02:00
|
|
|
#include <QskPageIndicator.h>
|
|
|
|
#include <QskPushButton.h>
|
2018-04-03 10:47:21 +02:00
|
|
|
#include <QskScrollView.h>
|
|
|
|
#include <QskSeparator.h>
|
2017-07-21 18:21:34 +02:00
|
|
|
#include <QskSlider.h>
|
2018-04-03 10:47:21 +02:00
|
|
|
#include <QskSubWindow.h>
|
2017-07-21 18:21:34 +02:00
|
|
|
#include <QskTabButton.h>
|
|
|
|
#include <QskTabBar.h>
|
|
|
|
#include <QskTabView.h>
|
2018-04-03 10:47:21 +02:00
|
|
|
#include <QskTextLabel.h>
|
|
|
|
#include <QskTextInput.h>
|
2018-03-28 09:01:25 -07:00
|
|
|
#include <QskVirtualKeyboard.h>
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
#include <QskSkinlet.h>
|
|
|
|
|
2017-07-21 18:21:34 +02:00
|
|
|
#include <QskAspect.h>
|
|
|
|
#include <QskNamespace.h>
|
|
|
|
#include <QskFunctions.h>
|
|
|
|
#include <QskRgbValue.h>
|
|
|
|
#include <QskAnimationHint.h>
|
2017-08-23 14:53:29 +02:00
|
|
|
#include <QskMargins.h>
|
2017-10-17 17:34:00 +02:00
|
|
|
#include <QskBoxShapeMetrics.h>
|
|
|
|
#include <QskBoxBorderMetrics.h>
|
|
|
|
#include <QskBoxBorderColors.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
|
2018-01-03 11:57:05 +01:00
|
|
|
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
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ColorPalette( const QColor base = QColor::fromRgba( QskRgbValue::Grey100 ),
|
|
|
|
const QColor& accent = QColor::fromRgba( QskRgbValue::Blue500 ),
|
|
|
|
const QColor& contrast = QColor::fromRgba( QskRgbValue::White ) )
|
|
|
|
{
|
|
|
|
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 )
|
|
|
|
? QskRgbValue::Black : QskRgbValue::White;
|
|
|
|
}
|
|
|
|
|
|
|
|
QColor accentColor;
|
|
|
|
QColor contrastColor;
|
|
|
|
|
|
|
|
QColor baseColor;
|
|
|
|
|
|
|
|
QColor lighter125;
|
|
|
|
QColor lighter150;
|
|
|
|
QColor lighter200;
|
|
|
|
|
|
|
|
QColor darker125;
|
|
|
|
QColor darker150;
|
|
|
|
QColor darker200;
|
|
|
|
|
|
|
|
QColor textColor;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
class QskMaterialSkin::PrivateData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ColorPalette palette;
|
|
|
|
};
|
|
|
|
|
|
|
|
QskMaterialSkin::QskMaterialSkin( QObject* parent ):
|
|
|
|
Inherited( parent ),
|
|
|
|
m_data( new PrivateData() )
|
|
|
|
{
|
|
|
|
m_data->palette = ColorPalette( QskRgbValue::Grey100,
|
|
|
|
QskRgbValue::Blue500, QskRgbValue::White );
|
|
|
|
|
|
|
|
// Default theme colors
|
|
|
|
setupFonts( "Roboto" );
|
|
|
|
|
|
|
|
auto buttonFont = font( QskSkin::DefaultFont );
|
|
|
|
buttonFont.setCapitalization( QFont::AllUppercase );
|
|
|
|
setFont( ButtonFontRole, buttonFont );
|
|
|
|
|
|
|
|
initHints();
|
|
|
|
}
|
|
|
|
|
|
|
|
QskMaterialSkin::~QskMaterialSkin()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void QskMaterialSkin::initHints()
|
|
|
|
{
|
|
|
|
initCommonHints();
|
2018-04-03 10:47:21 +02:00
|
|
|
|
|
|
|
initDialogButtonBoxHints();
|
|
|
|
initDialogButtonHints();
|
2017-07-21 18:21:34 +02:00
|
|
|
initFocusIndicatorHints();
|
2018-04-03 10:47:21 +02:00
|
|
|
initInputPanelHints();
|
|
|
|
initListViewHints();
|
2017-07-21 18:21:34 +02:00
|
|
|
initPageIndicatorHints();
|
|
|
|
initPopupHints();
|
2018-04-03 10:47:21 +02:00
|
|
|
initPushButtonHints();
|
|
|
|
initScrollViewHints();
|
|
|
|
initSeparatorHints();
|
2017-07-21 18:21:34 +02:00
|
|
|
initSliderHints();
|
2018-04-03 10:47:21 +02:00
|
|
|
initSubWindowHints();
|
2017-07-21 18:21:34 +02:00
|
|
|
initTabButtonHints();
|
|
|
|
initTabBarHints();
|
|
|
|
initTabViewHints();
|
2018-04-03 10:47:21 +02:00
|
|
|
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;
|
|
|
|
|
|
|
|
const ColorPalette& pal = m_data->palette;
|
|
|
|
|
2017-08-23 14:53:29 +02:00
|
|
|
setMargins( Control | Padding, 4 );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-10-17 17:34:00 +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 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
void QskMaterialSkin::initPopupHints()
|
|
|
|
{
|
|
|
|
using namespace QskAspect;
|
|
|
|
using Q = QskPopup;
|
|
|
|
|
|
|
|
const ColorPalette& pal = m_data->palette;
|
|
|
|
|
|
|
|
setSkinHint( Q::Overlay | QskAspect::Style, true );
|
2017-10-17 17:34:00 +02:00
|
|
|
|
|
|
|
const QskGradient gradient( QskGradient::Vertical,
|
|
|
|
qskShadedColor( pal.accentColor, 0.45 ), qskShadedColor( pal.accentColor, 0.7 ) );
|
2018-01-03 11:57:05 +01:00
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
setGradient( Q::Overlay, gradient );
|
2017-07-21 18:21:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void QskMaterialSkin::initTextLabelHints()
|
|
|
|
{
|
|
|
|
using namespace QskAspect;
|
|
|
|
using Q = QskTextLabel;
|
|
|
|
|
|
|
|
const ColorPalette& pal = m_data->palette;
|
|
|
|
|
|
|
|
setSkinHint( Q::Text | Alignment, Qt::AlignCenter );
|
|
|
|
setColor( Q::Text, pal.textColor );
|
|
|
|
}
|
|
|
|
|
2018-04-03 10:47:21 +02:00
|
|
|
void QskMaterialSkin::initTextInputHints()
|
|
|
|
{
|
|
|
|
using namespace QskAspect;
|
|
|
|
using Q = QskTextInput;
|
|
|
|
|
|
|
|
setSkinHint( Q::Text | Alignment,
|
|
|
|
static_cast<int>( Qt::AlignLeft | Qt::AlignTop ) );
|
|
|
|
|
|
|
|
const ColorPalette& pal = m_data->palette;
|
|
|
|
|
|
|
|
setColor( Q::Text, pal.textColor );
|
|
|
|
|
|
|
|
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::initFocusIndicatorHints()
|
|
|
|
{
|
|
|
|
using namespace QskAspect;
|
|
|
|
using Q = QskFocusIndicator;
|
|
|
|
|
|
|
|
const ColorPalette& pal = m_data->palette;
|
|
|
|
|
2017-08-23 14:53:29 +02:00
|
|
|
setMargins( Q::Panel | Padding, 5 );
|
2017-10-18 20:00:06 +02:00
|
|
|
setBoxShape( Q::Panel, 4 );
|
|
|
|
setBoxBorderMetrics( Q::Panel, 2 );
|
2017-10-17 17:34:00 +02:00
|
|
|
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;
|
|
|
|
|
|
|
|
const ColorPalette& pal = m_data->palette;
|
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
for ( auto placement : { Preserved, Transposed } )
|
|
|
|
{
|
|
|
|
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 );
|
2017-10-17 17:34:00 +02:00
|
|
|
setGradient( aspect, pal.baseColor );
|
|
|
|
}
|
2017-07-21 18:21:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void QskMaterialSkin::initPageIndicatorHints()
|
|
|
|
{
|
|
|
|
using namespace QskAspect;
|
|
|
|
using Q = QskPageIndicator;
|
|
|
|
|
|
|
|
const ColorPalette& pal = m_data->palette;
|
|
|
|
|
|
|
|
for ( auto subControl : { Q::Bullet, Q::Highlighted } )
|
|
|
|
{
|
2017-10-17 17:34:00 +02:00
|
|
|
setMetric( subControl | Size, qskDpiScaled( 10 ) );
|
|
|
|
|
|
|
|
// circles, without border
|
2017-10-18 20:00:06 +02:00
|
|
|
setBoxShape( subControl, 100, Qt::RelativeSize );
|
|
|
|
setBoxBorderMetrics( subControl, 0 );
|
2017-10-17 17:34:00 +02:00
|
|
|
|
|
|
|
const QColor color = ( subControl == Q::Bullet )
|
|
|
|
? pal.lighter150 : pal.accentColor;
|
|
|
|
|
|
|
|
setGradient( subControl, color );
|
|
|
|
setBoxBorderColors( subControl, color );
|
2017-07-21 18:21:34 +02:00
|
|
|
}
|
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
// no visible background panel
|
2017-10-18 20:00:06 +02:00
|
|
|
setBoxBorderMetrics( Q::Panel, 0 );
|
2017-10-17 17:34:00 +02:00
|
|
|
setGradient( Q::Panel, QskGradient() );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
setMetric( Q::Panel | Spacing, 3 );
|
2017-07-21 18:21:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void QskMaterialSkin::initPushButtonHints()
|
|
|
|
{
|
|
|
|
using namespace QskAspect;
|
2017-10-17 17:34:00 +02:00
|
|
|
using namespace QskRgbValue;
|
2017-07-21 18:21:34 +02:00
|
|
|
using Q = QskPushButton;
|
|
|
|
|
|
|
|
const ColorPalette& pal = m_data->palette;
|
|
|
|
|
2017-10-19 18:07:29 +02:00
|
|
|
setMetric( Q::Panel | MinimumWidth, qskDpiScaled( 75.0 ) );
|
|
|
|
setMetric( Q::Panel | MinimumHeight, qskDpiScaled( 23.0 ) );
|
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
setMetric( Q::Panel | Spacing, 4 );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-08-23 14:53:29 +02:00
|
|
|
const QskMargins margin( 4, 3 );
|
|
|
|
const QskMargins padding( 10, 6 );
|
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
setMargins( Q::Panel | Margin, margin );
|
|
|
|
setMargins( Q::Panel | Padding, padding );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
const QskBoxBorderColors borderColors( Grey400, Grey300, Grey400, Grey600 );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-10-17 17:34:00 +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 ) );
|
2017-10-17 17:34:00 +02:00
|
|
|
setBoxBorderColors( Q::Panel, noBorderColors );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
setGradient( Q::Panel, White );
|
|
|
|
setGradient( Q::Panel | Q::Flat, White & ColorMask );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-10-17 17:34:00 +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
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
for ( auto state1 : { NoState, Q::Checkable, Q::Focused, Q::Focused | Q::Checkable } )
|
2017-07-21 18:21:34 +02:00
|
|
|
{
|
2017-10-17 17:34:00 +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
|
|
|
|
2017-10-17 17:34:00 +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
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
setGradient( Q::Panel | states, pal.accentColor );
|
|
|
|
setColor( Q::Text | states, White );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-10-17 17:34:00 +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
|
|
|
}
|
|
|
|
|
2017-10-17 17:34:00 +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;
|
2017-10-17 17:34:00 +02:00
|
|
|
using namespace QskRgbValue;
|
2017-07-21 18:21:34 +02:00
|
|
|
using Q = QskDialogButton;
|
|
|
|
|
|
|
|
const ColorPalette& pal = m_data->palette;
|
|
|
|
|
|
|
|
setMetric( Q::Panel | MinimumWidth, 30 );
|
|
|
|
setMetric( Q::Panel | MinimumHeight, 16 );
|
2017-10-17 17:34:00 +02:00
|
|
|
setMetric( Q::Panel | Spacing, 4 );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
const QskMargins margin( 4, 3 );
|
|
|
|
const QskMargins padding( 10, 6 );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
setMargins( Q::Panel | Margin, margin );
|
|
|
|
setMargins( Q::Panel | Padding, padding );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
const QskBoxBorderColors borderColors( Grey400, Grey300, Grey400, Grey600 );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-10-17 17:34:00 +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 ) );
|
2017-10-17 17:34:00 +02:00
|
|
|
setBoxBorderColors( Q::Panel, noBorderColors );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-10-17 17:34:00 +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
|
|
|
|
2017-10-17 17:34:00 +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
|
|
|
|
2017-10-17 17:34:00 +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
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
setGradient( Q::Panel | states, pal.accentColor );
|
|
|
|
setColor( Q::Text | states, White );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-10-17 17:34:00 +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()
|
|
|
|
{
|
2017-10-17 17:34:00 +02:00
|
|
|
using namespace QskAspect;
|
|
|
|
using Q = QskDialogButtonBox;
|
|
|
|
|
|
|
|
const ColorPalette& 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;
|
2017-10-17 17:34:00 +02:00
|
|
|
using namespace QskRgbValue;
|
2017-07-21 18:21:34 +02:00
|
|
|
using Q = QskSlider;
|
|
|
|
|
|
|
|
const ColorPalette& pal = m_data->palette;
|
|
|
|
|
|
|
|
const qreal dim = 30;
|
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
// 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 );
|
2017-10-17 17:34:00 +02:00
|
|
|
setGradient( Q::Panel, QskGradient() );
|
2018-01-03 11:57:05 +01:00
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
setMargins( Q::Panel | Preserved | Padding, QskMargins( 0.5 * dim, 0 ) );
|
|
|
|
setMargins( Q::Panel | Transposed | 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 );
|
2017-10-17 17:34:00 +02:00
|
|
|
setMargins( subControl | Padding, 0 );
|
|
|
|
|
2017-10-18 20:00:06 +02:00
|
|
|
setBoxShape( subControl, 0 );
|
|
|
|
setBoxBorderMetrics( subControl, 0 );
|
2017-10-17 17:34:00 +02:00
|
|
|
setGradient( subControl, QskGradient() );
|
2017-07-21 18:21:34 +02:00
|
|
|
}
|
|
|
|
|
2017-10-17 17:34:00 +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 );
|
2018-01-03 11:57:05 +01:00
|
|
|
|
2017-07-21 18:21:34 +02:00
|
|
|
// handle expanding, when being pressed
|
2017-10-17 17:34:00 +02:00
|
|
|
setMetric( Q::Handle | Size, 0.6 * dim );
|
|
|
|
setMetric( Q::Handle | Size | Q::Pressed, dim );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
setGradient( Q::Handle | Q::Disabled, Grey );
|
|
|
|
setBoxBorderColors( Q::Handle | Q::Disabled, Grey );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
// should be transparent, but the current renderer doesn't "cut out" the background
|
|
|
|
setGradient( Q::Handle, pal.accentColor );
|
|
|
|
setGradient( Q::Pressed | Q::Handle, pal.accentColor );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-10-17 17:34:00 +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;
|
2017-10-17 17:34:00 +02:00
|
|
|
setGradient( aspect, Grey300 );
|
|
|
|
setBoxBorderColors( aspect, Grey );
|
2017-07-21 18:21:34 +02:00
|
|
|
}
|
2017-10-17 17:34:00 +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;
|
|
|
|
|
|
|
|
const ColorPalette& pal = m_data->palette;
|
|
|
|
|
|
|
|
setMetric( Q::Panel | MinimumWidth, 30 );
|
|
|
|
setMetric( Q::Panel | MinimumHeight, 16 );
|
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
for ( auto placement : { Preserved, Transposed } )
|
|
|
|
{
|
|
|
|
const Aspect aspect = Q::Panel | placement;
|
|
|
|
const Qt::Edge edge = ( placement == Preserved ) ? Qt::BottomEdge : Qt::RightEdge;
|
|
|
|
|
|
|
|
setGradient( aspect, QskRgbValue::White );
|
|
|
|
|
|
|
|
// The highlighted button has a accented bar at the bottom/right edge
|
|
|
|
|
2017-10-18 20:00:06 +02:00
|
|
|
setBoxShape( aspect, 0 );
|
2017-10-17 17:34:00 +02:00
|
|
|
|
|
|
|
QskBoxBorderMetrics border;
|
|
|
|
border.setWidthAt( edge, 3 );
|
2017-10-18 20:00:06 +02:00
|
|
|
setBoxBorderMetrics( aspect, border );
|
2017-10-17 17:34:00 +02:00
|
|
|
|
|
|
|
QskBoxBorderColors borderColors( QskRgbValue::White );
|
|
|
|
setBoxBorderColors( placement, borderColors );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
borderColors.setColorsAt( edge, pal.accentColor );
|
|
|
|
for ( auto state : { Q::Checked, Q::Pressed, Q::Checkable | Q::Hovered } )
|
|
|
|
setBoxBorderColors( Q::Panel | state, borderColors );
|
|
|
|
}
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
setAnimation( Q::Panel | Color, qskDuration );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
// text
|
2017-08-28 13:20:01 +02:00
|
|
|
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 ) );
|
|
|
|
setColor( Q::Text | Q::Disabled, QskRgbValue::Grey600 );
|
|
|
|
}
|
|
|
|
|
|
|
|
void QskMaterialSkin::initTabBarHints()
|
|
|
|
{
|
2017-10-17 17:34:00 +02:00
|
|
|
using namespace QskAspect;
|
|
|
|
using Q = QskTabBar;
|
|
|
|
|
2017-10-18 20:00:06 +02:00
|
|
|
setBoxShape( Q::Panel, 0 );
|
|
|
|
setBoxBorderMetrics( Q::Panel, 0 );
|
2017-10-17 17:34:00 +02:00
|
|
|
setGradient( Q::Panel, QskGradient() );
|
2017-07-21 18:21:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void QskMaterialSkin::initTabViewHints()
|
|
|
|
{
|
2017-10-17 17:34:00 +02:00
|
|
|
using namespace QskAspect;
|
|
|
|
using Q = QskTabView;
|
|
|
|
|
|
|
|
const ColorPalette& pal = m_data->palette;
|
|
|
|
|
2017-10-18 20:00:06 +02:00
|
|
|
setBoxShape( Q::Page, 0 );
|
|
|
|
setBoxBorderMetrics( Q::Page, 0 );
|
2017-10-17 17:34:00 +02:00
|
|
|
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-03-28 09:01:25 -07:00
|
|
|
using Q = QskVirtualKeyboardButton;
|
2017-07-21 18:21:34 +02:00
|
|
|
|
|
|
|
const ColorPalette& pal = m_data->palette;
|
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
// key panel
|
2018-03-28 09:01:25 -07:00
|
|
|
setMargins( QskVirtualKeyboard::Panel | Margin, 2 );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2018-03-14 17:30:41 +01:00
|
|
|
setBoxShape( Q::Panel, 20.0, Qt::RelativeSize );
|
|
|
|
setBoxBorderMetrics( Q::Panel, 2 );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2018-03-14 17:30:41 +01:00
|
|
|
setGradient( Q::Panel, pal.darker125 );
|
|
|
|
setBoxBorderColors( Q::Panel, pal.baseColor );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
for ( auto state : { NoState, Q::Focused } )
|
2018-03-14 17:30:41 +01:00
|
|
|
setBoxBorderColors( Q::Panel | Q::Pressed | state, pal.accentColor );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2018-03-14 17:30:41 +01:00
|
|
|
setAnimation( Q::Panel | Color, qskDuration );
|
|
|
|
setAnimation( Q::Panel | Metric, qskDuration );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
// panel
|
2017-10-18 20:00:06 +02:00
|
|
|
setBoxShape( Q::Panel, 0 );
|
|
|
|
setBoxBorderMetrics( Q::Panel, 0 );
|
2017-10-17 17:34:00 +02:00
|
|
|
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;
|
|
|
|
|
|
|
|
const ColorPalette& pal = m_data->palette;
|
|
|
|
|
|
|
|
setMetric( Q::Panel | Spacing, 2 );
|
|
|
|
|
2017-10-18 20:00:06 +02:00
|
|
|
setBoxShape( Q::Viewport, 5 );
|
|
|
|
setBoxBorderMetrics( Q::Viewport, 1 );
|
2017-10-17 17:34:00 +02:00
|
|
|
setGradient( Q::Viewport, QskRgbValue::White );
|
|
|
|
setBoxBorderColors( Q::Viewport, Qt::black );
|
2018-01-03 11:57:05 +01:00
|
|
|
|
2017-07-21 18:21:34 +02:00
|
|
|
for ( auto subControl : { Q::HorizontalScrollBar, Q::VerticalScrollBar } )
|
|
|
|
{
|
|
|
|
setMetric( subControl | Size, 12 );
|
2017-08-23 14:53:29 +02:00
|
|
|
setMargins( subControl | Padding, 0 );
|
2018-01-03 11:57:05 +01:00
|
|
|
}
|
|
|
|
|
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 );
|
2017-10-17 17:34:00 +02:00
|
|
|
setGradient( subControl, pal.accentColor );
|
|
|
|
setBoxBorderColors( subControl, QskRgbValue::White );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
|
|
|
setAnimation( subControl | Color, qskDuration );
|
2018-01-03 11:57:05 +01:00
|
|
|
}
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
for ( auto subControl : {
|
2017-07-21 18:21:34 +02:00
|
|
|
Q::HorizontalScrollHandle | Q::HorizontalHandlePressed,
|
|
|
|
Q::VerticalScrollHandle | Q::VerticalHandlePressed } )
|
|
|
|
{
|
2017-10-17 17:34:00 +02:00
|
|
|
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;
|
|
|
|
|
|
|
|
const ColorPalette& pal = m_data->palette;
|
|
|
|
|
|
|
|
// padding for each cell
|
2017-08-23 14:53:29 +02:00
|
|
|
setMargins( Q::Cell | Padding, QskMargins( 4, 8 ) );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
|
|
|
setColor( Q::Cell, pal.baseColor );
|
2017-10-17 17:34:00 +02:00
|
|
|
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;
|
|
|
|
|
|
|
|
const ColorPalette& pal = m_data->palette;
|
|
|
|
|
|
|
|
// panel
|
|
|
|
|
2017-08-23 14:53:29 +02:00
|
|
|
setMargins( Q::Panel | Padding, 10 );
|
2017-10-18 20:00:06 +02:00
|
|
|
setBoxShape( Q::Panel, 0 );
|
|
|
|
setBoxBorderMetrics( Q::Panel, 2 );
|
2017-10-17 17:34:00 +02:00
|
|
|
setGradient( Q::Panel, pal.baseColor );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-10-17 17:34:00 +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
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
setBoxBorderColors( Q::Panel, colors );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-10-17 17:34:00 +02:00
|
|
|
// title bar
|
2017-10-19 16:24:43 +02:00
|
|
|
setGradient( Q::TitleBar, pal.darker200 );
|
|
|
|
setGradient( Q::TitleBar | Q::Focused, pal.accentColor );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2017-08-28 13:20:01 +02:00
|
|
|
setFontRole( Q::TitleBar, QskSkin::TinyFont );
|
2017-07-21 18:21:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#include "moc_QskMaterialSkin.cpp"
|