Rename KeyboardLayout to PianoKeyBindings
This is to prevent polluting the global namespace with a symbol name that is likely to cause conflicts.
This commit is contained in:
parent
d4d57c844f
commit
1eb98316a3
|
@ -20,19 +20,19 @@
|
|||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
#include "keyboardlayout.h"
|
||||
#include "piano_key_bindings.h"
|
||||
|
||||
KeyboardLayout::KeyboardLayout ()
|
||||
PianoKeyBindings::PianoKeyBindings ()
|
||||
{
|
||||
bind_keys_qwerty ();
|
||||
}
|
||||
|
||||
KeyboardLayout::~KeyboardLayout ()
|
||||
PianoKeyBindings::~PianoKeyBindings ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
KeyboardLayout::set_layout (Layout layout)
|
||||
PianoKeyBindings::set_layout (Layout layout)
|
||||
{
|
||||
switch (layout) {
|
||||
case QWERTY:
|
||||
|
@ -57,7 +57,7 @@ KeyboardLayout::set_layout (Layout layout)
|
|||
}
|
||||
|
||||
int
|
||||
KeyboardLayout::key_binding (const char* key) const
|
||||
PianoKeyBindings::key_binding (const char* key) const
|
||||
{
|
||||
std::map<std::string, int>::const_iterator kv;
|
||||
if (key && (kv = _key_bindings.find (key)) != _key_bindings.end ()) {
|
||||
|
@ -67,7 +67,7 @@ KeyboardLayout::key_binding (const char* key) const
|
|||
}
|
||||
|
||||
const char*
|
||||
KeyboardLayout::note_binding (int note) const
|
||||
PianoKeyBindings::note_binding (int note) const
|
||||
{
|
||||
std::map<int, std::string>::const_iterator kv = _note_bindings.find (note);
|
||||
if (kv == _note_bindings.end ()) {
|
||||
|
@ -76,8 +76,8 @@ KeyboardLayout::note_binding (int note) const
|
|||
return kv->second.c_str();
|
||||
}
|
||||
|
||||
KeyboardLayout::Layout
|
||||
KeyboardLayout::layout (std::string const& l)
|
||||
PianoKeyBindings::Layout
|
||||
PianoKeyBindings::layout (std::string const& l)
|
||||
{
|
||||
if (l == "QWERTY") {
|
||||
return QWERTY;
|
||||
|
@ -99,7 +99,7 @@ KeyboardLayout::layout (std::string const& l)
|
|||
}
|
||||
|
||||
const char*
|
||||
KeyboardLayout::get_keycode (GdkEventKey* event)
|
||||
PianoKeyBindings::get_keycode (GdkEventKey* event)
|
||||
{
|
||||
/* We're not using event->keyval, because we need keyval with level set to 0.
|
||||
E.g. if user holds Shift and presses '7', we want to get a '7', not '&'. */
|
||||
|
@ -122,21 +122,21 @@ KeyboardLayout::get_keycode (GdkEventKey* event)
|
|||
}
|
||||
|
||||
void
|
||||
KeyboardLayout::bind_key (const char* key, int note)
|
||||
PianoKeyBindings::bind_key (const char* key, int note)
|
||||
{
|
||||
_key_bindings[key] = note;
|
||||
_note_bindings[note] = key;
|
||||
}
|
||||
|
||||
void
|
||||
KeyboardLayout::clear_notes ()
|
||||
PianoKeyBindings::clear_notes ()
|
||||
{
|
||||
_key_bindings.clear ();
|
||||
_note_bindings.clear ();
|
||||
}
|
||||
|
||||
void
|
||||
KeyboardLayout::bind_keys_qwerty ()
|
||||
PianoKeyBindings::bind_keys_qwerty ()
|
||||
{
|
||||
clear_notes ();
|
||||
|
||||
|
@ -187,7 +187,7 @@ KeyboardLayout::bind_keys_qwerty ()
|
|||
}
|
||||
|
||||
void
|
||||
KeyboardLayout::bind_keys_qwertz ()
|
||||
PianoKeyBindings::bind_keys_qwertz ()
|
||||
{
|
||||
bind_keys_qwerty ();
|
||||
|
||||
|
@ -197,7 +197,7 @@ KeyboardLayout::bind_keys_qwertz ()
|
|||
}
|
||||
|
||||
void
|
||||
KeyboardLayout::bind_keys_azerty ()
|
||||
PianoKeyBindings::bind_keys_azerty ()
|
||||
{
|
||||
clear_notes ();
|
||||
|
||||
|
@ -241,7 +241,7 @@ KeyboardLayout::bind_keys_azerty ()
|
|||
}
|
||||
|
||||
void
|
||||
KeyboardLayout::bind_keys_dvorak ()
|
||||
PianoKeyBindings::bind_keys_dvorak ()
|
||||
{
|
||||
clear_notes ();
|
||||
|
||||
|
@ -295,7 +295,7 @@ KeyboardLayout::bind_keys_dvorak ()
|
|||
}
|
||||
|
||||
void
|
||||
KeyboardLayout::bind_keys_basic_qwerty ()
|
||||
PianoKeyBindings::bind_keys_basic_qwerty ()
|
||||
{
|
||||
clear_notes ();
|
||||
|
||||
|
@ -325,7 +325,7 @@ KeyboardLayout::bind_keys_basic_qwerty ()
|
|||
}
|
||||
|
||||
void
|
||||
KeyboardLayout::bind_keys_basic_qwertz ()
|
||||
PianoKeyBindings::bind_keys_basic_qwertz ()
|
||||
{
|
||||
clear_notes ();
|
||||
|
|
@ -17,8 +17,8 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef _KEYBOARD_LAYOUT_H_
|
||||
#define _KEYBOARD_LAYOUT_H_
|
||||
#ifndef _PIANO_KEY_BINDINGS_H_
|
||||
#define _PIANO_KEY_BINDINGS_H_
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
@ -29,11 +29,11 @@
|
|||
* Class for mapping PC keyboard keys to note pitches. Used by the
|
||||
* Virtual MIDI Keyboard.
|
||||
*/
|
||||
class KeyboardLayout
|
||||
class PianoKeyBindings
|
||||
{
|
||||
public:
|
||||
KeyboardLayout ();
|
||||
~KeyboardLayout ();
|
||||
PianoKeyBindings ();
|
||||
~PianoKeyBindings ();
|
||||
|
||||
enum Layout {
|
||||
QWERTY,
|
|
@ -357,7 +357,7 @@ APianoKeyboard::on_key_press_event (GdkEventKey* event)
|
|||
return true;
|
||||
}
|
||||
|
||||
char const* key = KeyboardLayout::get_keycode (event);
|
||||
char const* key = PianoKeyBindings::get_keycode (event);
|
||||
int note = _keyboard_layout.key_binding (key);
|
||||
|
||||
if (note < -1) {
|
||||
|
@ -408,7 +408,7 @@ APianoKeyboard::on_key_release_event (GdkEventKey* event)
|
|||
return true;
|
||||
}
|
||||
|
||||
char const* key = KeyboardLayout::get_keycode (event);
|
||||
char const* key = PianoKeyBindings::get_keycode (event);
|
||||
|
||||
if (!key) {
|
||||
return false;
|
||||
|
@ -893,7 +893,7 @@ APianoKeyboard::set_octave_range (int octave_range)
|
|||
}
|
||||
|
||||
void
|
||||
APianoKeyboard::set_keyboard_layout (KeyboardLayout::Layout layout)
|
||||
APianoKeyboard::set_keyboard_layout (PianoKeyBindings::Layout layout)
|
||||
{
|
||||
_keyboard_layout.set_layout (layout);
|
||||
queue_draw ();
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <map>
|
||||
#include <gtkmm/drawingarea.h>
|
||||
|
||||
#include "keyboardlayout.h"
|
||||
#include "piano_key_bindings.h"
|
||||
|
||||
#define NNOTES (128)
|
||||
|
||||
|
@ -54,7 +54,7 @@ public:
|
|||
void set_monophonic (bool monophonic);
|
||||
void set_octave (int octave);
|
||||
void set_octave_range (int octave_range);
|
||||
void set_keyboard_layout (KeyboardLayout::Layout layout);
|
||||
void set_keyboard_layout (PianoKeyBindings::Layout layout);
|
||||
void set_velocities (int min_vel, int max_vel, int key_vel);
|
||||
|
||||
protected:
|
||||
|
@ -125,7 +125,7 @@ private:
|
|||
|
||||
PKNote _notes[NNOTES];
|
||||
|
||||
KeyboardLayout _keyboard_layout;
|
||||
PianoKeyBindings _keyboard_layout;
|
||||
std::map<std::string, int> _note_stack;
|
||||
|
||||
/* these are only valid during expose/draw */
|
||||
|
|
|
@ -365,7 +365,7 @@ VirtualKeyboardWindow::on_key_release_event (GdkEventKey* ev)
|
|||
void
|
||||
VirtualKeyboardWindow::select_keyboard_layout (std::string const& l)
|
||||
{
|
||||
_piano.set_keyboard_layout (KeyboardLayout::layout (l));
|
||||
_piano.set_keyboard_layout (PianoKeyBindings::layout (l));
|
||||
_piano.grab_focus ();
|
||||
}
|
||||
|
||||
|
|
|
@ -125,8 +125,6 @@ gtk2_ardour_sources = [
|
|||
'ghostregion.cc',
|
||||
'global_port_matrix.cc',
|
||||
'group_tabs.cc',
|
||||
'keyboardlayout.cc',
|
||||
'pianokeyboard.cc',
|
||||
'gui_object.cc',
|
||||
'idleometer.cc',
|
||||
'insert_remove_time_dialog.cc',
|
||||
|
@ -193,6 +191,8 @@ gtk2_ardour_sources = [
|
|||
'panner_ui.cc',
|
||||
'patch_change.cc',
|
||||
'patch_change_widget.cc',
|
||||
'pianokeyboard.cc',
|
||||
'piano_key_bindings.cc',
|
||||
'piano_roll_header.cc',
|
||||
'pingback.cc',
|
||||
'playlist_selector.cc',
|
||||
|
|
Loading…
Reference in New Issue