qskinny/examples/gallery/slider/CustomSlider.cpp

57 lines
1.6 KiB
C++
Raw Normal View History

2019-06-20 12:02:28 +02:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the 3-clause BSD License
*****************************************************************************/
2020-08-11 17:56:53 +02:00
#include "CustomSlider.h"
#include "CustomSliderSkinlet.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>
2017-10-20 20:26:39 +02:00
#include <QskBoxShapeMetrics.h>
#include <QskGradient.h>
2018-08-03 08:15:28 +02:00
#include <QskRgbValue.h>
2017-07-21 18:21:34 +02:00
2020-12-27 11:11:31 +01:00
#include <QskSkinHintTable.h>
#include <QskSkinHintTableEditor.h>
2020-08-11 17:56:53 +02:00
QSK_SUBCONTROL( CustomSlider, Scale )
QSK_SUBCONTROL( CustomSlider, Decoration )
2017-07-21 18:21:34 +02:00
2020-08-11 17:56:53 +02:00
CustomSlider::CustomSlider( QQuickItem* parentItem )
2018-08-03 08:15:28 +02:00
: QskSlider( parentItem )
2017-07-21 18:21:34 +02:00
{
2020-12-17 08:50:35 +01:00
using namespace QskRgb;
2020-12-27 11:11:31 +01:00
QskSkinHintTableEditor ed( &hintTable() );
ed.setBoxShape( Fill, 0 );
ed.setGradient( Fill, Grey700 );
ed.setColor( Scale, qRgb( 178, 178, 178 ) ); // for the ticks
2017-07-21 18:21:34 +02:00
2020-12-27 11:11:31 +01:00
ed.setStrutSize( Handle, 80, 80 );
ed.setColor( Handle, Grey800 );
2017-07-21 18:21:34 +02:00
for ( auto state : { Pressed, Focused | Hovered, Hovered, Focused } )
2020-12-27 11:11:31 +01:00
ed.setColor( Handle | state, Orange600 );
2017-07-21 18:21:34 +02:00
2020-12-27 11:11:31 +01:00
ed.setAnimation( Handle | QskAspect::Color, 1000 );
for ( auto state : { Focused | Hovered, Hovered, Focused } )
2020-12-27 11:11:31 +01:00
ed.setAnimation( Handle | QskAspect::Color | state, 300 );
2017-07-21 18:21:34 +02:00
// using an individual skinlet, not known by the skin
2020-08-11 17:56:53 +02:00
auto skinlet = new CustomSliderSkinlet();
2017-07-21 18:21:34 +02:00
skinlet->setOwnedBySkinnable( true );
setSkinlet( skinlet );
connect( this, &QskSlider::valueChanged,
this, &QskControl::focusIndicatorRectChanged );
2017-07-21 18:21:34 +02:00
}
2020-08-11 17:56:53 +02:00
QRectF CustomSlider::focusIndicatorRect() const
{
2020-12-17 08:50:35 +01:00
return subControlRect( Handle );
}