Files
BionxControl/bcvalueslider.h

66 lines
1.7 KiB
C
Raw Normal View History

2026-02-09 16:03:09 +01:00
#ifndef BC_VALUESLIDER_H
#define BC_VALUESLIDER_H
2026-01-11 11:37:52 +01:00
2026-01-10 22:18:54 +01:00
#include <QWidget>
2026-02-10 14:25:06 +01:00
#include <QTableView>
#include <QSlider>
#include <QPainter>
#include <QProxyStyle>
2026-01-22 22:16:19 +01:00
#include <bcvalue.h>
2026-02-09 16:03:09 +01:00
#include <ui_bcvalueslider.h>
2026-01-10 22:18:54 +01:00
class QSlider;
class QPushButton;
class BCValue;
2026-02-09 16:03:09 +01:00
class BCValueSlider : public QWidget, private Ui::BCValueSlider
2026-01-10 22:18:54 +01:00
{
Q_OBJECT
public:
2026-02-09 16:03:09 +01:00
explicit BCValueSlider(QWidget *parent = nullptr);
2026-01-10 22:18:54 +01:00
2026-01-21 17:07:00 +01:00
int value() const;
2026-01-22 22:16:19 +01:00
void setValueAndRange( const BCValue::ValueRange& params );
// helper functions
static QRect updateEditorRect( const QRect& rect);
2026-01-10 22:18:54 +01:00
2026-02-10 14:25:06 +01:00
static void paintSliderIndicator(QPainter* painter, const QRect& rect, double ratio );
static void paintSliderIndicator2(QPainter* painter, const QRect& rect, double ratio );
2026-01-10 22:18:54 +01:00
signals:
void valueChanged(int value);
2026-01-18 18:52:30 +01:00
void valueCommited(int value);
2026-01-10 22:18:54 +01:00
2026-01-22 22:16:19 +01:00
protected:
2026-02-10 14:25:06 +01:00
// 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;
};
2026-01-22 22:16:19 +01:00
static constexpr int cTextBlockOffset = 130;
static constexpr int cPaddingRight = 8;
static constexpr int cSliderWidth = 117;
2026-03-06 17:36:27 +01:00
std::unique_ptr<BCValueSliderStyle> _sliderStyle;
2026-01-10 22:18:54 +01:00
};
2026-01-21 17:07:00 +01:00
2026-02-09 16:03:09 +01:00
#endif // BC_VALUESLIDER_H