X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finput%2Fbinarycontrol.h;h=723e70dd4af8bd21573f55a5c675178eb8a5cfb0;hb=b99a9eb342d0f6ba5509c6d9f8ab0b0b5d5d2979;hp=851c6127f08006a11731e90ff037bd8b00c79344;hpb=47df97f4381412236a02f0fcf71a2e9b23f78187;p=libs%2Fgui.git diff --git a/source/input/binarycontrol.h b/source/input/binarycontrol.h index 851c612..723e70d 100644 --- a/source/input/binarycontrol.h +++ b/source/input/binarycontrol.h @@ -1,6 +1,7 @@ -#ifndef MSP_GBASE_BINARYCONTROL_H_ -#define MSP_GBASE_BINARYCONTROL_H_ +#ifndef MSP_INPUT_BINARYCONTROL_H_ +#define MSP_INPUT_BINARYCONTROL_H_ +#include #include "control.h" namespace Msp { @@ -11,31 +12,34 @@ A control with two possible states. Button state is mapped directly. An axis is considered to be active when its value is above a threshold (0.5 by default). */ -class BinaryControl: public Control +class MSPGUI_API BinaryControl: public Control { public: sigc::signal signal_press; sigc::signal signal_release; private: - bool state; - float threshold; + bool state = false; + float threshold = 0.5f; public: - BinaryControl(); + BinaryControl() = default; BinaryControl(const ControlSource &); BinaryControl(Device &, ControlSrcType, unsigned); + ~BinaryControl(); /** Sets the threshold between states for axis sources. No effect on button sources */ void set_threshold(float); bool get_state() const { return state; } + bool was_pressed() const { return rising_edge; } + bool was_released() const { return falling_edge; } 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