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
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef QSK_MATERIAL_SKIN_H
|
|
|
|
#define QSK_MATERIAL_SKIN_H
|
|
|
|
|
2018-10-12 08:03:03 +02:00
|
|
|
#include "QskMaterialGlobal.h"
|
2017-07-21 18:21:34 +02:00
|
|
|
#include <QskSkin.h>
|
2022-02-17 21:54:56 +01:00
|
|
|
#include <QskRgbValue.h>
|
2017-07-21 18:21:34 +02:00
|
|
|
#include <memory>
|
|
|
|
|
2022-02-17 21:54:56 +01:00
|
|
|
struct ColorPalette
|
|
|
|
{
|
|
|
|
enum Lightness { light, dark } lightness;
|
|
|
|
|
|
|
|
QColor primary;
|
|
|
|
QColor primaryVariant;
|
|
|
|
QColor onPrimary;
|
|
|
|
|
|
|
|
QColor secondary;
|
|
|
|
QColor secondaryVariant;
|
|
|
|
QColor onSecondary;
|
|
|
|
|
|
|
|
QColor background;
|
|
|
|
QColor onBackground;
|
|
|
|
|
|
|
|
QColor error;
|
|
|
|
QColor onError;
|
|
|
|
|
|
|
|
QColor primaryNoSaturation = QColor::fromHsl( primary.hslHue(), 0,
|
|
|
|
primary.lightness() );
|
|
|
|
|
|
|
|
QColor secondaryNoSaturation =
|
|
|
|
QColor::fromHsl( secondary.hslHue(), 0,
|
|
|
|
secondary.lightness() );
|
|
|
|
|
|
|
|
QColor secondaryVariantNoSaturation =
|
|
|
|
QColor::fromHsl( secondaryVariant.hslHue(), 0,
|
|
|
|
secondaryVariant.lightness() +
|
|
|
|
secondaryVariant.hslSaturation() );
|
|
|
|
|
|
|
|
qreal disabledOccupancy = 0.2;
|
|
|
|
qreal widgetBackgroundDisabled = 0.6;
|
|
|
|
|
|
|
|
qreal hover = 0.1;
|
|
|
|
qreal focused = 0.4;
|
|
|
|
qreal pressed = 0.5;
|
|
|
|
qreal disabled = 0.3;
|
|
|
|
|
|
|
|
ColorPalette(
|
|
|
|
Lightness lightness = light,
|
|
|
|
QColor primary = QColor::fromRgb( 0x6200EE ),
|
|
|
|
QColor primaryVariant = QColor::fromRgb( 0x3700B3 ),
|
|
|
|
QColor onPrimary = Qt::white,
|
|
|
|
QColor secondary = QColor::fromRgb( 0x03DAC6 ),
|
|
|
|
QColor secondaryVariant = QColor::fromRgb( 0x018786 ),
|
|
|
|
QColor onSecondary = Qt::white,
|
|
|
|
QColor background = QColor::fromRgba( QskRgb::Grey100 ),
|
|
|
|
QColor onBackground = Qt::black,
|
|
|
|
QColor error = QColor::fromRgb( 0xB00020 ),
|
|
|
|
QColor onError = Qt::white ):
|
|
|
|
lightness( lightness ),
|
|
|
|
primary( primary ),
|
|
|
|
primaryVariant( primaryVariant ),
|
|
|
|
onPrimary( onPrimary ),
|
|
|
|
secondary( secondary ),
|
|
|
|
secondaryVariant( secondaryVariant ),
|
|
|
|
onSecondary( onSecondary ),
|
|
|
|
background( background ),
|
|
|
|
onBackground( onBackground ),
|
|
|
|
error( error ),
|
|
|
|
onError( onError )
|
|
|
|
{
|
|
|
|
primaryNoSaturation = QColor::fromHsl( primary.hslHue(), 0,
|
|
|
|
primary.lightness() );
|
|
|
|
|
|
|
|
secondaryNoSaturation = QColor::fromHsl( secondary.hslHue(),
|
|
|
|
0,
|
|
|
|
secondary.lightness() );
|
|
|
|
|
|
|
|
secondaryVariantNoSaturation =
|
|
|
|
QColor::fromHsl( secondaryVariant.hslHue(), 0,
|
|
|
|
secondaryVariant.lightness() );
|
|
|
|
}
|
|
|
|
|
|
|
|
inline QColor elevated( const QColor target, const float level = 1 ) const {
|
|
|
|
return ( lightness == light ) ? target.darker( 100 + level * 15 )
|
|
|
|
: target.lighter( 130 + level * 30 );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-10-12 08:03:03 +02:00
|
|
|
class QSK_MATERIAL_EXPORT QskMaterialSkin : public QskSkin
|
2017-07-21 18:21:34 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
using Inherited = QskSkin;
|
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
public:
|
2022-02-17 21:54:56 +01:00
|
|
|
QskMaterialSkin( ColorPalette, QObject* parent = nullptr );
|
2018-07-31 17:32:25 +02:00
|
|
|
~QskMaterialSkin() override;
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
private:
|
2017-07-21 18:21:34 +02:00
|
|
|
class PrivateData;
|
|
|
|
std::unique_ptr< PrivateData > m_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|