2 Copyright (C) 2014 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <pangomm/layout.h>
26 #include "pbd/compose.h"
27 #include "pbd/error.h"
28 #include "pbd/stacktrace.h"
30 #include "gtkmm2ext/utils.h"
31 #include "gtkmm2ext/rgb_macros.h"
32 #include "gtkmm2ext/gui_thread.h"
33 #include "gtkmm2ext/keyboard.h"
35 #include "ardour/rc_configuration.h" // for widget prelight preference
37 #include "ardour_display.h"
38 #include "ardour_ui.h"
39 #include "global_signals.h"
43 using namespace Gtkmm2ext;
53 ArdourDisplay::ArdourDisplay (Element e)
56 add_elements(ArdourButton::Menu);
57 add_elements(ArdourButton::Text);
60 ArdourDisplay::~ArdourDisplay ()
65 ArdourDisplay::on_button_press_event (GdkEventButton*)
67 _menu.popup (1, gtk_get_current_event_time());
72 ArdourDisplay::on_scroll_event (GdkEventScroll* ev)
77 if (ev->state & Keyboard::GainFineScaleModifier) {
78 if (ev->state & Keyboard::GainExtraFineScaleModifier) {
85 boost::shared_ptr<PBD::Controllable> c = binding_proxy.get_controllable();
87 float val = c->get_interface();
89 if ( ev->direction == GDK_SCROLL_UP )
90 val += 0.05 * scale; //by default, we step in 1/20ths of the knob travel
94 c->set_interface(val);
102 ArdourDisplay::add_controllable_preset (const char *txt, float val)
104 using namespace Menu_Helpers;
106 MenuList& items = _menu.items ();
108 items.push_back (MenuElem (txt, sigc::bind (sigc::mem_fun(*this, &ArdourDisplay::handle_controllable_preset), val)));
113 ArdourDisplay::handle_controllable_preset (float p)
115 boost::shared_ptr<PBD::Controllable> c = binding_proxy.get_controllable();
124 ArdourDisplay::set_controllable (boost::shared_ptr<Controllable> c)
126 watch_connection.disconnect (); //stop watching the old controllable
130 binding_proxy.set_controllable (c);
132 c->Changed.connect (watch_connection, invalidator(*this), boost::bind (&ArdourDisplay::controllable_changed, this), gui_context());
134 controllable_changed();
138 ArdourDisplay::controllable_changed ()
140 boost::shared_ptr<PBD::Controllable> c = binding_proxy.get_controllable();
144 set_text(c->get_user_string());