ardour
slider_controller.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 1998-99 Paul Davis
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation; either version 2 of the License, or
6  (at your option) any later version.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 
17  $Id$
18 */
19 
20 #include <string>
21 
22 #include <gtkmm2ext/gtk_ui.h>
23 #include <gtkmm2ext/pixfader.h>
25 #include "pbd/controllable.h"
26 
27 #include "i18n.h"
28 
29 using namespace Gtkmm2ext;
30 using namespace PBD;
31 
32 SliderController::SliderController (Gtk::Adjustment *adj, boost::shared_ptr<PBD::Controllable> mc, int orientation, int fader_length, int fader_girth)
33  : PixFader (*adj, orientation, fader_length, fader_girth)
34  , _ctrl (mc)
35  , _ctrl_adj (adj)
36  , _spin_adj (0, 0, 1.0, .1, .01)
37  , _spin (_spin_adj, 0, 2)
38  , _ctrl_ignore (false)
39  , _spin_ignore (false)
40 {
41  if (mc) {
42  _spin_adj.set_lower (mc->lower ());
43  _spin_adj.set_upper (mc->upper ());
44  _spin_adj.set_step_increment(_ctrl->interface_to_internal(adj->get_step_increment()) - mc->lower ());
45  _spin_adj.set_page_increment(_ctrl->interface_to_internal(adj->get_page_increment()) - mc->lower ());
46 
47  adj->signal_value_changed().connect (sigc::mem_fun(*this, &SliderController::ctrl_adjusted));
48  _spin_adj.signal_value_changed().connect (sigc::mem_fun(*this, &SliderController::spin_adjusted));
49 
51  }
52 
53  _spin.set_name ("SliderControllerValue");
54  _spin.set_numeric (true);
55  _spin.set_snap_to_ticks (false);
56 }
57 
58 bool
60 {
62  return true;
63  }
64 
66 }
67 
68 void
70 {
71  assert (_ctrl); // only used w/BarControlle
72  if (_spin_ignore) return;
73  _ctrl_ignore = true;
74  // TODO consider using internal_to_user, too (amp, dB)
75  // (also needs _spin_adj min/max range changed accordingly
76  // and dedicated support for log-scale, revert parts of ceff2e3a62f839)
77  _spin_adj.set_value (_ctrl->interface_to_internal (_ctrl_adj->get_value()));
78  _ctrl_ignore = false;
79 }
80 
81 void
83 {
84  assert (_ctrl); // only used w/BarController
85  if (_ctrl_ignore) return;
86  _spin_ignore = true;
87  // TODO consider using user_to_internal, as well
88  _ctrl_adj->set_value(_ctrl->internal_to_interface (_spin_adj.get_value()));
89  _spin_ignore = false;
90 }
91 
92 
93 
94 VSliderController::VSliderController (Gtk::Adjustment *adj, boost::shared_ptr<PBD::Controllable> mc, int fader_length, int fader_girth)
95  : SliderController (adj, mc, VERT, fader_length, fader_girth)
96 {
97 }
98 
99 HSliderController::HSliderController (Gtk::Adjustment *adj, boost::shared_ptr<PBD::Controllable> mc, int fader_length, int fader_girth)
100  : SliderController (adj, mc, HORIZ, fader_length, fader_girth)
101 {
102 }
void set_controllable(boost::shared_ptr< PBD::Controllable >)
HSliderController(Gtk::Adjustment *adj, boost::shared_ptr< PBD::Controllable > mc, int, int)
virtual double upper() const
Definition: controllable.h:108
SliderController(Gtk::Adjustment *adj, boost::shared_ptr< PBD::Controllable > mc, int orientation, int, int)
virtual double internal_to_interface(double i) const
Definition: controllable.h:71
boost::shared_ptr< PBD::Controllable > _ctrl
virtual double lower() const
Definition: controllable.h:107
bool button_press_handler(GdkEventButton *)
virtual double interface_to_internal(double i) const
Definition: controllable.h:72
Definition: debug.h:30
bool on_button_press_event(GdkEventButton *)
Definition: pixfader.cc:369
VSliderController(Gtk::Adjustment *adj, boost::shared_ptr< PBD::Controllable > mc, int, int)
bool on_button_press_event(GdkEventButton *ev)