qskinny/src/controls/QskSlider.h

72 lines
1.9 KiB
C
Raw Normal View History

2017-07-21 16:21:34 +00:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
2023-04-06 07:23:37 +00:00
* SPDX-License-Identifier: BSD-3-Clause
2017-07-21 16:21:34 +00:00
*****************************************************************************/
#ifndef QSK_SLIDER_H
#define QSK_SLIDER_H
#include "QskBoundedValueInput.h"
2017-07-21 16:21:34 +00:00
class QSK_EXPORT QskSlider : public QskBoundedValueInput
2017-07-21 16:21:34 +00:00
{
Q_OBJECT
Q_PROPERTY( bool isPressed READ isPressed NOTIFY pressedChanged )
Q_PROPERTY( Qt::Orientation orientation READ orientation
WRITE setOrientation NOTIFY orientationChanged )
Q_PROPERTY( bool tracking READ isTracking
WRITE setTracking NOTIFY trackingChanged )
2020-09-23 10:43:46 +00:00
Q_PROPERTY( qreal handlePosition READ handlePosition )
2017-07-21 16:21:34 +00:00
using Inherited = QskBoundedValueInput;
2017-07-21 16:21:34 +00:00
2018-08-03 06:15:28 +00:00
public:
2022-07-05 11:27:35 +00:00
QSK_SUBCONTROLS( Panel, Groove, Fill, Scale, Handle, Ripple )
2017-07-21 16:21:34 +00:00
QSK_STATES( Pressed, Minimum, Maximum )
explicit QskSlider( QQuickItem* parent = nullptr );
explicit QskSlider( Qt::Orientation, QQuickItem* parent = nullptr );
2018-07-31 15:32:25 +00:00
~QskSlider() override;
2017-07-21 16:21:34 +00:00
bool isPressed() const;
void setOrientation( Qt::Orientation );
Qt::Orientation orientation() const;
void setTracking( bool );
bool isTracking() const;
2020-09-23 10:43:46 +00:00
qreal handlePosition() const; // [0,0, 1.0]
QskAspect::Variation effectiveVariation() const override;
2017-07-21 16:21:34 +00:00
2018-08-03 06:15:28 +00:00
Q_SIGNALS:
2017-07-21 16:21:34 +00:00
void pressedChanged( bool );
void orientationChanged( Qt::Orientation );
void trackingChanged( bool );
2018-08-03 06:15:28 +00:00
protected:
2022-01-04 14:54:16 +00:00
void mousePressEvent( QMouseEvent* ) override;
void mouseMoveEvent( QMouseEvent* ) override;
void mouseReleaseEvent( QMouseEvent* ) override;
2017-07-21 16:21:34 +00:00
QSizeF handleSize() const;
QRectF handleRect() const;
void aboutToShow() override;
2018-08-03 06:15:28 +00:00
private:
2020-09-23 10:43:46 +00:00
void moveHandle();
void moveHandleTo( qreal value, const QskAnimationHint& );
2017-07-21 16:21:34 +00:00
class PrivateData;
std::unique_ptr< PrivateData > m_data;
};
#endif