1 /* 2 * Copyright (C) 2018-2021 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 #ifndef __GUI_WIDGETS_CHANNEL_H__ 21 #define __GUI_WIDGETS_CHANNEL_H__ 22 23 #include "audio/channel.h" 24 #include "gui/widgets/meter.h" 25 26 #include <gtk/gtk.h> 27 28 typedef struct _PluginStripExpanderWidget 29 PluginStripExpanderWidget; 30 31 #define CHANNEL_WIDGET_TYPE \ 32 (channel_widget_get_type ()) 33 G_DECLARE_FINAL_TYPE ( 34 ChannelWidget, channel_widget, 35 Z, CHANNEL_WIDGET, 36 GtkEventBox) 37 38 typedef struct _ColorAreaWidget ColorAreaWidget; 39 typedef struct _KnobWidget KnobWidget; 40 typedef struct _FaderWidget FaderWidget; 41 typedef struct Channel Channel; 42 typedef struct _ChannelSlotWidget ChannelSlotWidget; 43 typedef struct _RouteTargetSelectorWidget 44 RouteTargetSelectorWidget; 45 typedef struct _BalanceControlWidget BalanceControlWidget; 46 typedef struct _EditableLabelWidget 47 EditableLabelWidget; 48 typedef struct _FaderButtonsWidget 49 FaderButtonsWidget; 50 typedef struct _ChannelSendsExpanderWidget 51 ChannelSendsExpanderWidget; 52 53 typedef struct _ChannelWidget 54 { 55 GtkEventBox parent_instance; 56 GtkGrid * grid; 57 RouteTargetSelectorWidget * output; 58 ColorAreaWidget * color; 59 GtkEventBox * icon_and_name_event_box; 60 EditableLabelWidget * name; 61 GtkBox * phase_controls; 62 GtkButton * phase_invert; 63 GtkLabel * phase_reading; 64 KnobWidget * phase_knob; 65 66 /** Instrument slot. */ 67 GtkBox * instrument_box; 68 ChannelSlotWidget * instrument_slot; 69 70 /* ----- mid box ------ */ 71 72 GtkBox * mid_box; 73 PluginStripExpanderWidget * inserts; 74 PluginStripExpanderWidget * midi_fx; 75 76 /** Sends. */ 77 ChannelSendsExpanderWidget * sends; 78 79 /* -------- end mid box --------- */ 80 81 FaderButtonsWidget * fader_buttons; 82 83 /** Meter area including reading. */ 84 GtkBox * meter_area; 85 GtkBox * balance_control_box; 86 BalanceControlWidget * balance_control; 87 FaderWidget * fader; 88 MeterWidget * meter_l; 89 MeterWidget * meter_r; 90 GtkLabel * meter_reading; 91 GtkImage * icon; 92 93 /** Cache. */ 94 double meter_reading_val; 95 96 /** Used for highlighting. */ 97 GtkBox * highlight_left_box; 98 GtkBox * highlight_right_box; 99 100 /** Box for auxiliary buttons near the top of the 101 * widget. */ 102 GtkBox * aux_buttons_box; 103 104 /** Mono compatibility button. */ 105 GtkToggleButton * mono_compat_btn; 106 107 /** Number of clicks, used when selecting/moving/ 108 * dragging channels. */ 109 int n_press; 110 111 /** Control held down on drag begin. */ 112 int ctrl_held_at_start; 113 114 /** If drag update was called at least once. */ 115 int dragged; 116 117 /** The track selection processing was done in 118 * the dnd callbacks, so no need to do it in 119 * drag_end. */ 120 int selected_in_dnd; 121 122 /** Pointer to owner Channel. */ 123 Channel * channel; 124 125 /** 126 * Last time a plugin was pressed. 127 * 128 * This is to detect when a channel was selected 129 * without clicking a plugin. 130 */ 131 gint64 last_plugin_press; 132 133 /** Last MIDI event trigger time, for MIDI 134 * output. */ 135 gint64 last_midi_trigger_time; 136 137 /** Whole channel press. */ 138 GtkGestureMultiPress * mp; 139 140 GtkGestureMultiPress * right_mouse_mp; 141 142 /** Drag on the icon and name event box. */ 143 GtkGestureDrag * drag; 144 145 bool setup; 146 } ChannelWidget; 147 148 /** 149 * Updates the inserts. 150 */ 151 void 152 channel_widget_update_midi_fx_and_inserts ( 153 ChannelWidget * self); 154 155 void 156 channel_widget_redraw_fader ( 157 ChannelWidget * self); 158 159 /** 160 * Creates a channel widget using the given channel 161 * data. 162 */ 163 ChannelWidget * 164 channel_widget_new ( 165 Channel * channel); 166 167 void 168 channel_widget_tear_down ( 169 ChannelWidget * self); 170 171 /** 172 * Updates the meter reading 173 */ 174 gboolean 175 channel_widget_update_meter_reading ( 176 ChannelWidget * widget, 177 GdkFrameClock * frame_clock, 178 gpointer user_data); 179 180 /** 181 * Updates everything on the widget. 182 * 183 * It is reduntant but keeps code organized. Should 184 * fix if it causes lags. 185 */ 186 void 187 channel_widget_refresh ( 188 ChannelWidget * self); 189 190 void 191 channel_widget_refresh_buttons ( 192 ChannelWidget * self); 193 194 /** 195 * Displays the widget. 196 */ 197 void 198 channel_widget_show ( 199 ChannelWidget * self); 200 201 #endif 202