Zrythm v2.0.0-DEV
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 = to_pointer_variant<wrap_variant_t<
28 structure::arrangement::ArrangerObjectVariant,
30 using ObjectOwnerProvider = std::function<ArrangerObjectOwnerPtrVariant (
31 structure::arrangement::ArrangerObjectPtrVariant)>;
32
33 explicit ArrangerObjectSelectionOperator (
34 undo::UndoStack &undoStack,
35 QItemSelectionModel &selectionModel,
36 ObjectOwnerProvider objectOwnerProvider,
38 QObject * parent = nullptr);
39
40 Q_INVOKABLE bool moveByTicks (double tick_delta);
41
42 Q_INVOKABLE bool moveNotesByPitch (int pitch_delta);
43
44 Q_INVOKABLE bool changeVelocities (int velocity_delta);
45
46 Q_INVOKABLE bool moveAutomationPointsByDelta (double delta);
47
48 Q_INVOKABLE bool resizeObjects (
49 commands::ResizeType type,
50 commands::ResizeDirection direction,
51 double delta);
52
53 Q_INVOKABLE bool deleteObjects ();
54
55 Q_INVOKABLE bool cloneObjects ();
56
57 Q_INVOKABLE bool toggleMute ();
58
59private:
60 auto extractSelectedObjects () const -> SelectedObjectsVector;
61
62 static bool validateHorizontalMovement (
63 const SelectedObjectsVector &objects,
64 double tick_delta);
65 static bool
66 validateVerticalMovement (const SelectedObjectsVector &objects, double delta);
67 static bool validateResize (
68 const SelectedObjectsVector &objects,
69 commands::ResizeType type,
70 commands::ResizeDirection direction,
71 double delta);
72 static bool validateBoundsResize (
73 structure::arrangement::ArrangerObjectPtrVariant obj_var,
74 commands::ResizeDirection direction,
75 double delta);
76 static bool validateFadesResize (
78 commands::ResizeDirection direction,
79 double delta);
80
81 bool process_vertical_move (double delta);
82
83private:
84 undo::UndoStack &undo_stack_;
85 QItemSelectionModel &selection_model_;
86 ObjectOwnerProvider object_owner_provider_;
88};
89
90} // namespace zrythm::actions
Base class for all objects in the arranger.