65 lines
1.6 KiB
C++
65 lines
1.6 KiB
C++
#ifndef BC_VALUESLIDER_H
|
|
#define BC_VALUESLIDER_H
|
|
|
|
|
|
#include <QWidget>
|
|
#include <QTableView>
|
|
#include <QSlider>
|
|
#include <QPainter>
|
|
#include <QProxyStyle>
|
|
|
|
#include <bcvalue.h>
|
|
#include <ui_bcvalueslider.h>
|
|
|
|
class QSlider;
|
|
class QPushButton;
|
|
class BCValue;
|
|
|
|
class BCValueSlider : public QWidget, private Ui::BCValueSlider
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit BCValueSlider(QWidget *parent = nullptr);
|
|
|
|
int value() const;
|
|
void setValueAndRange( const BCValue::ValueRange& params );
|
|
|
|
// helper functions
|
|
static QRect updateEditorRect( const QRect& rect);
|
|
|
|
static void paintSliderIndicator(QPainter* painter, const QRect& rect, double ratio );
|
|
static void paintSliderIndicator2(QPainter* painter, const QRect& rect, double ratio );
|
|
|
|
signals:
|
|
|
|
void valueChanged(int value);
|
|
void valueCommited(int value);
|
|
|
|
protected:
|
|
|
|
// Fluent Design Slider Style
|
|
class BCValueSliderStyle : public QProxyStyle
|
|
{
|
|
|
|
public:
|
|
|
|
BCValueSliderStyle();
|
|
|
|
int pixelMetric(PixelMetric metric, const QStyleOption* option = nullptr, const QWidget* widget = nullptr) const override;
|
|
|
|
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex* opt, SubControl sc, const QWidget* widget) const override;
|
|
void drawComplexControl(ComplexControl control, const QStyleOptionComplex* option, QPainter* painter, const QWidget* widget) const override;
|
|
void drawHorizontalFluentSlider(QPainter* painter, const QStyleOptionSlider* slider, const QColor& activeColor, const QColor& bgColor) const;
|
|
|
|
};
|
|
|
|
static constexpr int cTextBlockOffset = 130;
|
|
static constexpr int cPaddingRight = 8;
|
|
static constexpr int cSliderWidth = 117;
|
|
|
|
};
|
|
|
|
#endif // BC_VALUESLIDER_H
|