1 /* 2 * Copyright (C) 2019 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 this program. If not, see <https://www.gnu.org/licenses/>. 18 */ 19 20 /** 21 * \file 22 * 23 * Piano roll keys canvas. 24 */ 25 26 #ifndef __GUI_WIDGETS_PIANO_ROLL_KEYS_H__ 27 #define __GUI_WIDGETS_PIANO_ROLL_KEYS_H__ 28 29 #include <gtk/gtk.h> 30 31 #define PIANO_ROLL_KEYS_WIDGET_TYPE \ 32 (piano_roll_keys_widget_get_type ()) 33 G_DECLARE_FINAL_TYPE ( 34 PianoRollKeysWidget, 35 piano_roll_keys_widget, 36 Z, PIANO_ROLL_KEYS_WIDGET, 37 GtkDrawingArea) 38 39 /** 40 * @addtogroup widgets 41 * 42 * @{ 43 */ 44 45 #define MW_PIANO_ROLL_KEYS \ 46 MW_MIDI_EDITOR_SPACE->piano_roll_keys 47 48 /** 49 * The piano roll widget is the whole space inside 50 * the clip editor tab when a MIDI region is selected. 51 */ 52 typedef struct _PianoRollKeysWidget 53 { 54 GtkDrawingArea parent_instance; 55 56 /** Start key pressed. */ 57 int start_key; 58 59 /** Last key hovered during a press. */ 60 int last_key; 61 62 /** Last hovered key. */ 63 int last_hovered_key; 64 65 /** 66 * Note in the middle of the arranger (0-127). 67 * 68 * This will be used to scroll to each refresh. 69 */ 70 int last_mid_note; 71 72 /** 73 * Note pressed. 74 * 75 * Used for note presses (see 76 * MidiEditorSpaceKeyWidget). 77 */ 78 int note_pressed; 79 80 /** 81 * Note released. 82 * 83 * Used for note presses (see 84 * MidiEditorSpaceKeyWidget). 85 */ 86 int note_released; 87 88 /** Pixel height of each key, determined by the 89 * zoom level. */ 90 double px_per_key; 91 92 /** Pixel height of all keys combined. */ 93 double total_key_px; 94 95 GtkGestureMultiPress * multipress; 96 97 /** Cache layout for drawing the name. */ 98 PangoLayout * layout; 99 } PianoRollKeysWidget; 100 101 /** 102 * Returns the appropriate font size based on the 103 * current pixels (height) per key. 104 */ 105 int 106 piano_roll_keys_widget_get_font_size ( 107 PianoRollKeysWidget * self); 108 109 void 110 piano_roll_keys_widget_refresh ( 111 PianoRollKeysWidget * self); 112 113 void 114 piano_roll_keys_widget_redraw_note ( 115 PianoRollKeysWidget * self, 116 int note); 117 118 void 119 piano_roll_keys_widget_redraw_full ( 120 PianoRollKeysWidget * self); 121 122 void 123 piano_roll_keys_widget_setup ( 124 PianoRollKeysWidget * self); 125 126 int 127 piano_roll_keys_widget_get_key_from_y ( 128 PianoRollKeysWidget * self, 129 double y); 130 131 /** 132 * @} 133 */ 134 135 #endif 136