qskinny/skins/material3/QskMaterial3Skin.h

164 lines
3.7 KiB
C
Raw Normal View History

2017-07-21 18:21:34 +02:00
/******************************************************************************
2022-07-06 14:48:06 +02:00
* QSkinny - Copyright (C) 2022 Edelhirsch Software GmbH
* This file may be used under the terms of the 3-clause BSD License
2017-07-21 18:21:34 +02:00
*****************************************************************************/
2022-07-05 08:36:25 +02:00
#ifndef QSK_MATERIAL3_SKIN_H
#define QSK_MATERIAL3_SKIN_H
2017-07-21 18:21:34 +02:00
2022-07-05 08:36:25 +02:00
#include "QskMaterial3Global.h"
2022-06-27 14:32:37 +02:00
#include <QskBoxShapeMetrics.h>
#include <QskGraphicProvider.h>
2022-06-27 14:32:37 +02:00
#include <QskHctColor.h>
2017-07-21 18:21:34 +02:00
#include <QskSkin.h>
#include <QskShadowMetrics.h>
2017-07-21 18:21:34 +02:00
2022-06-14 11:26:12 +02:00
#include <array>
2022-07-05 08:36:25 +02:00
class QSK_MATERIAL3_EXPORT QskMaterial3Theme
2022-02-17 21:54:56 +01:00
{
public:
enum Lightness
{
Light,
Dark
};
enum PaletteType
{
Primary,
Secondary,
Tertiary,
Error,
Neutral,
NeutralVariant,
NumPaletteTypes
};
2022-07-05 08:36:25 +02:00
QskMaterial3Theme( Lightness );
QskMaterial3Theme( Lightness, std::array< QskHctColor, NumPaletteTypes > );
2022-02-17 21:54:56 +01:00
QRgb primary;
QRgb primary8; // ### rename to primaryHovered or so?
2022-07-15 08:39:52 +02:00
QRgb primary12;
QRgb onPrimary;
QRgb primaryContainer;
QRgb onPrimaryContainer;
QRgb secondary;
QRgb onSecondary;
QRgb secondaryContainer;
QRgb onSecondaryContainer;
QRgb onSecondaryContainer8;
QRgb onSecondaryContainer12;
QRgb tertiary;
QRgb onTertiary;
QRgb tertiaryContainer;
QRgb onTertiaryContainer;
QRgb error;
QRgb error8;
QRgb error12;
QRgb onError;
QRgb errorContainer;
QRgb onErrorContainer;
QRgb background;
QRgb onBackground;
QRgb surface;
2022-07-15 08:39:52 +02:00
QRgb surface1;
QRgb surface2;
QRgb surface3;
QRgb surface4;
QRgb surface5;
QRgb onSurface;
QRgb onSurface8;
2022-07-15 08:39:52 +02:00
QRgb onSurface12;
QRgb onSurface38;
QRgb surfaceVariant;
2022-07-15 08:39:52 +02:00
QRgb surfaceVariant12;
QRgb onSurfaceVariant;
QRgb outline;
2022-06-13 12:54:17 +02:00
QRgb shadow;
QskShadowMetrics elevation0;
QskShadowMetrics elevation1;
QskShadowMetrics elevation2;
QskShadowMetrics elevation3;
const qreal hoverOpacity = 0.08;
const qreal focusOpacity = 0.12;
const qreal pressedOpacity = 0.12;
const qreal draggedOpacity = 0.16;
QskBoxShapeMetrics shapeExtraSmallTop;
private:
2022-06-27 14:32:37 +02:00
std::array< QskHctColor, NumPaletteTypes > m_palettes;
2022-02-17 21:54:56 +01:00
};
class QSK_MATERIAL3_EXPORT QskMaterial3GraphicProvder : public QskGraphicProvider
{
Q_OBJECT
using Inherited = QskGraphicProvider;
public:
QskMaterial3GraphicProvder( QObject* parent = nullptr );
protected:
virtual const QskGraphic* loadGraphic( const QString& id ) const override;
};
2022-07-05 08:36:25 +02:00
class QSK_MATERIAL3_EXPORT QskMaterial3Skin : 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-07-05 08:36:25 +02:00
QskMaterial3Skin( const QskMaterial3Theme&, QObject* parent = nullptr );
~QskMaterial3Skin() override;
virtual QskGraphic symbol( int symbolType ) const override;
enum GraphicRole
{
GraphicRoleOnError,
GraphicRoleOnPrimary,
2023-01-27 16:56:50 +01:00
GraphicRoleOnSecondaryContainer,
GraphicRoleOnSurface,
GraphicRoleOnSurface38,
GraphicRoleOnSurfaceVariant,
GraphicRolePrimary,
GraphicRoleSurface,
};
2022-06-07 12:40:21 +02:00
enum FontRole
{
M3BodyMedium = QskSkin::HugeFont + 1,
M3BodyLarge,
2022-07-05 16:15:00 +02:00
M3HeadlineSmall,
2022-06-13 15:36:06 +02:00
M3LabelLarge,
2022-06-07 12:40:21 +02:00
};
static constexpr QskAspect::Variation Filled = QskAspect::NoVariation;
static constexpr QskAspect::Variation Tonal = QskAspect::Huge;
static constexpr QskAspect::Variation Elevated = QskAspect::Large;
static constexpr QskAspect::Variation Outlined = QskAspect::Small;
static constexpr QskAspect::Variation Text = QskAspect::Tiny;
2022-06-07 12:40:21 +02:00
private:
void setupFonts();
void setupGraphicFilters( const QskMaterial3Theme& palette );
2023-02-26 15:07:08 +01:00
void setGraphicColor( GraphicRole, QRgb );
2017-07-21 18:21:34 +02:00
};
#endif