qskinny/skins/squiek/QskSquiekSkin.cpp

1280 lines
34 KiB
C++
Raw Normal View History

2017-07-21 18:21:34 +02:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
2023-04-06 09:23:37 +02:00
* SPDX-License-Identifier: BSD-3-Clause
2017-07-21 18:21:34 +02:00
*****************************************************************************/
#include "QskSquiekSkin.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>
2023-03-05 13:30:40 +01:00
#include <QskComboBox.h>
#include <QskDialogButtonBox.h>
2023-05-01 20:21:07 +02:00
#include <QskDrawer.h>
2018-08-03 08:15:28 +02:00
#include <QskFocusIndicator.h>
#include <QskInputPanelBox.h>
#include <QskInputPredictionBar.h>
#include <QskListView.h>
2021-12-23 18:36:32 +01:00
#include <QskMenu.h>
2017-07-21 18:21:34 +02:00
#include <QskPageIndicator.h>
2021-12-23 18:19:52 +01:00
#include <QskPopup.h>
2020-08-01 17:51:45 +02:00
#include <QskProgressBar.h>
#include <QskProgressRing.h>
2017-07-21 18:21:34 +02:00
#include <QskPushButton.h>
2023-02-15 00:20:19 +01:00
#include <QskRadioBox.h>
2018-08-03 08:15:28 +02:00
#include <QskScrollView.h>
#include <QskSeparator.h>
#include <QskSegmentedBar.h>
2017-07-21 18:21:34 +02:00
#include <QskSlider.h>
2018-08-03 08:15:28 +02:00
#include <QskSubWindow.h>
2023-02-27 14:46:31 +01:00
#include <QskSpinBox.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>
2018-08-03 08:15:28 +02:00
#include <QskTextInput.h>
#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 <QskPlatform.h>
2018-08-03 08:15:28 +02:00
#include <QskMargins.h>
#include <QskNamespace.h>
#include <QskRgbValue.h>
#include <QskColorFilter.h>
#include <QskGraphic.h>
#include <QskStandardSymbol.h>
2017-07-21 18:21:34 +02:00
static const int qskDuration = 200;
namespace
{
2023-04-04 09:05:16 +02:00
Q_DECL_UNUSED inline double operator ""_dp( long double value )
{
return qskDpToPixels( static_cast< qreal >( value ) );
}
2023-04-04 09:05:16 +02:00
Q_DECL_UNUSED inline double operator ""_dp( unsigned long long value )
{
return qskDpToPixels( value );
}
2017-07-21 18:21:34 +02:00
class ColorPalette
{
2018-08-03 08:15:28 +02:00
public:
2020-08-15 13:29:17 +02:00
ColorPalette( const QColor& themeColor = QskRgb::Silver )
2017-07-21 18:21:34 +02:00
{
const bool isBright = themeColor.value() > 128;
theme = themeColor;
lighter110 = themeColor.lighter( 110 );
2017-07-21 18:21:34 +02:00
lighter125 = themeColor.lighter( 125 );
lighter135 = themeColor.lighter( 135 );
lighter150 = themeColor.lighter( 150 );
2017-07-21 18:21:34 +02:00
darker125 = themeColor.darker( 125 );
2017-07-21 18:21:34 +02:00
darker150 = themeColor.darker( 150 );
darker200 = themeColor.darker( 200 );
2020-08-15 13:29:17 +02:00
using namespace QskRgb;
2017-07-21 18:21:34 +02:00
if ( isBright )
{
2020-08-15 13:29:17 +02:00
themeForeground = Black;
2017-07-21 18:21:34 +02:00
2020-08-15 13:29:17 +02:00
contrasted = Gainsboro;
contrastedText = Black;
2017-07-21 18:21:34 +02:00
2020-08-15 13:29:17 +02:00
highlighted = RoyalBlue;
highlightedText = White;
2018-04-13 16:32:48 +02:00
2020-08-15 13:29:17 +02:00
base = White;
baseActive = Beige;
2017-07-21 18:21:34 +02:00
}
else
{
2020-08-15 13:29:17 +02:00
themeForeground = White;
2017-07-21 18:21:34 +02:00
2020-08-15 13:29:17 +02:00
contrasted = DarkGrey;
contrastedText = White;
2017-07-21 18:21:34 +02:00
2022-06-25 16:14:08 +02:00
highlighted = SlateGrey;
2020-08-15 13:29:17 +02:00
highlightedText = White;
2018-04-13 16:32:48 +02:00
2020-08-15 13:29:17 +02:00
base = Black;
2018-04-13 16:32:48 +02:00
baseActive = base.lighter( 110 );
2017-07-21 18:21:34 +02:00
}
}
QColor theme;
QColor themeForeground;
QColor lighter150;
QColor lighter135;
QColor lighter125;
QColor lighter110;
QColor darker125;
2017-07-21 18:21:34 +02:00
QColor darker150;
QColor darker200;
2018-04-13 16:32:48 +02:00
QColor base;
QColor baseActive;
2017-07-21 18:21:34 +02:00
QColor contrasted;
QColor contrastedText;
QColor highlighted;
QColor highlightedText;
};
2020-12-26 12:57:08 +01:00
class Editor : private QskSkinHintTableEditor
{
public:
Editor( QskSkinHintTable* table, const ColorPalette& palette )
: 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();
void setupBox();
void setupCheckBox();
2023-03-05 13:30:40 +01:00
void setupComboBox();
2020-12-26 12:57:08 +01:00
void setupDialogButtonBox();
2023-05-01 20:21:07 +02:00
void setupDrawer();
2020-12-26 12:57:08 +01:00
void setupFocusIndicator();
void setupInputPanel();
void setupInputPredictionBar();
void setupVirtualKeyboard();
void setupListView();
2021-12-23 18:36:32 +01:00
void setupMenu();
2020-12-26 12:57:08 +01:00
void setupPageIndicator();
void setupPopup();
void setupProgressBar();
void setupProgressRing();
2020-12-26 12:57:08 +01:00
void setupPushButton();
2023-02-25 23:31:29 +01:00
void setupRadioBox();
2020-12-26 12:57:08 +01:00
void setupScrollView();
void setupSegmentedBar();
2020-12-26 12:57:08 +01:00
void setupSeparator();
void setupSlider();
void setupSubWindow();
2023-02-27 14:46:31 +01:00
void setupSpinBox();
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 setupTextLabel();
void setupTextInput();
enum PanelStyle
{
NoPanel,
Raised,
Sunken,
Plain,
Flat
};
void setSeparator( QskAspect );
void setButton( QskAspect, PanelStyle, qreal border = 2.0 );
void setPanel( QskAspect, PanelStyle );
const ColorPalette& m_pal;
};
enum ColorRole
{
DisabledSymbol = 1,
CursorSymbol
};
2017-07-21 18:21:34 +02:00
}
2020-12-26 12:57:08 +01:00
void Editor::setSeparator( QskAspect aspect )
{
setGradient( aspect, m_pal.lighter110, m_pal.darker125 );
2017-10-18 20:00:06 +02:00
setBoxShape( aspect, 0 );
setBoxBorderMetrics( aspect, 0 );
}
2020-12-26 12:57:08 +01:00
void Editor::setButton( QskAspect aspect, PanelStyle style, qreal border )
{
#if 1
// Buttons shift ???
#endif
QskBoxBorderColors borderColors;
QskGradient gradient;
gradient.setLinearDirection( Qt::Vertical );
2018-08-03 08:15:28 +02:00
switch ( style )
{
case Raised:
{
borderColors.setGradientAt( Qt::TopEdge | Qt::LeftEdge, m_pal.lighter135 );
borderColors.setGradientAt( Qt::RightEdge | Qt::BottomEdge, m_pal.darker200 );
gradient.setStops( m_pal.lighter125, m_pal.lighter110 );
break;
}
case Sunken:
{
borderColors.setGradientAt( Qt::TopEdge | Qt::LeftEdge, m_pal.darker200 );
borderColors.setGradientAt( Qt::RightEdge | Qt::BottomEdge, m_pal.lighter135 );
gradient.setStops( m_pal.lighter110, m_pal.lighter125 );
break;
}
case Plain:
{
borderColors.setGradients( m_pal.darker125 );
gradient.setStops( m_pal.lighter125 );
break;
}
case Flat:
case NoPanel:
{
2020-12-26 12:57:08 +01:00
QColor noColor( m_pal.theme );
noColor.setAlpha( 0 );
borderColors.setGradients( noColor );
gradient.setStops( noColor );
if ( style == NoPanel )
border = 0;
break;
}
}
setBoxBorderColors( aspect, borderColors );
setGradient( aspect, gradient );
2017-10-18 20:00:06 +02:00
setBoxShape( aspect, 4 );
setBoxBorderMetrics( aspect, border );
}
2020-12-26 12:57:08 +01:00
void Editor::setPanel( QskAspect aspect, PanelStyle style )
{
setButton( aspect, style, 1 );
}
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();
2023-03-05 13:30:40 +01:00
setupComboBox();
2020-12-26 12:57:08 +01:00
setupDialogButtonBox();
2023-05-01 20:21:07 +02:00
setupDrawer();
2020-12-26 12:57:08 +01:00
setupFocusIndicator();
setupInputPanel();
setupInputPredictionBar();
setupVirtualKeyboard();
setupListView();
2021-12-23 18:36:32 +01:00
setupMenu();
2020-12-26 12:57:08 +01:00
setupPageIndicator();
setupPopup();
setupProgressBar();
setupProgressRing();
2020-12-26 12:57:08 +01:00
setupPushButton();
2023-02-15 00:20:19 +01:00
setupRadioBox();
2020-12-26 12:57:08 +01:00
setupScrollView();
setupSegmentedBar();
2020-12-26 12:57:08 +01:00
setupSeparator();
setupSlider();
setupSubWindow();
2023-02-27 14:46:31 +01:00
setupSpinBox();
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;
setPadding( A::NoSubcontrol, 4 );
2017-07-21 18:21:34 +02:00
setGradient( A::NoSubcontrol, m_pal.lighter135 );
setColor( A::NoSubcontrol | A::StyleColor, m_pal.themeForeground );
setColor( A::NoSubcontrol | A::StyleColor | Q::Disabled, m_pal.theme );
2017-07-21 18:21:34 +02:00
}
2020-12-26 12:57:08 +01:00
void Editor::setupBox()
2019-12-15 13:57:19 +01:00
{
setPanel( QskBox::Panel, Plain );
}
void Editor::setupCheckBox()
{
2022-04-05 08:48:16 +02:00
using A = QskAspect;
using Q = QskCheckBox;
const qreal size = 26_dp;
setSpacing( Q::Panel, 5_dp );
2022-04-05 08:48:16 +02:00
setStrutSize( Q::Box, size, size );
2022-04-05 08:48:16 +02:00
setPadding( Q::Box, 5_dp );
setBoxShape( Q::Box, 3_dp );
setBoxBorderMetrics( Q::Box, 1_dp );
setBoxBorderColors( Q::Box, m_pal.darker125 );
setGradient( Q::Box, m_pal.lighter135 );
setGradient( Q::Box | Q::Checked, m_pal.highlighted );
setGradient( Q::Box | Q::Disabled, m_pal.lighter110 );
setBoxBorderColors( Q::Box, m_pal.theme );
2022-04-05 08:48:16 +02:00
for ( auto state : { A::NoState, Q::Disabled } )
{
2023-03-02 15:13:37 +01:00
const auto symbol = QskStandardSymbol::graphic( QskStandardSymbol::CheckMark );
const auto aspect = Q::Indicator | Q::Checked | state;
2023-03-02 15:13:37 +01:00
setSymbol( aspect, symbol );
setSymbol( aspect | Q::Error, symbol );
}
2022-08-25 09:39:33 +02:00
setTextOptions( Q::Text, Qt::ElideMiddle, QskTextOptions::NoWrap );
setHint( Q::Text | Q::Disabled | A::Style, Qsk::Sunken );
setColor( Q::Text, m_pal.themeForeground );
setColor( Q::Text | Q::Disabled, m_pal.darker200 );
setAnimation( Q::Box | A::Color, qskDuration );
}
2023-03-05 13:30:40 +01:00
void Editor::setupComboBox()
{
using Q = QskComboBox;
2023-03-06 16:40:06 +01:00
setAlignment( Q::Text, Qt::AlignLeft | Qt::AlignVCenter );
2023-03-05 13:30:40 +01:00
setColor( Q::Text, m_pal.themeForeground );
setColor( Q::Text | Q::Disabled, m_pal.darker200 );
2023-03-06 16:40:06 +01:00
setStrutSize( Q::Panel, -1.0, 56_dp );
2023-03-05 13:30:40 +01:00
setPadding( Q::Panel, 5 );
setBoxBorderMetrics( Q::Panel, 2 );
setBoxShape( Q::Panel, 4 );
2023-03-06 16:40:06 +01:00
setSpacing( Q::Panel, 8_dp );
2023-03-05 13:30:40 +01:00
const QColor c = m_pal.theme.lighter( 120 );
const QskBoxBorderColors borderColors(
c.darker( 170 ), c.darker( 170 ),
c.darker( 105 ), c.darker( 105 ) );
setBoxBorderColors( Q::Panel, borderColors );
setGradient( Q::Panel, c );
setStrutSize( Q::Icon, 24_dp, 24_dp );
setGraphicRole( Q::Icon | Q::Disabled, DisabledSymbol );
2023-03-05 13:30:40 +01:00
setStrutSize( Q::StatusIndicator, 15_dp, 15_dp );
setGraphicRole( Q::StatusIndicator | Q::Disabled, DisabledSymbol );
2023-03-05 13:30:40 +01:00
setAlignment( Q::StatusIndicator, Qt::AlignRight | Qt::AlignVCenter );
2023-03-05 13:30:40 +01:00
setSymbol( Q::StatusIndicator,
2023-03-05 13:30:40 +01:00
QskStandardSymbol::graphic( QskStandardSymbol::TriangleDown ) );
setSymbol( Q::StatusIndicator | Q::PopupOpen,
2023-03-05 13:30:40 +01:00
QskStandardSymbol::graphic( QskStandardSymbol::TriangleUp ) );
}
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;
setHint( Q::Overlay | A::Style, true );
setGradient( Q::Overlay, qRgba( 220, 220, 220, 150 ) );
2017-07-21 18:21:34 +02:00
}
2021-12-23 18:36:32 +01:00
void Editor::setupMenu()
{
2021-12-29 16:23:19 +01:00
using A = QskAspect;
2021-12-23 18:36:32 +01:00
using Q = QskMenu;
setHint( Q::Overlay | A::Style, true );
setGradient( Q::Overlay, QColor( 220, 220, 220, 100 ) );
setBoxShape( Q::Panel, 4_dp );
setBoxBorderMetrics( Q::Panel, 1_dp );
2022-04-05 11:38:23 +02:00
setBoxBorderColors( Q::Panel, m_pal.darker125 );
2021-12-23 18:36:32 +01:00
2022-04-05 11:38:23 +02:00
setGradient( Q::Panel, m_pal.lighter110 );
2021-12-23 18:36:32 +01:00
2021-12-26 12:17:31 +01:00
const bool isCascading = qskMaybeDesktopPlatform();
setHint( Q::Panel | A::Style, isCascading );
2021-12-26 12:17:31 +01:00
setMetric( Q::Separator | A::Size, 2_dp );
setSeparator( Q::Separator );
setMargin( Q::Separator, 2 );
2021-12-23 18:36:32 +01:00
setPadding( Q::Segment, QskMargins( 2, 10, 2, 10 ) );
setSpacing( Q::Segment, 5 );
setGradient( Q::Segment, Qt::transparent );
2021-12-24 16:20:34 +01:00
2022-04-05 11:38:23 +02:00
setGradient( Q::Cursor, m_pal.highlighted );
2021-12-23 18:36:32 +01:00
2022-04-05 11:38:23 +02:00
setColor( Q::Text, m_pal.contrastedText );
setColor( Q::Text | Q::Selected, m_pal.highlightedText );
2021-12-23 18:36:32 +01:00
setStrutSize( Q::Icon, 16, 16 );
setGraphicRole( Q::Icon | Q::Disabled, DisabledSymbol );
setGraphicRole( Q::Icon | Q::Selected, CursorSymbol );
2021-12-29 17:19:19 +01:00
setAnimation( Q::Cursor | A::Position | A::Metric, 75, QEasingCurve::OutCubic );
setAnimation( Q::Panel | A::Position, 100 );
2021-12-23 18:36:32 +01:00
}
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 );
2020-12-26 12:57:08 +01:00
setColor( Q::Text, m_pal.themeForeground );
2019-12-15 13:57:19 +01:00
setPadding( Q::Panel, 5 );
2019-12-15 13:57:19 +01:00
setBoxBorderMetrics( Q::Panel, 2 );
setBoxShape( Q::Panel, 4 );
2020-12-26 12:57:08 +01:00
const QColor c = m_pal.base;
2019-12-15 13:57:19 +01:00
const QskBoxBorderColors borderColors(
c.darker( 170 ), c.darker( 170 ),
c.darker( 105 ), c.darker( 105 ) );
setBoxBorderColors( Q::Panel, borderColors );
setGradient( Q::Panel, c );
2017-07-21 18:21:34 +02:00
}
2020-12-26 12:57:08 +01:00
void Editor::setupTextInput()
{
2020-12-21 16:06:58 +01:00
using A = QskAspect;
using Q = QskTextInput;
setAlignment( Q::Text, Qt::AlignLeft | Qt::AlignTop );
2020-12-26 12:57:08 +01:00
setColor( Q::Text, m_pal.themeForeground );
setColor( Q::PanelSelected, m_pal.highlighted );
setColor( Q::TextSelected, m_pal.highlightedText );
setPadding( Q::Panel, 5 );
setBoxBorderMetrics( Q::Panel, 2 );
setBoxShape( Q::Panel, 4 );
2020-12-21 16:06:58 +01:00
for ( auto state : { A::NoState, Q::ReadOnly, Q::Editing } )
2018-04-13 16:32:48 +02:00
{
QColor c;
if ( state == Q::ReadOnly )
{
2020-12-26 12:57:08 +01:00
c = m_pal.theme.lighter( 120 );
2018-04-13 16:32:48 +02:00
}
else if ( state == Q::Editing )
{
2020-12-26 12:57:08 +01:00
c = m_pal.baseActive;
2018-04-13 16:32:48 +02:00
}
else
{
2020-12-26 12:57:08 +01:00
c = m_pal.base;
2018-04-13 16:32:48 +02:00
}
const auto aspect = Q::Panel | state;
const QskBoxBorderColors borderColors(
c.darker( 170 ), c.darker( 170 ),
c.darker( 105 ), c.darker( 105 ) );
2018-04-13 16:32:48 +02:00
setBoxBorderColors( aspect, borderColors );
setGradient( aspect, c );
}
2020-12-21 16:06:58 +01:00
setAnimation( Q::Panel | A::Color, qskDuration );
}
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
for ( auto subControl : { Q::Groove, Q::Fill } )
2023-06-20 16:43:30 +02:00
{
setMetric( subControl | A::Size, 6 );
setPadding( subControl, 0 );
setBoxShape( subControl, 4 );
}
2020-07-31 16:57:22 +02:00
setGradient( Q::Groove, m_pal.lighter110 );
setGradient( Q::Fill, m_pal.highlighted );
}
void Editor::setupProgressRing()
{
using A = QskAspect;
using Q = QskProgressRing;
for ( auto subControl : { Q::Groove, Q::Fill } )
{
setMetric( subControl | A::Size, 6 );
setPadding( subControl, 0 );
setBoxShape( subControl, 4 );
}
setArcMetrics( Q::Groove, 90, -360, 6 );
setGradient( Q::Groove, m_pal.lighter110 );
setStrutSize( Q::Fill, { 60, 60 } );
setGradient( Q::Fill, m_pal.highlighted );
setArcMetrics( Q::Fill, 90, -360, 6 );
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;
using A = QskAspect;
2017-07-21 18:21:34 +02:00
setPadding( Q::Panel, 5 );
2017-10-18 20:00:06 +02:00
setBoxBorderMetrics( Q::Panel, 2 );
setBoxShape( Q::Panel, 4 );
setGradient( Q::Panel, Qt::transparent );
2020-12-26 12:57:08 +01:00
setBoxBorderColors( Q::Panel, m_pal.highlighted );
setBoxBorderColors( Q::Panel | Q::Disabled,
QskRgb::toTransparent( m_pal.highlighted, 0 ) );
setAnimation( Q::Panel | A::Color, 200 );
setAnimation( Q::Panel | A::Color | Q::Disabled, 500 );
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
setMetric( Q::Panel | A::Size, 4 );
setSeparator( Q::Panel );
2017-07-21 18:21:34 +02:00
}
void Editor::setupSegmentedBar()
{
using A = QskAspect;
using Q = QskSegmentedBar;
const uint duration = 100;
{
// Panel
setPadding( Q::Panel, 0 );
setSpacing( Q::Panel, 5 );
setGradient( Q::Panel, m_pal.base );
setBoxBorderMetrics( Q::Panel, 2 );
const auto c = m_pal.base;
const QskBoxBorderColors borderColors(
c.darker( 170 ), c.darker( 170 ),
c.darker( 105 ), c.darker( 105 ) );
setBoxBorderColors( Q::Panel, borderColors );
2023-04-04 09:05:16 +02:00
const QSizeF strutSize( 100_dp, 50_dp );
setStrutSize( Q::Panel | A::Horizontal, strutSize );
setStrutSize( Q::Panel | A::Vertical, strutSize.transposed() );
}
{
// Segment
setPadding( Q::Segment, QskMargins( 2, 5, 2, 5 ) );
setGradient( Q::Segment, QskGradient() );
}
{
// Cursor
setGradient( Q::Cursor, m_pal.highlighted );
setBoxBorderColors( Q::Cursor, QColor( m_pal.highlighted ).darker( 120 ) );
setGradient( Q::Cursor | Q::Disabled, QColor( Qt::gray ).darker( 110 ) );
setBoxBorderColors( Q::Cursor | Q::Disabled, Qt::gray );
setAnimation( Q::Cursor | A::Metric | A::Position, duration );
}
for( auto subControl : { Q::Panel, Q::Cursor } )
setBoxShape( subControl, 3 );
{
// Text
2022-08-25 09:39:33 +02:00
setTextOptions( Q::Text, Qt::ElideMiddle, QskTextOptions::NoWrap );
setColor( Q::Text, m_pal.themeForeground );
setColor( Q::Text | Q::Selected, m_pal.highlightedText );
for( auto state : { A::NoState, Q::Selected } )
setColor( Q::Text | state | Q::Disabled, m_pal.darker200 );
setAnimation( Q::Text | A::Color, duration );
}
{
// Icon
setGraphicRole( Q::Icon | Q::Disabled, DisabledSymbol );
setGraphicRole( Q::Icon | Q::Selected, CursorSymbol );
setStrutSize( Q::Icon, -1, 30_dp );
}
}
2020-12-26 12:57:08 +01:00
void Editor::setupPageIndicator()
2017-07-21 18:21:34 +02:00
{
using Q = QskPageIndicator;
const auto extent = 8_dp;
2022-01-04 13:58:34 +01:00
setStrutSize( Q::Bullet, extent, extent );
2017-07-21 18:21:34 +02:00
2022-01-04 13:58:34 +01:00
// circles, without border
setBoxShape( Q::Bullet, 100, Qt::RelativeSize );
setBoxBorderMetrics( Q::Bullet, 0 );
2020-12-26 12:57:08 +01:00
setGradient( Q::Bullet, m_pal.darker150 );
setMargin( Q::Bullet, 1_dp );
2020-12-17 16:14:56 +01:00
2022-01-04 13:58:34 +01:00
setGradient( Q::Bullet | Q::Selected, m_pal.lighter150 );
setMargin( Q::Bullet | Q::Selected, 0 );
2017-07-21 18:21:34 +02:00
2022-01-04 13:58:34 +01:00
setSpacing( Q::Panel, 3 );
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;
2017-07-21 18:21:34 +02:00
using Q = QskPushButton;
// Panel
setHint( Q::Panel | QskAspect::Direction, Qsk::TopToBottom );
setStrutSize( Q::Panel, 75_dp, 23_dp );
2017-07-21 18:21:34 +02:00
setMargin( Q::Panel, 0 );
setPadding( Q::Panel, 10 );
2020-12-21 16:06:58 +01:00
setMetric( Q::Panel | A::Spacing, 4 );
2017-07-21 18:21:34 +02:00
setButton( Q::Panel, Raised );
setButton( Q::Panel | A::Header | Q::Hovered, Raised );
2017-07-21 18:21:34 +02:00
setButton( Q::Panel | A::Header, Flat );
setButton( Q::Panel | A::Header | Q::Disabled, Flat );
for ( auto state : { Q::Pressed, Q::Checked } )
{
setButton( Q::Panel | state, Sunken );
setButton( Q::Panel | A::Header | state, Sunken );
}
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 );
// Text
2022-08-25 09:39:33 +02:00
setTextOptions( Q::Text, Qt::ElideMiddle, QskTextOptions::NoWrap );
setHint( Q::Text | Q::Disabled | A::Style, Qsk::Sunken );
2022-08-26 12:56:12 +02:00
setAlignment( Q::Text, Qt::AlignCenter );
2017-07-21 18:21:34 +02:00
2020-12-26 12:57:08 +01:00
setColor( Q::Text, m_pal.themeForeground );
setColor( Q::Text | Q::Disabled, m_pal.darker200 );
// Icon
setAlignment( Q::Icon, Qt::AlignCenter );
2017-07-21 18:21:34 +02:00
}
2023-02-15 00:20:19 +01:00
void Editor::setupRadioBox()
{
using Q = QskRadioBox;
setSpacing( Q::Panel, 10_dp );
setSpacing( Q::Button, 10_dp );
setStrutSize( Q::CheckIndicatorPanel, 20_dp, 20_dp );
for ( auto subControl : { Q::CheckIndicatorPanel, Q::CheckIndicator, Q::Ripple } )
setBoxShape( subControl, 100, Qt::RelativeSize ); // circular
setBoxBorderMetrics( Q::CheckIndicatorPanel, 1_dp );
setBoxBorderColors( Q::CheckIndicatorPanel, m_pal.darker125 );
setBoxBorderColors( Q::CheckIndicatorPanel | Q::Disabled, m_pal.theme );
2023-02-15 00:20:19 +01:00
setPadding( Q::CheckIndicatorPanel, 5_dp );
2023-02-15 00:20:19 +01:00
setGradient( Q::Button, QskGradient() );
2023-02-15 00:20:19 +01:00
setColor( Q::Text, m_pal.themeForeground );
setColor( Q::Text | Q::Disabled, m_pal.darker200 );
2023-02-15 00:20:19 +01:00
setColor( Q::Panel, m_pal.lighter125 );
setColor( Q::Panel | Q::Disabled, m_pal.lighter125 );
setColor( Q::CheckIndicatorPanel | Q::Disabled, m_pal.lighter110 );
setColor( Q::CheckIndicator, Qt::transparent);
setColor( Q::CheckIndicator | Q::Selected, m_pal.themeForeground );
setColor( Q::CheckIndicator | Q::Selected | Q::Disabled, m_pal.darker200 );
2023-02-15 00:20:19 +01:00
}
2020-12-26 12:57:08 +01:00
void Editor::setupDialogButtonBox()
2017-07-21 18:21:34 +02:00
{
using Q = QskDialogButtonBox;
2020-12-26 12:57:08 +01:00
setBoxBorderColors( Q::Panel, m_pal.theme );
setGradient( Q::Panel, m_pal.lighter135 );
2017-10-18 20:00:06 +02:00
setBoxBorderMetrics( Q::Panel, 0 );
setBoxShape( Q::Panel, 2 );
2023-05-01 20:21:07 +02:00
}
void Editor::setupDrawer()
{
2023-05-01 20:21:07 +02:00
using Q = QskDrawer;
using A = QskAspect;
2023-05-01 20:21:07 +02:00
setPanel( Q::Panel, Plain );
setAnimation( Q::Panel | A::Position, 300, QEasingCurve::OutCubic );
2017-07-21 18:21:34 +02:00
}
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
for ( auto variation : { A::Top, A::Bottom } )
2020-08-11 17:52:28 +02:00
{
setVGradient( Q::Panel | variation, m_pal.lighter125, m_pal.lighter110 );
2020-08-10 14:30:29 +02:00
for ( const auto state : { Q::Checked | A::NoState, Q::Checked | Q::Pressed } )
2020-08-11 17:52:28 +02:00
{
setGradient( Q::Panel | variation | state, m_pal.lighter125 );
setColor( Q::Text | variation | state, m_pal.themeForeground );
2020-08-11 17:52:28 +02:00
}
}
for ( auto variation : { A::Left, A::Right } )
2020-08-10 14:30:29 +02:00
{
setGradient( Q::Panel | variation, m_pal.lighter125 );
2020-08-11 17:52:28 +02:00
for ( const auto state : { Q::Checked | A::NoState, Q::Checked | Q::Pressed } )
2020-08-11 17:52:28 +02:00
{
setGradient( Q::Panel | variation | state, m_pal.highlighted );
setColor( Q::Text | variation | state, m_pal.highlightedText );
2020-08-11 17:52:28 +02:00
}
2020-08-10 14:30:29 +02:00
}
2020-12-26 12:57:08 +01:00
setBoxBorderColors( Q::Panel, m_pal.darker200 );
2020-08-10 14:30:29 +02:00
for ( auto variation : { A::Left, A::Right, A::Top, A::Bottom } )
{
const auto aspect = Q::Panel | variation;
2017-07-21 18:21:34 +02:00
2023-07-03 16:56:19 +02:00
QskMargins margins0, margins1;
2020-08-10 14:30:29 +02:00
QskBoxBorderMetrics border( 1 );
QskBoxShapeMetrics shape( 4 );
const int indent = 4;
if ( variation == A::Top )
{
2020-08-10 14:30:29 +02:00
margins0 = QskMargins( -1, indent, -1, -1 );
margins1 = QskMargins( -1, 0, -1, -2 );
border.setWidthAt( Qt::BottomEdge, 0 );
shape.setRadius( Qt::BottomLeftCorner, 0 );
shape.setRadius( Qt::BottomRightCorner, 0 );
}
else if ( variation == A::Bottom )
{
2020-08-10 14:30:29 +02:00
margins0 = QskMargins( -1, -1, -1, indent );
margins1 = QskMargins( -1, -2, -1, 0 );
border.setWidthAt( Qt::TopEdge, 0 );
shape.setRadius( Qt::TopLeftCorner, 0 );
shape.setRadius( Qt::TopRightCorner, 0 );
}
else if ( variation == A::Left )
{
2020-08-10 14:30:29 +02:00
margins0 = QskMargins( indent, -1, -1, -1 );
margins1 = QskMargins( 0, -1, -2, 0 );
border.setWidthAt( Qt::RightEdge, 0 );
shape.setRadius( Qt::TopRightCorner, 0 );
shape.setRadius( Qt::BottomRightCorner, 0 );
}
else if ( variation == A::Right )
{
2020-08-10 14:30:29 +02:00
margins0 = QskMargins( -1, -1, indent, -1 );
margins1 = QskMargins( -2, -1, 0, 0 );
border.setWidthAt( Qt::LeftEdge, 0 );
shape.setRadius( Qt::TopLeftCorner, 0 );
shape.setRadius( Qt::BottomLeftCorner, 0 );
}
2017-07-21 18:21:34 +02:00
setMargin( aspect, margins0 );
2017-07-21 18:21:34 +02:00
for ( const auto state : { Q::Checked | A::NoState, Q::Checked | Q::Pressed } )
setMargin( aspect | state, margins1 );
2023-07-03 16:56:19 +02:00
setPadding( aspect, { 6, 12, 6, 12 } );
2020-08-10 14:30:29 +02:00
setBoxBorderMetrics( aspect, border );
setBoxShape( aspect, shape );
2017-07-21 18:21:34 +02:00
}
QskAnimationHint animationHint( qskDuration );
animationHint.updateFlags = QskAnimationHint::UpdateNode;
2020-12-21 16:06:58 +01:00
setAnimation( Q::Panel | A::Color, animationHint );
setAnimation( Q::Panel | A::Metric, animationHint );
// text
setAlignment( Q::Text, Qt::AlignCenter );
2020-12-26 12:57:08 +01:00
setColor( Q::Text, m_pal.themeForeground );
setColor( Q::Text | Q::Disabled, m_pal.darker200 );
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;
2017-07-21 18:21:34 +02:00
using Q = QskSlider;
2020-12-17 16:14:56 +01:00
const qreal extent = 40;
2017-07-21 18:21:34 +02:00
// Panel
2017-07-21 18:21:34 +02:00
for ( auto variation : { A::Horizontal, A::Vertical } )
2017-07-21 18:21:34 +02:00
{
const auto aspect = Q::Panel | variation;
2020-12-21 16:06:58 +01:00
setMetric( aspect | A::Size, extent );
2017-10-18 20:00:06 +02:00
setBoxBorderMetrics( aspect, 0 );
setBoxShape( aspect, 0 );
setGradient( aspect, QskGradient() );
2017-07-21 18:21:34 +02:00
}
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 ) );
2017-07-21 18:21:34 +02:00
// Groove, Fill
2017-07-21 18:21:34 +02:00
for ( auto variation : { A::Horizontal, A::Vertical } )
{
for ( auto subControl : { Q::Groove, Q::Fill } )
{
const auto aspect = subControl | variation;
2017-07-21 18:21:34 +02:00
2020-12-21 16:06:58 +01:00
setMetric( aspect | A::Size, 0.3 * extent );
setPadding( aspect, 0 );
2017-10-18 20:00:06 +02:00
setBoxBorderMetrics( aspect, 0 );
2020-12-17 16:14:56 +01:00
setBoxShape( aspect, 0.1 * extent );
}
2020-12-17 16:14:56 +01:00
setGradient( Q::Groove | variation, m_pal.darker200 );
setGradient( Q::Fill | variation, QskGradient() ); // no filling
}
// Handle
for ( auto variation : { A::Horizontal, A::Vertical } )
2017-07-21 18:21:34 +02:00
{
const auto aspect = Q::Handle | variation;
setButton( aspect, Raised, 1 );
2017-10-18 20:00:06 +02:00
setBoxShape( aspect, 20.0, Qt::RelativeSize );
setButton( aspect | Q::Pressed, Sunken, 1 );
2020-12-17 16:14:56 +01:00
const qreal sz = 0.75 * extent;
setStrutSize( aspect, sz, sz );
2017-07-21 18:21:34 +02:00
}
2020-12-21 16:06:58 +01:00
setAnimation( Q::Handle | A::Color, qskDuration );
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;
2017-07-21 18:21:34 +02:00
using Q = QskTabBar;
2020-08-11 17:52:28 +02:00
setBoxBorderMetrics( Q::Panel, 0 );
setMargin( Q::Panel, 0 );
2020-08-11 17:52:28 +02:00
const qreal vb = 1.0; // borderWidth of the view
const qreal pw = 1.0; // extra space for the negative padding of the buttons
2020-12-21 16:06:58 +01:00
setPadding( Q::Panel | A::Top, pw, 0.0, pw, vb );
setPadding( Q::Panel | A::Bottom, pw, vb, pw, 0.0 );
setPadding( Q::Panel | A::Left, 0.0, pw, vb, pw );
setPadding( Q::Panel | A::Right, vb, pw, 0.0, pw );
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::OutCubic ) );
2017-07-21 18:21:34 +02:00
}
2020-12-26 12:57:08 +01:00
void Editor::setupTabView()
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 = QskTabView;
setPadding( Q::Page, 0 );
setMargin( Q::Page, 0 );
2020-08-10 14:30:29 +02:00
setPanel( Q::Page, Plain );
const qreal radius = 8.0;
2020-12-21 16:06:58 +01:00
setBoxShape( Q::Page | A::Top, 0, 0, radius, radius );
setBoxShape( Q::Page | A::Bottom, radius, radius, 0, 0 );
setBoxShape( Q::Page | A::Left, 0, radius, 0, radius );
setBoxShape( Q::Page | A::Right, radius, 0, radius, 0 );
2017-07-21 18:21:34 +02:00
setAnimation( Q::Page, qskDuration );
}
2020-12-26 12:57:08 +01:00
void Editor::setupInputPanel()
{
2018-06-12 08:20:48 +02:00
using Q = QskInputPanelBox;
setPadding( Q::Panel, 5 );
setPanel( Q::Panel, Raised );
}
2020-12-26 12:57:08 +01:00
void Editor::setupInputPredictionBar()
2018-04-30 10:03:51 +02:00
{
using Q = QskInputPredictionBar;
setPadding( Q::Panel, 5 );
2018-04-30 10:03:51 +02:00
setPanel( Q::Panel, Flat );
setButton( Q::ButtonPanel, Flat );
setButton( Q::ButtonPanel | QskPushButton::Pressed, Sunken );
setStrutSize( Q::ButtonPanel, 30_dp, 23_dp );
2018-04-30 10:03:51 +02:00
2020-12-26 12:57:08 +01:00
setColor( Q::ButtonText, m_pal.themeForeground );
setColor( Q::ButtonText | QskPushButton::Disabled, m_pal.darker200 );
2018-04-30 10:03:51 +02:00
}
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
setPadding( Q::Panel, 5 );
2020-12-21 16:06:58 +01:00
setMetric( Q::Panel | A::Spacing, 5 );
2018-04-06 17:30:24 +02:00
setPanel( Q::Panel, Raised );
2017-07-21 18:21:34 +02:00
2018-04-06 17:30:24 +02:00
setButton( Q::ButtonPanel, Raised );
setButton( Q::ButtonPanel | QskPushButton::Pressed, Sunken );
2017-07-21 18:21:34 +02:00
2020-12-21 16:06:58 +01:00
setAnimation( Q::ButtonPanel | A::Color, qskDuration );
2017-07-21 18:21:34 +02:00
2020-12-26 12:57:08 +01:00
setColor( Q::ButtonText, m_pal.themeForeground );
setColor( Q::ButtonText | QskPushButton::Disabled, m_pal.darker200 );
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;
2020-12-21 16:06:58 +01:00
setMetric( Q::Panel | A::Spacing, 4 );
2022-12-05 12:06:49 +01:00
setGradient( Q::Panel, QskGradient() );
2017-07-21 18:21:34 +02:00
2017-10-18 20:00:06 +02:00
setBoxBorderMetrics( Q::Viewport, 2 );
setBoxShape( Q::Viewport, 8 );
QColor fillColor( Qt::white );
2017-07-21 18:21:34 +02:00
const QskBoxBorderColors borderColors(
fillColor.darker( 170 ), fillColor.darker( 170 ),
fillColor.darker( 105 ), fillColor.darker( 105 ) );
2017-07-21 18:21:34 +02:00
setBoxBorderColors( Q::Viewport, borderColors );
setGradient( Q::Viewport, fillColor );
// scroll bars
2017-07-21 18:21:34 +02:00
for ( auto subControl : { Q::HorizontalScrollBar, Q::VerticalScrollBar } )
{
2023-07-20 16:46:21 +02:00
setMetric( subControl | A::Size, 14 );
setPadding( subControl, 2 );
setMargin( subControl, 0 );
2023-07-20 16:46:21 +02:00
setPanel( subControl, Sunken );
setBoxShape( subControl, 100, Qt::RelativeSize );
setBoxBorderMetrics( subControl, 1 );
2017-07-21 18:21:34 +02:00
}
// scrollbar handles
2017-07-21 18:21:34 +02:00
for ( auto subControl : { Q::HorizontalScrollHandle, Q::VerticalScrollHandle } )
{
const qreal bw = 1.0;
2017-07-21 18:21:34 +02:00
setButton( subControl, Raised, bw );
setButton( subControl | Q::Pressed, Sunken, bw );
2023-07-20 16:46:21 +02:00
setBoxShape( subControl, 100, Qt::RelativeSize );
setBoxShape( subControl | Q::Pressed, 100, Qt::RelativeSize );
2017-07-21 18:21:34 +02:00
const auto extent = 40_dp;
if ( subControl == Q::HorizontalScrollHandle )
setStrutSize( subControl, extent, 0.0 );
else
setStrutSize( subControl, 0.0, extent );
2017-07-21 18:21:34 +02:00
2020-12-21 16:06:58 +01:00
setAnimation( subControl | A::Color, qskDuration );
}
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::OutCubic ) );
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 A = QskAspect;
2017-07-21 18:21:34 +02:00
using Q = QskListView;
// padding for each cell
setPadding( Q::Cell, QskMargins( 4, 8 ) );
2017-07-21 18:21:34 +02:00
2020-12-26 12:57:08 +01:00
setColor( Q::Text, m_pal.themeForeground );
setColor( Q::Cell, Qt::white );
2017-07-21 18:21:34 +02:00
for ( auto state : { A::NoState, Q::Hovered, Q::Pressed } )
{
setColor( Q::Cell | state | Q::Selected, m_pal.highlighted );
setColor( Q::Text | state | Q::Selected, m_pal.highlightedText );
}
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
const qreal radius = 5.0;
// Panel
setPadding( Q::Panel, 10 );
2017-10-18 20:00:06 +02:00
setBoxBorderMetrics( Q::Panel, 2 );
2018-10-29 20:11:48 +01:00
setBoxShape( Q::Panel, radius, radius, 0, 0, Qt::AbsoluteSize );
2017-07-21 18:21:34 +02:00
QskBoxBorderColors borderColors;
borderColors.setGradientAt( Qt::TopEdge | Qt::LeftEdge, m_pal.lighter125 );
borderColors.setGradientAt( Qt::RightEdge | Qt::BottomEdge, m_pal.darker200 );
2017-07-21 18:21:34 +02:00
setBoxBorderColors( Q::Panel, borderColors );
2020-12-26 12:57:08 +01:00
setGradient( Q::Panel, m_pal.lighter135 );
2017-07-21 18:21:34 +02:00
2021-04-28 09:32:49 +02:00
// TitleBarPanel
setHint( Q::TitleBarPanel | QskAspect::Style,
2021-04-28 09:32:49 +02:00
Q::TitleBar | Q::Title | Q::Symbol );
setGradient( Q::TitleBarPanel | Q::Focused, m_pal.highlighted );
setGradient( Q::TitleBarPanel, m_pal.contrasted );
setSpacing( Q::TitleBarPanel, 5 );
setStrutSize( Q::TitleBarPanel, 0, 20 );
setBoxShape( Q::TitleBarPanel, radius, radius, 0, 0, Qt::AbsoluteSize );
2018-10-29 20:11:48 +01:00
// TitleBarText
2022-08-25 09:39:33 +02:00
setTextOptions( Q::TitleBarText, Qt::ElideRight, QskTextOptions::NoWrap );
2018-10-29 20:11:48 +01:00
setFontRole( Q::TitleBarText, QskSkin::SmallFont );
2020-12-26 12:57:08 +01:00
setColor( Q::TitleBarText | Q::Focused, m_pal.highlightedText );
setColor( Q::TitleBarText, m_pal.themeForeground );
2018-10-29 20:11:48 +01:00
setAlignment( Q::TitleBarText, Qt::AlignLeft | Qt::AlignVCenter );
2018-10-29 20:11:48 +01:00
#if 1
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 );
#endif
setAnimation( Q::Panel | A::Position, qskDuration, QEasingCurve::OutCubic );
2017-07-21 18:21:34 +02:00
}
2023-02-27 14:46:31 +01:00
void Editor::setupSpinBox()
{
using A = QskAspect;
using Q = QskSpinBox;
setHint( Q::Panel | A::Style, Q::UpDownControl );
2023-02-27 14:46:31 +01:00
setSpacing( Q::Panel, 2 );
setPadding( Q::TextPanel, 5 );
setBoxBorderMetrics( Q::TextPanel, 2 );
setBoxShape( Q::TextPanel, 4 );
const auto c = m_pal.base;
const QskBoxBorderColors borderColors(
c.darker( 170 ), c.darker( 170 ),
c.darker( 105 ), c.darker( 105 ) );
setBoxBorderColors( Q::TextPanel, borderColors );
setGradient( Q::TextPanel, c );
for ( auto subControl : { Q::UpPanel, Q::DownPanel } )
{
setButton( subControl, Raised, 1.0 );
setPadding( subControl, 4 );
2023-02-27 14:46:31 +01:00
setStrutSize( subControl, 20, 10 );
setBoxShape( subControl, 0 );
2023-02-27 15:21:09 +01:00
const auto downState = ( subControl == Q::UpPanel )
? Q::Increasing : Q::Decreasing;
2023-02-27 15:21:09 +01:00
setButton( subControl | downState, Sunken, 1.0 );
setAnimation( subControl | A::Metric, 100 );
setAnimation( subControl | A::Color, 100 );
2023-02-27 14:46:31 +01:00
}
setSymbol( Q::UpIndicator,
QskStandardSymbol::graphic( QskStandardSymbol::TriangleUp ) );
setSymbol( Q::DownIndicator,
QskStandardSymbol::graphic( QskStandardSymbol::TriangleDown ) );
2023-02-27 14:46:31 +01:00
for ( auto subControl : { Q::UpIndicator, Q::DownIndicator } )
{
setGraphicRole( subControl | Q::Disabled, DisabledSymbol );
2023-02-27 14:46:31 +01:00
setAlignment( subControl, Qt::AlignCenter );
2023-02-27 15:21:09 +01:00
setAnimation( subControl | A::Color, 100 );
2023-02-27 14:46:31 +01:00
}
}
2021-08-02 13:22:37 +02:00
void Editor::setupSwitchButton()
{
using A = QskAspect;
using Q = QskSwitchButton;
const qreal radius = 15_dp;
const qreal handleSize = 2 * ( radius - 2 );
setBoxShape( Q::Groove, 100, Qt::RelativeSize );
const QSizeF grooveSize( 3.4 * radius, 2 * radius );
setStrutSize( Q::Groove | A::Horizontal, grooveSize );
setStrutSize( Q::Groove | A::Vertical, grooveSize.transposed() );
setGradient( Q::Groove, m_pal.theme );
setGradient( Q::Groove | Q::Checked, m_pal.highlighted );
setGradient( Q::Groove | Q::Disabled, m_pal.lighter150 );
2021-08-02 13:22:37 +02:00
2021-08-02 19:17:04 +02:00
setBoxBorderColors( Q::Groove | Q::Disabled, m_pal.theme );
setBoxBorderMetrics( Q::Groove, 2 );
setBoxBorderColors( Q::Groove, m_pal.darker200 );
setBoxShape( Q::Handle, 100, Qt::RelativeSize );
setStrutSize( Q::Handle, handleSize, handleSize );
2022-10-21 16:47:53 +02:00
setVGradient( Q::Handle, m_pal.lighter150, m_pal.lighter110 );
setGradient( Q::Handle | Q::Disabled, m_pal.lighter110 );
2021-08-02 19:17:04 +02:00
setBoxBorderMetrics( Q::Handle, 2 );
setBoxBorderColors( Q::Handle, m_pal.darker200 );
setBoxBorderColors( Q::Handle | Q::Disabled, m_pal.theme );
2021-08-02 13:22:37 +02:00
for( auto state : { A::NoState, Q::Disabled } )
{
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
}
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
class QskSquiekSkin::PrivateData
{
public:
ColorPalette palette;
};
QskSquiekSkin::QskSquiekSkin( QObject* parent )
: Inherited( parent )
, m_data( new PrivateData() )
{
2022-03-25 10:32:14 +01:00
setupFonts( QStringLiteral( "DejaVuSans" ) );
2020-12-26 12:57:08 +01:00
const auto& pal = m_data->palette;
2023-03-05 13:30:40 +01:00
addGraphicRole( DisabledSymbol, pal.darker200 );
addGraphicRole( CursorSymbol, pal.highlightedText );
Editor editor( &hintTable(), pal );
2020-12-26 12:57:08 +01:00
editor.setup();
}
QskSquiekSkin::~QskSquiekSkin()
{
}
void QskSquiekSkin::resetColors( const QColor& accent )
{
m_data->palette = ColorPalette( accent );
Editor editor( &hintTable(), m_data->palette );
editor.setup();
}
void QskSquiekSkin::addGraphicRole( int role, const QColor& color )
{
QskColorFilter colorFilter;
colorFilter.addColorSubstitution( QskRgb::Black, color.rgba() );
setGraphicFilter( role, colorFilter );
}
2020-12-26 12:57:08 +01:00
2017-07-21 18:21:34 +02:00
#include "moc_QskSquiekSkin.cpp"