1 /*
2  * Copyright (C) 2020-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 /**
21  * \file
22  *
23  * Clipboard (copy/paste).
24  */
25 
26 #ifndef __GUI_BACKEND_CLIPBOARD_H__
27 #define __GUI_BACKEND_CLIPBOARD_H__
28 
29 #include "gui/backend/automation_selections.h"
30 #include "gui/backend/chord_selections.h"
31 #include "gui/backend/midi_arranger_selections.h"
32 #include "gui/backend/mixer_selections.h"
33 #include "gui/backend/timeline_selections.h"
34 #include "utils/yaml.h"
35 
36 #include <gtk/gtk.h>
37 
38 /**
39  * @addtogroup gui_backend
40  */
41 
42 /**
43  * Clipboard type.
44  */
45 typedef enum ClipboardType
46 {
47   CLIPBOARD_TYPE_TIMELINE_SELECTIONS,
48   CLIPBOARD_TYPE_MIDI_SELECTIONS,
49   CLIPBOARD_TYPE_AUTOMATION_SELECTIONS,
50   CLIPBOARD_TYPE_CHORD_SELECTIONS,
51   CLIPBOARD_TYPE_MIXER_SELECTIONS,
52 } ClipboardType;
53 
54 static const cyaml_strval_t
55 clipboard_type_strings[] =
56 {
57   { "Timeline selections",
58     CLIPBOARD_TYPE_TIMELINE_SELECTIONS },
59   { "MIDI selections",
60     CLIPBOARD_TYPE_MIDI_SELECTIONS },
61   { "Automation selections",
62     CLIPBOARD_TYPE_AUTOMATION_SELECTIONS },
63   { "Chord selections",
64     CLIPBOARD_TYPE_CHORD_SELECTIONS },
65   { "Mixer selections",
66     CLIPBOARD_TYPE_MIXER_SELECTIONS },
67 };
68 
69 /**
70  * Clipboard struct.
71  */
72 typedef struct Clipboard
73 {
74   ClipboardType            type;
75   TimelineSelections *     timeline_sel;
76   MidiArrangerSelections * ma_sel;
77   ChordSelections *        chord_sel;
78   AutomationSelections *   automation_sel;
79   MixerSelections *        mixer_sel;
80 } Clipboard;
81 
82 static const cyaml_schema_field_t
83   clipboard_fields_schema[] =
84 {
85   YAML_FIELD_ENUM (
86     Clipboard, type, clipboard_type_strings),
87   YAML_FIELD_MAPPING_PTR_OPTIONAL (
88     Clipboard, timeline_sel,
89     timeline_selections_fields_schema),
90   YAML_FIELD_MAPPING_PTR_OPTIONAL (
91     Clipboard, ma_sel,
92     midi_arranger_selections_fields_schema),
93   YAML_FIELD_MAPPING_PTR_OPTIONAL (
94     Clipboard, chord_sel,
95     chord_selections_fields_schema),
96   YAML_FIELD_MAPPING_PTR_OPTIONAL (
97     Clipboard, automation_sel,
98     automation_selections_fields_schema),
99   YAML_FIELD_MAPPING_PTR_OPTIONAL (
100     Clipboard, mixer_sel,
101     mixer_selections_fields_schema),
102 
103   CYAML_FIELD_END
104 };
105 
106 static const cyaml_schema_value_t
107   clipboard_schema =
108 {
109   YAML_VALUE_PTR (
110     Clipboard, clipboard_fields_schema),
111 };
112 
113 /**
114  * Creates a new Clipboard instance for the given
115  * arranger selections.
116  */
117 Clipboard *
118 clipboard_new_for_arranger_selections (
119   ArrangerSelections * sel,
120   bool                 clone);
121 
122 Clipboard *
123 clipboard_new_for_mixer_selections (
124   MixerSelections * sel,
125   bool              clone);
126 
127 /**
128  * Gets the ArrangerSelections, if this clipboard
129  * contains arranger selections.
130  */
131 ArrangerSelections *
132 clipboard_get_selections (
133   Clipboard * self);
134 
135 /**
136  * Frees the clipboard and all associated data.
137  */
138 void
139 clipboard_free (
140   Clipboard * self);
141 
142 /**
143  * @}
144  */
145 
146 #endif
147