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
14#include <stdbool.h>
15
16typedef struct ArrangerObject ArrangerObject;
17typedef struct Position Position;
18typedef struct AudioClip AudioClip;
19typedef struct UndoableAction UndoableAction;
21typedef struct ZRegion ZRegion;
22
29#define ARRANGER_SELECTIONS_MAGIC 35867752
30#define IS_ARRANGER_SELECTIONS(x) \
31 (((ArrangerSelections *) x)->magic == ARRANGER_SELECTIONS_MAGIC)
32#define IS_ARRANGER_SELECTIONS_AND_NONNULL(x) (x && IS_ARRANGER_SELECTIONS (x))
33#define ARRANGER_SELECTIONS(x) arranger_selections_cast (x)
34
35#define ARRANGER_SELECTIONS_DEFAULT_NUDGE_TICKS 0.1
36
37typedef enum ArrangerSelectionsType
38{
39 ARRANGER_SELECTIONS_TYPE_NONE,
40 ARRANGER_SELECTIONS_TYPE_CHORD,
41 ARRANGER_SELECTIONS_TYPE_TIMELINE,
42 ARRANGER_SELECTIONS_TYPE_MIDI,
43 ARRANGER_SELECTIONS_TYPE_AUTOMATION,
44 ARRANGER_SELECTIONS_TYPE_AUDIO,
45} ArrangerSelectionsType;
46
47static const char * arranger_selections_type_strings[] = {
48 "None", "Chord", "Timeline", "MIDI", "Automation", "Audio",
49};
50
51typedef struct ArrangerSelections
52{
54 ArrangerSelectionsType type;
55
56 int magic;
58
59typedef enum ArrangerSelectionsProperty
60{
61 ARRANGER_SELECTIONS_PROPERTY_HAS_LENGTH,
62 ARRANGER_SELECTIONS_PROPERTY_CAN_LOOP,
63 ARRANGER_SELECTIONS_PROPERTY_HAS_LOOPED,
64 ARRANGER_SELECTIONS_PROPERTY_CAN_FADE,
65} ArrangerSelectionsProperty;
66
67static inline const char *
68arranger_selections_type_to_str (const ArrangerSelections * self)
69{
70 return arranger_selections_type_strings[self->type];
71}
72
73static inline ArrangerSelections *
74arranger_selections_cast (void * sel)
75{
76 if (!IS_ARRANGER_SELECTIONS ((ArrangerSelections *) sel))
77 {
78 g_warning ("%s", __func__);
79 }
80 return (ArrangerSelections *) sel;
81}
82
93 ArrangerSelections * self,
94 bool project,
95 UndoableAction * action);
96
100NONNULL void
101arranger_selections_init (ArrangerSelections * self, ArrangerSelectionsType type);
102
107arranger_selections_new (ArrangerSelectionsType type);
108
112NONNULL bool
114
118NONNULL void
120
125NONNULL void
127 ArrangerSelections * dest,
128 ArrangerSelections * src);
129
139NONNULL void
141
142NONNULL void
143arranger_selections_sort_by_positions (ArrangerSelections * self, int desc);
144
148NONNULL ArrangerSelections *
150
154NONNULL bool
156
166NONNULL void
168 const ArrangerSelections * self,
169 Position * pos,
170 const bool global);
171
180NONNULL void
182 ArrangerSelections * self,
183 Position * pos,
184 int global);
185
189NONNULL int
191
195NONNULL ArrangerObject *
197
204NONNULL ArrangerObject *
206 const ArrangerSelections * self,
207 bool ends_last);
208
213NONNULL void
215 ArrangerSelections * self,
216 Position * pos,
217 bool undoable);
218
222NONNULL void
224 const ArrangerSelections * self,
225 GPtrArray * arr);
226
227#if 0
231NONNULL
232void
233arranger_selections_redraw (
234 ArrangerSelections * self);
235#endif
236
244void
246 ArrangerSelections * self,
247 ZRegion * region,
248 bool clone);
249
256NONNULL void
258
263NONNULL bool
265
269NONNULL void
271
275NONNULL void
276arranger_selections_clear (ArrangerSelections * self, bool free, bool fire_events);
277
281NONNULL void
283
284NONNULL bool
285arranger_selections_validate (ArrangerSelections * self);
286
291NONNULL void
293
297NONNULL void
299
306NONNULL void
308
316NONNULL int
318 ArrangerSelections * self,
319 ArrangerObject * obj);
320
325NONNULL bool
327 const ArrangerSelections * self);
328
333NONNULL bool
335
336NONNULL bool
337arranger_selections_contains_unrenamable_object (
338 const ArrangerSelections * self);
339
349NONNULL bool
351 ArrangerSelections * self,
352 ArrangerSelectionsProperty property,
353 bool value);
354
358NONNULL void
360 ArrangerSelections * self,
361 ArrangerObject * obj);
362
368NONNULL void
370
374NONNULL bool
376
377NONNULL bool
378arranger_selections_contains_looped (ArrangerSelections * self);
379
380NONNULL bool
381arranger_selections_can_be_merged (ArrangerSelections * self);
382
383NONNULL double
384arranger_selections_get_length_in_ticks (ArrangerSelections * self);
385
386NONNULL bool
387arranger_selections_contains_clip (ArrangerSelections * self, AudioClip * clip);
388
389NONNULL bool
390arranger_selections_can_split_at_pos (
391 const ArrangerSelections * self,
392 const Position * pos);
393
394NONNULL ArrangerSelections *
395arranger_selections_get_for_type (ArrangerSelectionsType type);
396
401#endif
ArrangerSelectionsActionEditType
Type used when the action is an EDIT action.
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.
void arranger_selections_add_to_region(ArrangerSelections *self, ZRegion *region, bool clone)
Adds each object in the selection to the given region (if applicable).
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.
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:33
A Position is made up of bars.beats.sixteenths.ticks.
Definition position.h:129
Base struct to be inherited by implementing undoable actions.
A region (clip) is an object on the timeline that contains either MidiNote's or AudioClip's.
Definition region.h:77