X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finput%2Fsmoothcontrol.h;h=b5eb9aa2fd9dea6c56d81a38d40ed88755893671;hb=27356249e3607c78f5da9823c88703a6f4f7bed1;hp=fb6f84e41e2ff64ceee262656d6ac9cc96c27a60;hpb=c9626e6953c16efc66575eff80c4c0de2f739041;p=libs%2Fgui.git diff --git a/source/input/smoothcontrol.h b/source/input/smoothcontrol.h index fb6f84e..b5eb9aa 100644 --- a/source/input/smoothcontrol.h +++ b/source/input/smoothcontrol.h @@ -1,5 +1,5 @@ -#ifndef MSP_GBASE_SMOOTHCONTROL_H_ -#define MSP_GBASE_SMOOTHCONTROL_H_ +#ifndef MSP_INPUT_SMOOTHCONTROL_H_ +#define MSP_INPUT_SMOOTHCONTROL_H_ #include "control.h" @@ -20,30 +20,34 @@ 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