]> git.tdb.fi Git - libs/gui.git/blobdiff - source/input/binarycontrol.h
Add decorations for things which should be exported from the library
[libs/gui.git] / source / input / binarycontrol.h
index fafa58537175cc19610742a45de9e805ef175dc1..723e70dd4af8bd21573f55a5c675178eb8a5cfb0 100644 (file)
@@ -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 <msp/graphics/mspgui_api.h>
 #include "control.h"
 
 namespace Msp {
@@ -8,35 +9,37 @@ namespace Input {
 
 /**
 A control with two possible states.  Button state is mapped directly.  An axis
-is considered to be active when its value is within 10% of the end of the 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<void> signal_press;
        sigc::signal<void> 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
-       */
+       /** 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