Zrythm v2.0.0-alpha.1
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
arranger_object_selection_operator.h
1// SPDX-FileCopyrightText: © 2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "commands/change_qobject_property_command.h"
7#include "commands/resize_arranger_objects_command.h"
8#include "structure/arrangement/arranger_object_factory.h"
9#include "undo/undo_stack.h"
10#include "utils/variant_helpers.h"
11
12#include <QItemSelectionModel>
13#include <QtQmlIntegration/qqmlintegration.h>
14
15namespace zrythm::actions
16{
17class ArrangerObjectSelectionOperator : public QObject
18{
19 Q_OBJECT
20 QML_ELEMENT
21 QML_UNCREATABLE ("")
22 QML_EXTENDED_NAMESPACE (zrythm::commands)
23
24public:
25 using SelectedObjectsVector =
26 std::vector<structure::arrangement::ArrangerObjectUuidReference>;
27 using ArrangerObjectOwnerPtrVariant =
29 structure::arrangement::ArrangerObjectVariant,
31 using ObjectOwnerProvider = std::function<ArrangerObjectOwnerPtrVariant (
32 structure::arrangement::ArrangerObjectPtrVariant)>;
33
34 explicit ArrangerObjectSelectionOperator (
35 undo::UndoStack &undoStack,
36 QItemSelectionModel &selectionModel,
37 ObjectOwnerProvider objectOwnerProvider,
39 QObject * parent = nullptr);
40
41 Q_INVOKABLE bool moveByTicks (double tick_delta);
42
43 Q_INVOKABLE bool moveNotesByPitch (int pitch_delta);
44
45 Q_INVOKABLE bool changeVelocities (int velocity_delta);
46
47 Q_INVOKABLE bool moveAutomationPointsByDelta (double delta);
48
49 Q_INVOKABLE bool resizeObjects (
50 commands::ResizeType type,
51 commands::ResizeDirection direction,
52 double delta);
53
54 Q_INVOKABLE bool deleteObjects ();
55
56 Q_INVOKABLE bool cloneObjects ();
57
58 Q_INVOKABLE bool toggleMute ();
59
60private:
61 auto extractSelectedObjects () const -> SelectedObjectsVector;
62
63 static bool validateHorizontalMovement (
64 const SelectedObjectsVector &objects,
65 double tick_delta);
66 static bool
67 validateVerticalMovement (const SelectedObjectsVector &objects, double delta);
68 static bool validateResize (
69 const SelectedObjectsVector &objects,
70 commands::ResizeType type,
71 commands::ResizeDirection direction,
72 double delta);
73 static bool validateBoundsResize (
74 structure::arrangement::ArrangerObjectPtrVariant obj_var,
75 commands::ResizeDirection direction,
76 double delta);
77 static bool validateFadesResize (
79 commands::ResizeDirection direction,
80 double delta);
81
82 bool process_vertical_move (double delta);
83
84private:
85 undo::UndoStack &undo_stack_;
86 QItemSelectionModel &selection_model_;
87 ObjectOwnerProvider object_owner_provider_;
89};
90
91} // namespace zrythm::actions
Base class for all objects in the arranger.
typename to_pointer_variant_impl< Variant >::type to_pointer_variant
Converts a variant to a variant of pointers.
typename wrap_variant_impl< Variant, Wrapper >::type wrap_variant_t
Converts a variant to a variant where each type is wrapped by Wrapper<T>.