use new method in MidiPatchManager to use MIDNAM data when setting a MidiTimeAxisView
[ardour.git] / gtk2_ardour / control_point_dialog.cc
1 /*
2  * Copyright (C) 2008-2011 Carl Hetherington <carl@carlh.net>
3  *
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.
8  *
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.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18
19 #include "control_point_dialog.h"
20 #include "control_point.h"
21 #include "automation_line.h"
22 #include "pbd/i18n.h"
23 #include <gtkmm/stock.h>
24
25 /**
26  *    ControlPointDialog constructor.
27  *
28  *    @param p ControlPoint to edit.
29  */
30
31 ControlPointDialog::ControlPointDialog (ControlPoint* p)
32         : ArdourDialog (_("Control point")),
33           point_ (p)
34 {
35         assert (point_);
36
37         double const y_fraction = 1.0 - (p->get_y () / p->line().height ());
38
39         value_.set_text (p->line().fraction_to_string (y_fraction));
40         value_.set_activates_default ();
41
42         Gtk::HBox* b = Gtk::manage (new Gtk::HBox ());
43
44         b->pack_start (*Gtk::manage (new Gtk::Label (_("Value"))));
45         b->pack_start (value_);
46
47         if (p->line ().get_uses_gain_mapping ()) {
48                 b->pack_start (*Gtk::manage (new Gtk::Label (_("dB"))));
49         }
50
51         get_vbox ()->pack_end (*b);
52         b->show_all ();
53
54         add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
55         add_button (Gtk::Stock::APPLY, Gtk::RESPONSE_ACCEPT);
56         set_default_response (Gtk::RESPONSE_ACCEPT);
57 }
58
59 double
60 ControlPointDialog::get_y_fraction () const
61 {
62         return point_->line().string_to_fraction (value_.get_text ());
63 }