Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
scene.h
1// SPDX-FileCopyrightText: © 2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "structure/arrangement/arranger_object.h"
7#include "structure/scenes/clip_slot.h"
8#include "structure/tracks/track_collection.h"
9
10#include <QtQmlIntegration/qqmlintegration.h>
11
12namespace zrythm::structure::scenes
13{
14
15class Scene : public QObject
16{
17 Q_OBJECT
18 Q_PROPERTY (QString name READ name WRITE setName NOTIFY nameChanged)
19 Q_PROPERTY (QColor color READ color WRITE setColor NOTIFY colorChanged)
20 Q_PROPERTY (
21 zrythm::structure::scenes::ClipSlotList * clipSlots READ clipSlots CONSTANT)
22 QML_ELEMENT
23 QML_UNCREATABLE ("")
24
25public:
26 Scene (
27 arrangement::ArrangerObjectRegistry &object_registry,
28 const tracks::TrackCollection &track_collection,
29 QObject * parent = nullptr)
30 : QObject (parent),
31 clip_slot_list_ (
32 utils::make_qobject_unique<
33 ClipSlotList> (object_registry, track_collection, this))
34 {
35 }
36
37 ClipSlotList * clipSlots () const { return clip_slot_list_.get (); }
38
39 // Name property
40 QString name () const { return name_; }
41 void setName (const QString &name);
42 Q_SIGNAL void nameChanged (const QString &name);
43
44 // Color property
45 QColor color () const { return color_; }
46 void setColor (const QColor &color);
47 Q_SIGNAL void colorChanged (const QColor &color);
48
49 // Access to clip slots
50 auto &clip_slots () const { return clip_slot_list_->clip_slots (); }
51
52private:
53 QString name_;
54 QColor color_;
56};
57
58class SceneList : public QAbstractListModel
59{
60 Q_OBJECT
61 QML_ELEMENT
62 QML_UNCREATABLE ("")
63
64public:
65 enum SceneListRoles
66 {
67 ScenePtrRole = Qt::UserRole + 1,
68 };
69
70 // Scene management
71 void insert_scene (utils::QObjectUniquePtr<Scene> scene, int index);
72 Q_INVOKABLE void removeScene (int index);
73 Q_INVOKABLE void moveScene (int fromIndex, int toIndex);
74
75 auto &scenes () const { return scenes_; }
76
77 // ========================================================================
78 // QML Interface
79 // ========================================================================
80
81 QHash<int, QByteArray> roleNames () const override
82 {
83 QHash<int, QByteArray> roles;
84 roles[ScenePtrRole] = "scene";
85 return roles;
86 }
87 int rowCount (const QModelIndex &parent = QModelIndex ()) const override
88 {
89 if (parent.isValid ())
90 return 0;
91 return static_cast<int> (scenes_.size ());
92 }
93 QVariant
94 data (const QModelIndex &index, int role = Qt::DisplayRole) const override
95 {
96 const auto index_int = index.row ();
97 if (!index.isValid () || index_int >= static_cast<int> (scenes_.size ()))
98 return {};
99
100 if (role == ScenePtrRole)
101 {
102 return QVariant::fromValue (scenes_.at (index_int).get ());
103 }
104
105 return {};
106 }
107 // ========================================================================
108
109private:
110 std::vector<utils::QObjectUniquePtr<Scene>> scenes_;
111};
112}
A collection of tracks that provides a QAbstractListModel interface.
A unique pointer for QObject objects that also works with QObject-based ownership.
Definition qt.h:38