clear button states at startup *and* shutdown
[ardour.git] / libs / surfaces / push2 / buttons.cc
index 1db04f486e91755103013fd4a86f292657f4f81d..a8aa6d015005eaa37d0d32e298dd8a577a33fbe1 100644 (file)
@@ -1,8 +1,29 @@
+/*
+  Copyright (C) 2016 Paul Davis
+
+  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., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "ardour/mute_control.h"
 #include "ardour/session.h"
+#include "ardour/solo_control.h"
 
 #include "push2.h"
 
 using namespace ArdourSurface;
+using namespace ARDOUR;
 
 void
 Push2::button_play ()
@@ -17,7 +38,6 @@ Push2::button_play ()
 void
 Push2::button_recenable ()
 {
-       std::cerr << "RE toggle\n";
        rec_enable_toggle ();
 }
 
@@ -32,3 +52,183 @@ Push2::button_down ()
 {
        scroll_dn_1_track ();
 }
+
+void
+Push2::button_right ()
+{
+       ScrollTimeline (0.75);
+}
+
+void
+Push2::button_left ()
+{
+       ScrollTimeline (-0.75);
+}
+
+void
+Push2::button_repeat ()
+{
+       loop_toggle ();
+}
+
+void
+Push2::button_metronome ()
+{
+       toggle_click ();
+}
+
+void
+Push2::button_solo ()
+{
+       cancel_all_solo ();
+}
+
+void
+Push2::button_new ()
+{
+       access_action ("Editor/start-range-from-playhead");
+
+       id_button_map[New]->set_color (LED::White);
+       id_button_map[New]->set_state (LED::NoTransition);
+       write (id_button_map[New]->state_msg());
+
+       /* blink the button for the other half of this operation */
+
+       id_button_map[FixedLength]->set_color (LED::White);
+       id_button_map[FixedLength]->set_state (LED::Blinking4th);
+       write (id_button_map[FixedLength]->state_msg());
+}
+
+
+void
+Push2::button_fixed_length ()
+{
+       access_action ("Editor/finish-range-from-playhead");
+
+       /* turn off both buttons for this operation */
+
+       id_button_map[New]->set_color (LED::Black);
+       id_button_map[New]->set_state (LED::NoTransition);
+       write (id_button_map[New]->state_msg());
+       id_button_map[FixedLength]->set_color (LED::Black);
+       id_button_map[FixedLength]->set_state (LED::NoTransition);
+       write (id_button_map[FixedLength]->state_msg());
+}
+
+void
+Push2::button_shift_press ()
+{
+       modifier_state = ModifierState (modifier_state | ModShift);
+}
+
+void
+Push2::button_shift_release ()
+{
+       modifier_state = ModifierState (modifier_state & ~ModShift);
+}
+
+void
+Push2::button_browse ()
+{
+       switch_bank (max (0, bank_start - 8));
+}
+
+void
+Push2::button_clip ()
+{
+       switch_bank (max (0, bank_start + 8));
+}
+
+void
+Push2::button_upper (uint32_t n)
+{
+       if (!stripable[n]) {
+               return;
+       }
+
+       boost::shared_ptr<SoloControl> sc = stripable[n]->solo_control ();
+       if (sc) {
+               sc->set_value (!sc->get_value(), PBD::Controllable::UseGroup);
+       }
+}
+
+void
+Push2::button_lower (uint32_t n)
+{
+       if (!stripable[n]) {
+               return;
+       }
+
+       boost::shared_ptr<MuteControl> mc = stripable[n]->mute_control ();
+
+       if (mc) {
+               mc->set_value (!mc->get_value(), PBD::Controllable::UseGroup);
+       }
+}
+
+void
+Push2::button_undo ()
+{
+       if (modifier_state & ModShift) {
+               ControlProtocol::Redo ();
+       } else {
+               ControlProtocol::Undo ();
+       }
+}
+
+void
+Push2::button_fwd32t ()
+{
+       const int n = (modifier_state & ModShift) ? 8 : 0;
+       goto_nth_marker (0+n);
+}
+
+void
+Push2::button_fwd32 ()
+{
+       const int n = (modifier_state & ModShift) ? 8 : 0;
+       goto_nth_marker (1+n);
+}
+
+void
+Push2::button_fwd16t ()
+{
+       const int n = (modifier_state & ModShift) ? 8 : 0;
+       goto_nth_marker (2+n);
+}
+
+void
+Push2::button_fwd16 ()
+{
+       const int n = (modifier_state & ModShift) ? 8 : 0;
+       goto_nth_marker (3+n);
+}
+
+void
+Push2::button_fwd8t ()
+{
+       const int n = (modifier_state & ModShift) ? 8 : 0;
+       goto_nth_marker (4+n);
+}
+
+void
+Push2::button_fwd8 ()
+{
+       const int n = (modifier_state & ModShift) ? 8 : 0;
+       goto_nth_marker (5+n);
+}
+
+void
+Push2::button_fwd4t ()
+{
+       const int n = (modifier_state & ModShift) ? 8 : 0;
+       goto_nth_marker (6+n);
+}
+
+void
+Push2::button_fwd4 ()
+{
+       const int n = (modifier_state & ModShift) ? 8 : 0;
+       goto_nth_marker (7+n);
+}
+