10#ifndef __GUI_BACKEND_ARRANGER_OBJECT_H__
11#define __GUI_BACKEND_ARRANGER_OBJECT_H__
18#include <glib/gi18n.h>
23typedef struct _ArrangerObjectWidget ArrangerObjectWidget;
33#define ARRANGER_OBJECT_MAGIC 347616554
34#define IS_ARRANGER_OBJECT(tr) \
35 (((ArrangerObject *) tr)->magic == ARRANGER_OBJECT_MAGIC \
36 && ((ArrangerObject *) tr)->type \
37 >= ArrangerObjectType::ARRANGER_OBJECT_TYPE_REGION \
38 && ((ArrangerObject *) tr)->type \
39 <= ArrangerObjectType::ARRANGER_OBJECT_TYPE_VELOCITY)
40#define IS_ARRANGER_OBJECT_AND_NONNULL(x) (x && IS_ARRANGER_OBJECT (x))
47 ARRANGER_OBJECT_RESIZE_NORMAL,
48 ARRANGER_OBJECT_RESIZE_LOOP,
49 ARRANGER_OBJECT_RESIZE_FADE,
50 ARRANGER_OBJECT_RESIZE_STRETCH,
67 ARRANGER_OBJECT_TYPE_NONE,
68 ARRANGER_OBJECT_TYPE_ALL,
70 ARRANGER_OBJECT_TYPE_REGION,
71 ARRANGER_OBJECT_TYPE_MIDI_NOTE,
72 ARRANGER_OBJECT_TYPE_CHORD_OBJECT,
73 ARRANGER_OBJECT_TYPE_SCALE_OBJECT,
74 ARRANGER_OBJECT_TYPE_MARKER,
75 ARRANGER_OBJECT_TYPE_AUTOMATION_POINT,
76 ARRANGER_OBJECT_TYPE_VELOCITY,
79static const char * arranger_object_type_strings[] = {
80 N_ (
"None"), N_ (
"All"),
81 N_ (
"Region"), N_ (
"Midi Note"),
82 N_ (
"Chord Object"), N_ (
"Scale Object"),
83 N_ (
"Marker"), N_ (
"Automation Point"),
100enum class ArrangerObjectPositionType
102 ARRANGER_OBJECT_POSITION_TYPE_START,
103 ARRANGER_OBJECT_POSITION_TYPE_END,
104 ARRANGER_OBJECT_POSITION_TYPE_CLIP_START,
105 ARRANGER_OBJECT_POSITION_TYPE_LOOP_START,
106 ARRANGER_OBJECT_POSITION_TYPE_LOOP_END,
107 ARRANGER_OBJECT_POSITION_TYPE_FADE_IN,
108 ARRANGER_OBJECT_POSITION_TYPE_FADE_OUT,
271#define arranger_object_type_has_length(type) \
272 (type == ArrangerObjectType::ARRANGER_OBJECT_TYPE_REGION \
273 || type == ArrangerObjectType::ARRANGER_OBJECT_TYPE_MIDI_NOTE)
278#define arranger_object_type_has_global_pos(type) \
279 (type == ArrangerObjectType::ARRANGER_OBJECT_TYPE_REGION \
280 || type == ArrangerObjectType::ARRANGER_OBJECT_TYPE_SCALE_OBJECT \
281 || type == ArrangerObjectType::ARRANGER_OBJECT_TYPE_MARKER)
283#define arranger_object_type_has_name(type) \
284 (type == ArrangerObjectType::ARRANGER_OBJECT_TYPE_REGION \
285 || type == ArrangerObjectType::ARRANGER_OBJECT_TYPE_MARKER)
290#define arranger_object_can_have_lanes(_obj) \
291 ((_obj)->type == ArrangerObjectType::ARRANGER_OBJECT_TYPE_REGION \
292 && region_type_has_lane (((Region *) _obj)->id.type))
295#define arranger_object_type_can_loop(type) \
296 (type == ArrangerObjectType::ARRANGER_OBJECT_TYPE_REGION)
298#define arranger_object_can_fade(_obj) \
299 ((_obj)->type == ArrangerObjectType::ARRANGER_OBJECT_TYPE_REGION \
300 && region_type_can_fade (((Region *) _obj)->id.type))
302#define arranger_object_can_mute(_obj) \
303 ((_obj)->type == ArrangerObjectType::ARRANGER_OBJECT_TYPE_REGION \
304 || (_obj)->type == ArrangerObjectType::ARRANGER_OBJECT_TYPE_MIDI_NOTE)
306#define arranger_object_owned_by_region(_obj) \
307 ((_obj)->type == ArrangerObjectType::ARRANGER_OBJECT_TYPE_VELOCITY \
308 || (_obj)->type == ArrangerObjectType::ARRANGER_OBJECT_TYPE_MIDI_NOTE \
309 || (_obj)->type == ArrangerObjectType::ARRANGER_OBJECT_TYPE_CHORD_OBJECT \
310 || (_obj)->type == ArrangerObjectType::ARRANGER_OBJECT_TYPE_AUTOMATION_POINT)
315#define arranger_object_can_cache_drawing(_obj) (false)
318 ((_obj)->type == ArrangerObjectType::ARRANGER_OBJECT_TYPE_REGION && \
320 ((
Region *) _obj)->id.type))
507arranger_object_get_position_from_type (
510 ArrangerObjectPositionType type);
531arranger_object_edit_position_finish (const
ArrangerObject * self);
580HOT NONNULL WARN_UNUSED_RESULT
bool
584 ArrangerObjectPositionType pos_type);
586#define arranger_object_validate_pos arranger_object_is_position_valid
603 ArrangerObjectPositionType pos_type,
604 const bool validate);
631NONNULL WARN_UNUSED_RESULT
static inline double
632arranger_object_get_length_in_ticks (
const ArrangerObject *
const self)
646arranger_object_get_length_in_frames (
const ArrangerObject *
const self)
656NONNULL
static inline double
657arranger_object_get_loop_length_in_ticks (
const ArrangerObject *
const self)
668arranger_object_get_loop_length_in_frames (
const ArrangerObject *
const self)
707WARN_UNUSED_RESULT
bool
713 bool during_ui_action,
717arranger_object_append_children (
ArrangerObject * self, GPtrArray * children);
728#define _ARRANGER_OBJECT_FREE_AND_SET_STRING(_obj, _val_name, _val_value) \
729 g_free_and_null (_obj->_val_name); \
730 _obj->_val_name = g_strdup (_val_value)
740#define arranger_object_set_string(cc, obj, val_name, val_value) \
742 cc * _obj = (cc *) obj; \
743 _ARRANGER_OBJECT_FREE_AND_SET_STRING (_obj, val_name, val_value); \
752static inline const char *
755 return arranger_object_type_strings[
static_cast<int> (type)];
815WARN_UNUSED_RESULT
bool
819 const bool pos_is_local,
843arranger_object_set_name (
878WARN_UNUSED_RESULT
NONNULL_ARGS (1)
bool arranger_object_add_to_project (
894WARN_UNUSED_RESULT
bool
ArrangerSelectionsActionEditType
Type used when the action is an EDIT action.
#define region_type_can_fade(rtype)
Returns if the given Region type can have fades.
void arranger_object_set_start_pos_full_size(ArrangerObject *obj, Position *pos)
Sets the end position of the ArrangerObject and also sets the loop end and fade out so that they are ...
ArrangerObject * arranger_object_clone(const ArrangerObject *self)
Clones the ArrangerObject.
void arranger_object_loop_end_pos_setter(ArrangerObject *self, const Position *pos)
The setter is for use in e.g.
void arranger_object_get_end_pos(const ArrangerObject *self, Position *pos)
Getter.
void arranger_object_pos_setter(ArrangerObject *self, const Position *pos)
The setter is for use in e.g.
void arranger_object_free(ArrangerObject *self)
Frees only this object.
void arranger_object_select(ArrangerObject *self, const bool select, const bool append, bool fire_events)
Selects the object by adding it to its corresponding selections or making it the only selection.
HOT NONNULL WARN_UNUSED_RESULT bool arranger_object_is_position_valid(const ArrangerObject *const self, const Position *pos, ArrangerObjectPositionType pos_type)
Returns if the given Position is valid.
WARN_UNUSED_RESULT bool arranger_object_insert_to_project(ArrangerObject *obj, GError **error)
Inserts the ArrangerObject where it belongs in the project (eg, a Track).
bool arranger_object_is_deletable(const ArrangerObject *obj)
Returns whether the given object is deletable or not (eg, start marker).
void arranger_object_set_to_object(ArrangerObject *dest, ArrangerObject *src)
Sets the dest object's values to the main src object's values.
void arranger_object_get_clip_start_pos(const ArrangerObject *self, Position *pos)
Getter.
ArrangerObject * arranger_object_get_object(ArrangerObject *self)
Gets the object the ArrangerObjectInfo represents.
WARN_UNUSED_RESULT bool arranger_object_is_hit(const ArrangerObject *self, const Position *start, const Position *end)
Returns whether the given object is hit by the given position or range.
void arranger_object_remove_child(ArrangerObject *self, ArrangerObject *child)
Removes the child from the given object.
void arranger_object_set_name_with_action(ArrangerObject *self, const char *name)
Changes the name and adds an action to the undo stack.
void arranger_object_edit_finish(const ArrangerObject *self, ArrangerSelectionsActionEditType type)
Callback when finishing editing the object.
void arranger_object_get_pos(const ArrangerObject *self, Position *pos)
Getter.
WARN_UNUSED_RESULT bool arranger_object_split(ArrangerObject *self, const Position *pos, const bool pos_is_local, ArrangerObject **r1, ArrangerObject **r2, bool is_project, GError **error)
Splits the given object at the given Position.
void arranger_object_get_fade_in_pos(const ArrangerObject *self, Position *pos)
Getter.
ArrangerSelections * arranger_object_get_selections_for_type(ArrangerObjectType type)
Returns the ArrangerSelections corresponding to the given object type.
NONNULL void arranger_object_print(const ArrangerObject *self)
Prints debug information about the given object.
void arranger_object_move(ArrangerObject *self, const double ticks)
Moves the object by the given amount of ticks.
void arranger_object_get_fade_out_pos(const ArrangerObject *self, Position *pos)
Getter.
void arranger_object_set_magic(ArrangerObject *self)
Sets the magic on the arranger object.
char * arranger_object_gen_human_readable_name(const ArrangerObject *self)
Generates a human readable name for the object.
void arranger_object_get_loop_start_pos(const ArrangerObject *self, Position *pos)
Getter.
void arranger_object_update_positions(ArrangerObject *self, bool from_ticks, bool bpm_change, UndoableAction *action)
Updates the positions in each child recursively.
void arranger_object_add_ticks_to_children(ArrangerObject *self, const double ticks)
Adds the given ticks to each included object.
void arranger_object_edit_begin(const ArrangerObject *self)
Callback when beginning to edit the object.
ArrangerObjectFlags
ArrangerObject flags.
void arranger_object_set_muted(ArrangerObject *self, bool muted, bool fire_events)
Sets the mute status of the object.
bool arranger_object_validate_name(ArrangerObject *self, const char *name)
Validates the given name.
void arranger_object_get_loop_end_pos(const ArrangerObject *self, Position *pos)
Getter.
#define arranger_object_type_has_length(type)
Returns if the object type has a length.
void arranger_object_set_end_pos_full_size(ArrangerObject *obj, Position *pos)
Sets the end position of the ArrangerObject and also sets the loop end and fade out to that position.
HOT Region * arranger_object_get_region(const ArrangerObject *const self)
If the object is part of a Region, returns it, otherwise returns NULL.
bool arranger_object_is_selected(ArrangerObject *self)
Returns if the object is in the selections.
void arranger_object_init_loaded(ArrangerObject *self)
Initializes the object after loading a Project.
bool arranger_object_set_position(ArrangerObject *self, const Position *pos, ArrangerObjectPositionType pos_type, const bool validate)
Sets the given position on the object, optionally attempting to validate before.
void arranger_object_clip_start_pos_setter(ArrangerObject *self, const Position *pos)
The setter is for use in e.g.
void arranger_object_remove_from_project(ArrangerObject *obj)
Removes the object from its parent in the project.
ArrangerObjectType
The type of the object.
const char * arranger_object_get_name(const ArrangerObject *self)
Returns a pointer to the name of the object, if the object can have names.
ArrangerObjectResizeType
Flag used in some functions.
NONNULL bool arranger_object_get_muted(ArrangerObject *self, bool check_parent)
Gets the mute status of the object.
void arranger_object_copy_identifier(ArrangerObject *dest, ArrangerObject *src)
Copies the identifier from src to dest.
void arranger_object_loop_start_pos_setter(ArrangerObject *self, const Position *pos)
The setter is for use in e.g.
bool arranger_object_validate(const ArrangerObject *const self)
Validates the arranger object.
bool arranger_object_is_frozen(ArrangerObject *obj)
Returns whether the arranger object is part of a frozen track.
void arranger_object_gen_escaped_name(const ArrangerObject *self)
Generates the escaped name for the object, where applicable.
WARN_UNUSED_RESULT NONNULL_ARGS(1, 2) bool arranger_object_unsplit(ArrangerObject *r1
Undoes what arranger_object_split() did.
ArrangerObject * arranger_object_find(ArrangerObject *obj)
Returns the ArrangerObject matching the given one.
WARN_UNUSED_RESULT bool arranger_object_resize(ArrangerObject *self, const bool left, ArrangerObjectResizeType type, const double ticks, bool during_ui_action, GError **error)
Resizes the object on the left side or right side by given amount of ticks, for objects that do not h...
HOT NONNULL Track * arranger_object_get_track(const ArrangerObject *const self)
Returns the Track this ArrangerObject is in.
int arranger_object_get_num_loops(ArrangerObject *self, const int count_incomplete)
Returns the number of loops in the ArrangerObject, optionally including incomplete ones.
void arranger_object_end_pos_setter(ArrangerObject *self, const Position *pos)
The setter is for use in e.g.
ArrangerWidget * arranger_object_get_arranger(const ArrangerObject *self)
Gets the arranger for this arranger object.
@ ARRANGER_OBJECT_FLAG_NON_PROJECT
This object is not a project object, but an object used temporarily eg.
@ ARRANGER_OBJECT_RESIZE_STRETCH_BPM_CHANGE
Used when we want to resize to contents when BPM changes.
int_fast64_t signed_frame_t
Signed type for frame index.
Base struct for arranger objects.
ArrangerObjectFlags flags
Flags.
Position fade_in_pos
Fade in position, relative to the object's start.
bool deleted_temporarily
Whether deleted with delete tool.
RegionIdentifier region_id
Parent region identifier for objects that are part of a region.
bool muted
Whether muted or not (if applicable).
Position loop_start_pos
Loop start Position, if the object has one, relative to the object's start.
Position fade_out_pos
Fade out position, relative to the object's start.
int textw
Cache text H extents and W extents for the text, if the object has any.
ArrangerObject * transient
A copy ArrangerObject corresponding to this, such as when ctrl+dragging.
Position clip_start_pos
Start position of the clip loop, relative to the object's start.
GdkRectangle last_name_rect
Last drawn name rectangle, if object has a name.
bool is_auditioner
Whether part of an auditioner track.
cairo_surface_t * cached_surface[2]
Cached surface containing drawing.
Position end_pos
End Position, if the object has one.
Position loop_end_pos
End position of the clip loop, relative to the object's start.
CurveOptions fade_out_opts
Fade out curve options.
ArrangerObject * main
The opposite of the above.
GdkRectangle full_rect
The full rectangle this object covers including off-screen parts, in absolute coordinates.
CurveOptions fade_in_opts
Fade in curve options.
Position pos
Position (or start Position if the object has length).
cairo_t * cached_cr[2]
Cached cairo_t.
int index_in_prev_lane
Object's index in the previous lane (before being moved to a new lane/track).
A Position is made up of bars.beats.sixteenths.ticks.
double ticks
Precise total number of ticks.
signed_frame_t frames
Position in frames (samples).
Index/identifier for a Region, so we can get Region objects quickly with it without searching by name...
A region (clip) is an object on the timeline that contains either MidiNote's or AudioClip's.
Track to be inserted into the Project's Tracklist.
Base struct to be inherited by implementing undoable actions.