Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
muteable_object.h
1// SPDX-FileCopyrightText: © 2024-2026 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "utils/icloneable.h"
7
8#include <QtQmlIntegration/qqmlintegration.h>
9
10#include <boost/describe.hpp>
11#include <nlohmann/json_fwd.hpp>
12
13namespace zrythm::structure::arrangement
14{
15
16class ArrangerObjectMuteFunctionality : public QObject
17{
18 Q_OBJECT
19 Q_PROPERTY (bool muted READ muted WRITE setMuted NOTIFY mutedChanged)
20 QML_ELEMENT
21
22public:
23 ArrangerObjectMuteFunctionality (QObject * parent = nullptr) noexcept
24 : QObject (parent)
25 {
26 }
27 ~ArrangerObjectMuteFunctionality () override = default;
28 Q_DISABLE_COPY_MOVE (ArrangerObjectMuteFunctionality)
29
30 // ========================================================================
31 // QML Interface
32 // ========================================================================
33 bool muted () const { return muted_; }
34 void setMuted (bool muted)
35 {
36 if (muted_ != muted)
37 {
38 muted_ = muted;
39 Q_EMIT mutedChanged (muted);
40 }
41 }
42 Q_SIGNAL void mutedChanged (bool muted);
43
44 // ========================================================================
45
46// TODO
47#if 0
48template <typename RegionT>
49bool
50RegionImpl<RegionT>::get_muted (bool check_parent) const
51{
52 if (check_parent)
53 {
54 if constexpr (is_laned ())
55 {
56 auto &lane = get_derived ().get_lane ();
57 if (lane.is_effectively_muted ())
58 return true;
59 }
60 }
61 return muted ();
62}
63#endif
64
65private:
66 friend void init_from (
67 ArrangerObjectMuteFunctionality &obj,
68 const ArrangerObjectMuteFunctionality &other,
69 utils::ObjectCloneType clone_type)
70 {
71 obj.muted_ = other.muted_;
72 }
73
74 static constexpr std::string_view kMutedKey = "muted";
75 friend void
76 to_json (nlohmann::json &j, const ArrangerObjectMuteFunctionality &object)
77 {
78 j[kMutedKey] = object.muted_;
79 }
80 friend void
81 from_json (const nlohmann::json &j, ArrangerObjectMuteFunctionality &object)
82 {
83 j.at (kMutedKey).get_to (object.muted_);
84 Q_EMIT object.mutedChanged (object.muted_);
85 }
86
87private:
89 bool muted_{ false };
90
91 BOOST_DESCRIBE_CLASS (ArrangerObjectMuteFunctionality, (), (), (), (muted_))
92};
93
94} // namespace zrythm::structure::arrangement