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  * Channel slot.
24  */
25 
26 #ifndef __GUI_WIDGETS_CHANNEL_SLOT_H__
27 #define __GUI_WIDGETS_CHANNEL_SLOT_H__
28 
29 #include <gtk/gtk.h>
30 
31 #define CHANNEL_SLOT_WIDGET_TYPE \
32   (channel_slot_widget_get_type ())
33 G_DECLARE_FINAL_TYPE (
34   ChannelSlotWidget,
35   channel_slot_widget,
36   Z, CHANNEL_SLOT_WIDGET,
37   GtkDrawingArea)
38 
39 typedef struct Plugin Plugin;
40 typedef struct Channel Channel;
41 
42 /**
43  * @addtogroup widgets
44  *
45  * @{
46  */
47 
48 typedef struct _ChannelSlotWidget
49 {
50   GtkDrawingArea       parent_instance;
51 
52   PluginSlotType      type;
53 
54   /** The Track this belongs to. */
55   Track *             track;
56 
57   /** The Channel slot index. */
58   int                  slot_index;
59   GtkGestureMultiPress * multipress;
60   GtkGestureDrag *     drag;
61 
62   /**
63    * Previous plugin name at
64    * this slot in the last draw callback, or NULL.
65    *
66    * If this changes, the tooltip is changed.
67    */
68   char *               pl_name;
69 
70   /** For multipress. */
71   int                  n_press;
72 
73   GtkGestureMultiPress * right_mouse_mp;
74 
75   /** Layout cache for empty slot. */
76   PangoLayout *        empty_slot_layout;
77   /** Layout cache for plugin name. */
78   PangoLayout *        pl_name_layout;
79 
80   /** Cache to check if the selection state was
81    * changed. */
82   bool                 was_selected;
83 
84   /** Whether to open the plugin inspector on click
85    * or not. */
86   bool                 open_plugin_inspector_on_click;
87 } ChannelSlotWidget;
88 
89 /**
90  * Creates a new ChannelSlot widget whose track
91  * and plugin can change.
92  */
93 ChannelSlotWidget *
94 channel_slot_widget_new_instrument (void);
95 
96 /**
97  * Creates a new ChannelSlot widget and binds it to
98  * the given value.
99  */
100 ChannelSlotWidget *
101 channel_slot_widget_new (
102   int       slot_index,
103   Track *   track,
104   PluginSlotType type,
105   bool      open_plugin_inspector_on_click);
106 
107 void
108 channel_slot_widget_set_instrument (
109   ChannelSlotWidget * self,
110   Track *             track);
111 
112 /**
113  * Sets or unsets state flags and redraws the
114  * widget.
115  *
116  * @param set True to set, false to unset.
117  */
118 void
119 channel_slot_widget_set_state_flags (
120   ChannelSlotWidget * self,
121   GtkStateFlags       flags,
122   bool                set);
123 
124 /**
125  * @}
126  */
127 
128 #endif
129