Small cleanups to port matrix context menu.
[ardour.git] / gtk2_ardour / add_midi_cc_track_dialog.cc
1 /*
2     Copyright (C) 2000-2007 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 <cstdio>
21 #include <cmath>
22 #include <cassert>
23
24 #include <sigc++/bind.h>
25 #include <gtkmm/stock.h>
26 #include "pbd/error.h"
27 #include "pbd/convert.h"
28
29 #include "utils.h"
30 #include "add_midi_cc_track_dialog.h"
31 #include "i18n.h"
32
33 using namespace Gtk;
34 using namespace sigc;
35 using namespace std;
36 using namespace PBD;
37 using namespace ARDOUR;
38
39 AddMidiCCTrackDialog::AddMidiCCTrackDialog ()
40         : Dialog (_("ardour: add midi controller track"))
41         , _chan_adjustment (1, 1, 16, 1, 8, 8)
42         , _chan_spinner (_chan_adjustment)
43         , _cc_num_adjustment (1, 1, 128, 1, 10, 10)
44         , _cc_num_spinner (_cc_num_adjustment)
45 {
46         set_name ("AddMidiCCTrackDialog");
47         set_wmclass (X_("ardour_add_track_bus"), "Ardour");
48         set_position (Gtk::WIN_POS_MOUSE);
49         set_resizable (false);
50
51         _chan_spinner.set_name ("AddMidiCCTrackDialogSpinner");
52         _cc_num_spinner.set_name ("AddMidiCCTrackDialogSpinner");
53
54         HBox *chan_box = manage (new HBox());
55         Label *chan_label = manage(new Label("Channel: "));
56         chan_box->pack_start(*chan_label, true, true, 4);
57         chan_box->pack_start(_chan_spinner, false, false, 4);
58         get_vbox()->pack_start(*chan_box, true, true, 4);
59
60         HBox* num_box = manage (new HBox());
61         Label *num_label = manage(new Label("Controller: "));
62         num_box->pack_start(*num_label, true, true, 4);
63         num_box->pack_start(_cc_num_spinner, false, false, 4);
64         get_vbox()->pack_start(*num_box, true, true, 4);
65
66         add_button (Stock::CANCEL, RESPONSE_CANCEL);
67         add_button (Stock::ADD, RESPONSE_ACCEPT);
68
69         _chan_spinner.show();
70         chan_box->show();
71         chan_label->show();
72         _cc_num_spinner.show();
73         num_box->show();
74         num_label->show();
75 }
76
77
78 Evoral::Parameter
79 AddMidiCCTrackDialog::parameter ()
80 {
81         int chan   = _chan_spinner.get_value_as_int() - 1;
82         int cc_num = _cc_num_spinner.get_value_as_int() - 1;
83
84         return Evoral::Parameter(MidiCCAutomation, chan, cc_num);
85 }
86