Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
tool.h
1// SPDX-FileCopyrightText: © 2018-2019, 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/serialization.h"
8
9#include <QObject>
10#include <QtQmlIntegration>
11
12namespace zrythm::gui::backend
13{
14
15class Tool : public QObject
16{
17 Q_OBJECT
18 QML_ELEMENT
19 Q_PROPERTY (
20 int toolValue READ getToolValue WRITE setToolValue NOTIFY toolValueChanged)
21
22public:
23 enum ToolType
24 {
25 Select,
26 Edit,
27 Cut,
28 Eraser,
29 Ramp,
30 Audition,
31 };
32 Q_ENUM (ToolType)
33
34 Tool (QObject * parent = nullptr);
35 Z_DISABLE_COPY_MOVE (Tool)
36 ~Tool () override;
37
38 [[nodiscard]] int getToolValue () const;
39 void setToolValue (int tool);
40 Q_SIGNAL void toolValueChanged (int tool);
41
42 friend void
43 init_from (Tool &obj, const Tool &other, utils::ObjectCloneType clone_type);
44
45private:
46 static constexpr auto kToolValueKey = "toolValue"sv;
47 friend void to_json (nlohmann::json &j, const Tool &tool)
48 {
49 j[kToolValueKey] = tool.tool_;
50 }
51 friend void from_json (const nlohmann::json &j, Tool &tool)
52 {
53 j.at (kToolValueKey).get_to (tool.tool_);
54 }
55
56private:
57 ToolType tool_{ ToolType::Select };
58};
59
60}; // namespace zrythm::gui::backend