somewhat illogical and temporary workaround to the problems with consolidate & bounce...
[ardour2.git] / gtk2_ardour / patch_change_dialog.cc
blobd2c23e7365978100ab95463b2e19a905786dee99
1 /*
2 Copyright (C) 2010 Paul Davis
3 Author: Carl Hetherington <cth@carlh.net>
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.
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.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <gtkmm/stock.h>
22 #include <gtkmm/table.h>
23 #include "ardour/beats_frames_converter.h"
24 #include "patch_change_dialog.h"
25 #include "i18n.h"
27 using namespace Gtk;
29 /** @param tc If non-0, a time converter for this patch change. If 0, time and channel controls will be desensitized */
30 PatchChangeDialog::PatchChangeDialog (
31 const ARDOUR::BeatsFramesConverter* tc,
32 ARDOUR::Session* session,
33 Evoral::PatchChange<Evoral::MusicalTime> const & patch,
34 const Gtk::BuiltinStockID& ok
36 : ArdourDialog (_("Patch Change"), true)
37 , _time_converter (tc)
38 , _time (X_("patchchangetime"), true, X_("PatchChangeTimeClock"), true, false)
39 , _channel (*manage (new Adjustment (1, 1, 16, 1, 4)))
40 , _program (*manage (new Adjustment (1, 1, 128, 1, 16)))
41 , _bank (*manage (new Adjustment (1, 1, 16384, 1, 64)))
43 Table* t = manage (new Table (4, 2));
44 t->set_spacings (6);
45 int r = 0;
47 if (_time_converter) {
49 Label* l = manage (new Label (_("Time")));
50 l->set_alignment (0, 0.5);
51 t->attach (*l, 0, 1, r, r + 1);
52 t->attach (_time, 1, 2, r, r + 1);
53 ++r;
55 _time.set_session (session);
56 _time.set_mode (AudioClock::BBT);
57 _time.set (_time_converter->to (patch.time ()), true);
59 l = manage (new Label (_("Channel")));
60 l->set_alignment (0, 0.5);
61 t->attach (*l, 0, 1, r, r + 1);
62 t->attach (_channel, 1, 2, r, r + 1);
63 ++r;
65 _channel.set_value (patch.channel() + 1);
68 Label* l = manage (new Label (_("Program")));
69 l->set_alignment (0, 0.5);
70 t->attach (*l, 0, 1, r, r + 1);
71 t->attach (_program, 1, 2, r, r + 1);
72 ++r;
74 _program.set_value (patch.program () + 1);
76 l = manage (new Label (_("Bank")));
77 l->set_alignment (0, 0.5);
78 t->attach (*l, 0, 1, r, r + 1);
79 t->attach (_bank, 1, 2, r, r + 1);
80 ++r;
82 _bank.set_value (patch.bank() + 1);
84 get_vbox()->add (*t);
86 add_button (Stock::CANCEL, RESPONSE_CANCEL);
87 add_button (ok, RESPONSE_ACCEPT);
88 set_default_response (RESPONSE_ACCEPT);
90 show_all ();
93 Evoral::PatchChange<Evoral::MusicalTime>
94 PatchChangeDialog::patch () const
96 Evoral::MusicalTime t = 0;
97 if (_time_converter) {
98 t = _time_converter->from (_time.current_time ());
101 return Evoral::PatchChange<Evoral::MusicalTime> (
103 _channel.get_value_as_int() - 1,
104 _program.get_value_as_int() - 1,
105 _bank.get_value_as_int() - 1