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