Fixed slider painting, part III

This commit is contained in:
2026-03-29 23:30:42 +02:00
parent 0389f98ba6
commit 43508cd698
10 changed files with 573 additions and 243 deletions

67
trash/bcvaluesliderold.h Normal file
View File

@@ -0,0 +1,67 @@
#ifndef BC_VALUESLIDER_H
#define BC_VALUESLIDER_H
#include <QWidget>
#include <QTableView>
#include <QSlider>
#include <QPainter>
#include <QProxyStyle>
#include <bcvalue.h>
#include <ui_bcvaluesliderold.h>
class QSlider;
class QPushButton;
class BCValue;
class BCValueSliderOld : public QWidget, private Ui::BCValueSliderOld
{
Q_OBJECT
public:
explicit BCValueSliderOld(QWidget *parent = nullptr);
int value() const;
void setValueAndRange( const BCValue::ValueRange& params );
// helper functions
static QRect clipToSliderRect( const QRect& rect);
static void paintSliderIndicator(QPainter* painter, const QRect& rect, double ratio );
static constexpr int cToolIconOffset = 24;
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;
std::unique_ptr<BCValueSliderStyle> _sliderStyle;
};
#endif // BC_VALUESLIDER_H