1 /* 2 * Copyright (C) 2019-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 * Automation mode. 24 */ 25 26 #ifndef __GUI_WIDGETS_AUTOMATION_MODE_H__ 27 #define __GUI_WIDGETS_AUTOMATION_MODE_H__ 28 29 #include "audio/automation_track.h" 30 #include "gui/widgets/custom_button.h" 31 32 #include <gtk/gtk.h> 33 34 typedef struct AutomationTrack AutomationTrack; 35 36 /** 37 * @addtogroup widgets 38 * 39 * @{ 40 */ 41 42 #define AUTOMATION_MODE_HPADDING 3 43 #define AUTOMATION_MODE_HSEPARATOR_SIZE 1 44 45 /** 46 * Custom button group to be drawn inside drawing 47 * areas. 48 */ 49 typedef struct AutomationModeWidget 50 { 51 /** X/y relative to parent drawing area. */ 52 double x; 53 double y; 54 55 /** Total width/height. */ 56 int width; 57 int height; 58 59 /** Width of each button, including padding. */ 60 //int widths[NUM_AUTOMATION_MODES]; 61 62 int text_widths[NUM_AUTOMATION_MODES]; 63 int text_heights[NUM_AUTOMATION_MODES]; 64 int max_text_height; 65 66 int has_hit_mode; 67 68 /** Currently hit mode. */ 69 AutomationMode hit_mode; 70 71 /** Default color. */ 72 GdkRGBA def_color; 73 74 /** Hovered color. */ 75 GdkRGBA hovered_color; 76 77 /** Toggled color. */ 78 GdkRGBA toggled_colors[NUM_AUTOMATION_MODES]; 79 80 /** Held color (used after clicking and before 81 * releasing). */ 82 GdkRGBA held_colors[NUM_AUTOMATION_MODES]; 83 84 /** Aspect ratio for the rounded rectangle. */ 85 double aspect; 86 87 /** Corner curvature radius for the rounded 88 * rectangle. */ 89 double corner_radius; 90 91 /** Cairo caches. */ 92 cairo_t * cached_cr; 93 cairo_surface_t * cached_surface; 94 95 /** Used to update caches if state changed. */ 96 CustomButtonWidgetState last_states[ 97 NUM_AUTOMATION_MODES]; 98 99 /** Used during drawing. */ 100 CustomButtonWidgetState current_states[ 101 NUM_AUTOMATION_MODES]; 102 103 /** Used during transitions. */ 104 GdkRGBA last_colors[NUM_AUTOMATION_MODES]; 105 106 /** Cache layout for drawing text. */ 107 PangoLayout * layout; 108 109 /** Owner. */ 110 AutomationTrack * owner; 111 112 /** Frames left for a transition in color. */ 113 int transition_frames; 114 115 } AutomationModeWidget; 116 117 /** 118 * Creates a new track widget from the given track. 119 */ 120 AutomationModeWidget * 121 automation_mode_widget_new ( 122 int height, 123 PangoLayout * layout, 124 AutomationTrack * owner); 125 126 void 127 automation_mode_widget_init ( 128 AutomationModeWidget * self); 129 130 void 131 automation_mode_widget_draw ( 132 AutomationModeWidget * self, 133 cairo_t * cr, 134 double x, 135 double y, 136 double x_cursor, 137 CustomButtonWidgetState state); 138 139 void 140 automation_mode_widget_free ( 141 AutomationModeWidget * self); 142 143 /** 144 * @} 145 */ 146 147 #endif 148