mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 16:46:35 +01:00
Note selector dialog for note controls.
This commit is contained in:
parent
7204702c3f
commit
35672fb80a
7 changed files with 148 additions and 0 deletions
|
|
@ -30,6 +30,7 @@
|
||||||
#include "ardour_ui.h"
|
#include "ardour_ui.h"
|
||||||
#include "automation_controller.h"
|
#include "automation_controller.h"
|
||||||
#include "gui_thread.h"
|
#include "gui_thread.h"
|
||||||
|
#include "note_select_dialog.h"
|
||||||
|
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
|
|
||||||
|
|
@ -52,6 +53,9 @@ AutomationController::AutomationController(boost::shared_ptr<Automatable>
|
||||||
StartGesture.connect (sigc::mem_fun(*this, &AutomationController::start_touch));
|
StartGesture.connect (sigc::mem_fun(*this, &AutomationController::start_touch));
|
||||||
StopGesture.connect (sigc::mem_fun(*this, &AutomationController::end_touch));
|
StopGesture.connect (sigc::mem_fun(*this, &AutomationController::end_touch));
|
||||||
|
|
||||||
|
signal_button_release_event().connect(
|
||||||
|
sigc::mem_fun(*this, &AutomationController::on_button_release));
|
||||||
|
|
||||||
_adjustment->signal_value_changed().connect (
|
_adjustment->signal_value_changed().connect (
|
||||||
sigc::mem_fun(*this, &AutomationController::value_adjusted));
|
sigc::mem_fun(*this, &AutomationController::value_adjusted));
|
||||||
|
|
||||||
|
|
@ -144,6 +148,32 @@ AutomationController::end_touch ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AutomationController::run_note_select_dialog()
|
||||||
|
{
|
||||||
|
NoteSelectDialog* dialog = new NoteSelectDialog();
|
||||||
|
if (dialog->run() == Gtk::RESPONSE_ACCEPT) {
|
||||||
|
_controllable->set_value(dialog->note_number());
|
||||||
|
}
|
||||||
|
delete dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
AutomationController::on_button_release(GdkEventButton* ev)
|
||||||
|
{
|
||||||
|
using namespace Gtk::Menu_Helpers;
|
||||||
|
|
||||||
|
if (ev->button == 3 && _controllable->desc().unit == ARDOUR::ParameterDescriptor::MIDI_NOTE) {
|
||||||
|
Gtk::Menu* menu = manage(new Menu());
|
||||||
|
MenuList& items = menu->items();
|
||||||
|
items.push_back(MenuElem(_("Select Note..."),
|
||||||
|
sigc::mem_fun(*this, &AutomationController::run_note_select_dialog)));
|
||||||
|
menu->popup(1, ev->time);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AutomationController::value_changed ()
|
AutomationController::value_changed ()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,9 @@ private:
|
||||||
void start_touch();
|
void start_touch();
|
||||||
void end_touch();
|
void end_touch();
|
||||||
|
|
||||||
|
void run_note_select_dialog();
|
||||||
|
bool on_button_release(GdkEventButton* ev);
|
||||||
|
|
||||||
void value_changed();
|
void value_changed();
|
||||||
|
|
||||||
bool _ignore_change;
|
bool _ignore_change;
|
||||||
|
|
|
||||||
|
|
@ -155,6 +155,13 @@ press_key(PianoKeyboard *pk, int key)
|
||||||
else
|
else
|
||||||
pk->notes[key].sustained = 0;
|
pk->notes[key].sustained = 0;
|
||||||
|
|
||||||
|
if (pk->monophonic && pk->last_key != key) {
|
||||||
|
pk->notes[pk->last_key].pressed = 0;
|
||||||
|
pk->notes[pk->last_key].sustained = 0;
|
||||||
|
queue_note_draw(pk, pk->last_key);
|
||||||
|
}
|
||||||
|
pk->last_key = key;
|
||||||
|
|
||||||
pk->notes[key].pressed = 1;
|
pk->notes[key].pressed = 1;
|
||||||
|
|
||||||
g_signal_emit_by_name(GTK_WIDGET(pk), "note-on", key);
|
g_signal_emit_by_name(GTK_WIDGET(pk), "note-on", key);
|
||||||
|
|
@ -677,6 +684,8 @@ piano_keyboard_new(void)
|
||||||
pk->enable_keyboard_cue = 0;
|
pk->enable_keyboard_cue = 0;
|
||||||
pk->octave = 4;
|
pk->octave = 4;
|
||||||
pk->note_being_pressed_using_mouse = -1;
|
pk->note_being_pressed_using_mouse = -1;
|
||||||
|
pk->last_key = 0;
|
||||||
|
pk->monophonic = FALSE;
|
||||||
memset((void *)pk->notes, 0, sizeof(struct PKNote) * NNOTES);
|
memset((void *)pk->notes, 0, sizeof(struct PKNote) * NNOTES);
|
||||||
pk->key_bindings = g_hash_table_new(g_str_hash, g_str_equal);
|
pk->key_bindings = g_hash_table_new(g_str_hash, g_str_equal);
|
||||||
bind_keys_qwerty(pk);
|
bind_keys_qwerty(pk);
|
||||||
|
|
@ -690,6 +699,12 @@ piano_keyboard_set_keyboard_cue(PianoKeyboard *pk, int enabled)
|
||||||
pk->enable_keyboard_cue = enabled;
|
pk->enable_keyboard_cue = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
piano_keyboard_set_monophonic(PianoKeyboard *pk, gboolean monophonic)
|
||||||
|
{
|
||||||
|
pk->monophonic = monophonic;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
piano_keyboard_sustain_press(PianoKeyboard *pk)
|
piano_keyboard_sustain_press(PianoKeyboard *pk)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,8 @@ struct _PianoKeyboard
|
||||||
int octave;
|
int octave;
|
||||||
int widget_margin;
|
int widget_margin;
|
||||||
int note_being_pressed_using_mouse;
|
int note_being_pressed_using_mouse;
|
||||||
|
int last_key;
|
||||||
|
gboolean monophonic;
|
||||||
volatile struct PKNote notes[NNOTES];
|
volatile struct PKNote notes[NNOTES];
|
||||||
/* Table used to translate from PC keyboard character to MIDI note number. */
|
/* Table used to translate from PC keyboard character to MIDI note number. */
|
||||||
GHashTable *key_bindings;
|
GHashTable *key_bindings;
|
||||||
|
|
@ -76,6 +78,7 @@ void piano_keyboard_sustain_release (PianoKeyboard *pk);
|
||||||
void piano_keyboard_set_note_on (PianoKeyboard *pk, int note);
|
void piano_keyboard_set_note_on (PianoKeyboard *pk, int note);
|
||||||
void piano_keyboard_set_note_off (PianoKeyboard *pk, int note);
|
void piano_keyboard_set_note_off (PianoKeyboard *pk, int note);
|
||||||
void piano_keyboard_set_keyboard_cue (PianoKeyboard *pk, int enabled);
|
void piano_keyboard_set_keyboard_cue (PianoKeyboard *pk, int enabled);
|
||||||
|
void piano_keyboard_set_monophonic (PianoKeyboard *pk, gboolean monophonic);
|
||||||
void piano_keyboard_set_octave (PianoKeyboard *pk, int octave);
|
void piano_keyboard_set_octave (PianoKeyboard *pk, int octave);
|
||||||
gboolean piano_keyboard_set_keyboard_layout (PianoKeyboard *pk, const char *layout);
|
gboolean piano_keyboard_set_keyboard_layout (PianoKeyboard *pk, const char *layout);
|
||||||
|
|
||||||
|
|
|
||||||
55
gtk2_ardour/note_select_dialog.cc
Normal file
55
gtk2_ardour/note_select_dialog.cc
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2014 Paul Davis
|
||||||
|
Author: David Robillard
|
||||||
|
|
||||||
|
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <gtkmm/stock.h>
|
||||||
|
|
||||||
|
#include "note_select_dialog.h"
|
||||||
|
|
||||||
|
#include "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;
|
||||||
|
}
|
||||||
41
gtk2_ardour/note_select_dialog.h
Normal file
41
gtk2_ardour/note_select_dialog.h
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2014 Paul Davis
|
||||||
|
Author: David Robillard
|
||||||
|
|
||||||
|
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __gtk2_ardour_note_select_dialog_h__
|
||||||
|
#define __gtk2_ardour_note_select_dialog_h__
|
||||||
|
|
||||||
|
#include "ardour_dialog.h"
|
||||||
|
#include "gtk_pianokeyboard.h"
|
||||||
|
|
||||||
|
class NoteSelectDialog : public ArdourDialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NoteSelectDialog();
|
||||||
|
|
||||||
|
uint8_t note_number() const { return _note_number; }
|
||||||
|
|
||||||
|
void note_on_event_handler(int note);
|
||||||
|
|
||||||
|
private:
|
||||||
|
PianoKeyboard* _piano;
|
||||||
|
Gtk::Widget* _pianomm;
|
||||||
|
uint8_t _note_number;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __gtk2_ardour_note_select_dialog_h__ */
|
||||||
|
|
@ -153,6 +153,7 @@ gtk2_ardour_sources = [
|
||||||
'note.cc',
|
'note.cc',
|
||||||
'note_base.cc',
|
'note_base.cc',
|
||||||
'note_player.cc',
|
'note_player.cc',
|
||||||
|
'note_select_dialog.cc',
|
||||||
'nsm.cc',
|
'nsm.cc',
|
||||||
'nsmclient.cc',
|
'nsmclient.cc',
|
||||||
'option_editor.cc',
|
'option_editor.cc',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue