LCOV - code coverage report
Current view: top level - src/engraving/editing - editchord.h Coverage Total Hit
Test: filtered_coverage.info Lines: 63.6 % 33 21
Test Date: 2026-11-05 04:07:02

            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) 2025 MuseScore Limited and others
       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              : #pragma once
      24              : 
      25              : #include "transaction/undoablecommand.h"
      26              : 
      27              : #include "../dom/chord.h"
      28              : #include "../dom/parenthesis.h"
      29              : 
      30              : namespace mu::engraving {
      31              : class Chord;
      32              : class Note;
      33              : class EngravingItem;
      34              : class Articulation;
      35              : enum class SymId;
      36              : 
      37              : class EditChord
      38              : {
      39              : public:
      40              :     static void addChordParentheses(Chord* chord, std::vector<Note*> notes, bool addToLinked = true, bool generated = false);
      41              :     static void removeChordParentheses(Chord* chord, std::vector<Note*> notes, bool addToLinked = true, bool generated = false);
      42              :     static void toggleArticulation(Score* score, SymId attr);
      43              :     static bool toggleArticulation(Score* score, EngravingItem* el, Articulation* a);
      44              : 
      45              : private:
      46              : 
      47              :     static void undoAddParenthesesToNotes(Chord* chord, std::vector<Note*> notes, bool addToLinked = true, bool generated = false);
      48              :     static void undoRemoveParenthesesFromNote(Chord* chord, Note* note, Parenthesis* leftParen, bool removeFromLinked = true);
      49              :     static void undoClearParenthesisGroup(Chord* chord, std::vector<Note*> notes, Parenthesis* leftParen, Parenthesis* rightParen,
      50              :                                           bool removeFromLinked = true);
      51              : 
      52              :     static void doAddNoteParentheses(Chord* chord, std::vector<Note*> notes, Parenthesis* leftParen, Parenthesis* rightParen);
      53              :     static void doRemoveSingleNoteParenthesis(Chord* chord, Note* note, Parenthesis* leftParen);
      54              :     static void doRemoveAllNoteParentheses(Chord* chord, Parenthesis* leftParen);
      55              : };
      56              : 
      57              : class ChangeChordStaffMove : public UndoableCommand
      58              : {
      59            6 :     OBJECT_ALLOCATOR(engraving, ChangeChordStaffMove)
      60              : 
      61              :     ChordRest* chordRest = nullptr;
      62              :     int staffMove = 0;
      63              : 
      64              :     void flip() override;
      65              : 
      66              : public:
      67            4 :     ChangeChordStaffMove(ChordRest* cr, int v)
      68            4 :         : chordRest(cr), staffMove(v) {}
      69              : 
      70            4 :     UNDO_TYPE(CommandType::ChangeChordStaffMove)
      71            0 :     UNDO_NAME("ChangeChordStaffMove")
      72           12 :     UNDO_CHANGED_OBJECTS({ chordRest })
      73              : };
      74              : 
      75              : class SwapCR : public UndoableCommand
      76              : {
      77            0 :     OBJECT_ALLOCATOR(engraving, SwapCR)
      78              : 
      79              :     ChordRest* cr1 = nullptr;
      80              :     ChordRest* cr2 = nullptr;
      81              : 
      82              :     void flip() override;
      83              : 
      84              : public:
      85            0 :     SwapCR(ChordRest* a, ChordRest* b)
      86            0 :         : cr1(a), cr2(b) {}
      87              : 
      88            0 :     UNDO_TYPE(CommandType::SwapCR)
      89            0 :     UNDO_NAME("SwapCR")
      90            0 :     UNDO_CHANGED_OBJECTS({ cr1, cr2 })
      91              : };
      92              : 
      93              : class ChangeSpanArpeggio : public UndoableCommand
      94              : {
      95          162 :     OBJECT_ALLOCATOR(engraving, ChangeSpanArpeggio)
      96              : 
      97              :     Chord* m_chord = nullptr;
      98              :     Arpeggio* m_spanArpeggio = nullptr;
      99              : 
     100              :     void flip() override;
     101              : public:
     102           81 :     ChangeSpanArpeggio(Chord* chord, Arpeggio* spanArp)
     103           81 :         : m_chord(chord), m_spanArpeggio(spanArp) {}
     104              : 
     105            0 :     UNDO_NAME("ChangeSpanArpeggio")
     106            0 :     UNDO_CHANGED_OBJECTS({ m_chord })
     107              : };
     108              : 
     109              : class AddNoteParenthesisInfo : public UndoableCommand
     110              : {
     111          223 :     OBJECT_ALLOCATOR(engraving, AddNoteParenthesisInfo)
     112              : 
     113              :     void redo() override;
     114              :     void undo() override;
     115              : 
     116              :     void cleanup(bool wasDone) override;
     117              : 
     118              :     Chord* m_chord = nullptr;
     119              :     NoteParenthesisInfo* m_noteParenInfo = nullptr;
     120              : 
     121              : public:
     122          118 :     AddNoteParenthesisInfo(Chord* chord, NoteParenthesisInfo* noteParenInfo)
     123          118 :         : m_chord(chord), m_noteParenInfo(noteParenInfo) {}
     124              : 
     125            0 :     UNDO_NAME("AddNoteParenthesesInfo")
     126           22 :     UNDO_TYPE(CommandType::AddNoteParenthesesInfo)
     127              : };
     128              : 
     129              : class RemoveNoteParenthesisInfo : public UndoableCommand
     130              : {
     131            1 :     OBJECT_ALLOCATOR(engraving, RemoveNoteParenthesisInfo)
     132              : 
     133              :     void redo() override;
     134              :     void undo() override;
     135              : 
     136              :     void cleanup(bool wasDone) override;
     137              : 
     138              :     Chord* m_chord = nullptr;
     139              :     NoteParenthesisInfo* m_noteParenInfo = nullptr;
     140              : 
     141              : public:
     142            1 :     RemoveNoteParenthesisInfo(Chord* chord, NoteParenthesisInfo* noteParenInfo)
     143            1 :         : m_chord(chord), m_noteParenInfo(noteParenInfo) {}
     144              : 
     145            0 :     UNDO_NAME("RemoveNoteParenthesesInfo")
     146            1 :     UNDO_TYPE(CommandType::RemoveNoteParenthesesInfo)
     147              : };
     148              : 
     149              : class RemoveSingleNoteParentheses : public UndoableCommand
     150              : {
     151            9 :     OBJECT_ALLOCATOR(engraving, RemoveSingleNoteParentheses)
     152              : 
     153              :     Chord* m_chord = nullptr;
     154              :     Note* m_note = nullptr;
     155              :     Parenthesis* m_paren = nullptr;
     156              : 
     157              :     void redo() override;
     158              :     void undo() override;
     159              : 
     160              : public:
     161            9 :     RemoveSingleNoteParentheses(Chord* chord, Note* note, Parenthesis* paren)
     162            9 :         : m_chord(chord), m_note(note), m_paren(paren) {}
     163              : 
     164            0 :     UNDO_NAME("RemoveSingleNoteParentheses")
     165           18 :     UNDO_TYPE(CommandType::RemoveSingleNoteParentheses)
     166           54 :     UNDO_CHANGED_OBJECTS({ m_chord, m_paren })
     167              : };
     168              : }
        

Generated by: LCOV version 2.0-1