various fixes to MidiRegionView selection handling, key handling, drawing of ghost...
[ardour2.git] / gtk2_ardour / patch_change_dialog.cc
blob475ae1f6a47e130e3bc393bb604d285a0aeaab4b
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 control 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 Label* l;
45 t->set_spacings (6);
46 int r = 0;
48 if (_time_converter) {
50 l = manage (new Label (_("Time")));
51 l->set_alignment (0, 0.5);
52 t->attach (*l, 0, 1, r, r + 1);
53 t->attach (_time, 1, 2, r, r + 1);
54 ++r;
56 _time.set_session (session);
57 _time.set_mode (AudioClock::BBT);
58 _time.set (_time_converter->to (patch.time ()), true);
61 l = manage (new Label (_("Channel")));
62 l->set_alignment (0, 0.5);
63 t->attach (*l, 0, 1, r, r + 1);
64 t->attach (_channel, 1, 2, r, r + 1);
65 ++r;
67 _channel.set_value (patch.channel() + 1);
69 l = manage (new Label (_("Program")));
70 l->set_alignment (0, 0.5);
71 t->attach (*l, 0, 1, r, r + 1);
72 t->attach (_program, 1, 2, r, r + 1);
73 ++r;
75 _program.set_value (patch.program () + 1);
77 l = manage (new Label (_("Bank")));
78 l->set_alignment (0, 0.5);
79 t->attach (*l, 0, 1, r, r + 1);
80 t->attach (_bank, 1, 2, r, r + 1);
81 ++r;
83 _bank.set_value (patch.bank() + 1);
85 get_vbox()->add (*t);
87 add_button (Stock::CANCEL, RESPONSE_CANCEL);
88 add_button (ok, RESPONSE_ACCEPT);
89 set_default_response (RESPONSE_ACCEPT);
91 show_all ();
94 Evoral::PatchChange<Evoral::MusicalTime>
95 PatchChangeDialog::patch () const
97 Evoral::MusicalTime t = 0;
99 if (_time_converter) {
100 t = _time_converter->from (_time.current_time ());
103 return Evoral::PatchChange<Evoral::MusicalTime> (
105 _channel.get_value_as_int() - 1,
106 _program.get_value_as_int() - 1,
107 _bank.get_value_as_int() - 1