Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-Studio-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2026 MuseScore Limited
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 :
23 : #include "notationautomation.h"
24 :
25 : #include "engraving/dom/masterscore.h"
26 : #include "engraving/editing/transaction/transaction.h"
27 :
28 : #include "translation.h"
29 : #include "log.h"
30 :
31 : using namespace mu::notation;
32 :
33 0 : NotationAutomation::NotationAutomation(INotationUndoStackPtr undoStack)
34 0 : : m_undoStack(std::move(undoStack))
35 : {
36 0 : }
37 :
38 0 : bool NotationAutomation::isAutomationModeEnabled() const
39 : {
40 0 : return m_isAutomationModeEnabled;
41 : }
42 :
43 0 : void NotationAutomation::setAutomationModeEnabled(bool enabled)
44 : {
45 0 : if (m_isAutomationModeEnabled == enabled) {
46 0 : return;
47 : }
48 0 : m_isAutomationModeEnabled = enabled;
49 0 : m_automationModeEnabledChanged.notify();
50 : }
51 :
52 0 : muse::async::Notification NotationAutomation::automationModeEnabledChanged() const
53 : {
54 0 : return m_automationModeEnabledChanged;
55 : }
56 :
57 0 : AutomationDataConstPtr NotationAutomation::automationData() const
58 : {
59 0 : return m_masterScore ? m_masterScore->automationData() : nullptr;
60 : }
61 :
62 0 : void NotationAutomation::editPoints(const AutomationCurveKey& key, AutomationPointEdits& edits)
63 : {
64 0 : IF_ASSERT_FAILED(m_masterScore && m_undoStack) {
65 0 : return;
66 : }
67 :
68 0 : m_undoStack->transaction(muse::TranslatableString("undoableAction", "Edit automation points"),
69 0 : [&](engraving::Transaction&) {
70 0 : m_masterScore->editAutomationPoints(key, edits);
71 0 : });
72 : }
73 :
74 0 : muse::async::Notification NotationAutomation::resetEditStateRequested() const
75 : {
76 0 : return m_resetEditStateRequested;
77 : }
78 :
79 0 : void NotationAutomation::setMasterScore(engraving::MasterScore* masterScore)
80 : {
81 0 : m_masterScore = masterScore;
82 0 : }
|