13
0

NO-OP: whitespace

This commit is contained in:
Robin Gareus 2019-10-25 14:35:38 +02:00
parent 683f7a0be7
commit 7672b1cb43
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 37 additions and 40 deletions

View File

@ -92,7 +92,7 @@ PianoKeyboard::draw_keyboard_cue (cairo_t* cr, int note)
if (nkey < 0 || nkey >= NNOTES) {
return;
}
if (_note_bindings.find (nkey) == _note_bindings.end()) {
if (_note_bindings.find (nkey) == _note_bindings.end ()) {
return;
}
@ -107,7 +107,7 @@ PianoKeyboard::draw_keyboard_cue (cairo_t* cr, int note)
char buf[32];
sprintf (buf, "ArdourMono %dpx", MAX (8, MIN (20, w / 2 + 3)));
PangoFontDescription* font = pango_font_description_from_string (buf);
snprintf(buf, 16, "%lc", gdk_keyval_to_unicode (gdk_keyval_to_upper (gdk_keyval_from_name (_note_bindings[nkey].c_str()))));
snprintf (buf, 16, "%lc", gdk_keyval_to_unicode (gdk_keyval_to_upper (gdk_keyval_from_name (_note_bindings[nkey].c_str ()))));
PangoLayout* pl = pango_cairo_create_layout (cr);
pango_layout_set_font_description (pl, font);
pango_layout_set_text (pl, buf, -1);
@ -133,15 +133,15 @@ PianoKeyboard::draw_keyboard_cue (cairo_t* cr, int note)
void
PianoKeyboard::queue_note_draw (int note)
{
Gdk::Rectangle rect;
Glib::RefPtr<Gdk::Window> win = get_window();
Gdk::Rectangle rect;
Glib::RefPtr<Gdk::Window> win = get_window ();
rect.set_x (_notes[note].x);
rect.set_y (0);
rect.set_width (_notes[note].w);
rect.set_height (_notes[note].h);
win->invalidate_rect(rect, true); // -> queue_draw_area ()
win->invalidate_rect (rect, true); // -> queue_draw_area ()
}
void
@ -187,8 +187,7 @@ PianoKeyboard::draw_note (cairo_t* cr, int note)
if (_enable_keyboard_cue) {
draw_keyboard_cue (cr, note);
}
else if (_print_note_label && (note % 12) == 0) {
} else if (_print_note_label && (note % 12) == 0) {
int tw, th;
char buf[32];
sprintf (buf, "ArdourMono %dpx", MAX (10, MIN (20, MIN (w / 2 + 3, h / 7))));
@ -311,7 +310,7 @@ PianoKeyboard::stop_sustained_notes ()
int
PianoKeyboard::key_binding (const char* key)
{
if (_key_bindings.find (key) != _key_bindings.end()) {
if (_key_bindings.find (key) != _key_bindings.end ()) {
return _key_bindings.at (key);
}
return -1;
@ -320,7 +319,7 @@ PianoKeyboard::key_binding (const char* key)
void
PianoKeyboard::bind_key (const char* key, int note)
{
_key_bindings[key] = note;
_key_bindings[key] = note;
_note_bindings[note] = key;
}
@ -487,7 +486,7 @@ PianoKeyboard::on_key_press_event (GdkEventKey* event)
char* key;
guint keyval;
GdkKeymapKey kk;
GdkKeymapKey kk;
/* 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 '&'. */
@ -605,7 +604,7 @@ PianoKeyboard::on_button_press_event (GdkEventButton* event)
release_key (_note_being_pressed_using_mouse);
}
press_key (note, get_velocity_for_note_at_y ( note, y));
press_key (note, get_velocity_for_note_at_y (note, y));
_note_being_pressed_using_mouse = note;
} else if (event->type == GDK_BUTTON_RELEASE) {
@ -758,8 +757,8 @@ PianoKeyboard::recompute_dimensions ()
if (is_black (note)) {
/* This note is black key. */
_notes[note].x = widget_margin +
(white_key * key_width) -
(black_key_width * black_key_left_shift (note));
(white_key * key_width) -
(black_key_width * black_key_left_shift (note));
_notes[note].w = black_key_width;
_notes[note].h = (height * 2) / 3;
_notes[note].white = 0;
@ -786,7 +785,7 @@ PianoKeyboard::on_size_allocate (Gtk::Allocation& allocation)
PianoKeyboard::PianoKeyboard ()
{
using namespace Gdk;
add_events (KEY_PRESS_MASK|KEY_RELEASE_MASK|BUTTON_PRESS_MASK|BUTTON_RELEASE_MASK|POINTER_MOTION_MASK|POINTER_MOTION_HINT_MASK);
add_events (KEY_PRESS_MASK | KEY_RELEASE_MASK | BUTTON_PRESS_MASK | BUTTON_RELEASE_MASK | POINTER_MOTION_MASK | POINTER_MOTION_HINT_MASK);
_maybe_stop_sustained_notes = false;
_sustain_new_notes = false;
@ -955,7 +954,7 @@ PianoKeyboard::set_octave_range (int octave_range)
if (_min_note < 3) {
upper_offset = 0;
_min_note = 0;
_min_note = 0;
} else if (_octave_range > 5) {
/* extend down to A */
upper_offset = 3;
@ -988,7 +987,6 @@ PianoKeyboard::set_keyboard_layout (Layout layout)
case DVORAK:
bind_keys_dvorak ();
break;
}
queue_draw ();
}

View File

@ -40,7 +40,7 @@ public:
sigc::signal<void, int, int> NoteOn;
sigc::signal<void, int> NoteOff;
sigc::signal<void > Rest;
sigc::signal<void> Rest;
enum Layout {
QWERTY,
@ -63,8 +63,8 @@ public:
void set_velocities (int min_vel, int max_vel, int key_vel);
protected:
bool on_key_press_event (GdkEventKey *);
bool on_key_release_event (GdkEventKey *);
bool on_key_press_event (GdkEventKey*);
bool on_key_release_event (GdkEventKey*);
bool on_button_press_event (GdkEventButton*);
bool on_button_release_event (GdkEventButton*);
bool on_motion_notify_event (GdkEventMotion*);
@ -74,16 +74,15 @@ protected:
void on_size_allocate (Gtk::Allocation&);
private:
void draw_keyboard_cue (cairo_t* cr, int note);
void queue_note_draw (int note);
void draw_note (cairo_t* cr, int note);
int press_key (int key, int vel);
int release_key (int key);
int press_key (int key, int vel);
int release_key (int key);
void release_key ();
void stop_unsustained_notes ();
void stop_sustained_notes ();
int key_binding (const char* key);
int key_binding (const char* key);
void bind_key (const char* key, int note);
void clear_notes ();
@ -95,27 +94,27 @@ private:
int get_note_for_xy (int x, int y) const;
int get_velocity_for_note_at_y (int note, int y) const;
int is_black (int key) const;
int is_black (int key) const;
double black_key_left_shift (int key) const;
void recompute_dimensions ();
struct PKNote {
PKNote ()
: pressed (false)
, sustained (false)
, white (false)
, x (0)
, w (0)
, h (0)
: pressed (false)
, sustained (false)
, white (false)
, x (0)
, w (0)
, h (0)
{}
bool pressed; /* 1 if key is in pressed down state. */
bool sustained; /* 1 if note is sustained. */
bool white; /* 1 if key is white; 0 otherwise. */
int x; /* Distance between the left edge of the key * and the left edge of the widget, in pixels. */
int w; /* Width of the key, in pixels. */
int h; /* Height of the key, in pixels. */
bool pressed; /* true if key is in pressed down state. */
bool sustained; /* true if note is sustained. */
bool white; /* true if key is white; 0 otherwise. */
int x; /* Distance between the left edge of the key and the left edge of the widget, in pixels. */
int w; /* Width of the key, in pixels. */
int h; /* Height of the key, in pixels. */
};
bool _maybe_stop_sustained_notes;
@ -136,7 +135,7 @@ private:
PKNote _notes[NNOTES];
std::map<std::string, int> _key_bindings; /**< Table used to translate from PC keyboard character to MIDI note number. */
std::map<std::string, int> _key_bindings; /**< Table used to translate from PC keyboard character to MIDI note number. */
std::map<int, std::string> _note_bindings; /**< Table to translate from MIDI note number to PC keyboard character. */
};
#endif /* __PIANO_KEYBOARD_H__ */

View File

@ -59,7 +59,7 @@ VirtualKeyboardWindow::VirtualKeyboardWindow ()
{
_piano.set_flags (Gtk::CAN_FOCUS);
_piano.set_keyboard_layout(PianoKeyboard::QWERTY);
_piano.set_keyboard_layout (PianoKeyboard::QWERTY);
_piano.show_note_label (true);
using namespace Menu_Helpers;
@ -362,10 +362,10 @@ VirtualKeyboardWindow::set_state (const XMLNode& root)
}
bool
VirtualKeyboardWindow::on_focus_in_event (GdkEventFocus *ev)
VirtualKeyboardWindow::on_focus_in_event (GdkEventFocus* ev)
{
_piano.grab_focus ();
return ArdourWindow::on_focus_in_event(ev);
return ArdourWindow::on_focus_in_event (ev);
}
void