Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
arranger_selections.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2019-2023 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
11#ifndef __GUI_BACKEND_ARRANGER_SELECTIONS_H__
12#define __GUI_BACKEND_ARRANGER_SELECTIONS_H__
13
14typedef struct ArrangerObject ArrangerObject;
15typedef struct Position Position;
16typedef struct AudioClip AudioClip;
17typedef struct UndoableAction UndoableAction;
18typedef struct Region Region;
19
26#define ARRANGER_SELECTIONS_MAGIC 35867752
27#define IS_ARRANGER_SELECTIONS(x) \
28 (((ArrangerSelections *) x)->magic == ARRANGER_SELECTIONS_MAGIC)
29#define IS_ARRANGER_SELECTIONS_AND_NONNULL(x) (x && IS_ARRANGER_SELECTIONS (x))
30#define ARRANGER_SELECTIONS(x) arranger_selections_cast (x)
31
32#define ARRANGER_SELECTIONS_DEFAULT_NUDGE_TICKS 0.1
33
34enum class ArrangerSelectionsType
35{
36 ARRANGER_SELECTIONS_TYPE_NONE,
37 ARRANGER_SELECTIONS_TYPE_CHORD,
38 ARRANGER_SELECTIONS_TYPE_TIMELINE,
39 ARRANGER_SELECTIONS_TYPE_MIDI,
40 ARRANGER_SELECTIONS_TYPE_AUTOMATION,
41 ARRANGER_SELECTIONS_TYPE_AUDIO,
42};
43
44static const char * arranger_selections_type_strings[] = {
45 "None", "Chord", "Timeline", "MIDI", "Automation", "Audio",
46};
47
48typedef struct ArrangerSelections
49{
51 ArrangerSelectionsType type;
52
53 int magic;
55
56enum class ArrangerSelectionsProperty
57{
58 ARRANGER_SELECTIONS_PROPERTY_HAS_LENGTH,
59 ARRANGER_SELECTIONS_PROPERTY_CAN_LOOP,
60 ARRANGER_SELECTIONS_PROPERTY_HAS_LOOPED,
61 ARRANGER_SELECTIONS_PROPERTY_CAN_FADE,
62};
63
64static inline const char *
65arranger_selections_type_to_str (const ArrangerSelections * self)
66{
67 return arranger_selections_type_strings[static_cast<int> (self->type)];
68}
69
70static inline ArrangerSelections *
71arranger_selections_cast (void * sel)
72{
73 if (!IS_ARRANGER_SELECTIONS ((ArrangerSelections *) sel))
74 {
75 g_warning ("%s", __func__);
76 }
77 return (ArrangerSelections *) sel;
78}
79
90 ArrangerSelections * self,
91 bool project,
92 UndoableAction * action);
93
97NONNULL void
98arranger_selections_init (ArrangerSelections * self, ArrangerSelectionsType type);
99
104arranger_selections_new (ArrangerSelectionsType type);
105
109NONNULL bool
111
115NONNULL void
117
122NONNULL void
124 ArrangerSelections * dest,
125 ArrangerSelections * src);
126
136NONNULL void
138
139NONNULL void
140arranger_selections_sort_by_positions (ArrangerSelections * self, int desc);
141
145NONNULL ArrangerSelections *
147
151NONNULL bool
153
163NONNULL void
165 const ArrangerSelections * self,
166 Position * pos,
167 const bool global);
168
177NONNULL void
179 ArrangerSelections * self,
180 Position * pos,
181 int global);
182
186NONNULL int
188
192NONNULL ArrangerObject *
194
201NONNULL ArrangerObject *
203 const ArrangerSelections * self,
204 bool ends_last);
205
210NONNULL void
212 ArrangerSelections * self,
213 Position * pos,
214 bool undoable);
215
219NONNULL void
221 const ArrangerSelections * self,
222 GPtrArray * arr);
223
224#if 0
228NONNULL
229void
230arranger_selections_redraw (
231 ArrangerSelections * self);
232#endif
233
241void
243 ArrangerSelections * self,
244 Region * region,
245 bool clone);
246
253NONNULL void
255
260NONNULL bool
262
266NONNULL void
268
272NONNULL void
273arranger_selections_clear (ArrangerSelections * self, bool free, bool fire_events);
274
278NONNULL void
280
281NONNULL bool
282arranger_selections_validate (ArrangerSelections * self);
283
288NONNULL void
290
294NONNULL void
296
303NONNULL void
305
313NONNULL int
315 ArrangerSelections * self,
316 ArrangerObject * obj);
317
322NONNULL bool
324 const ArrangerSelections * self);
325
330NONNULL bool
332
333NONNULL bool
334arranger_selections_contains_unrenamable_object (
335 const ArrangerSelections * self);
336
346NONNULL bool
348 ArrangerSelections * self,
349 ArrangerSelectionsProperty property,
350 bool value);
351
355NONNULL void
357 ArrangerSelections * self,
358 ArrangerObject * obj);
359
365NONNULL void
367
371NONNULL bool
373
374NONNULL bool
375arranger_selections_contains_looped (ArrangerSelections * self);
376
377NONNULL bool
378arranger_selections_can_be_merged (ArrangerSelections * self);
379
380NONNULL double
381arranger_selections_get_length_in_ticks (ArrangerSelections * self);
382
383NONNULL bool
384arranger_selections_contains_clip (ArrangerSelections * self, AudioClip * clip);
385
386NONNULL bool
387arranger_selections_can_split_at_pos (
388 const ArrangerSelections * self,
389 const Position * pos);
390
391NONNULL ArrangerSelections *
392arranger_selections_get_for_type (ArrangerSelectionsType type);
393
398#endif
NONNULL_ARGS(1) int undo_manager_undo(UndoManager *self
Undo last action.
NONNULL bool arranger_selections_contains_object_with_property(ArrangerSelections *self, ArrangerSelectionsProperty property, bool value)
Checks whether an object matches the given parameters.
NONNULL void arranger_selections_remove_object(ArrangerSelections *self, ArrangerObject *obj)
Removes the arranger object from the selections.
NONNULL void arranger_selections_add_ticks(ArrangerSelections *self, const double ticks)
Moves the selections by the given amount of ticks.
NONNULL void arranger_selections_merge(ArrangerSelections *self)
Merges the given selections into one region.
NONNULL void arranger_selections_set_from_selections(ArrangerSelections *dest, ArrangerSelections *src)
Sets the values of each object in the dest selections to the values in the src selections.
NONNULL bool arranger_selections_verify(ArrangerSelections *self)
Verify that the objects are not invalid.
NONNULL void arranger_selections_post_deserialize(ArrangerSelections *self)
Code to run after deserializing.
NONNULL void arranger_selections_free_members(ArrangerSelections *self)
Frees anything allocated by the selections but not the objects or self itself.
NONNULL void arranger_selections_get_all_objects(const ArrangerSelections *self, GPtrArray *arr)
Appends all objects in the given array.
NONNULL ArrangerObject * arranger_selections_get_last_object(const ArrangerSelections *self, bool ends_last)
Gets last object.
NONNULL bool arranger_selections_all_on_same_lane(ArrangerSelections *self)
Returns whether all the selections are on the same lane (track lane or automation lane).
NONNULL void arranger_selections_get_start_pos(const ArrangerSelections *self, Position *pos, const bool global)
Returns the position of the leftmost object.
NONNULL void arranger_selections_free(ArrangerSelections *self)
Frees the selections but not the objects.
NONNULL void arranger_selections_add_object(ArrangerSelections *self, ArrangerObject *obj)
Appends the given object to the selections.
NONNULL void arranger_selections_init(ArrangerSelections *self, ArrangerSelectionsType type)
Initializes the selections.
NONNULL int arranger_selections_get_num_objects(const ArrangerSelections *self)
Returns the number of selected objects.
NONNULL bool arranger_selections_can_be_pasted(ArrangerSelections *self)
Returns if the selections can be pasted.
void arranger_selections_add_to_region(ArrangerSelections *self, Region *region, bool clone)
Adds each object in the selection to the given region (if applicable).
NONNULL int arranger_selections_contains_object(ArrangerSelections *self, ArrangerObject *obj)
Returns if the arranger object is in the selections or not.
NONNULL void arranger_selections_paste_to_pos(ArrangerSelections *self, Position *pos, bool undoable)
Pastes the given selections to the given Position.
NONNULL void arranger_selections_select_all(ArrangerSelections *self, bool fire_events)
Selects all possible objects from the project.
NONNULL void arranger_selections_free_full(ArrangerSelections *self)
Frees all the objects as well.
NONNULL void arranger_selections_clear(ArrangerSelections *self, bool free, bool fire_events)
Clears selections.
NONNULL ArrangerObject * arranger_selections_get_first_object(const ArrangerSelections *self)
Gets first object.
NONNULL bool arranger_selections_contains_unclonable_object(const ArrangerSelections *self)
Returns if the selections contain an unclonable object (such as the start marker).
NONNULL void arranger_selections_sort_by_indices(ArrangerSelections *sel, int desc)
Sorts the selections by their indices (eg, for regions, their track indices, then the lane indices,...
NONNULL bool arranger_selections_has_any(ArrangerSelections *self)
Returns if there are any selections.
ArrangerSelections * arranger_selections_new(ArrangerSelectionsType type)
Creates new arranger selections.
NONNULL bool arranger_selections_contains_undeletable_object(const ArrangerSelections *self)
Returns if the selections contain an undeletable object (such as the start marker).
void arranger_selections_init_loaded(ArrangerSelections *self, bool project, UndoableAction *action)
Inits the selections after loading a project.
NONNULL void arranger_selections_get_end_pos(ArrangerSelections *self, Position *pos, int global)
Returns the end position of the rightmost object.
NONNULL ArrangerSelections * arranger_selections_clone(const ArrangerSelections *self)
Clone the struct for copying, undoing, etc.
Base struct for arranger objects.
ArrangerSelectionsType type
Type of selections.
Audio clips for the pool.
Definition clip.h:31
A Position is made up of bars.beats.sixteenths.ticks.
Definition position.h:124
A region (clip) is an object on the timeline that contains either MidiNote's or AudioClip's.
Definition region.h:72
Base struct to be inherited by implementing undoable actions.