1 /* 2 * Copyright (C) 2020 Alexandros Theodotou <alex at zrythm dot org> 3 * 4 * This file is part of Zrythm 5 * 6 * Zrythm is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU Affero General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * Zrythm is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU Affero General Public License for more details. 15 * 16 * You should have received a copy of the GNU Affero General Public License 17 * along with Zrythm. If not, see <https://www.gnu.org/licenses/>. 18 */ 19 20 /** 21 * \file 22 * 23 * Piano keyboard widget. 24 */ 25 26 #ifndef __GUI_WIDGETS_PIANO_KEYBOARD_H__ 27 #define __GUI_WIDGETS_PIANO_KEYBOARD_H__ 28 29 #include <stdbool.h> 30 #include <gtk/gtk.h> 31 32 #define PIANO_KEYBOARD_WIDGET_TYPE \ 33 (piano_keyboard_widget_get_type ()) 34 G_DECLARE_FINAL_TYPE ( 35 PianoKeyboardWidget, 36 piano_keyboard_widget, Z, PIANO_KEYBOARD, 37 GtkDrawingArea) 38 39 typedef struct ChordDescriptor ChordDescriptor; 40 41 /** 42 * @addtogroup widgets 43 * 44 * @{ 45 */ 46 47 /** 48 * Piano Keyboard widget. 49 */ 50 typedef struct _PianoKeyboardWidget 51 { 52 GtkDrawingArea parent_instance; 53 54 /** Number of visible keys (1-128). */ 55 int num_keys; 56 57 /** 0-127. */ 58 int start_key; 59 60 int pressed_keys[128]; 61 int num_pressed_keys; 62 63 /** When true, start key can change and when false 64 * the keys are fixed. */ 65 bool scrollable; 66 67 /** Whether clicking on keys plays them. */ 68 bool playable; 69 70 /** Whether clicking on keys "enables" them. */ 71 bool editable; 72 73 /** Horizontal/vertical. */ 74 GtkOrientation orientation; 75 76 /** Chord descriptor, if this widget is for 77 * a chord key. */ 78 ChordDescriptor * chord_descr; 79 80 } PianoKeyboardWidget; 81 82 /** 83 * Creates a piano keyboard widget. 84 */ 85 PianoKeyboardWidget * 86 piano_keyboard_widget_new ( 87 GtkOrientation orientation); 88 89 void 90 piano_keyboard_widget_refresh ( 91 PianoKeyboardWidget * self); 92 93 /** 94 * Creates a piano keyboard widget. 95 */ 96 PianoKeyboardWidget * 97 piano_keyboard_widget_new_for_chord_key ( 98 ChordDescriptor * descr); 99 100 /** 101 * @} 102 */ 103 104 #endif 105