qskinny/examples/tabview/OtherSlider.cpp

92 lines
2.4 KiB
C++
Raw Normal View History

2020-08-11 17:56:53 +02:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the 3-clause BSD License
*****************************************************************************/
#include "OtherSlider.h"
#include <QskAspect.h>
#include <QskRgbValue.h>
#include <QskBoxShapeMetrics.h>
#include <QskBoxBorderMetrics.h>
#include <QskBoxBorderColors.h>
2020-12-27 11:11:31 +01:00
#include <QskSkinHintTable.h>
#include <QskSkinHintTableEditor.h>
2020-08-11 17:56:53 +02:00
#include <cmath>
OtherSlider::OtherSlider( QQuickItem* parentItem )
: QskSlider( parentItem )
{
2020-12-21 16:06:58 +01:00
using A = QskAspect;
2020-08-15 13:29:17 +02:00
using namespace QskRgb;
2020-08-11 17:56:53 +02:00
const qreal h = 30;
const qreal w = 2.0 * h;
const qreal paddingW = 0.5 * w + 1;
2020-12-27 11:11:31 +01:00
QskSkinHintTableEditor ed( &hintTable() );
2020-08-11 17:56:53 +02:00
// Panel
for ( auto variation : { A::Horizontal, A::Vertical } )
2020-08-11 17:56:53 +02:00
{
const auto aspect = Panel | variation;
2020-08-11 17:56:53 +02:00
2020-12-27 11:11:31 +01:00
ed.setMetric( aspect | A::Size, h );
ed.setBoxShape( aspect, 4 );
ed.setBoxBorderMetrics( aspect, 1 );
2022-06-25 16:14:08 +02:00
ed.setBoxBorderColors( aspect, DimGray );
ed.setGradient( aspect, Silver );
2020-08-11 17:56:53 +02:00
if ( variation == A::Horizontal )
2020-12-27 11:11:31 +01:00
ed.setPadding( aspect, QskMargins( paddingW, 0 ) );
2020-08-11 17:56:53 +02:00
else
2020-12-27 11:11:31 +01:00
ed.setPadding( aspect, QskMargins( 0, paddingW ) );
2020-08-11 17:56:53 +02:00
}
// Groove
for ( auto variation : { A::Horizontal, A::Vertical } )
2020-08-11 17:56:53 +02:00
{
const auto aspect = Groove | variation;
2020-08-11 17:56:53 +02:00
2020-12-27 11:11:31 +01:00
ed.setMetric( aspect | A::Size, 4 );
ed.setBoxBorderMetrics( aspect, 0 );
ed.setBoxShape( aspect, 1 );
2020-08-11 17:56:53 +02:00
2020-12-27 11:11:31 +01:00
ed.setGradient( aspect, Qt::black );
2020-08-11 17:56:53 +02:00
}
// no Fill
for ( auto variation : { A::Horizontal, A::Vertical } )
2020-08-11 17:56:53 +02:00
{
const auto aspect = Fill | variation;
2020-12-27 11:11:31 +01:00
ed.setMetric( aspect | A::Size, 0 );
2020-08-11 17:56:53 +02:00
}
// Handle
for ( auto variation : { A::Horizontal, A::Vertical } )
2020-08-11 17:56:53 +02:00
{
const auto aspect = Handle | variation;
2020-08-11 17:56:53 +02:00
2020-12-27 11:11:31 +01:00
ed.setBoxBorderMetrics( aspect, 1 );
ed.setBoxShape( aspect, 4 );
2020-08-11 17:56:53 +02:00
const qreal m = 0.5 * std::ceil( 0.5 * ( w - h ) ) + 1;
if ( variation == A::Horizontal )
2020-12-27 11:11:31 +01:00
ed.setMargin( aspect, QskMargins( -m, 0 ) );
2020-08-11 17:56:53 +02:00
else
2020-12-27 11:11:31 +01:00
ed.setMargin( aspect, QskMargins( 0, -m ) );
2020-08-11 17:56:53 +02:00
2020-12-21 16:06:58 +01:00
for ( auto state : { A::NoState, Pressed } )
2020-08-11 17:56:53 +02:00
{
2022-06-25 16:14:08 +02:00
ed.setBoxBorderColors( aspect | state, SlateGrey );
ed.setGradient( aspect | state, DodgerBlue );
2020-08-11 17:56:53 +02:00
}
}
}