qskinny/src/controls/QskSlider.h

72 lines
1.9 KiB
C
Raw Normal View History

2017-07-21 18:21:34 +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
2017-07-21 18:21:34 +02:00
*****************************************************************************/
#ifndef QSK_SLIDER_H
#define QSK_SLIDER_H
#include "QskBoundedValueInput.h"
2017-07-21 18:21:34 +02:00
class QSK_EXPORT QskSlider : public QskBoundedValueInput
2017-07-21 18:21:34 +02: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 12:43:46 +02:00
Q_PROPERTY( qreal handlePosition READ handlePosition )
2017-07-21 18:21:34 +02:00
using Inherited = QskBoundedValueInput;
2017-07-21 18:21:34 +02:00
2018-08-03 08:15:28 +02:00
public:
2022-07-05 13:27:35 +02:00
QSK_SUBCONTROLS( Panel, Groove, Fill, Scale, Handle, Ripple )
2024-02-22 10:05:10 +01:00
QSK_STATES( Pressed )
2017-07-21 18:21:34 +02:00
explicit QskSlider( QQuickItem* parent = nullptr );
explicit QskSlider( Qt::Orientation, QQuickItem* parent = nullptr );
2018-07-31 17:32:25 +02:00
~QskSlider() override;
2017-07-21 18:21:34 +02:00
bool isPressed() const;
void setOrientation( Qt::Orientation );
Qt::Orientation orientation() const;
void setTracking( bool );
bool isTracking() const;
2020-09-23 12:43:46 +02:00
qreal handlePosition() const; // [0,0, 1.0]
QskAspect::Variation effectiveVariation() const override;
2017-07-21 18:21:34 +02:00
2018-08-03 08:15:28 +02:00
Q_SIGNALS:
2017-07-21 18:21:34 +02:00
void pressedChanged( bool );
void orientationChanged( Qt::Orientation );
void trackingChanged( bool );
2018-08-03 08:15:28 +02:00
protected:
2022-01-04 15:54:16 +01:00
void mousePressEvent( QMouseEvent* ) override;
void mouseMoveEvent( QMouseEvent* ) override;
void mouseReleaseEvent( QMouseEvent* ) override;
2017-07-21 18:21:34 +02:00
QSizeF handleSize() const;
QRectF handleRect() const;
void aboutToShow() override;
2018-08-03 08:15:28 +02:00
private:
2020-09-23 12:43:46 +02:00
void moveHandle();
void moveHandleTo( qreal value, const QskAnimationHint& );
2017-07-21 18:21:34 +02:00
class PrivateData;
std::unique_ptr< PrivateData > m_data;
};
#endif