summaryrefslogtreecommitdiff
path: root/gtk2_ardour/control_point_dialog.cc
blob: cec9a3dd4cc76aedba4a20c9f402ee88dd4f97fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
 * Copyright (C) 2008-2011 Carl Hetherington <carl@carlh.net>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#include "control_point_dialog.h"
#include "control_point.h"
#include "automation_line.h"
#include "pbd/i18n.h"
#include <gtkmm/stock.h>

/**
 *    ControlPointDialog constructor.
 *
 *    @param p ControlPoint to edit.
 */

ControlPointDialog::ControlPointDialog (ControlPoint* p)
	: ArdourDialog (_("Control point")),
	  point_ (p)
{
	assert (point_);

	double const y_fraction = 1.0 - (p->get_y () / p->line().height ());

	value_.set_text (p->line().fraction_to_string (y_fraction));
	value_.set_activates_default ();

	Gtk::HBox* b = Gtk::manage (new Gtk::HBox ());

	b->pack_start (*Gtk::manage (new Gtk::Label (_("Value"))));
	b->pack_start (value_);

	if (p->line ().get_uses_gain_mapping ()) {
		b->pack_start (*Gtk::manage (new Gtk::Label (_("dB"))));
	}

	get_vbox ()->pack_end (*b);
	b->show_all ();

	add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
	add_button (Gtk::Stock::APPLY, Gtk::RESPONSE_ACCEPT);
	set_default_response (Gtk::RESPONSE_ACCEPT);
}

double
ControlPointDialog::get_y_fraction () const
{
	return point_->line().string_to_fraction (value_.get_text ());
}