qskinny/skins/material/QskMaterialSkin.cpp

791 lines
23 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"
2020-12-26 12:57:08 +01:00
#include <QskSkinHintTableEditor.h>
2019-12-15 13:57:19 +01:00
#include <QskBox.h>
#include <QskCheckBox.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>
2022-04-05 11:38:23 +02:00
#include <QskMenu.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>
2021-08-02 13:22:37 +02:00
#include <QskSwitchButton.h>
#include <QskSwitchButtonSkinlet.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
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>
#include <QskMargins.h>
2017-07-21 18:21:34 +02:00
#include <QskNamespace.h>
#include <QskPlatform.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;
namespace
{
2020-12-26 12:57:08 +01:00
class Editor : private QskSkinHintTableEditor
{
public:
Editor( QskSkinHintTable* table, const QskMaterialPalette& palette )
2020-12-26 12:57:08 +01:00
: QskSkinHintTableEditor( table )
, m_pal( palette )
{
}
2017-07-21 18:21:34 +02:00
2020-12-26 12:57:08 +01:00
void setup();
private:
void setupControl();
2021-08-02 13:22:37 +02:00
2020-12-26 12:57:08 +01:00
void setupBox();
void setupCheckBox();
2020-12-26 12:57:08 +01:00
void setupDialogButtonBox();
void setupDialogButton();
void setupFocusIndicator();
void setupInputPanel();
void setupVirtualKeyboard();
void setupListView();
2022-04-05 11:38:23 +02:00
void setupMenu();
2020-12-26 12:57:08 +01:00
void setupPageIndicator();
void setupPopup();
void setupProgressBar();
void setupPushButton();
void setupScrollView();
void setupSeparator();
void setupSubWindow();
void setupSlider();
2021-08-02 13:22:37 +02:00
void setupSwitchButton();
2020-12-26 12:57:08 +01:00
void setupTabButton();
void setupTabBar();
void setupTabView();
void setupTextInput();
void setupTextLabel();
const QskMaterialPalette& m_pal;
2022-02-17 21:54:56 +01:00
const uint rippleSize = 30;
2020-12-26 12:57:08 +01:00
};
2017-07-21 18:21:34 +02:00
}
2020-12-26 12:57:08 +01:00
void Editor::setup()
2017-07-21 18:21:34 +02:00
{
2020-12-26 12:57:08 +01:00
setupControl();
setupBox();
setupCheckBox();
2020-12-26 12:57:08 +01:00
setupDialogButtonBox();
setupDialogButton();
setupFocusIndicator();
setupInputPanel();
setupVirtualKeyboard();
setupListView();
2022-04-05 11:38:23 +02:00
setupMenu();
2020-12-26 12:57:08 +01:00
setupPageIndicator();
setupPopup();
setupProgressBar();
setupPushButton();
setupScrollView();
setupSeparator();
setupSlider();
setupSubWindow();
2021-08-02 13:22:37 +02:00
setupSwitchButton();
2020-12-26 12:57:08 +01:00
setupTabButton();
setupTabBar();
setupTabView();
setupTextLabel();
setupTextInput();
2017-07-21 18:21:34 +02:00
}
2020-12-26 12:57:08 +01:00
void Editor::setupControl()
2017-07-21 18:21:34 +02:00
{
2020-12-21 16:06:58 +01:00
using A = QskAspect;
2017-07-21 18:21:34 +02:00
using Q = QskControl;
2022-02-17 21:54:56 +01:00
setPadding( A::Control, 11 );
2017-07-21 18:21:34 +02:00
2022-02-17 21:54:56 +01:00
setGradient( A::Control, m_pal.background );
setColor( A::Control | A::StyleColor, m_pal.onBackground );
2020-12-21 16:06:58 +01:00
setColor( A::Control | A::StyleColor | Q::Disabled,
QskRgb::toTransparentF( m_pal.onBackground, 0.6 ) );
2017-07-21 18:21:34 +02:00
}
void Editor::setupCheckBox()
{
2022-04-05 08:48:16 +02:00
using A = QskAspect;
using Q = QskCheckBox;
2022-04-05 08:48:16 +02:00
const qreal size = qskDpiScaled( 18 );
setStrutSize( Q::Panel, size, size );
setPadding( Q::Panel, 3 );
2022-04-05 08:48:16 +02:00
setBoxShape( Q::Panel, 2 );
setGradient( Q::Panel, m_pal.secondaryNoSaturation );
setGradient( Q::Panel | Q::Checked, m_pal.secondary );
2022-04-05 08:48:16 +02:00
setGradient( Q::Panel | Q::Checked | Q::Disabled, QskRgb::Grey );
setColor( Q::Indicator, m_pal.primary );
2022-04-05 08:48:16 +02:00
setAnimation( Q::Panel | A::Color, qskDuration );
}
2020-12-26 12:57:08 +01:00
void Editor::setupBox()
2019-12-15 13:57:19 +01:00
{
using Q = QskBox;
2022-02-17 21:54:56 +01:00
setGradient( Q::Panel, m_pal.background );
setBoxShape( Q::Panel, 14 );
2019-12-15 13:57:19 +01:00
setBoxBorderMetrics( Q::Panel, 0 );
}
2020-12-26 12:57:08 +01:00
void Editor::setupPopup()
2017-07-21 18:21:34 +02:00
{
2020-12-21 16:06:58 +01:00
using A = QskAspect;
2017-07-21 18:21:34 +02:00
using Q = QskPopup;
2020-12-26 12:57:08 +01:00
setFlagHint( Q::Overlay | A::Style, true );
const QskGradient gradient( QskGradient::Vertical,
QskRgb::toTransparentF( m_pal.secondary, 0.45 ),
QskRgb::toTransparentF( m_pal.secondary, 0.7 ) );
setGradient( Q::Overlay, gradient );
2017-07-21 18:21:34 +02:00
}
2022-04-05 11:38:23 +02:00
void Editor::setupMenu()
{
using A = QskAspect;
using Q = QskMenu;
setBoxShape( Q::Panel, qskDpiScaled( 4 ) );
setBoxBorderMetrics( Q::Panel, qskDpiScaled( 1 ) );
2022-04-05 11:55:26 +02:00
setBoxBorderColors( Q::Panel, m_pal.primary );
2022-04-05 11:38:23 +02:00
2022-04-05 11:55:26 +02:00
setGradient( Q::Panel, m_pal.background );
2022-04-05 11:38:23 +02:00
const bool isCascading = qskMaybeDesktopPlatform();
setFlagHint( Q::Panel | A::Style, isCascading );
#if 0
setPadding( Q::Separator, QMarginsF( 10, 0, 10, 0 ) );
#endif
setMetric( Q::Separator | A::Size, qskDpiScaled( 1 ) );
setBoxShape( Q::Separator, 0 );
setBoxBorderMetrics( Q::Separator, 0 );
2022-04-05 11:55:26 +02:00
setGradient( Q::Separator, m_pal.primary );
2022-04-05 11:38:23 +02:00
setPadding( Q::Cell, QskMargins( 2, 10, 2, 10 ) );
setSpacing( Q::Cell, 5 );
setGradient( Q::Cell, Qt::transparent );
2022-04-05 11:55:26 +02:00
setGradient( Q::Cursor, QskRgb::toTransparentF( m_pal.onBackground, m_pal.focused ) );
2022-04-05 11:38:23 +02:00
2022-04-05 11:55:26 +02:00
setColor( Q::Text, m_pal.onBackground );
2022-04-05 11:38:23 +02:00
setFontRole( Q::Text, QskSkin::SmallFont );
setPosition( Q::Panel, 0 );
setPosition( Q::Panel | QskPopup::Closed, 1 );
setAnimation( Q::Panel | A::Metric, 150 );
setAnimation( Q::Cursor | A::Position | A::Metric, 75, QEasingCurve::OutCubic );
}
2020-12-26 12:57:08 +01:00
void Editor::setupTextLabel()
2017-07-21 18:21:34 +02:00
{
using Q = QskTextLabel;
setAlignment( Q::Text, Qt::AlignCenter );
2022-02-17 21:54:56 +01:00
setColor( Q::Text, m_pal.onBackground );
2019-12-15 13:57:19 +01:00
setPadding( Q::Panel, 5 );
2019-12-15 13:57:19 +01:00
setBoxShape( Q::Panel, 4 );
setBoxBorderMetrics( Q::Panel, 2 );
2022-02-17 21:54:56 +01:00
setBoxBorderColors( Q::Panel, m_pal.primaryNoSaturation );
setGradient( Q::Panel, m_pal.background );
2017-07-21 18:21:34 +02:00
}
2022-02-17 21:54:56 +01:00
2020-12-26 12:57:08 +01:00
void Editor::setupTextInput()
{
using Q = QskTextInput;
2022-04-02 11:50:55 +02:00
using namespace QskRgb;
setAlignment( Q::Text, Qt::AlignLeft | Qt::AlignTop );
2022-02-17 21:54:56 +01:00
setColor( Q::Text, m_pal.onBackground );
setPadding( Q::Panel, 5 );
2022-02-17 21:54:56 +01:00
setBoxShape( Q::Panel, 4, 4, 0, 0 );
setBoxBorderMetrics( Q::Panel, 0, 0, 0, 1 );
setBoxBorderColors( Q::Panel, m_pal.onBackground );
setBoxBorderMetrics( Q::Panel | Q::Focused, 0, 0, 0, 2 );
setBoxBorderColors( Q::Panel | Q::Focused, m_pal.primary );
setBoxBorderMetrics( Q::Panel | Q::Editing, 0, 0, 0, 2 );
setBoxBorderColors( Q::Panel | Q::Editing, m_pal.primary );
setBoxBorderColors( Q::Panel | Q::Focused, m_pal.primary );
2022-04-02 11:50:55 +02:00
setGradient( Q::Panel, m_pal.elevated( m_pal.background, 1 ) );
setGradient( Q::Panel | Q::Hovered, m_pal.elevated( m_pal.background, 2 ) );
setGradient( Q::Panel | Q::Focused, m_pal.elevated( m_pal.background, 3 ) );
setGradient( Q::Panel | Q::Editing, m_pal.elevated( m_pal.background, 4 ) );
setGradient( Q::Panel | Q::Disabled,
m_pal.toDisabled( m_pal.secondaryVariantNoSaturation ) );
2022-02-17 21:54:56 +01:00
2022-04-02 11:50:55 +02:00
setColor( Q::Text | Q::Disabled, m_pal.toDisabled( m_pal.onBackground ) );
setBoxBorderColors( Q::Panel, m_pal.toDisabled( m_pal.onBackground ) );
}
2020-12-26 12:57:08 +01:00
void Editor::setupProgressBar()
2020-07-31 16:57:22 +02:00
{
2020-12-21 16:06:58 +01:00
using A = QskAspect;
2020-08-01 17:51:45 +02:00
using Q = QskProgressBar;
2020-07-31 16:57:22 +02:00
2022-02-17 21:54:56 +01:00
auto size = qskDpiScaled( 5 );
2020-08-06 09:28:18 +02:00
for ( auto subControl : { Q::Groove, Q::Bar } )
2020-12-05 15:09:31 +01:00
{
2022-02-17 21:54:56 +01:00
setMetric( subControl | A::Size, size );
setPadding( subControl, 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
2022-02-17 21:54:56 +01:00
setMetric( Q::Groove | A::Size, size );
2022-04-02 11:50:55 +02:00
setGradient( Q::Groove, m_pal.secondaryNoSaturation );
2022-02-17 21:54:56 +01:00
setGradient( Q::Groove | Q::Disabled,
2022-04-02 11:50:55 +02:00
m_pal.toDisabled( m_pal.secondaryNoSaturation ) );
setGradient( Q::Bar, m_pal.secondary );
setGradient( Q::Bar | Q::Disabled, m_pal.toDisabled( m_pal.secondary ) );
2020-07-31 16:57:22 +02:00
}
2020-12-26 12:57:08 +01:00
void Editor::setupFocusIndicator()
2017-07-21 18:21:34 +02:00
{
using Q = QskFocusIndicator;
setGradient( Q::Panel, QskGradient() );
2017-07-21 18:21:34 +02:00
}
2020-12-26 12:57:08 +01:00
void Editor::setupSeparator()
2017-07-21 18:21:34 +02:00
{
2020-12-21 16:06:58 +01:00
using A = QskAspect;
2017-07-21 18:21:34 +02:00
using Q = QskSeparator;
2020-12-21 16:06:58 +01:00
for ( auto placement : { A::Horizontal, A::Vertical } )
{
const auto aspect = Q::Panel | placement;
2020-12-21 16:06:58 +01:00
setMetric( aspect | A::Size, 4 );
2017-10-18 20:00:06 +02:00
setBoxShape( Q::Panel, 0 );
setBoxBorderMetrics( Q::Panel, 0 );
2022-02-17 21:54:56 +01:00
setGradient( aspect, m_pal.background );
}
2017-07-21 18:21:34 +02:00
}
2020-12-26 12:57:08 +01:00
void Editor::setupPageIndicator()
2017-07-21 18:21:34 +02:00
{
using Q = QskPageIndicator;
2022-01-04 13:58:34 +01:00
const auto extent = qskDpiScaled( 9 );
setStrutSize( Q::Bullet, extent, extent );
2022-01-04 13:58:34 +01:00
// circles, without border
setBoxShape( Q::Bullet, 100, Qt::RelativeSize );
setBoxBorderMetrics( Q::Bullet, 0 );
2022-02-17 21:54:56 +01:00
setGradient( Q::Bullet, m_pal.secondaryNoSaturation );
setGradient( Q::Bullet | Q::Selected, m_pal.secondary );
2017-07-21 18:21:34 +02:00
2022-02-17 21:54:56 +01:00
setGradient( Q::Bullet | Q::Disabled,
2022-04-02 11:50:55 +02:00
m_pal.toDisabled( m_pal.secondaryNoSaturation ) );
2022-02-17 21:54:56 +01:00
setGradient( Q::Bullet | Q::Selected | Q::Disabled,
2022-04-02 11:50:55 +02:00
m_pal.toDisabled( m_pal.secondary ) );
2022-02-17 21:54:56 +01:00
setSpacing( Q::Panel, qskDpiScaled( 3 ) );
2022-01-04 13:58:34 +01:00
setPadding( Q::Panel, 0 );
setGradient( Q::Panel, QskGradient() ); // invisible
2017-07-21 18:21:34 +02:00
}
2020-12-26 12:57:08 +01:00
void Editor::setupPushButton()
2017-07-21 18:21:34 +02:00
{
2020-12-21 16:06:58 +01:00
using A = QskAspect;
2020-08-15 13:29:17 +02:00
using namespace QskRgb;
2017-07-21 18:21:34 +02:00
using Q = QskPushButton;
setStrutSize( Q::Panel, qskDpiScaled( 75.0 ), qskDpiScaled( 23.0 ) );
2022-02-17 21:54:56 +01:00
setSpacing( Q::Panel, qskDpiScaled( 4 ) );
2017-07-21 18:21:34 +02:00
const QskMargins margin( 4, 3 );
const QskMargins padding( 10, 6 );
setMargin( Q::Panel, margin );
setPadding( Q::Panel, padding );
2017-07-21 18:21:34 +02:00
2022-02-17 21:54:56 +01:00
setBoxShape( Q::Panel, 5 );
2017-07-21 18:21:34 +02:00
2022-02-17 21:54:56 +01:00
setColor( Q::Text, m_pal.primary );
2022-04-02 11:50:55 +02:00
setColor( Q::Text | Q::Disabled, toTransparentF( m_pal.primary, 0.6 ) );
setFontRole( Q::Text, ButtonFontRole );
setAlignment( Q::Text, Qt::AlignCenter );
2017-07-21 18:21:34 +02:00
2022-02-17 21:54:56 +01:00
setBoxBorderMetrics( Q::Panel, 1 );
setBoxBorderColors( Q::Panel, m_pal.primary );
2017-07-21 18:21:34 +02:00
2022-04-02 11:50:55 +02:00
setBoxBorderColors( Q::Panel | Q::Disabled, m_pal.toDisabled( m_pal.onBackground ) );
setColor( Q::Text | Q::Disabled, m_pal.toDisabled( m_pal.onBackground ) );
2017-07-21 18:21:34 +02:00
2022-04-02 11:50:55 +02:00
setGradient( Q::Panel | Q::Hovered, toTransparentF( m_pal.primary, m_pal.hover ) );
setGradient( Q::Panel | Q::Focused, toTransparentF( m_pal.primary, m_pal.focused ) );
setGradient( Q::Panel | Q::Pressed, toTransparentF( m_pal.primary, m_pal.pressed ) );
2022-04-03 16:24:50 +02:00
setGradient( Q::Panel | Q::Flat, White & ColorMask );
2017-07-21 18:21:34 +02:00
2020-12-21 16:06:58 +01:00
setAnimation( Q::Panel | A::Color, qskDuration );
setAnimation( Q::Panel | A::Metric, qskDuration );
setAnimation( Q::Text | A::Color, qskDuration );
2017-07-21 18:21:34 +02:00
}
2020-12-26 12:57:08 +01:00
void Editor::setupDialogButton()
2017-07-21 18:21:34 +02:00
{
2020-12-21 16:06:58 +01:00
using A = QskAspect;
2020-08-15 13:29:17 +02:00
using namespace QskRgb;
2017-07-21 18:21:34 +02:00
using Q = QskDialogButton;
setStrutSize( Q::Panel, 30, 16 );
setSpacing( Q::Panel, 4 );
2017-07-21 18:21:34 +02:00
2020-12-15 18:12:48 +01:00
setMargin( Q::Panel, QskMargins( 4, 3 ) );
setPadding( Q::Panel, QskMargins( 10, 6 ) );
2017-07-21 18:21:34 +02:00
2017-10-18 20:00:06 +02:00
setBoxShape( Q::Panel, 0 );
2017-07-21 18:21:34 +02:00
2022-02-17 21:54:56 +01:00
setGradient( Q::Panel, m_pal.primary );
setColor( Q::Text, m_pal.onBackground );
setColor( Q::Text | Q::Disabled, QskRgb::toTransparentF( m_pal.onPrimary, 0.6 ) );
setFontRole( Q::Text, ButtonFontRole );
setAlignment( Q::Text, Qt::AlignCenter );
2017-07-21 18:21:34 +02:00
for ( auto state1 : { A::NoState, Q::Focused } )
{
2020-12-21 16:06:58 +01:00
for ( auto state2 : { A::NoState, Q::Hovered } )
{
2022-02-17 21:54:56 +01:00
for ( auto state3 : { Q::Pressed | A::NoState,
Q::Checked | A::NoState, Q::Checked | Q::Pressed } )
{
const auto states = state1 | state2 | state3;
2017-07-21 18:21:34 +02:00
2022-02-17 21:54:56 +01:00
setGradient( Q::Panel | states, m_pal.secondary );
setColor( Q::Text | states, m_pal.onSecondary );
}
}
}
2017-07-21 18:21:34 +02:00
2020-12-21 16:06:58 +01:00
setAnimation( Q::Panel | A::Color, qskDuration );
setAnimation( Q::Panel | A::Metric, qskDuration );
setAnimation( Q::Text | A::Color, qskDuration );
2017-07-21 18:21:34 +02:00
}
2020-12-26 12:57:08 +01:00
void Editor::setupDialogButtonBox()
2017-07-21 18:21:34 +02:00
{
using Q = QskDialogButtonBox;
2022-02-17 21:54:56 +01:00
setGradient( Q::Panel, m_pal.background );
2017-10-18 20:00:06 +02:00
setBoxShape( Q::Panel, 0 );
setBoxBorderMetrics( Q::Panel, 0 );
2017-07-21 18:21:34 +02:00
}
2020-12-26 12:57:08 +01:00
void Editor::setupSlider()
2017-07-21 18:21:34 +02:00
{
2020-12-21 16:06:58 +01:00
using A = QskAspect;
2020-08-15 13:29:17 +02:00
using namespace QskRgb;
2017-07-21 18:21:34 +02:00
using Q = QskSlider;
2020-12-17 16:14:56 +01:00
const qreal extent = 30;
2017-07-21 18:21:34 +02:00
// Panel
2020-12-21 16:06:58 +01:00
setMetric( Q::Panel | A::Size, extent );
2017-10-18 20:00:06 +02:00
setBoxShape( Q::Panel, 0 );
setBoxBorderMetrics( Q::Panel, 0 );
setGradient( Q::Panel, QskGradient() );
2020-12-21 16:06:58 +01:00
setPadding( Q::Panel | A::Horizontal, QskMargins( 0.5 * extent, 0 ) );
setPadding( Q::Panel | A::Vertical, QskMargins( 0, 0.5 * extent ) );
// Groove, Fill
2017-07-21 18:21:34 +02:00
for ( auto subControl : { Q::Groove, Q::Fill } )
{
setPadding( subControl, 0 );
2017-10-18 20:00:06 +02:00
setBoxShape( subControl, 0 );
setBoxBorderMetrics( subControl, 0 );
2017-07-21 18:21:34 +02:00
}
2022-02-17 21:54:56 +01:00
setMetric( Q::Groove | A::Size, qskDpiScaled( 4 ) );
setMetric( Q::Fill | A::Size, qskDpiScaled( 6 ) );
2017-07-21 18:21:34 +02:00
setGradient( Q::Groove, QskRgb::toTransparentF( m_pal.secondary, .38 ) );
2022-02-17 21:54:56 +01:00
setGradient( Q::Groove | Q::Disabled,
2022-04-02 11:50:55 +02:00
m_pal.toDisabled( m_pal.secondaryNoSaturation ) );
2022-02-17 21:54:56 +01:00
setGradient( Q::Fill, m_pal.secondary );
setGradient( Q::Fill | Q::Disabled,
2022-04-02 11:50:55 +02:00
m_pal.toDisabled( m_pal.secondaryNoSaturation ) );
2017-07-21 18:21:34 +02:00
2017-10-18 20:00:06 +02:00
setBoxShape( Q::Handle, 100, Qt::RelativeSize );
2022-02-17 21:54:56 +01:00
setBoxBorderMetrics( Q::Handle, 0 );
2022-02-17 21:54:56 +01:00
setStrutSize( Q::Handle, qskDpiScaled( 20 + rippleSize ),
qskDpiScaled( 20 + rippleSize ) );
2017-07-21 18:21:34 +02:00
2022-02-17 21:54:56 +01:00
setGradient( Q::Handle | Q::Disabled, m_pal.secondaryNoSaturation );
2017-07-21 18:21:34 +02:00
2022-02-17 21:54:56 +01:00
setGradient( Q::Handle, m_pal.secondary );
setGradient( Q::Handle | Q::Pressed, m_pal.secondary );
2017-07-21 18:21:34 +02:00
2022-02-17 21:54:56 +01:00
setBoxBorderMetrics( Q::Handle, qskDpiScaled( rippleSize / 2 ) );
2017-07-21 18:21:34 +02:00
2022-02-17 21:54:56 +01:00
setBoxBorderColors( Q::Handle | Q::Hovered,
QskRgb::toTransparentF( m_pal.secondary, m_pal.hover ) );
2022-02-17 21:54:56 +01:00
setBoxBorderColors( Q::Handle | Q::Focused,
QskRgb::toTransparentF( m_pal.secondary, m_pal.focused ) );
2022-02-17 21:54:56 +01:00
setBoxBorderColors( Q::Handle | Q::Pressed,
QskRgb::toTransparentF( m_pal.secondary, m_pal.pressed ) );
// move the handle smoothly, when using keys
2020-12-21 16:06:58 +01:00
setAnimation( Q::Handle | A::Metric | A::Position, 2 * qskDuration );
setAnimation( Q::Handle | A::Metric | A::Position | Q::Pressed, 0 );
2017-07-21 18:21:34 +02:00
}
2021-08-02 13:22:37 +02:00
void Editor::setupSwitchButton()
{
using A = QskAspect;
using Q = QskSwitchButton;
const qreal radius = qskDpiScaled( 10 );
setBoxShape( Q::Groove, 100, Qt::RelativeSize );
const QSizeF grooveSize( 3.4 * radius, 1.2 * radius );
setStrutSize( Q::Groove | A::Horizontal, grooveSize );
setStrutSize( Q::Groove | A::Vertical, grooveSize.transposed() );
2022-04-02 11:50:55 +02:00
setGradient( Q::Groove, m_pal.secondaryNoSaturation );
setGradient( Q::Groove | Q::Disabled, m_pal.toDisabled( m_pal.secondaryNoSaturation ) );
setGradient( Q::Groove | Q::Checked, m_pal.secondaryVariant );
2022-02-17 21:54:56 +01:00
setGradient( Q::Groove | Q::Checked | Q::Disabled,
QskRgb::toTransparentF( m_pal.secondaryVariant, m_pal.disabledOccupancy ) );
2021-08-02 19:17:04 +02:00
setBoxShape( Q::Handle, 100, Qt::RelativeSize );
2022-02-17 21:54:56 +01:00
setStrutSize( Q::Handle, qskDpiScaled( 2 * radius + rippleSize ),
qskDpiScaled( 2 * radius + rippleSize ) );
setGradient( Q::Handle, QskRgb::lighter( m_pal.background, 900 ) );
2022-02-17 21:54:56 +01:00
setGradient( Q::Handle | Q::Checked, m_pal.secondary );
setGradient( Q::Handle | Q::Disabled,
m_pal.elevated( m_pal.secondaryNoSaturation, -2 ) );
setGradient( Q::Handle | Q::Disabled | Q::Checked,
m_pal.elevated( m_pal.secondary, -3 ) );
setBoxBorderMetrics( Q::Handle, qskDpiScaled( rippleSize / 2 ) );
setBoxBorderMetrics( Q::Handle, qskDpiScaled( rippleSize / 2 ) );
setBoxBorderColors( Q::Handle | Q::Checked | Q::Hovered,
QskRgb::toTransparentF( m_pal.secondary, m_pal.hover ) );
2022-02-17 21:54:56 +01:00
setBoxBorderColors( Q::Handle | Q::Checked | Q::Focused,
QskRgb::toTransparentF( m_pal.secondary, m_pal.focused ) );
2022-02-17 21:54:56 +01:00
setBoxBorderColors( Q::Handle | Q::Checked | Q::Pressed,
QskRgb::toTransparentF( m_pal.secondary, m_pal.pressed ) );
2022-02-17 21:54:56 +01:00
setBoxBorderColors( Q::Handle | Q::Hovered,
QskRgb::toTransparentF( m_pal.secondaryVariantNoSaturation,
2022-02-17 21:54:56 +01:00
m_pal.hover ) );
setBoxBorderColors( Q::Handle | Q::Focused,
QskRgb::toTransparentF( m_pal.secondaryVariantNoSaturation,
2022-02-17 21:54:56 +01:00
m_pal.focused ) );
setBoxBorderColors( Q::Handle | Q::Pressed,
QskRgb::toTransparentF( m_pal.secondaryVariantNoSaturation,
2022-02-17 21:54:56 +01:00
m_pal.pressed ) );
for ( auto state : { A::NoState, Q::Disabled } )
2021-08-02 13:22:37 +02:00
{
2021-12-29 17:05:29 +01:00
auto aspect = Q::Handle | state;
2021-08-02 13:22:37 +02:00
2021-12-29 17:05:29 +01:00
setPosition( aspect, 0 );
setPosition( aspect | Q::Checked, 1 );
2021-08-02 13:22:37 +02:00
}
setAnimation( Q::Handle | A::Color, qskDuration );
2021-08-02 19:17:04 +02:00
setAnimation( Q::Handle | A::Metric, qskDuration );
2021-08-02 13:22:37 +02:00
setAnimation( Q::Groove | A::Color, qskDuration );
}
2020-12-26 12:57:08 +01:00
void Editor::setupTabButton()
2017-07-21 18:21:34 +02:00
{
2020-12-21 16:06:58 +01:00
using A = QskAspect;
2017-07-21 18:21:34 +02:00
using Q = QskTabButton;
setStrutSize( Q::Panel, 30, 16 );
2017-07-21 18:21:34 +02:00
2020-12-21 16:06:58 +01:00
for ( const auto placement : { A::Left, A::Right, A::Top, A::Bottom } )
{
const auto aspect = Q::Panel | placement;
Qt::Edge edge;
switch( placement )
{
2020-12-21 16:06:58 +01:00
case A::Left:
edge = Qt::RightEdge;
break;
2020-12-21 16:06:58 +01:00
case A::Right:
edge = Qt::LeftEdge;
break;
2020-12-21 16:06:58 +01:00
case A::Top:
edge = Qt::BottomEdge;
break;
2020-12-21 16:06:58 +01:00
case A::Bottom:
edge = Qt::TopEdge;
break;
default:
2019-06-19 13:59:07 +02:00
edge = Qt::Edge( 0 ); // making gcc4 happy
}
2022-02-17 21:54:56 +01:00
QskBoxBorderColors borderColors( m_pal.elevated( m_pal.background ) );
auto borderColorsActive = m_pal.primary;
// 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 );
setBoxBorderColors( aspect, borderColors );
2017-07-21 18:21:34 +02:00
2022-02-17 21:54:56 +01:00
borderColors.setGradientAt( edge, borderColorsActive );
setBoxBorderColors( aspect | Q::Checked, borderColors );
}
2017-07-21 18:21:34 +02:00
2022-02-17 21:54:56 +01:00
setColor( Q::Text, m_pal.onBackground );
setColor( Q::Text | Q::Disabled,
QskRgb::toTransparentF( m_pal.onBackground,
2022-02-17 21:54:56 +01:00
m_pal.widgetBackgroundDisabled ) );
setColor( Q::Text | Q::Checked, m_pal.primary );
setColor( Q::Text | Q::Hovered, m_pal.primary );
2022-04-02 11:50:55 +02:00
setGradient( Q::Panel, m_pal.elevated( m_pal.background ) );
setGradient( Q::Panel | Q::Hovered, QskRgb::toTransparentF( m_pal.primary, m_pal.hover ) );
setGradient( Q::Panel | Q::Focused, QskRgb::toTransparentF( m_pal.primary, m_pal.focused ) );
setGradient( Q::Panel | Q::Pressed, QskRgb::toTransparentF( m_pal.primary, m_pal.pressed ) );
2022-02-17 21:54:56 +01:00
2020-12-21 16:06:58 +01:00
setAnimation( Q::Panel | A::Color, qskDuration );
2017-07-21 18:21:34 +02:00
setFontRole( Q::Text, ButtonFontRole );
setAlignment( Q::Text, Qt::AlignCenter );
2017-07-21 18:21:34 +02:00
}
2020-12-26 12:57:08 +01:00
void Editor::setupTabBar()
2017-07-21 18:21:34 +02:00
{
2020-12-21 16:06:58 +01:00
using A = QskAspect;
using Q = QskTabBar;
2017-10-18 20:00:06 +02:00
setBoxShape( Q::Panel, 0 );
setBoxBorderMetrics( Q::Panel, 0 );
2022-02-17 21:54:56 +01:00
setGradient( Q::Panel, m_pal.elevated( m_pal.background ) );
setPadding( Q::Panel, 0 );
2020-03-13 07:39:31 +01:00
// when flicking
2020-12-21 16:06:58 +01:00
setAnimation( Q::Panel | A::Metric, QskAnimationHint( 200, QEasingCurve::InCubic ) );
2017-07-21 18:21:34 +02:00
}
void Editor::setupTabView()
{
using Q = QskTabView;
setGradient( Q::Page, m_pal.background );
setAnimation( Q::Page, qskDuration );
2017-07-21 18:21:34 +02:00
}
2020-12-26 12:57:08 +01:00
void Editor::setupInputPanel()
{
2018-06-12 08:20:48 +02:00
using Q = QskInputPanelBox;
setBoxShape( Q::Panel, 0 );
setBoxBorderMetrics( Q::Panel, 0 );
2022-02-17 21:54:56 +01:00
setGradient( Q::Panel, m_pal.elevated( m_pal.background, 1 ) );
setBoxBorderColors( Q::Panel, m_pal.background );
}
2020-12-26 12:57:08 +01:00
void Editor::setupVirtualKeyboard()
2017-07-21 18:21:34 +02:00
{
2020-12-21 16:06:58 +01:00
using A = QskAspect;
2018-04-06 17:30:24 +02:00
using Q = QskVirtualKeyboard;
2017-07-21 18:21:34 +02:00
// key panel
setMargin( Q::ButtonPanel, 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 );
2022-02-17 21:54:56 +01:00
setBoxBorderColors( Q::ButtonPanel, m_pal.background );
2017-07-21 18:21:34 +02:00
2020-12-21 16:06:58 +01:00
for ( auto state : { A::NoState, Q::Focused } )
2022-02-17 21:54:56 +01:00
setBoxBorderColors( Q::ButtonPanel | QskPushButton::Pressed | state,
m_pal.secondary );
2017-07-21 18:21:34 +02:00
2020-12-21 16:06:58 +01:00
setAnimation( Q::ButtonPanel | A::Color, qskDuration );
setAnimation( Q::ButtonPanel | A::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 );
2022-02-17 21:54:56 +01:00
setGradient( Q::Panel, m_pal.elevated( m_pal.background, 1 ) );
setBoxBorderColors( Q::Panel, m_pal.background );
2017-07-21 18:21:34 +02:00
}
2020-12-26 12:57:08 +01:00
void Editor::setupScrollView()
2017-07-21 18:21:34 +02:00
{
2020-12-21 16:06:58 +01:00
using A = QskAspect;
2017-07-21 18:21:34 +02:00
using Q = QskScrollView;
2022-02-17 21:54:56 +01:00
setSpacing( Q::Panel, 5 );
2017-07-21 18:21:34 +02:00
2017-10-18 20:00:06 +02:00
setBoxBorderMetrics( Q::Viewport, 1 );
2022-02-17 21:54:56 +01:00
setGradient( Q::Viewport, m_pal.background );
setBoxBorderColors( Q::Viewport, m_pal.onBackground );
2017-07-21 18:21:34 +02:00
for ( auto subControl : { Q::HorizontalScrollBar, Q::VerticalScrollBar } )
{
2022-02-17 21:54:56 +01:00
setMetric( subControl | A::Size, 10 );
setPadding( subControl, 0 );
}
const auto handleExtent = qskDpiScaled( 40.0 );
setStrutSize( Q::HorizontalScrollHandle, handleExtent, 0.0 );
setStrutSize( Q::VerticalScrollHandle, 0.0, handleExtent );
2017-07-21 18:21:34 +02:00
for ( auto subControl : { Q::HorizontalScrollHandle, Q::VerticalScrollHandle } )
{
2017-10-18 20:00:06 +02:00
setBoxShape( subControl, 3 );
2022-02-17 21:54:56 +01:00
setBoxBorderMetrics( subControl, 0 );
2022-04-02 11:50:55 +02:00
setGradient( subControl, QskRgb::toTransparentF( m_pal.onBackground, m_pal.hover ) );
2020-12-21 16:06:58 +01:00
setAnimation( subControl | A::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 } )
{
2022-04-02 11:50:55 +02:00
setGradient( subControl,
QskRgb::toTransparentF( m_pal.onBackground, m_pal.pressed ) );
2017-07-21 18:21:34 +02:00
}
2018-01-16 12:13:38 +01:00
// when changing the position by QskScrollView::scrollTo
2020-12-21 16:06:58 +01:00
setAnimation( Q::Viewport | A::Metric, QskAnimationHint( 200, QEasingCurve::InCubic ) );
2017-07-21 18:21:34 +02:00
}
2020-12-26 12:57:08 +01:00
void Editor::setupListView()
2017-07-21 18:21:34 +02:00
{
using Q = QskListView;
2022-02-17 21:54:56 +01:00
setPadding( Q::Cell, 0 );
2017-07-21 18:21:34 +02:00
2022-04-02 11:50:55 +02:00
setGradient( Q::Cell, m_pal.background );
2022-02-17 21:54:56 +01:00
setColor( Q::Text, m_pal.onBackground );
2017-07-21 18:21:34 +02:00
2022-04-02 11:50:55 +02:00
setGradient( Q::Cell | Q::Selected, QskRgb::toTransparentF( m_pal.onBackground, m_pal.focused ) );
2022-02-17 21:54:56 +01:00
setColor( Q::Text | Q::Selected, m_pal.onBackground );
2017-07-21 18:21:34 +02:00
}
2020-12-26 12:57:08 +01:00
void Editor::setupSubWindow()
2017-07-21 18:21:34 +02:00
{
2020-12-21 16:06:58 +01:00
using A = QskAspect;
2017-07-21 18:21:34 +02:00
using Q = QskSubWindow;
2018-10-29 20:11:48 +01:00
// Panel
2017-07-21 18:21:34 +02:00
setPadding( Q::Panel, 10 );
2017-10-18 20:00:06 +02:00
setBoxShape( Q::Panel, 0 );
setBoxBorderMetrics( Q::Panel, 2 );
2022-02-17 21:54:56 +01:00
setGradient( Q::Panel, m_pal.onBackground );
2017-07-21 18:21:34 +02:00
2022-02-17 21:54:56 +01:00
setBoxBorderColors( Q::Panel, m_pal.primary );
2017-07-21 18:21:34 +02:00
2021-04-28 09:32:49 +02:00
// TitleBarPanel
setFlagHint( Q::TitleBarPanel | QskAspect::Style,
Q::TitleBar | Q::Title | Q::Symbol );
2022-02-17 21:54:56 +01:00
setGradient( Q::TitleBarPanel, m_pal.primary );
setGradient( Q::TitleBarPanel | Q::Focused, m_pal.primaryVariant );
2017-07-21 18:21:34 +02:00
2018-10-29 20:11:48 +01:00
// TitleBarText
setFontRole( Q::TitleBarText, QskSkin::SmallFont );
setAlignment( Q::TitleBarText, Qt::AlignLeft | Qt::AlignVCenter );
2018-10-29 20:11:48 +01:00
2021-04-28 09:32:49 +02:00
for ( auto subControl : { Q::Panel, Q::TitleBarPanel, Q::TitleBarText } )
2020-12-21 16:06:58 +01:00
setAnimation( subControl | A::Color, qskDuration );
2018-10-29 20:11:48 +01:00
2017-07-21 18:21:34 +02:00
}
QskMaterialSkin::QskMaterialSkin( const QskMaterialPalette& palette, QObject* parent )
2020-12-26 12:57:08 +01:00
: Inherited( parent )
{
// Default theme colors
2022-03-25 10:32:14 +01:00
setupFonts( QStringLiteral( "Roboto" ) );
2020-12-26 12:57:08 +01:00
auto buttonFont = font( QskSkin::DefaultFont );
buttonFont.setCapitalization( QFont::AllUppercase );
setFont( ButtonFontRole, buttonFont );
Editor editor( &hintTable(), palette );
2020-12-26 12:57:08 +01:00
editor.setup();
}
QskMaterialSkin::~QskMaterialSkin()
{
}
2017-07-21 18:21:34 +02:00
#include "moc_QskMaterialSkin.cpp"