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 #include "audio/channel.h"
21 #include "audio/track.h"
22 #include "gui/widgets/channel_slot.h"
23 #include "gui/widgets/fader_controls_expander.h"
24 #include "gui/widgets/fader_controls_grid.h"
25 #include "project.h"
26 #include "utils/gtk.h"
27 
28 #include <gtk/gtk.h>
29 #include <glib/gi18n.h>
30 
31 #define FADER_CONTROLS_EXPANDER_WIDGET_TYPE \
32   (fader_controls_expander_widget_get_type ())
G_DEFINE_TYPE(FaderControlsExpanderWidget,fader_controls_expander_widget,EXPANDER_BOX_WIDGET_TYPE)33 G_DEFINE_TYPE (
34   FaderControlsExpanderWidget,
35   fader_controls_expander_widget,
36   EXPANDER_BOX_WIDGET_TYPE)
37 
38 /**
39  * Refreshes each field.
40  */
41 void
42 fader_controls_expander_widget_refresh (
43   FaderControlsExpanderWidget * self)
44 {
45 }
46 
47 /**
48  * Sets up the FaderControlsExpanderWidget.
49  */
50 void
fader_controls_expander_widget_setup(FaderControlsExpanderWidget * self,Track * track)51 fader_controls_expander_widget_setup (
52   FaderControlsExpanderWidget * self,
53   Track *                     track)
54 {
55   /* set name and icon */
56   expander_box_widget_set_label (
57     Z_EXPANDER_BOX_WIDGET (self),
58     _("Fader"));
59 
60   self->track = track;
61 
62   fader_controls_grid_widget_setup (
63     self->grid, track);
64 
65   fader_controls_expander_widget_refresh (self);
66 }
67 
68 /**
69  * Prepare for finalization.
70  */
71 void
fader_controls_expander_widget_tear_down(FaderControlsExpanderWidget * self)72 fader_controls_expander_widget_tear_down (
73   FaderControlsExpanderWidget * self)
74 {
75   fader_controls_grid_widget_tear_down (self->grid);
76 }
77 
78 static void
fader_controls_expander_widget_class_init(FaderControlsExpanderWidgetClass * klass)79 fader_controls_expander_widget_class_init (
80   FaderControlsExpanderWidgetClass * klass)
81 {
82 }
83 
84 static void
fader_controls_expander_widget_init(FaderControlsExpanderWidget * self)85 fader_controls_expander_widget_init (
86   FaderControlsExpanderWidget * self)
87 {
88   self->grid =
89     fader_controls_grid_widget_new ();
90   gtk_widget_set_visible (
91     GTK_WIDGET (self->grid), 1);
92 
93   expander_box_widget_add_content (
94     Z_EXPANDER_BOX_WIDGET (self),
95     GTK_WIDGET (self->grid));
96 
97   expander_box_widget_set_icon_name (
98     Z_EXPANDER_BOX_WIDGET (self), "fader");
99 
100   /* add css classes */
101   GtkStyleContext * context =
102     gtk_widget_get_style_context (
103       GTK_WIDGET (self));
104   gtk_style_context_add_class (
105     context, "fader-controls-expander");
106 }
107