#pragma once #include #include #include #include class QWidget; // Swift's NumericScrub: a label dragged sideways changes its value. class NumericScrub : public QObject { public: struct Options { double sensitivity; double low; double high; // Dragged values snap to multiples of this, when set. std::optional step; std::function value; std::function set; std::function onStart = [] {}; std::function onEnd = [] {}; }; // Lives as the label's child and filters its events. NumericScrub(QWidget *label, Options options); // Ends a drag as a release would. void end(); protected: bool eventFilter(QObject *watched, QEvent *event) override; private: QWidget *const m_label; const Options m_options; // The press, until the release; Swift's gesture begins there. std::optional m_press; // Swift's startValue: set once the drag moves a point. std::optional m_start; };