remove unused member
[ardour.git] / libs / surfaces / faderport8 / fp8_button.h
index cddf7f471f4effbfb07a2e10265668b5b78c74c6..cf3bfe5225357e5838f5b041b1bfd6404e3c24f8 100644 (file)
@@ -1,20 +1,19 @@
-/* FaderPort8 Button Interface
- *
+/*
  * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #ifndef _ardour_surfaces_fp8button_h_
@@ -27,7 +26,7 @@
 
 #include "fp8_base.h"
 
-namespace ArdourSurface {
+namespace ArdourSurface { namespace FP_NAMESPACE {
 
 /* virtual base-class and interface */
 class FP8ButtonInterface
@@ -106,20 +105,22 @@ public:
                return true;
        }
 
-       void ignore_release () {
+       virtual void ignore_release () {
                if (_pressed) {
                        _ignore_release = true;
                }
        }
 
+       bool blinking () const { return _blinking; }
+
        void set_blinking (bool yes) {
                if (yes && !_blinking) {
                        _blinking = true;
                        _base.BlinkIt.connect_same_thread (_blink_connection, boost::bind (&FP8ButtonBase::blink, this, _1));
                } else if (!yes && _blinking) {
                        _blink_connection.disconnect ();
-                       blink (true);
                        _blinking = false;
+                       blink (true);
                }
        }
 
@@ -360,14 +361,12 @@ private:
 // short press: activate in press, deactivate on release,
 // long press + hold, activate on press, de-activate directly on release
 // e.g. mute/solo  press + hold => changed()
-class FP8MomentaryButton : public FP8ButtonInterface
+class FP8MomentaryButton : public FP8ButtonBase
 {
 public:
        FP8MomentaryButton (FP8Base& b, uint8_t id)
-               : _base (b)
+               : FP8ButtonBase (b)
                , _midi_id (id)
-               , _pressed (false)
-               , _active (false)
        {}
 
        ~FP8MomentaryButton () {
@@ -391,6 +390,8 @@ public:
                _hold_connection.disconnect ();
        }
 
+       void ignore_release () { }
+
        bool midi_event (bool a)
        {
                if (a == _pressed) {
@@ -423,12 +424,18 @@ public:
        }
 
 protected:
-       FP8Base& _base;
+       void blink (bool onoff)
+       {
+               if (!blinking ()) {
+                       _base.tx_midi3 (0x90, _midi_id, _active ? 0x7f : 0x00);
+                       return;
+               }
+               _base.tx_midi3 (0x90, _midi_id, onoff ? 0x7f : 0x00);
+       }
+
        uint8_t  _midi_id; // MIDI-note
-       bool     _pressed;
        bool     _momentaty;
        bool     _was_active_on_press;
-       bool     _active;
 
 private:
        bool hold_timeout ()
@@ -497,5 +504,5 @@ private:
        sigc::connection _press_timeout_connection;
 };
 
-} /* namespace */
+} /* namespace */
 #endif /* _ardour_surfaces_fp8button_h_ */