qskinny/examples/tabview/CustomSlider.cpp

59 lines
1.6 KiB
C++
Raw Normal View History

2019-06-20 12:02:28 +02:00
/******************************************************************************
2024-01-17 14:31:45 +01:00
* QSkinny - Copyright (C) The authors
2023-04-06 09:23:37 +02:00
* SPDX-License-Identifier: BSD-3-Clause
2019-06-20 12:02:28 +02:00
*****************************************************************************/
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 );
2022-06-25 16:14:08 +02:00
ed.setGradient( Fill, QskRgb::DimGray );
2020-12-27 11:11:31 +01:00
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 );
2022-06-25 16:14:08 +02:00
ed.setColor( Handle, QskRgb::DimGray );
2017-07-21 18:21:34 +02:00
2022-06-25 16:14:08 +02:00
ed.setColor( Handle | Pressed, QskRgb::Orange );
2021-09-03 06:51:50 +02:00
2021-09-04 16:48:02 +02:00
const auto combinationMask = Focused | Hovered;
2021-09-03 06:51:50 +02:00
2022-06-25 16:14:08 +02:00
ed.setColor( Handle, QskRgb::Orange, combinationMask );
2021-09-04 16:48:02 +02:00
ed.setAnimation( Handle | QskAspect::Color, 300, combinationMask );
2017-07-21 18:21:34 +02:00
2020-12-27 11:11:31 +01:00
ed.setAnimation( Handle | QskAspect::Color, 1000 );
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 );
}