summaryrefslogtreecommitdiff
path: root/gtk2_ardour/note_select_dialog.cc
blob: 51198da98e227c9b81ec79b4a4ace34c977a06dc (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
/*
 * Copyright (C) 2014 David Robillard <d@drobilla.net>
 * Copyright (C) 2016 Paul Davis <paul@linuxaudiosystems.com>
 *
 * 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 <gtkmm/stock.h>

#include "note_select_dialog.h"

#include "pbd/i18n.h"

static void
_note_on_event_handler(GtkWidget* /*widget*/, int note, gpointer arg)
{
	((NoteSelectDialog*)arg)->note_on_event_handler(note);
}

NoteSelectDialog::NoteSelectDialog()
	: ArdourDialog (_("Select Note"))
	, _piano((PianoKeyboard*)piano_keyboard_new())
	, _pianomm(Glib::wrap((GtkWidget*)_piano))
	, _note_number(60)
{
	_pianomm->set_flags(Gtk::CAN_FOCUS);
	_pianomm->show();
	g_signal_connect(G_OBJECT(_piano), "note-on", G_CALLBACK(_note_on_event_handler), this);
	piano_keyboard_set_monophonic(_piano, TRUE);
	piano_keyboard_sustain_press(_piano);

	get_vbox()->pack_start(*_pianomm);
	add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
	add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
	set_default_response(Gtk::RESPONSE_ACCEPT);
}

void
NoteSelectDialog::note_on_event_handler(int note)
{
	printf("NOTE: %d\n", note);
	_note_number = note;
}