enough with umpteen "i18n.h" files. Consolidate on pbd/i18n.h
[ardour.git] / gtk2_ardour / control_point_dialog.cc
1 /*
2     Copyright (C) 2000-2008 Paul Davis
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
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include "control_point_dialog.h"
21 #include "control_point.h"
22 #include "automation_line.h"
23 #include "pbd/i18n.h"
24 #include <gtkmm/stock.h>
25
26 /**
27  *    ControlPointDialog constructor.
28  *
29  *    @param p ControlPoint to edit.
30  */
31
32 ControlPointDialog::ControlPointDialog (ControlPoint* p)
33         : ArdourDialog (_("Control point")),
34           point_ (p)
35 {
36         assert (point_);
37
38         double const y_fraction = 1.0 - (p->get_y () / p->line().height ());
39
40         value_.set_text (p->line().fraction_to_string (y_fraction));
41         value_.set_activates_default ();
42
43         Gtk::HBox* b = Gtk::manage (new Gtk::HBox ());
44
45         b->pack_start (*Gtk::manage (new Gtk::Label (_("Value"))));
46         b->pack_start (value_);
47
48         if (p->line ().get_uses_gain_mapping ()) {
49                 b->pack_start (*Gtk::manage (new Gtk::Label (_("dB"))));
50         }
51
52         get_vbox ()->pack_end (*b);
53         b->show_all ();
54
55         add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
56         add_button (Gtk::Stock::APPLY, Gtk::RESPONSE_ACCEPT);
57         set_default_response (Gtk::RESPONSE_ACCEPT);
58 }
59
60 double
61 ControlPointDialog::get_y_fraction () const
62 {
63         return point_->line().string_to_fraction (value_.get_text ());
64 }