Ardour  8.12
proxy_controllable.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011-2014 David Robillard <d@drobilla.net>
3  * Copyright (C) 2011-2016 Paul Davis <paul@linuxaudiosystems.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef __libardour_proxy_controllable_h__
21 #define __libardour_proxy_controllable_h__
22 
23 #include <boost/function.hpp>
24 
25 #include "pbd/controllable.h"
26 
27 namespace ARDOUR {
28 
34  public:
35  ProxyControllable (const std::string& name, PBD::Controllable::Flag flags,
36  boost::function1<bool,double> setter,
37  boost::function0<double> getter)
38  : PBD::Controllable (name, flags)
39  , _setter (setter)
40  , _getter (getter)
41  {}
42 
43  void set_value (double v, PBD::Controllable::GroupControlDisposition gcd) { if (_setter (v)) { Changed (true, gcd); /* EMIT SIGNAL */ } }
44  double get_value () const { return _getter (); }
45 
46  std::string get_user_string () const {
47  char theBuf[32]; sprintf( theBuf, "%3.1f dB", accurate_coefficient_to_dB (get_value()));
48  return std::string(theBuf);
49  }
50 
51  private:
52  boost::function1<bool,double> _setter;
53  boost::function0<double> _getter;
54 };
55 
56 } // namespace
57 
58 #endif /* __libardour_proxy_controllable_h__ */
std::string get_user_string() const
boost::function1< bool, double > _setter
boost::function0< double > _getter
ProxyControllable(const std::string &name, PBD::Controllable::Flag flags, boost::function1< bool, double > setter, boost::function0< double > getter)
void set_value(double v, PBD::Controllable::GroupControlDisposition gcd)
static float accurate_coefficient_to_dB(float coeff)
Definition: dB.h:39
GtkImageIconNameData name
Definition: gtkimage.h:6
#define LIBARDOUR_API
std::shared_ptr< PBD::Controllable > Controllable
Definition: console1.h:80
Definition: axis_view.h:42