X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finput%2Fsmoothcontrol.h;h=16dc7e6cae73f5a737ea93f1971fcb4db0364224;hb=b99a9eb342d0f6ba5509c6d9f8ab0b0b5d5d2979;hp=78edbb3acd64a73b26a4ee9391c9b855b3ae5003;hpb=1023b38fa278cea71fba3d2881e1bfde930cd025;p=libs%2Fgui.git diff --git a/source/input/smoothcontrol.h b/source/input/smoothcontrol.h index 78edbb3..16dc7e6 100644 --- a/source/input/smoothcontrol.h +++ b/source/input/smoothcontrol.h @@ -1,6 +1,7 @@ #ifndef MSP_INPUT_SMOOTHCONTROL_H_ #define MSP_INPUT_SMOOTHCONTROL_H_ +#include #include "control.h" namespace Msp { @@ -14,36 +15,40 @@ Two smooth controls can also be paired to each other. Motion on one control of the pair will cause negative motion on the other. This works best when the controls are bound to the opposite sides of the same axis. */ -class SmoothControl: public Control +class MSPGUI_API SmoothControl: public Control { public: sigc::signal signal_motion; private: - float value; - SmoothControl *paired_ctrl; - float dead_zone; - float threshold; + float value = 0.0f; + SmoothControl *paired_ctrl = nullptr; + float dead_zone = 0.1f; + float threshold = 0.9f; public: - SmoothControl(); + SmoothControl() = default; SmoothControl(const ControlSource &); SmoothControl(Device &, ControlSrcType, unsigned); - virtual ~SmoothControl(); + ~SmoothControl(); /// Sets the dead zone value. Any value below this will be treated as 0. void set_dead_zone(float); - /// Sets the max-out threshold. Any value above this will be treated as 1. + /** Sets the max-out threshold. Any value above this will be treated as 1. + A negative value can be used to disable the threshold entirely. */ void set_threshold(float); + /// Sets dead zone and threshold in a single function call. + void set_range(float, float); + void pair(SmoothControl *ctrl); float get_value() const { return value; } private: - virtual void on_press(); - virtual void on_release(); - virtual void on_motion(float, float); + void on_press() override; + void on_release() override; + void on_motion(float, float) override; }; } // namespace Input