Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
editor_settings.h
1// SPDX-FileCopyrightText: © 2020-2022, 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 <nlohmann/json_fwd.hpp>
11
12namespace zrythm::structure::arrangement
13{
14using namespace std::string_view_literals;
15
19class EditorSettings : public QObject
20{
21 Q_OBJECT
22 QML_ELEMENT
23 Q_PROPERTY (double x READ getX WRITE setX NOTIFY xChanged)
24 Q_PROPERTY (double y READ getY WRITE setY NOTIFY yChanged)
25 Q_PROPERTY (
26 double horizontalZoomLevel READ getHorizontalZoomLevel WRITE
27 setHorizontalZoomLevel NOTIFY horizontalZoomLevelChanged)
28
29public:
30 EditorSettings (QObject * parent = nullptr) : QObject (parent) { }
31
32 // =========================================================
33 // QML interface
34 // =========================================================
35
36 double getX () const { return scroll_start_x_; }
37 void setX (double x);
38 Q_SIGNAL void xChanged (double x);
39
40 double getY () const { return scroll_start_y_; }
41 void setY (double y);
42 Q_SIGNAL void yChanged (double y);
43
44 double getHorizontalZoomLevel () const { return hzoom_level_; }
45 void setHorizontalZoomLevel (double hzoom_level);
46 Q_SIGNAL void horizontalZoomLevelChanged (double hzoom_level);
47
48 // =========================================================
49
50 double clamp_scroll_start_x (double x);
51
52 double clamp_scroll_start_y (double y);
53
57 void append_scroll (double dx, double dy, bool validate);
58
59protected:
60 friend void init_from (
61 EditorSettings &obj,
62 const EditorSettings &other,
63 utils::ObjectCloneType clone_type)
64 {
65 obj.scroll_start_x_ = other.scroll_start_x_;
66 obj.scroll_start_y_ = other.scroll_start_y_;
67 obj.hzoom_level_ = other.hzoom_level_;
68 }
69
70private:
71 static constexpr auto kScrollStartXKey = "scrollStartX"sv;
72 static constexpr auto kScrollStartYKey = "scrollStartY"sv;
73 static constexpr auto kHZoomLevelKey = "hZoomLevel"sv;
74 friend void to_json (nlohmann::json &j, const EditorSettings &settings);
75 friend void from_json (const nlohmann::json &j, EditorSettings &settings);
76
77private:
79 double scroll_start_x_ = 0;
80
82 double scroll_start_y_ = 0;
83
85 double hzoom_level_ = 1.0;
86};
87
88}
void append_scroll(double dx, double dy, bool validate)
Appends the given deltas to the scroll x/y values.